Leon Matthes uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.threaded-LM.3346.mcz
==================== Summary ====================
Name: VMMaker.threaded-LM.3346 Author: LM Time: 14 November 2023, 4:11:25.618986 pm UUID: 7d055d36-9459-44e9-b9b7-48a15a3c109f Ancestors: VMMaker.threaded-LM.3345
Refactor pop operation to immediately remove MyList.
=============== Diff against VMMaker.threaded-LM.3345 ===============
Item was changed: ----- Method: CoInterpreterMT>>popProcessWithTemporaryAffinity:fromList: (in category 'process primitive support') ----- popProcessWithTemporaryAffinity: anAffinity fromList: aList "Find the first process from the list that is temporarily affined to the given affinity. Remove this process from the list and return it. This is used by the preempt/restore flow to find the process that is to be restored." | firstLink lastLink nextLink tempLink theProcess | self assert: (anAffinity ~= 0). self deny: (objectMemory isForwarded: aList). "any process on the list could have been becomed, so use a read barrier..." firstLink := objectMemory followField: FirstLinkIndex ofObject: aList. lastLink := objectMemory followField: LastLinkIndex ofObject: aList. "fail if any link doesn't look like a process..." ((objectMemory isPointers: firstLink) and: [(objectMemory numSlotsOf: firstLink) > MyListIndex]) ifFalse: [^ objectMemory nilObject].
(firstLink ~= objectMemory nilObject and: [(self temporaryAffinityOfProcess: firstLink) = anAffinity]) ifTrue: [theProcess := firstLink. nextLink := objectMemory followField: NextLinkIndex ofObject: firstLink. objectMemory storePointer: FirstLinkIndex ofObject: aList withValue: nextLink. firstLink = lastLink ifTrue: [objectMemory storePointerUnchecked: LastLinkIndex ofObject: aList withValue: objectMemory nilObject]] ifFalse: [tempLink := firstLink. [ nextLink := objectMemory followField: NextLinkIndex ofObject: tempLink. "fail if any link doesn't look like a process..." ((objectMemory isPointers: nextLink) and: [(objectMemory numSlotsOf: nextLink) > MyListIndex]) ifFalse: [^ objectMemory nilObject]. (self temporaryAffinityOfProcess: nextLink) = anAffinity] whileFalse: [tempLink := nextLink]. theProcess := nextLink. nextLink := objectMemory fetchPointer: NextLinkIndex ofObject: nextLink. objectMemory storePointer: NextLinkIndex ofObject: tempLink withValue: nextLink. theProcess = lastLink ifTrue: [objectMemory storePointer: LastLinkIndex ofObject: aList withValue: tempLink]]. + objectMemory + storePointerUnchecked: NextLinkIndex ofObject: theProcess withValue: objectMemory nilObject; + storePointerUnchecked: MyListIndex ofObject: theProcess withValue: objectMemory nilObject. - objectMemory storePointerUnchecked: NextLinkIndex ofObject: theProcess withValue: objectMemory nilObject. ^ theProcess!
Item was changed: ----- Method: CoInterpreterMT>>restoreVMStateFor:andFlags: (in category 'vm scheduling') ----- restoreVMStateFor: vmThread andFlags: flags "We've been preempted; we must restore state and update the threadId in our process, and may have to put the active process to sleep." | sched activeProc myProc | sched := self schedulerPointer. activeProc := objectMemory fetchPointer: ActiveProcessIndex ofObject: sched. (flags anyMask: OwnVMForeignThreadFlag) ifTrue: [self assert: foreignCallbackProcessSlot == ForeignCallbackProcess. myProc := objectMemory splObj: foreignCallbackProcessSlot. self assert: myProc ~= objectMemory nilObject. objectMemory splObj: foreignCallbackProcessSlot put: objectMemory nilObject] ifFalse: [myProc := self popProcessWithTemporaryAffinity: vmThread index fromList: (objectMemory splObj: ProcessInExternalCodeTag)]. + self assert: (myProc ~= objectMemory nilObject and: [activeProc ~= myProc]). (activeProc ~= objectMemory nilObject and: [(objectMemory fetchPointer: MyListIndex ofObject: activeProc) = objectMemory nilObject]) ifTrue: [self putToSleep: activeProc yieldingIf: preemptionYields]. objectMemory storePointerUnchecked: MyListIndex ofObject: myProc withValue: objectMemory nilObject; storePointer: ActiveProcessIndex ofObject: sched withValue: myProc.
+ self setTemporaryThreadAffinityOfProcess: myProc to: 0. - "Only unaffine if the process was affined at this level and did not become bound in the interim." - ((flags anyMask: ProcessUnaffinedOnDisown) - and: [(self isBoundProcess: myProc) not]) ifTrue: - [self setTemporaryThreadAffinityOfProcess: myProc to: 0]. self initPrimCall. self cCode: [self externalSetStackPageAndPointersForSuspendedContextOfProcess: myProc] inSmalltalk: ["Bypass the no-offset stack depth check in the simulator's externalSetStackPageAndPointersForSuspendedContextOfProcess:" super externalSetStackPageAndPointersForSuspendedContextOfProcess: myProc. "We're in ownVM:, hence in a primitive, hence need to include the argument count" (self isMachineCodeFrame: framePointer) ifTrue: [self maybeCheckStackDepth: vmThread argumentCount sp: stackPointer pc: instructionPointer]]. "If this primitive is called from machine code maintain the invariant that the return pc of an interpreter callee calling a machine code caller is ceReturnToInterpreterPC." (vmThread inMachineCode and: [instructionPointer >= objectMemory startOfMemory]) ifTrue: [self iframeSavedIP: framePointer put: instructionPointer. instructionPointer := cogit ceReturnToInterpreterPC]. newMethod := vmThread newMethodOrNull. argumentCount := vmThread argumentCount. vmThread newMethodOrNull: nil. self cCode: '' inSmalltalk: [| range | range := self cStackRangeForThreadIndex: vmThread index. self assert: ((range includes: vmThread cStackPointer) and: [range includes: vmThread cFramePointer])]. self setCFramePointer: vmThread cFramePointer setCStackPointer: vmThread cStackPointer. self assert: newMethod notNil !
vm-dev@lists.squeakfoundation.org