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

commits at source.squeak.org commits at source.squeak.org
Thu Jan 6 23:09:44 UTC 2022


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

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

Name: VMMaker.oscog-eem.3134
Author: eem
Time: 6 January 2022, 3:09:35.534862 pm
UUID: eaff35f9-c25a-44d9-9640-539e065e1970
Ancestors: VMMaker.oscog-eem.3133

CoInterpreter suspend:
Correct the code for dealing with machine code embedded block activations.

Alas the new suspend semantics do not work correctly with Virtend login (the lobby is reached but never populates). This is evidence that some images depend on the old semantics.  Hence the semantics must be rewritten to be optional.  This will happen soon.

=============== Diff against VMMaker.oscog-eem.3133 ===============

Item was changed:
  ----- Method: CoInterpreter>>backupContext:toBlockingSendTo: (in category 'process primitive support') -----
  backupContext: suspendedContext toBlockingSendTo: conditionVariable
  	"Support for primitiveSuspend.
  	 Assume suspendedContext is that of a process waiting on a condition variable.
  	 Backup the PC of suspendedContext to the send that entered the wait state.
  	 primitiveEnterCriticalSection pushes false for blocked waiters. false must be
  	 replaced by the condition variable."
  
+ 	"The suspendedContext is in one of six states, hence six cases:
+ 		1 & 2: single context with bytecode pc or single context with machine code pc
+ 		3 & 4: married to machine code frame in embedded (v3) block or machine code frame in method/full block
+ 		5 & 6: married to interpreter frame with saved ip or interpreter frame with pushed pc"
  	| theMethod pc sp theIP theNewIP theFP thePage |
  	self assert: (objectMemory isContext: suspendedContext).
  	theMethod := objectMemory fetchPointer: MethodIndex ofObject: suspendedContext.
+ 	"cases 1 & 2"
  	(self isSingleContext: suspendedContext) ifTrue:
  		[pc := objectMemory fetchPointer: InstructionPointerIndex ofObject: suspendedContext.
  		 sp := objectMemory fetchPointer: StackPointerIndex ofObject: suspendedContext.
  		 self assert: ((objectMemory isIntegerObject: pc) and: [(objectMemory integerValueOf: pc) ~= 0]).
  		 self assert: ((objectMemory isIntegerObject: sp) and: [(objectMemory integerValueOf: sp) > 0]).
+ 		 "case 2"
  		 (pc := objectMemory integerValueOf: pc) < 0 ifTrue: "context with machine code pc; must map..."
  			[pc := objectMemory integerValueOf: (self mustMapMachineCodePC: pc context: suspendedContext)].
  		 theIP := theMethod + objectMemory baseHeaderSize + pc - 1.
  		 theNewIP := self perform: pcPreviousToFunction with: theIP with: theMethod.
  		 self assert: (theNewIP < theIP and: [theIP - theNewIP <= 3]).
  		 pc := theNewIP - theMethod - objectMemory baseHeaderSize + 1.
  		 objectMemory
  			storePointerUnchecked: InstructionPointerIndex
  			ofObject: suspendedContext
  			withValue: (objectMemory integerObjectOf: pc).
  		 sp := (objectMemory integerValueOf: sp) + ReceiverIndex. "implicitly converts to 0 relative"
  		 self assert: ((objectMemory fetchPointer: sp ofObject: suspendedContext) = objectMemory falseObject
  					or: [(objectMemory fetchPointer: sp ofObject: suspendedContext) = conditionVariable]).
  		 objectMemory storePointer: sp ofObject: suspendedContext withValue: conditionVariable.
  		 ^self].
  	self assert: (self isMarriedOrWidowedContext: suspendedContext).
  	self deny: (self isWidowedContextNoConvert: suspendedContext).
  	theFP := self frameOfMarriedContext: suspendedContext.
  	thePage := stackPages stackPageFor: theFP.
  	self deny: thePage = stackPage.
  	self assert: theFP = thePage headFP.
  	(self isMachineCodeFrame: theFP)
