David T. Lewis uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker-dtl.423.mcz ==================== Summary ==================== Name: VMMaker-dtl.423 Author: dtl Time: 20 March 2021, 12:27:52.291 pm UUID: b744c4a9-0a90-4104-8680-6e815df0f064 Ancestors: VMMaker-dtl.422 VMMaker 4.19.6 restore support for objects as methods. Extend the internal size of primitiveTable beyond MaxPrimitiveIndex and reinstall primitiveInvokeObjectAsMethod in the protected region. Allows invocation from lookupMethodInDictionary without exposing the method to the image as a numbered primitive. Also clean up a duplicate currentByteCode in class Interpreter declaration, not sure how that happened. =============== Diff against VMMaker-dtl.422 =============== Item was changed: ----- Method: ContextInterpreter class>>declareCVarsIn: (in category 'translation') ----- declareCVarsIn: aCCodeGenerator aCCodeGenerator addHeaderFile: '<setjmp.h>'. aCCodeGenerator var: #statGCTime type: #sqLong. aCCodeGenerator var: #statFullGCMSecs type: #sqLong. aCCodeGenerator var: #statIGCDeltaTime type: #sqLong. aCCodeGenerator var: #statIncrGCMSecs type: #sqLong. aCCodeGenerator var: #compilerHooks declareC: 'sqInt (*compilerHooks[' , (CompilerHooksSize + 1) printString , '])()'. aCCodeGenerator var: #interpreterVersion declareC: 'const char *interpreterVersion = "' , SmalltalkImage current datedVersion , ' [' , SmalltalkImage current lastUpdateString , ']"'. self declareCAsOop: {#newMethod. #activeContext. #theHomeContext} in: aCCodeGenerator. "Reinitialized at interpreter entry by #initializeImageFormatVersion" aCCodeGenerator var: #imageFormatVersionNumber declareC: 'sqInt imageFormatVersionNumber = 0'. "Declared here to prevent inclusion in foo struct by CCodeGeneratorGlobalStructure" aCCodeGenerator var: #imageFormatInitialVersion declareC: 'sqInt imageFormatInitialVersion = 0'. + aCCodeGenerator var: #primitiveTable declareC: 'void (*primitiveTable[', (MaxPrimitiveIndex + ProtectedPrimitiveCount + 1) asString, '])(void)'. - aCCodeGenerator var: #primitiveTable declareC: 'void (*primitiveTable[', MaxPrimitiveIndex asString, '])(void)'. aCCodeGenerator var: #primitiveTableDefaults declareC: 'void (*primitiveTableDefaults[' , (MaxPrimitiveIndex + 2) printString , '] )(void)= ' , self primitiveTableString. ! Item was changed: ----- Method: ContextInterpreter>>installPrimitiveTable (in category 'primitive table') ----- installPrimitiveTable <inline: false> + 0 to: MaxPrimitiveIndex + ProtectedPrimitiveCount do: [ :i | - 0 to: MaxPrimitiveIndex do: [ :i | primitiveTable at: i put: (primitiveTableDefaults at: i) ]. self updatePrimitiveTable. ! Item was changed: ----- Method: ContextInterpreter>>lookupMethodInDictionary: (in category 'message sending') ----- lookupMethodInDictionary: dictionary "This method lookup tolerates integers as Dictionary keys to support execution of images in which Symbols have been compacted out" | length index mask wrapAround nextSelector methodArray | <inline: true> length := objectMemory fetchWordLengthOf: dictionary. mask := length - SelectorStart - 1. (objectMemory isIntegerObject: messageSelector) ifTrue: [index := (mask bitAnd: (objectMemory integerValueOf: messageSelector)) + SelectorStart] ifFalse: [index := (mask bitAnd: (objectMemory hashBitsOf: messageSelector)) + SelectorStart]. "It is assumed that there are some nils in this dictionary, and search will stop when one is encountered. However, if there are no nils, then wrapAround will be detected the second time the loop gets to the end of the table." wrapAround := false. [true] whileTrue: [nextSelector := objectMemory fetchPointer: index ofObject: dictionary. nextSelector = objectMemory getNilObj ifTrue: [^ false]. nextSelector = messageSelector ifTrue: [methodArray := objectMemory fetchPointer: MethodArrayIndex ofObject: dictionary. newMethod := objectMemory fetchPointer: index - SelectorStart ofObject: methodArray. "Check if newMethod is a CompiledMethod." (objectMemory isCompiledMethod: newMethod) ifTrue: [primitiveIndex := self primitiveIndexOf: newMethod. primitiveIndex > MaxPrimitiveIndex ifTrue: ["If primitiveIndex is out of range, set to zero before putting in cache. This is equiv to primFail, and avoids the need to check on every send." primitiveIndex := 0]] ifFalse: ["indicate that this is no compiled method - use primitiveInvokeObjectAsMethod" + self flag: #primitiveInvokeObjectAsMethod. + primitiveIndex := MaxPrimitiveIndex + 1]. - primitiveIndex := 248]. ^ true]. index := index + 1. index = length ifTrue: [wrapAround ifTrue: [^ false]. wrapAround := true. index := SelectorStart]]! Item was changed: InterpreterPrimitives subclass: #Interpreter + instanceVariableNames: 'currentBytecode semaphoresUseBufferA semaphoresToSignalA semaphoresToSignalCountA semaphoresToSignalB semaphoresToSignalCountB extraVMMemory globalSessionID method instructionPointer stackPointer localIP localSP localReturnValue messageSelector primitiveFunctionPointer methodCache atCache lkupClass interruptPending savedWindowSize deferDisplayUpdates pendingFinalizationSignals interpreterProxy showSurfaceFn externalPrimitiveTable jmpBuf jmpDepth suspendedCallbacks suspendedMethods' + classVariableNames: 'AtCacheEntries AtCacheFixedFields AtCacheFmt AtCacheMask AtCacheOop AtCacheSize AtCacheTotalSize AtPutBase MaxExternalPrimitiveTableSize MaxJumpBuf MaxPrimitiveIndex ProtectedPrimitiveCount SemaphoresToSignalSize' - instanceVariableNames: 'currentBytecode semaphoresUseBufferA semaphoresToSignalA semaphoresToSignalCountA semaphoresToSignalB semaphoresToSignalCountB extraVMMemory globalSessionID method instructionPointer stackPointer localIP localSP localReturnValue messageSelector currentByteCode primitiveFunctionPointer methodCache atCache lkupClass interruptPending savedWindowSize deferDisplayUpdates pendingFinalizationSignals interpreterProxy showSurfaceFn externalPrimitiveTable jmpBuf jmpDepth suspendedCallbacks suspendedMethods' - classVariableNames: 'AtCacheEntries AtCacheFixedFields AtCacheFmt AtCacheMask AtCacheOop AtCacheSize AtCacheTotalSize AtPutBase MaxExternalPrimitiveTableSize MaxJumpBuf MaxPrimitiveIndex SemaphoresToSignalSize' poolDictionaries: 'VMMethodCacheConstants' category: 'VMMaker-Interpreter'! !Interpreter commentStamp: 'dtl 4/22/2016 22:14' prior: 0! This class is a complete implementation of the Smalltalk-80 virtual machine, derived originally from the Blue Book specification but quite different in some areas. ContextInterpreter is the Squeak interpreter VM as originally implemented by Dan Ingalls. StackInterpreter is the stack mapped interpreter by Eliot Miranda, which provides the basis for later Cog and Spur VMs.! Item was changed: ----- Method: Interpreter class>>declareCVarsIn: (in category 'translation') ----- declareCVarsIn: aCCodeGenerator aCCodeGenerator var: #interpreterProxy type: #'struct VirtualMachine*'. aCCodeGenerator var: 'semaphoresToSignalA' declareC: 'sqInt semaphoresToSignalA[' , (SemaphoresToSignalSize + 1) printString , ']'. aCCodeGenerator var: 'semaphoresToSignalB' declareC: 'sqInt semaphoresToSignalB[' , (SemaphoresToSignalSize + 1) printString , ']'. + self declareC: #(stackPointer instructionPointer method) - self declareC: #(instructionPointer method) as: #usqInt in: aCCodeGenerator. + self declareC: #(localIP localSP) - self declareC: #(stackPointer localIP localSP) as: #'char *' in: aCCodeGenerator. aCCodeGenerator var: #primitiveFunctionPointer declareC: 'void (*primitiveFunctionPointer)()'. aCCodeGenerator var: #methodCache declareC: 'long methodCache[MethodCacheSize + 1 /* ', (MethodCacheSize + 1) printString, ' */]'. aCCodeGenerator var: #atCache declareC: 'sqInt atCache[AtCacheTotalSize + 1 /* ', (AtCacheTotalSize + 1) printString, ' */]'. aCCodeGenerator var: #showSurfaceFn type: #'void *'. aCCodeGenerator var: #externalPrimitiveTable declareC: 'void (*externalPrimitiveTable[' , (MaxExternalPrimitiveTableSize + 1) printString , '])(void)'. aCCodeGenerator var: #jmpBuf declareC: 'jmp_buf jmpBuf[MaxJumpBuf + 1 /* ', (MaxJumpBuf + 1) printString, ' */]'. aCCodeGenerator var: #suspendedCallbacks declareC: 'usqInt suspendedCallbacks[MaxJumpBuf + 1 /* ', (MaxJumpBuf + 1) printString, ' */]'. aCCodeGenerator var: #suspendedMethods declareC: 'usqInt suspendedMethods[MaxJumpBuf + 1 /* ', (MaxJumpBuf + 1) printString, ' */]'. ! Item was changed: ----- Method: Interpreter class>>initializePrimitiveTable (in category 'initialization') ----- (excessive size, no diff calculated) Item was changed: ----- Method: VMMaker class>>versionString (in category 'version testing') ----- versionString "VMMaker versionString" + ^'4.19.6'! - ^'4.19.5'! |
Free forum by Nabble | Edit this page |