[Vm-dev] VM Maker: VMMaker.oscog-eem.1377.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jun 24 19:17:22 UTC 2015


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1377.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.1377
Author: eem
Time: 24 June 2015, 12:15:15.033 pm
UUID: 5b760c4a-fa68-41f0-bb5f-de1657f1a7f3
Ancestors: VMMaker.oscog-EstebanLorenzano.1376

Make InterpreterPlugin>>#sizeof: work for e.g. #'void *'.

Exclude nsMethodCache from non-Newspeak VMs.

Make the assert in topOfObjStack an eassert for
faster simulation of Spur GC.

=============== Diff against VMMaker.oscog-EstebanLorenzano.1376 ===============

Item was changed:
  ----- Method: InterpreterPlugin>>sizeof: (in category 'simulation support') -----
  sizeof: objectSymbolOrClass
  	<doNotGenerate>
  	objectSymbolOrClass isInteger ifTrue:
  		[^interpreterProxy wordSize].
+ 	objectSymbolOrClass isSymbol ifTrue:
+ 		["In the simulator file handles are just integer indices into openFiles and so need
+ 		 only be BytesPerWord big. But in the actual VM they are at least 5 words long."
+ 		objectSymbolOrClass == #SQFile ifTrue:
+ 			[^interpreterProxy wordSize * 5].
+ 		"SQSocket is typedef struct { int sessionID; int socketType; void *privateSocketPtr; } SQSocket"
+ 		objectSymbolOrClass == #SQSocket ifTrue:
+ 			[^8 + interpreterProxy wordSize].
+ 		"We assume the file offset type is always 64-bits."
+ 		objectSymbolOrClass == #squeakFileOffsetType ifTrue:
+ 			[^8].
+ 		(objectSymbolOrClass last == $*
+ 		 or: [#long == objectSymbolOrClass
+ 		 or: [#'unsigned long' == objectSymbolOrClass]]) ifTrue:
+ 			[^interpreterProxy wordSize].
+ 		(#(usqInt sqInt) includes: objectSymbolOrClass) ifTrue:
+ 			[^interpreterProxy bytesPerOop]].
- 	"In the simulator file handles are just integer indices into openFiles and so need
- 	 only be BytesPerWord big. But in the actual VM they are at least 5 words long."
- 	objectSymbolOrClass == #SQFile ifTrue:
- 		[^interpreterProxy wordSize * 5].
- 	"SQSocket is typedef struct { int sessionID; int socketType; void *privateSocketPtr; } SQSocket"
- 	objectSymbolOrClass == #SQSocket ifTrue:
- 		[^8 + interpreterProxy wordSize].
- 	"We assume the file offset type is always 64-bits."
- 	objectSymbolOrClass == #squeakFileOffsetType ifTrue:
- 		[^8].
  	^super sizeof: objectSymbolOrClass!

Item was changed:
  ----- Method: SpurMemoryManager>>topOfObjStack: (in category 'obj stacks') -----
  topOfObjStack: objStack
  	| topx |
  	"This assert is tricky.  push:onObjStack: may call topOfObjStack: just after pushing an
  	 empty page on the stack, and will ask if the second page is valid."
+ 	self eassert: [self isValidObjStackPage: objStack
- 	self assert: (self isValidObjStackPage: objStack
  					myIndex: (self fetchPointer: ObjStackMyx ofObject: objStack)
+ 					firstPage: (objStack = (self fetchPointer: (self fetchPointer: ObjStackMyx ofObject: objStack) ofObject: hiddenRootsObj))].
- 					firstPage: (objStack = (self fetchPointer: (self fetchPointer: ObjStackMyx ofObject: objStack) ofObject: hiddenRootsObj))).
  	topx := self fetchPointer: ObjStackTopx ofObject: objStack.
  	topx = 0 ifTrue:
  		[self assert: (self fetchPointer: ObjStackNextx ofObject: objStack) = 0.
  		^nil].
  	^self fetchPointer: topx + ObjStackFixedSlots - 1 ofObject: objStack!

Item was changed:
  ----- Method: StackInterpreter class>>declareCVarsIn: (in category 'translation') -----
  declareCVarsIn: aCCodeGenerator
  	| vmClass |
  	self class == thisContext methodClass ifFalse: [^self]. "Don't duplicate decls in subclasses"
  	vmClass := aCCodeGenerator vmClass. "Generate primitiveTable etc based on vmClass, not just StackInterpreter"
  	aCCodeGenerator
  		addHeaderFile:'<stddef.h> /* for e.g. alloca */';
  		addHeaderFile:'<setjmp.h>';
  		addHeaderFile:'<wchar.h> /* for wint_t */';
  		addHeaderFile:'"vmCallback.h"';
  		addHeaderFile:'"sqMemoryFence.h"';
  		addHeaderFile:'"dispdbg.h"'.
  	vmClass declareInterpreterVersionIn: aCCodeGenerator defaultName: 'Stack'.
  	aCCodeGenerator
  		var: #interpreterProxy  type: #'struct VirtualMachine*'.
  	aCCodeGenerator
  		declareVar: #sendTrace type: 'volatile int';
  		declareVar: #byteCount type: 'unsigned long'.
  	"These need to be pointers or unsigned."
  	self declareC: #(instructionPointer method newMethod)
  		as: #usqInt
  		in: aCCodeGenerator.
  	"These are all pointers; char * because Slang has no support for C pointer arithmetic."
  	self declareC: #(localIP localSP localFP stackPointer framePointer stackLimit stackMemory breakSelector)
  		as: #'char *'
  		in: aCCodeGenerator.
  	aCCodeGenerator
  		var: #breakSelectorLength
  		declareC: 'sqInt breakSelectorLength = MinSmallInteger'.
  	self declareC: #(stackPage overflowedPage)
  		as: #'StackPage *'
  		in: aCCodeGenerator.
  	aCCodeGenerator removeVariable: 'stackPages'.  "this is an implicit receiver in the translated code."
  	NewspeakVM ifFalse:
+ 		[aCCodeGenerator
+ 			removeVariable: 'localAbsentReceiver';
+ 			removeVariable: 'localAbsentReceiverOrZero';
+ 			removeVariable: 'nsMethodCache'].
- 		[aCCodeGenerator removeVariable: 'localAbsentReceiver'.
- 		 aCCodeGenerator removeVariable: 'localAbsentReceiverOrZero'].
  	"This defines bytecodeSetSelector as 0 if MULTIPLEBYTECODESETS
  	 is not defined, for the benefit of the interpreter on slow machines."
  	aCCodeGenerator addConstantForBinding: (self bindingOf: #MULTIPLEBYTECODESETS).
  	MULTIPLEBYTECODESETS == false ifTrue:
  		[aCCodeGenerator
  			removeVariable: 'extA';
  			removeVariable: 'extB';
  			removeVariable: 'bytecodeSetSelector'].
  	aCCodeGenerator
  		var: #methodCache
  		declareC: 'long methodCache[MethodCacheSize + 1 /* ', (MethodCacheSize + 1) printString, ' */]'.
  	aCCodeGenerator
  		var: #nsMethodCache
  		declareC: 'long nsMethodCache[NSMethodCacheSize + 1 /* ', (NSMethodCacheSize + 1) printString, ' */]'.
  	aCCodeGenerator
  		var: #atCache
  		declareC: 'sqInt atCache[AtCacheTotalSize + 1 /* ', (AtCacheTotalSize + 1) printString, ' */]'.
  	aCCodeGenerator
  		var: #primitiveTable
  		declareC: 'void (*primitiveTable[MaxPrimitiveIndex + 2 /* ', (MaxPrimitiveIndex + 2) printString, ' */])(void) = ', vmClass primitiveTableString.
  	vmClass primitiveTable do:
  		[:symbolOrNot|
  		(symbolOrNot isSymbol
  		 and: [symbolOrNot ~~ #primitiveFail]) ifTrue:
  			[(aCCodeGenerator methodNamed: symbolOrNot) ifNotNil:
  				[:tMethod| tMethod returnType: #void]]].
  	vmClass objectMemoryClass hasSpurMemoryManagerAPI
  		ifTrue:
  			[aCCodeGenerator
  				var: #primitiveAccessorDepthTable
  				type: 'signed char'
  				sizeString: 'MaxPrimitiveIndex + 2 /* ', (MaxPrimitiveIndex + 2) printString, ' */'
  				array: vmClass primitiveAccessorDepthTable]
  		ifFalse:
  			[aCCodeGenerator removeVariable: #primitiveAccessorDepthTable].
  	aCCodeGenerator
  		var: #primitiveFunctionPointer
  		declareC: 'void (*primitiveFunctionPointer)()'.
  	aCCodeGenerator
  		var: #externalPrimitiveTable
  		declareC: 'void (*externalPrimitiveTable[MaxExternalPrimitiveTableSize + 1 /* ', (MaxExternalPrimitiveTableSize + 1) printString, ' */])(void)'.
  	aCCodeGenerator var: #showSurfaceFn type: #'void *'.
  	aCCodeGenerator
  		var: #jmpBuf
  		declareC: 'jmp_buf jmpBuf[MaxJumpBuf + 1 /* ', (MaxJumpBuf + 1) printString, ' */]'.
  	aCCodeGenerator
  		var: #suspendedCallbacks
  		declareC: 'usqInt suspendedCallbacks[MaxJumpBuf + 1 /* ', (MaxJumpBuf + 1) printString, ' */]'.
  	aCCodeGenerator
  		var: #suspendedMethods
  		declareC: 'usqInt suspendedMethods[MaxJumpBuf + 1 /* ', (MaxJumpBuf + 1) printString, ' */]'.
  	aCCodeGenerator
  		var: #interruptCheckChain
  		declareC: 'void (*interruptCheckChain)(void) = 0'.
  
  	self declareCAsUSqLong: #(nextPollUsecs nextWakeupUsecs longRunningPrimitiveGCUsecs
  								longRunningPrimitiveStartUsecs longRunningPrimitiveStopUsecs
  								"these are high-frequency enough that they're overflowing quite quickly on modern hardware"
  								statProcessSwitch statIOProcessEvents statForceInterruptCheck
  								statCheckForEvents statStackOverflow statStackPageDivorce)
  		in: aCCodeGenerator.
  	aCCodeGenerator var: #nextProfileTick type: #sqLong!



More information about the Vm-dev mailing list