Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2941.mcz ==================== Summary ==================== Name: VMMaker.oscog-eem.2941 Author: eem Time: 26 January 2021, 5:37:27.815241 pm UUID: 84ab4f06-0db7-4eca-b3de-b5ac04b17b92 Ancestors: VMMaker.oscog-eem.2940 Add explicit variables for the handler and unwind primitive markers (PrimNumberHandlerMarker & PrimNumberUnwindMarker), and add 123 as the no-context-switch marker (PrimNumberNoContextSwitchMarker). =============== Diff against VMMaker.oscog-eem.2940 =============== Item was changed: ----- Method: CurrentImageCoInterpreterFacade>>canContextSwitchIfActivating:header: (in category 'accessing') ----- canContextSwitchIfActivating: method header: header "Would like to do ^coInterpreter canContextSwitchIfActivating: method header: header but the bytecode access to get at the primitive number defeats us :-(, so the following may well get out-of-date..." + ^(self objectForOop: method) primitive ~= PrimNumberUnwindMarker + and: [(self objectForOop: method) primitive ~= PrimNumberNoContextSwitchMarker]! - ^(self objectForOop: method) primitive ~= 198! Item was changed: ----- Method: Interpreter>>isHandlerMarked: (in category 'compiled methods') ----- isHandlerMarked: aContext "Is this a MethodContext whose meth has a primitive number of 199?" | header meth pIndex | "NB: the use of a primitive number for marking the method is pretty grungy, but it is simple to use for a test sytem, not too expensive and we don't actually have the two spare method header bits we need. We can probably obtain them when the method format is changed. NB 2: actually, the jitter will probably implement the prim to actually mark the volatile frame by changing the return function pointer." <inline: true> header := self baseHeader: aContext. (self isMethodContextHeader: header) ifFalse: [^false]. meth := self fetchPointer: MethodIndex ofObject: aContext. pIndex := self primitiveIndexOf: meth. + ^pIndex == PrimNumberHandlerMarker - ^pIndex == 199 ! Item was changed: ----- Method: StackInterpreter class>>initializePrimitiveTable (in category 'initialization') ----- (excessive size, no diff calculated) Item was changed: ----- Method: StackInterpreter>>canContextSwitchIfActivating:header: (in category 'message sending') ----- canContextSwitchIfActivating: theMethod header: methodHeader + "Context switch should not be allowed on every method activation. In particular the + implementation of ensure: and ifCurtailed: depends on there being no suspension point + on failing primitive 198 (primitiveMarkUnwindMethod, primitiveMarkUnwindMethod). + slowPrimitiveResponse used to state - "Context switch should not be allowed on every method activation. In particular - the implementation of ensure: and ifCurtailed: depends on there being no - suspension point on failing primitive 198 (primitiveMarkUnwindMethod). - slowPrimitiveResponse states ``N.B. This means there is no suspension point on primitive failure which methods such as ensure: and ifCurtailed: rely on.'' Rather than prevent context switch on all primitives but the ones we really need to be suspension points (primitiveSignal et al) we choose to allow context switch + for all but primitiveMarkUnwindMethod and PrimNumberNoContextSwitch." - for all but primitiveMarkUnwindMethod." | primitiveIndex | <api> <inline: true> primitiveIndex := self primitiveIndexOfMethod: theMethod header: methodHeader. ^self cppIf: true ifTrue: + [primitiveIndex ~= PrimNumberUnwindMarker "198 primitiveMarkUnwindMethod" + and: [primitiveIndex ~= PrimNumberNoContextSwitchMarker "123"]] - [primitiveIndex ~= 198] "primitiveMarkUnwindMethod" ifFalse: [primitiveIndex = 0 or: [(primitiveIndex between: 85 and: 88) "primitiveSignal primitiveWait primitiveResume primitiveSuspend" or: [primitiveIndex = 167 "primitiveYield" or: [primitiveIndex between: 185 and: 186 "primitiveExitCriticalSection primitiveEnterCriticalSection"]]]]! Item was changed: ----- Method: StackInterpreter>>findUnwindThroughContext: (in category 'return bytecodes') ----- findUnwindThroughContext: homeContext + "Search for either an unwind-protect (activation of method with primitive 198, PrimNumberUnwindMarker) - "Search for either an unwind-protect (activation of method with primitive 198) or homeContext along the sender chain, which ever is found first. Return values: 0 home context was found on sender chain with no intervening unwind-protects nilObj home context could not be found => cannotReturn context the context of an intervening unwind-protect implies home context was found" | onSamePage ctxtOrNilOrZero theMethod | "Almost always (98%) the home is on the same page, in which case we know it will be found." onSamePage := (self isStillMarriedContext: homeContext) and: [(stackPages pageIndexFor: framePointer) = (stackPages pageIndexFor: (self frameOfMarriedContext: homeContext))]. "Since nothing changes we don't need to internalize." + ctxtOrNilOrZero := self findMethodWithPrimitive: PrimNumberUnwindMarker FromFP: framePointer UpToContext: homeContext. - ctxtOrNilOrZero := self findMethodWithPrimitive: 198 FromFP: framePointer UpToContext: homeContext. self deny: (onSamePage and: [ctxtOrNilOrZero = objectMemory nilObject]). ctxtOrNilOrZero = 0 ifTrue: [theMethod := objectMemory fetchPointer: MethodIndex ofObject: homeContext. + (self primitiveIndexOf: theMethod) = PrimNumberUnwindMarker ifTrue: - (self primitiveIndexOf: theMethod) = 198 ifTrue: [^homeContext]. ^0]. "If an unwind was found, can the home context be found also? No need to look if on the same page. No need to look if cannot return (ctxtOrNilOrZero = objectMemory nilObject)" (onSamePage or: [ctxtOrNilOrZero = objectMemory nilObject]) ifFalse: [(self findMethodWithPrimitive: 0 FromContext: ctxtOrNilOrZero UpToContext: homeContext) = objectMemory nilObject ifTrue: [^objectMemory nilObject]]. ^ctxtOrNilOrZero! Item was changed: ----- Method: StackInterpreterPrimitives>>primitiveFindHandlerContext (in category 'control primitives') ----- primitiveFindHandlerContext "Primitive. Search up the context stack for the next method context marked for exception handling starting at the receiver. Return nil if none found" | handlerOrNilOrZero | self externalWriteBackHeadFramePointers. handlerOrNilOrZero := self + findMethodWithPrimitive: PrimNumberHandlerMarker - findMethodWithPrimitive: 199 FromContext: self stackTop UpToContext: objectMemory nilObject. handlerOrNilOrZero = 0 ifTrue: [handlerOrNilOrZero := objectMemory nilObject]. self pop: 1 thenPush: handlerOrNilOrZero! Item was changed: ----- Method: StackInterpreterPrimitives>>primitiveFindNextUnwindContext (in category 'control primitives') ----- primitiveFindNextUnwindContext "Primitive. Search up the context stack for the next method context marked for unwind handling from the receiver up to but not including the argument. Return nil if none found." | stopContext calleeContext handlerOrNilOrZero | <var: #theFP type: #'char *'> stopContext := self stackTop. calleeContext := self stackValue: 1. (stopContext = objectMemory nilObject or: [objectMemory isContext: stopContext]) ifFalse: [^self primitiveFail]. "The following should never be true, but developing full blocks, early in September 2016 we were seeing invalid invocations of this primitive.. Hence the assert:" self assert: stopContext ~= calleeContext. self externalWriteBackHeadFramePointers. (self isStillMarriedContext: calleeContext) ifTrue: [| theFP | theFP := self frameOfMarriedContext: calleeContext. (self isBaseFrame: theFP) ifTrue: + [handlerOrNilOrZero := self findMethodWithPrimitive: PrimNumberUnwindMarker - [handlerOrNilOrZero := self findMethodWithPrimitive: 198 FromContext: (self frameCallerContext: theFP) UpToContext: stopContext] ifFalse: + [handlerOrNilOrZero := self findMethodWithPrimitive: PrimNumberUnwindMarker - [handlerOrNilOrZero := self findMethodWithPrimitive: 198 FromFP: (self frameCallerFP: theFP) UpToContext: stopContext]] ifFalse: [| startContext | startContext := objectMemory fetchPointer: SenderIndex ofObject: calleeContext. (objectMemory isContext: startContext) ifTrue: + [handlerOrNilOrZero := self findMethodWithPrimitive: PrimNumberUnwindMarker - [handlerOrNilOrZero := self findMethodWithPrimitive: 198 FromContext: startContext UpToContext: stopContext] ifFalse: [handlerOrNilOrZero := 0]]. handlerOrNilOrZero = 0 ifTrue: [handlerOrNilOrZero := objectMemory nilObject]. self pop: 2 thenPush: handlerOrNilOrZero! Item was changed: SharedPool subclass: #VMBasicConstants instanceVariableNames: '' + classVariableNames: 'BaseHeaderSize BytecodeSetHasExtensions BytesPerOop BytesPerWord COGMTVM COGVM CloneOnGC CloneOnScavenge DisownVMForFFICall DisownVMForThreading DoAssertionChecks DoExpensiveAssertionChecks GCCheckPrimCall GCModeBecome GCModeFreeSpace GCModeFull GCModeImageSegment GCModeIncremental GCModeNewSpace HashMultiplyConstant HashMultiplyMask IMMUTABILITY LowcodeVM MULTIPLEBYTECODESETS NewspeakVM PharoVM PrimErrBadArgument PrimErrBadIndex PrimErrBadMethod PrimErrBadNumArgs PrimErrBadReceiver PrimErrCallbackError PrimErrFFIException PrimErrGenericFailure PrimErrInappropriate PrimErrLimitExceeded PrimErrNamedInternal PrimErrNeedCompaction PrimErrNoCMemory PrimErrNoMemory PrimErrNoModification PrimErrNotFound PrimErrOSError PrimErrObjectIsPinned PrimErrObjectMayMove PrimErrObjectMoved PrimErrObjectNotPinned PrimErrOperationFailed PrimErrUnsupported PrimErrWritePastObject PrimNoErr PrimNumberHandlerMarker PrimNumberNoContextSwitchMarker PrimNumberUnwindMarker SPURVM STACKV M SistaVM TempVectReadBarrier VMBIGENDIAN' - classVariableNames: 'BaseHeaderSize BytecodeSetHasExtensions BytesPerOop BytesPerWord COGMTVM COGVM CloneOnGC CloneOnScavenge DisownVMForFFICall DisownVMForThreading DoAssertionChecks DoExpensiveAssertionChecks GCCheckPrimCall GCModeBecome GCModeFreeSpace GCModeFull GCModeImageSegment GCModeIncremental GCModeNewSpace HashMultiplyConstant HashMultiplyMask IMMUTABILITY LowcodeVM MULTIPLEBYTECODESETS NewspeakVM PharoVM PrimErrBadArgument PrimErrBadIndex PrimErrBadMethod PrimErrBadNumArgs PrimErrBadReceiver PrimErrCallbackError PrimErrFFIException PrimErrGenericFailure PrimErrInappropriate PrimErrLimitExceeded PrimErrNamedInternal PrimErrNeedCompaction PrimErrNoCMemory PrimErrNoMemory PrimErrNoModification PrimErrNotFound PrimErrOSError PrimErrObjectIsPinned PrimErrObjectMayMove PrimErrObjectMoved PrimErrObjectNotPinned PrimErrOperationFailed PrimErrUnsupported PrimErrWritePastObject PrimNoErr SPURVM STACKVM SistaVM TempVectReadBarrier VMBIGENDIAN' poolDictionaries: '' category: 'VMMaker-Interpreter'! !VMBasicConstants commentStamp: '<historical>' prior: 0! I am a shared pool for basic constants upon which the VM as a whole depends. self ensureClassPool. self classPool declare: #BytesPerWord from: VMSqueakV3ObjectRepresentationConstants classPool. self classPool declare: #BaseHeaderSize from: VMSqueakV3ObjectRepresentationConstants classPool (ObjectMemory classPool keys select: [:k| k beginsWith: 'Byte']) do: [:k| self classPool declare: k from: ObjectMemory classPool]! |
Free forum by Nabble | Edit this page |