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

commits at source.squeak.org commits at source.squeak.org
Thu Jan 30 23:51:31 UTC 2020


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

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

Name: VMMaker.oscog-eem.2691
Author: eem
Time: 30 January 2020, 3:51:09.421807 pm
UUID: d6b8b9b3-701f-47a6-a62b-6f95bfd498c3
Ancestors: VMMaker.oscog-nice.2690

CoInterpreter: eliminate all but one compiler warning.
Cogit: hey ho, initializeCodeZoneFrom:upTo:writableCodeZone: has got to go.

=============== Diff against VMMaker.oscog-nice.2690 ===============

Item was changed:
  ----- Method: CoInterpreter>>callbackEnter: (in category 'callback support') -----
  callbackEnter: callbackID
  	"Re-enter the interpreter for executing a callback"
  	| currentCStackPointer currentCFramePointer savedReenterInterpreter
  	  wasInMachineCode calledFromMachineCode |
  	<volatile>
  	<export: true>
+ 	<var: #currentCStackPointer type: #usqIntptr_t>
+ 	<var: #currentCFramePointer type: #usqIntptr_t>
- 	<var: #currentCStackPointer type: #'void *'>
- 	<var: #currentCFramePointer type: #'void *'>
  	<var: #callbackID type: #'sqInt *'>
  	<var: #savedReenterInterpreter type: #'jmp_buf'>
  
  	"For now, do not allow a callback unless we're in a primitiveResponse"
  	(self asserta: primitiveFunctionPointer ~= 0) ifFalse:
  		[^false].
  
  	self assert: primFailCode = 0.
  
  	"Check if we've exceeded the callback depth"
  	(self asserta: jmpDepth < MaxJumpBuf) ifFalse:
  		[^false].
  	jmpDepth := jmpDepth + 1.
  
  	wasInMachineCode := self isMachineCodeFrame: framePointer.
  	calledFromMachineCode := instructionPointer <= objectMemory startOfMemory.
  
  	"Suspend the currently active process"
  	suspendedCallbacks at: jmpDepth put: self activeProcess.
  	"We need to preserve newMethod explicitly since it is not activated yet
  	and therefore no context has been created for it. If the caller primitive
  	for any reason decides to fail we need to make sure we execute the correct
  	method and not the one 'last used' in the call back"
  	suspendedMethods at: jmpDepth put: newMethod.
  	self flag: 'need to debug this properly.  Conceptually it is the right thing to do but it crashes in practice'.
  	false
  		ifTrue:
  			["Signal external semaphores since a signalSemaphoreWithIndex: request may
  			  have been issued immediately prior to this callback before the VM has any
  			  chance to do a signalExternalSemaphores in checkForEventsMayContextSwitch:"
  			 self signalExternalSemaphores.
  			 "If no process is awakened by signalExternalSemaphores then transfer
  			  to the highest priority runnable one."
  			 (suspendedCallbacks at: jmpDepth) = self activeProcess ifTrue:
  				[self transferTo: self wakeHighestPriority from: CSCallbackLeave]]
  		ifFalse:
  			[self transferTo: self wakeHighestPriority from: CSCallbackLeave].
  
  	"Typically, invoking the callback means that some semaphore has been 
  	signaled to indicate the callback. Force an interrupt check as soon as possible."
  	self forceInterruptCheck.
  
  	"Save the previous CStackPointers and interpreter entry jmp_buf."
  	currentCStackPointer := CStackPointer.
  	currentCFramePointer := CFramePointer.
  	self memcpy: savedReenterInterpreter asVoidPointer
  		_: reenterInterpreter
  		_: (self sizeof: #'jmp_buf').
  	cogit assertCStackWellAligned.
  	(self setjmp: (jmpBuf at: jmpDepth)) = 0 ifTrue: "Fill in callbackID"
  		[callbackID at: 0 put: jmpDepth.
  		 self enterSmalltalkExecutive.
  		 self assert: false "NOTREACHED"].
  
  	"Restore the previous CStackPointers and interpreter entry jmp_buf."
  	self setCFramePointer: currentCFramePointer setCStackPointer: currentCStackPointer.
  	self memcpy: reenterInterpreter
  		_: (self cCoerceSimple: savedReenterInterpreter to: #'void *')
  		_: (self sizeof: #'jmp_buf').
  
  	"Transfer back to the previous process so that caller can push result"
  	self putToSleep: self activeProcess yieldingIf: preemptionYields.
  	self transferTo: (suspendedCallbacks at: jmpDepth) from: CSCallbackLeave.
  	newMethod := suspendedMethods at: jmpDepth.	"see comment above"
  	argumentCount := self argumentCountOf: newMethod.
  	self assert: wasInMachineCode = (self isMachineCodeFrame: framePointer).
  	calledFromMachineCode
  		ifTrue:
  			[instructionPointer asUnsignedInteger >= objectMemory startOfMemory ifTrue:
  				[self iframeSavedIP: framePointer put: instructionPointer.
  				 instructionPointer := cogit ceReturnToInterpreterPC]]
  		ifFalse:
  			["Even if the context was flushed to the heap and rebuilt in transferTo:from:
  			  above it will remain an interpreted frame because the context's pc would
  			  remain a bytecode pc.  So the instructionPointer must also be a bytecode pc."
  			 self assert: (self isMachineCodeFrame: framePointer) not.
  			 self assert: instructionPointer > objectMemory startOfMemory].
  	self assert: primFailCode = 0.
  	jmpDepth := jmpDepth-1.
  	^true!

Item was changed:
  ----- Method: CoInterpreter>>mcprimFunctionForPrimitiveIndex: (in category 'cog jit support') -----
  mcprimFunctionForPrimitiveIndex: primIndex
  	<api>
  	primIndex = PrimNumberHashMultiply ifTrue:
+ 		[^self cCoerceSimple: #mcprimHashMultiply: to: #sqInt].
- 		[^#mcprimHashMultiply:].
  	self error: 'unknown mcprim'.
  	^nil!

Item was changed:
  ----- Method: CoInterpreter>>saveCStackStateForCallbackContext: (in category 'callback support') -----
  saveCStackStateForCallbackContext: vmCallbackContext
  	<var: #vmCallbackContext type: #'VMCallbackContext *'>
  	vmCallbackContext
+ 		savedCStackPointer: CStackPointer asVoidPointer;
+ 		savedCFramePointer: CFramePointer asVoidPointer.
- 		savedCStackPointer: CStackPointer;
- 		savedCFramePointer: CFramePointer.
  	super saveCStackStateForCallbackContext: vmCallbackContext!

Item was removed:
- ----- Method: Cogit>>initializeCodeZoneFrom:upTo:writableCodeZone: (in category 'initialization') -----
- initializeCodeZoneFrom: startAddress upTo: endAddress writableCodeZone: writableCodeZone
- 	<api>
- 	<var: 'startAddress' type: #usqInt>
- 	<var: 'endAddress' type: #usqInt>
- 	<var: 'writableCodeZone' type: #usqInt>
- 	"If the OS platform requires dual mapping to achieve a writable code zone
- 	 then startAddress will be the non-zero address of the read/write zone and
- 	 executableCodeZone will be the non-zero address of the read/execute zone.
- 	 If the OS platform does not require dual mapping then startAddress will be
- 	 the first address of the read/write/executable zone and executableCodeZone
- 	 will be zero."
- 	self initializeBackend.
- 	codeToDataDelta := writableCodeZone = 0 ifTrue: [0] ifFalse: [writableCodeZone - startAddress].
- 	backEnd stopsFrom: startAddress to: endAddress - 1.
- 	self cCode:
- 			[writableCodeZone = 0 ifTrue:
- 				[self sqMakeMemoryExecutableFrom: startAddress To: endAddress]]
- 		inSmalltalk:
- 			[startAddress = self class guardPageSize ifTrue:
- 				[backEnd stopsFrom: 0 to: endAddress - 1].
- 			 self initializeProcessor].
- 
- 	codeBase := methodZoneBase := startAddress.
- 	minValidCallAddress := (codeBase min: coInterpreter interpretAddress) min: coInterpreter primitiveFailAddress.
- 	methodZone manageFrom: methodZoneBase to: endAddress.
- 	self assertValidDualZone.
- 	self maybeGenerateCheckFeatures.
- 	self maybeGenerateCheckLZCNT.
- 	self maybeGenerateICacheFlush.
- 	self generateVMOwnerLockFunctions.
- 	self genGetLeafCallStackPointer.
- 	self generateStackPointerCapture.
- 	self generateTrampolines.
- 	self computeEntryOffsets.
- 	self computeFullBlockEntryOffsets.
- 	self generateClosedPICPrototype.
- 	self alignMethodZoneBase.
- 	"repeat so that now the methodZone ignores the generated run-time"
- 	methodZone manageFrom: methodZoneBase to: endAddress.
- 	"N.B. this is assumed to be the last thing done in initialization; see Cogit>>initialized"
- 	self generateOpenPICPrototype!



More information about the Vm-dev mailing list