Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2961.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2961 Author: eem Time: 20 May 2021, 3:54:32.723618 pm UUID: fa08f5a0-f381-4cee-9c68-6a7610fd2728 Ancestors: VMMaker.oscog-eem.2960 Tweak primitiveResume to get better Slang inlining. =============== Diff against VMMaker.oscog-eem.2960 =============== Item was changed: ----- Method: CoInterpreterPrimitives>>primitiveResume (in category 'process primitives') ----- primitiveResume "Put this process on the scheduler's lists thus allowing it to proceed next time there is a chance for processes of it's priority level. It must go to the back of its run queue so as not to preempt any already running processes at this level. If the process's priority is higher than the current process, preempt the current process." + | proc ctxt inInterpreter | - | proc inInterpreter | proc := self stackTop. "rcvr" + ctxt := objectMemory followField: SuspendedContextIndex ofObject: proc. "written this way to get better Slang inlining" + (objectMemory isContext: ctxt) ifFalse: + [^self primitiveFailFor: PrimErrBadReceiver]. - (objectMemory isContext: (objectMemory followField: SuspendedContextIndex ofObject: proc)) ifFalse: - [^self primitiveFail]. "We're about to switch process, either to an interpreted frame or a machine code frame. To know whether to return or enter machine code we have to know from whence we came. We could have come from the interpreter, either directly or via a machine code primitive. We could have come from machine code. The instructionPointer tells us where from:" inInterpreter := instructionPointer >= objectMemory startOfMemory. (self resume: proc preemptedYieldingIf: preemptionYields from: CSResume) ifTrue: [self forProcessPrimitiveReturnToExecutivePostContextSwitch: inInterpreter] "Personally I would like to check MyList, which should not be one of the elements of the scheduler lists. But there are awful race conditions in things like should:notTakeMoreThan: that mean we can't. eem 9/27/2010 23:08, updated eem 5/20/2021 15:36. e.g. + | proc field | - | proc | proc := self stackTop. ''rcvr'' ''We only have to check for myList being nil. If it is nil then this is either the active process or a process suspended with primitiveSuspend (and if it is the activeProcess suspendedContext will be nil and the isContext: test will fail). If it is not nil then either the process is waiting on some semaphore-like list or on one of the scheduler's lists. If it is on some semaphore-like list it should not resume. If it is on one of the scheduler's lists it is runnable (already resumed).'' + field := objectMemory followField: MyListIndex ofObject: proc. + objectMemory nilObject = field ifFalse: - objectMemory nilObject = (objectMemory followField: MyListIndex ofObject: proc) ifFalse: [^self primitiveFailFor: PrimErrInappropriate]. + field := objectMemory followField: SuspendedContextIndex ofObject: proc. + (objectMemory isContext: field) ifFalse: - (objectMemory isContext: (objectMemory followField: SuspendedContextIndex ofObject: proc)) ifFalse: [^self primitiveFailFor: PrimErrBadReceiver]. ''We're about to switch process, either to an interpreted frame or a machine code frame. To know whether to return or enter machine code we have to know from whence we came. We could have come from the interpreter, either directly or via a machine code primitive. We could have come from machine code. The instructionPointer tells us where from:'' inInterpreter := instructionPointer >= objectMemory startOfMemory. (self resume: proc preemptedYieldingIf: preemptionYields from: CSResume) ifTrue: [self forProcessPrimitiveReturnToExecutivePostContextSwitch: inInterpreter]"! Item was changed: ----- Method: InterpreterPrimitives>>primitiveResume (in category 'process primitives') ----- primitiveResume "Put this process on the scheduler's lists thus allowing it to proceed next time there is a chance for processes of it's priority level. It must go to the back of its run queue so as not to preempt any already running processes at this level. If the process's priority is higher than the current process, preempt the current process." + | proc ctxt | - | proc | proc := self stackTop. "rcvr" + ctxt := objectMemory followField: SuspendedContextIndex ofObject: proc. "written this way to get better Slang inlining" + (objectMemory isContext: ctxt) ifFalse: + [^self primitiveFailFor: PrimErrBadReceiver]. - (objectMemory isContext: (objectMemory followField: SuspendedContextIndex ofObject: proc)) ifFalse: - [^self primitiveFail]. self resume: proc preemptedYieldingIf: preemptionYields "Personally I would like to check MyList, which should not be one of the elements of the scheduler lists. But there are awful race conditions in things like should:notTakeMoreThan: that mean we can't. eem 9/27/2010 23:08, updated eem 5/20/2021 15:36. e.g. + | proc field | - | proc | proc := self stackTop. ''rcvr'' ''We only have to check for myList being nil. If it is nil then this is either the active process or a process suspended with primitiveSuspend (and if it is the activeProcess suspendedContext will be nil and the isContext: test will fail). If it is not nil then either the process is waiting on some semaphore-like list or on one of the scheduler's lists. If it is on some semaphore-like list it should not resume. If it is on one of the scheduler's lists it is runnable (already resumed).'' + field := objectMemory followField: MyListIndex ofObject: proc. + objectMemory nilObject = field ifFalse: - objectMemory nilObject = (objectMemory followField: MyListIndex ofObject: proc) ifFalse: [^self primitiveFailFor: PrimErrInappropriate]. + field := objectMemory followField: SuspendedContextIndex ofObject: proc. + (objectMemory isContext: field) ifFalse: - (objectMemory isContext: (objectMemory followField: SuspendedContextIndex ofObject: proc)) ifFalse: [^self primitiveFailFor: PrimErrBadReceiver]. self resume: proc preemptedYieldingIf: preemptionYields"! |
Free forum by Nabble | Edit this page |