Esteban Lorenzano uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-EstebanLorenzano.1321.mcz
==================== Summary ====================
Name: VMMaker.oscog-EstebanLorenzano.1321 Author: EstebanLorenzano Time: 22 May 2015, 1:10:57.157449 pm UUID: 1d5fdcdd-b2cb-4f67-b92d-c3b4e1ac710a Ancestors: VMMaker.oscog-EstebanLorenzano.1320, VMMaker.oscog-eem.1319
- merged - nuked unused/incorrect methods - removed executable memory flags... this is just necesary for NativeBoost and we are not including at the moment. I took notes in case we want to put it back in the future. - removed inclusion of <setjmp.h>, it was needed for windows in the case of nativeboost.
=============== Diff against VMMaker.oscog-EstebanLorenzano.1320 ===============
Item was changed: ----- Method: CoInterpreter>>initStackPagesAndInterpret (in category 'initialization') ----- initStackPagesAndInterpret "Initialize the stack pages and enter interpret. Use alloca'ed memory so that when we have a JIT its stack pointer will be on the native stack since alloca allocates memory on the stack. Certain thread systems use the native stack pointer as the frame ID so putting the stack anywhere else can confuse the thread system."
"Override to establish the setjmp/longjmp handler for reentering the interpreter from machine code, and disable executablity on the heap and stack pages."
"This should be in its own initStackPages method but Slang can't inline C code strings." | stackPageBytes stackPagesBytes theStackMemory | <var: #theStackMemory type: #'char *'> stackPageBytes := self stackPageByteSize. stackPagesBytes := self computeStackZoneSize. theStackMemory := self cCode: [self alloca: stackPagesBytes] inSmalltalk: [stackPages initializeWithByteSize: stackPagesBytes for: self]. self cCode: [self me: theStackMemory ms: 0 et: stackPagesBytes]. + self sqMakeMemoryNotExecutableFrom: objectMemory startOfMemory asUnsignedInteger + To: objectMemory memoryLimit asUnsignedInteger. + self sqMakeMemoryNotExecutableFrom: theStackMemory asUnsignedInteger - self cppIf: #PHAROVM_USE_EXECUTABLE_MEMORY - ifTrue: [ - self - sqMakeMemoryExecutableFrom: objectMemory startOfMemory asUnsignedInteger - To: objectMemory memoryLimit asUnsignedInteger ] - ifFalse: [ - self - sqMakeMemoryNotExecutableFrom: objectMemory startOfMemory asUnsignedInteger - To: objectMemory memoryLimit asUnsignedInteger ]. - self - sqMakeMemoryNotExecutableFrom: theStackMemory asUnsignedInteger To: theStackMemory asUnsignedInteger + stackPagesBytes. - stackPages initializeStack: theStackMemory numSlots: stackPagesBytes / objectMemory wordSize pageSize: stackPageBytes / objectMemory wordSize. self assert: self minimumUnusedHeadroom = stackPageBytes.
"Once the stack pages are initialized we can continue to bootstrap the system." self loadInitialContext. "We're ready for the heartbeat (poll interrupt)" self ioInitHeartbeat. self initialEnterSmalltalkExecutive. ^nil!
Item was changed: ----- Method: Cogit class>>declareCVarsIn: (in category 'translation') ----- declareCVarsIn: aCCodeGenerator #( 'coInterpreter' 'objectMemory' 'methodZone' 'objectRepresentation' 'cogBlockMethodSurrogateClass' 'cogMethodSurrogateClass' 'nsSendCacheSurrogateClass' 'threadManager' 'processor' 'lastNInstructions' 'simulatedAddresses' 'simulatedTrampolines' 'simulatedVariableGetters' 'simulatedVariableSetters' 'printRegisters' 'printInstructions' 'clickConfirm' 'singleStep') do: [:simulationVariableNotNeededForRealVM| aCCodeGenerator removeVariable: simulationVariableNotNeededForRealVM]. NewspeakVM ifFalse: [#( 'selfSendTrampolines' 'dynamicSuperSendTrampolines' 'implicitReceiverSendTrampolines' 'outerSendTrampolines' 'ceEnclosingObjectTrampoline' 'numIRCs' 'indexOfIRC' 'theIRCs') do: [:variableNotNeededInNormalVM| aCCodeGenerator removeVariable: variableNotNeededInNormalVM]]. aCCodeGenerator removeConstant: #COGMTVM. "this should be defined at compile time" aCCodeGenerator addHeaderFile:'<stddef.h>'; "for e.g. offsetof" - addHeaderFile:'<setjmp.h>'; addHeaderFile:'"sqCogStackAlignment.h"'; addHeaderFile:'"dispdbg.h"'; "must preceed cointerp.h & cogit.h otherwise NoDbgRegParms gets screwed up" addHeaderFile:'"cogmethod.h"'. NewspeakVM ifTrue: [aCCodeGenerator addHeaderFile:'"nssendcache.h"']. aCCodeGenerator addHeaderFile:'#if COGMTVM'; addHeaderFile:'"cointerpmt.h"'; addHeaderFile:'#else'; addHeaderFile:'"cointerp.h"'; addHeaderFile:'#endif'; addHeaderFile:'"cogit.h"'. aCCodeGenerator var: #ceGetSP declareC: 'unsigned long (*ceGetSP)(void)'; var: #ceCaptureCStackPointers declareC: 'void (*ceCaptureCStackPointers)(void)'; var: #ceEnterCogCodePopReceiverReg declareC: 'void (*ceEnterCogCodePopReceiverReg)(void)'; var: #realCEEnterCogCodePopReceiverReg declareC: 'void (*realCEEnterCogCodePopReceiverReg)(void)'; var: #ceCallCogCodePopReceiverReg declareC: 'void (*ceCallCogCodePopReceiverReg)(void)'; var: #realCECallCogCodePopReceiverReg declareC: 'void (*realCECallCogCodePopReceiverReg)(void)'; var: #ceCallCogCodePopReceiverAndClassRegs declareC: 'void (*ceCallCogCodePopReceiverAndClassRegs)(void)'; var: #realCECallCogCodePopReceiverAndClassRegs declareC: 'void (*realCECallCogCodePopReceiverAndClassRegs)(void)'; var: #ceFlushICache declareC: 'static void (*ceFlushICache)(unsigned long from, unsigned long to)'; var: #ceCheckFeaturesFunction declareC: 'static unsigned long (*ceCheckFeaturesFunction)(void)'; var: #ceTryLockVMOwner declareC: 'unsigned long (*ceTryLockVMOwner)(void)'; var: #ceUnlockVMOwner declareC: 'void (*ceUnlockVMOwner)(void)'; var: #postCompileHook declareC: 'void (*postCompileHook)(CogMethod *, void *)'; var: #openPICList declareC: 'CogMethod *openPICList = 0'; var: #maxMethodBefore type: #'CogBlockMethod *'. aCCodeGenerator declareVar: 'aMethodLabel' type: #'AbstractInstruction'; "Has to come lexicographically before backEnd & methodLabel" var: #backEnd declareC: 'AbstractInstruction * const backEnd = &aMethodLabel'; var: #methodLabel declareC: 'AbstractInstruction * const methodLabel = &aMethodLabel'; var: #primInvokeLabel type: #'AbstractInstruction *'. self declareC: #(abstractOpcodes stackCheckLabel blockEntryLabel blockEntryNoContextSwitch stackOverflowCall sendMiss entry noCheckEntry selfSendEntry dynSuperEntry picMNUAbort picInterpretAbort endCPICCase0 endCPICCase1) as: #'AbstractInstruction *' in: aCCodeGenerator. aCCodeGenerator declareVar: #annotations type: #'InstructionAnnotation *'; declareVar: #blockStarts type: #'BlockStart *'; declareVar: #fixups type: #'BytecodeFixup *'. aCCodeGenerator var: #ordinarySendTrampolines declareC: 'sqInt ordinarySendTrampolines[NumSendTrampolines]'; var: #superSendTrampolines declareC: 'sqInt superSendTrampolines[NumSendTrampolines]'; var: #directedSuperSendTrampolines declareC: 'sqInt directedSuperSendTrampolines[NumSendTrampolines]'; var: #selfSendTrampolines declareC: 'sqInt selfSendTrampolines[NumSendTrampolines]'; var: #dynamicSuperSendTrampolines declareC: 'sqInt dynamicSuperSendTrampolines[NumSendTrampolines]'; var: #implicitReceiverSendTrampolines declareC: 'sqInt implicitReceiverSendTrampolines[NumSendTrampolines]'; var: #outerSendTrampolines declareC: 'sqInt outerSendTrampolines[NumSendTrampolines]'; var: #trampolineAddresses declareC: 'static char *trampolineAddresses[NumTrampolines*2]'; var: #objectReferencesInRuntime declareC: 'static sqInt objectReferencesInRuntime[NumObjRefsInRuntime]'; var: #labelCounter type: #int; var: #traceFlags declareC: 'int traceFlags = 8 /* prim trace log on by default */'; var: #cStackAlignment declareC: 'const int cStackAlignment = STACK_ALIGN_BYTES'. aCCodeGenerator declareVar: #CFramePointer type: #'void *'; declareVar: #CStackPointer type: #'void *'; declareVar: #minValidCallAddress type: #'unsigned long'; declareVar: #debugPrimCallStackOffset type: #'unsigned long'. aCCodeGenerator vmClass generatorTable ifNotNil: [:bytecodeGenTable| aCCodeGenerator var: #generatorTable declareC: 'static BytecodeDescriptor generatorTable[', bytecodeGenTable size, ']', (self tableInitializerFor: bytecodeGenTable in: aCCodeGenerator); var: #primitiveGeneratorTable declareC: 'static PrimitiveDescriptor primitiveGeneratorTable[MaxCompiledPrimitiveIndex+1]', (self tableInitializerFor: aCCodeGenerator vmClass primitiveTable in: aCCodeGenerator)]. "In C the abstract opcode names clash with the Smalltak generator syntactic sugar. Most of the syntactic sugar is inlined, but alas some remains. Rename the syntactic sugar to avoid the clash." (self organization listAtCategoryNamed: #'abstract instructions') do: [:s| aCCodeGenerator addSelectorTranslation: s to: 'g', (aCCodeGenerator cFunctionNameFor: s)]. aCCodeGenerator addSelectorTranslation: #halt: to: 'haltmsg'!
Item was changed: ----- Method: Cogit>>generateClosedPICPrototype (in category 'initialization') ----- generateClosedPICPrototype "Generate the prototype ClosedPIC to determine how much space as full PIC takes. When we first allocate a closed PIC it only has one or two cases and we want to grow it. So we have to determine how big a full one is before hand." numPICCases := 6. + methodLabel + address: methodZoneBase; + dependent: nil. "stack allocate the various collections so that they are effectively garbage collected on return." self allocateOpcodes: numPICCases * 7 bytecodes: 0. self compileClosedPICPrototype. self computeMaximumSizes. methodLabel concretizeAt: methodZoneBase. closedPICSize := (self sizeof: CogMethod) + (self generateInstructionsAt: methodZoneBase + (self sizeof: CogMethod)). firstCPICCaseOffset := endCPICCase0 address - methodZoneBase. cPICCaseSize := endCPICCase1 address - endCPICCase0 address. cPICEndSize := closedPICSize - (numPICCases - 1 * cPICCaseSize + firstCPICCaseOffset). closedPICSize := methodZone roundUpLength: closedPICSize "self cCode: '' inSmalltalk: [| end | end := self outputInstructionsAt: methodZoneBase + headerSize. self disassembleFrom: methodZoneBase + headerSize to: end - 1. self halt]"!
Item was removed: - ----- Method: CurrentImageCoInterpreterFacadeForSqueakV3ObjectRepresentation>>compactClassIndexOfClass: (in category 'accessing') ----- - compactClassIndexOfClass: classOop - "Ugh, can't reply on the host. Spur doesn't have compact classes" - | aClass contextClass | - aClass := self objectForOop: classOop. - "Pharo requires Context while Squeak uses MethodContext" - contextClass := (Smalltalk at: #MethodContext - ifAbsent: [ Smalltalk at: #Context ]). - ^false - ifTrue: [aClass indexIfCompact] - ifFalse: - [aClass caseOf: { - [CompiledMethod] -> [1]. - [Array] -> [3]. - [LargeNegativeInteger] -> [4]. - [LargePositiveInteger] -> [5]. - [Float] -> [6]. - [Association] -> [8]. - [Point] -> [9]. - [Rectangle] -> [10]. - [ByteString] -> [11]. - [contextClass ] -> [14]. - [Bitmap] -> [16] - } - otherwise: [0]]!
Item was changed: ----- Method: Spur32BitCoMemoryManager>>assimilateNewSegment: (in category 'growing/shrinking memory') ----- assimilateNewSegment: segInfo "Update after adding a segment. Here we make sure the new segment is not executable." <var: #segInfo type: #'SpurSegmentInfo *'> super assimilateNewSegment: segInfo. + coInterpreter sqMakeMemoryNotExecutableFrom: segInfo segStart To: segInfo segLimit! - self - cppIf: #PHAROVM_USE_EXECUTABLE_MEMORY - ifTrue: [ coInterpreter sqMakeMemoryExecutableFrom: segInfo segStart To: segInfo segLimit ] - ifFalse: [ coInterpreter sqMakeMemoryNotExecutableFrom: segInfo segStart To: segInfo segLimit ] - !
Item was removed: - ----- Method: Spur32BitMemoryManager class>>objectRepresentationClass (in category 'accessing class hierarchy') ----- - objectRepresentationClass - ^CogObjectRepresentationFor32BitSpur!
vm-dev@lists.squeakfoundation.org