+ 		ifTrue: "cases 3 & 4"
+ 			[| mcpc startBcpc cogMethod |
- 		ifTrue:
- 			[| mcpc maybeClosure startBcpc cogMethodForIP |
  			 mcpc := stackPages longAt: thePage headSP. "a machine code pc... it must be converted..."
+ 			 cogMethod := self mframeCogMethod: theFP.
+ 			 cogMethod cmType = CMBlock "case 3"
+ 				ifTrue: [self assert: (self frameStackedReceiver: theFP numArgs: cogMethod cmNumArgs)
+ 								= (objectMemory fetchPointer: ClosureIndex ofObject: suspendedContext).
+ 						startBcpc := self startPCOfClosure: (objectMemory fetchPointer: ClosureIndex ofObject: suspendedContext)]
+ 				ifFalse: [startBcpc := self startPCOfMethod: theMethod]. "case 4"
+ 			 theIP := cogit bytecodePCFor: mcpc startBcpc: startBcpc in: cogMethod.
- 			 maybeClosure := objectMemory fetchPointer: ClosureIndex ofObject: suspendedContext.
- 			 (maybeClosure ~= objectMemory nilObject
- 			  and: [self isVanillaBlockClosure: maybeClosure])
- 				ifTrue: [cogMethodForIP := self mframeHomeMethod: theFP.
- 						startBcpc := self startPCOfClosure: maybeClosure]
- 				ifFalse: [cogMethodForIP := self cCoerceSimple: (self mframeMethod: theFP) to: #'CogMethod *'.
- 						startBcpc := self startPCOfMethod: theMethod].
- 			 theIP := cogit bytecodePCFor: mcpc startBcpc: startBcpc in: cogMethodForIP.
  			 theIP := theIP + theMethod + objectMemory baseHeaderSize.
  			 theNewIP := self perform: pcPreviousToFunction with: theIP with: theMethod.
  			 self assert: (theNewIP < theIP and: [theIP - theNewIP <= 3]).
  			 self convertFrame: theFP toInterpreterFrame: theIP - theNewIP]
+ 		ifFalse: "cases 5&6"
- 		ifFalse:
  			[theIP := stackPages longAt: thePage headSP.
  			 theIP = cogit ceReturnToInterpreterPC
+ 				ifTrue: "case 5"
- 				ifTrue:
  					[theIP := (self iframeSavedIP: theFP) + 1. "fetchByte uses pre-increment; must + 1 to point at correct bytecode..."
  					 theNewIP := self perform: pcPreviousToFunction with: theIP with: theMethod.
  					 self assert: (theNewIP < theIP and: [theIP - theNewIP <= 3]).
  					 self iframeSavedIP: theFP put: theNewIP - 1] "fetchByte uses pre-increment; must - 1 to fetch correct bytecode..."
+ 				ifFalse: "case 6"
- 				ifFalse:
  					[theIP := theIP + 1. "fetchByte uses pre-increment; must + 1 to point at correct bytecode..."
  					 self assert: (self validInstructionPointer: theIP inMethod: theMethod framePointer: theFP).
  					 theNewIP := self perform: pcPreviousToFunction with: theIP with: theMethod.
  					 self assert: (theNewIP < theIP and: [theIP - theNewIP <= 3]).
  					 stackPages longAt: thePage headSP put: theNewIP - 1]]. "fetchByte uses pre-increment; must - 1 to fetch correct bytecode..."
  	self assert: ((stackPages longAt: thePage headSP + objectMemory wordSize) = objectMemory falseObject
  				or: [(stackPages longAt: thePage headSP + objectMemory wordSize) = conditionVariable]).
  	stackPages longAt: thePage headSP + objectMemory wordSize put: conditionVariable!



More information about the Vm-dev mailing list