Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1412.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1412 Author: eem Time: 13 July 2015, 12:11:15.513 pm UUID: 9ad800be-824a-428d-a1ce-e71b7619aa00 Ancestors: VMMaker.oscog-tpr.1411
P{rovide hook for ARM compiler to declare the divmod functions.
=============== Diff against VMMaker.oscog-tpr.1411 ===============
Item was added: + ----- Method: CogAbstractInstruction class>>declareCVarsIn: (in category 'translation') ----- + declareCVarsIn: aCCodeGenerator + "Do nothing; subclasses that need to can add code in their own version."!
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:'"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 *)'; 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'. self declareC: #(abstractOpcodes stackCheckLabel blockEntryLabel blockEntryNoContextSwitch stackOverflowCall sendMiss entry noCheckEntry selfSendEntry dynSuperEntry picMNUAbort picInterpretAbort endCPICCase0 endCPICCase1) as: #'AbstractInstruction *' in: aCCodeGenerator. aCCodeGenerator 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 usqInt 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'. + + self activeCompilerClass declareCVarsIn: aCCodeGenerator! - aCCodeGenerator addSelectorTranslation: #halt: to: 'haltmsg'!
Item was changed: ----- Method: StackToRegisterMappingCogit>>genPrimitiveDiv (in category 'primitive generators') ----- genPrimitiveDiv | jumpNotSI jumpZero jumpExact jumpSameSign convert | - "this is for primitive 12" <var: #convert type: #'AbstractInstruction *'> <var: #jumpZero type: #'AbstractInstruction *'> <var: #jumpNotSI type: #'AbstractInstruction *'> <var: #jumpExact type: #'AbstractInstruction *'> <var: #jumpSameSign type: #'AbstractInstruction *'> self MoveR: Arg0Reg R: ClassReg. self MoveR: Arg0Reg R: Arg1Reg. jumpNotSI := objectRepresentation genJumpNotSmallInteger: Arg0Reg scratchReg: TempReg. "We must shift away the tags, not just subtract them, so that the overflow case doesn't actually overflow the machine instruction." objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: ClassReg. (self lastOpcode setsConditionCodesFor: JumpZero) ifFalse: [self CmpCq: 0 R: ClassReg]. jumpZero := self JumpZero: 0. self MoveR: ReceiverResultReg R: TempReg. objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: TempReg. self DivR: ClassReg R: TempReg Quo: TempReg Rem: ClassReg. "If remainder is zero we must check for overflow." self CmpCq: 0 R: ClassReg. jumpExact := self JumpZero: 0. "If arg and remainder signs are different we must round down." self XorR: ClassReg R: Arg1Reg. (self lastOpcode setsConditionCodesFor: JumpZero) ifFalse: [self CmpCq: 0 R: Arg1Reg]. jumpSameSign := self JumpGreaterOrEqual: 0. self SubCq: 1 R: TempReg. jumpSameSign jmpTarget: (convert := self Label). objectRepresentation genConvertIntegerToSmallIntegerInReg: TempReg. self MoveR: TempReg R: ReceiverResultReg. self RetN: 0. "test for overflow; the only case is SmallInteger minVal // -1" jumpExact jmpTarget: (self CmpCq: (1 << (objectRepresentation numSmallIntegerBits - 1)) R: TempReg). self JumpLess: convert. jumpZero jmpTarget: (jumpNotSI jmpTarget: self Label). ^0!
Item was changed: ----- Method: StackToRegisterMappingCogit>>genPrimitiveDivide (in category 'primitive generators') ----- genPrimitiveDivide | jumpNotSI jumpZero jumpInexact jumpOverflow | - "this is for primitive 10" <var: #jumpNotSI type: #'AbstractInstruction *'> <var: #jumpZero type: #'AbstractInstruction *'> <var: #jumpInexact type: #'AbstractInstruction *'> <var: #jumpOverflow type: #'AbstractInstruction *'> self MoveR: Arg0Reg R: ClassReg. jumpNotSI := objectRepresentation genJumpNotSmallInteger: Arg0Reg scratchReg: TempReg. "We must shift away the tags, not just subtract them, so that the overflow case doesn't actually overflow the machine instruction." objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: ClassReg. jumpZero := self JumpZero: 0. self MoveR: ReceiverResultReg R: TempReg. objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: TempReg. self DivR: ClassReg R: TempReg Quo: TempReg Rem: ClassReg. "If remainder is non-zero fail." self CmpCq: 0 R: ClassReg. jumpInexact := self JumpNonZero: 0. "test for overflow; the only case is SmallInteger minVal / -1" self CmpCq: (1 << (objectRepresentation numSmallIntegerBits - 1)) R: TempReg. jumpOverflow := self JumpGreaterOrEqual: 0. objectRepresentation genConvertIntegerToSmallIntegerInReg: TempReg. self MoveR: TempReg R: ReceiverResultReg. self RetN: 0. jumpOverflow jmpTarget: (jumpInexact jmpTarget: (jumpZero jmpTarget: (jumpNotSI jmpTarget: self Label))). ^0!
Item was changed: ----- Method: StackToRegisterMappingCogit>>genPrimitiveMod (in category 'primitive generators') ----- genPrimitiveMod | jumpNotSI jumpZero jumpExact jumpSameSign | - "this is for primitive 11" <var: #jumpNotSI type: #'AbstractInstruction *'> <var: #jumpZero type: #'AbstractInstruction *'> <var: #jumpExact type: #'AbstractInstruction *'> <var: #jumpSameSign type: #'AbstractInstruction *'> self MoveR: Arg0Reg R: ClassReg. jumpNotSI := objectRepresentation genJumpNotSmallInteger: Arg0Reg scratchReg: TempReg. objectRepresentation genRemoveSmallIntegerTagsInScratchReg: ClassReg. jumpZero := self JumpZero: 0. self MoveR: ClassReg R: Arg1Reg. self MoveR: ReceiverResultReg R: TempReg. objectRepresentation genRemoveSmallIntegerTagsInScratchReg: TempReg. self DivR: ClassReg R: TempReg Quo: TempReg Rem: ClassReg. "If remainder is zero we're done." self CmpCq: 0 R: ClassReg. jumpExact := self JumpZero: 0. "If arg and remainder signs are different we must reflect around zero." self XorR: ClassReg R: Arg1Reg. (self lastOpcode setsConditionCodesFor: JumpZero) ifFalse: [self CmpCq: 0 R: Arg1Reg]. jumpSameSign := self JumpGreaterOrEqual: 0. self XorR: ClassReg R: Arg1Reg. self AddR: Arg1Reg R: ClassReg. jumpSameSign jmpTarget: (jumpExact jmpTarget: self Label). objectRepresentation genSetSmallIntegerTagsIn: ClassReg. self MoveR: ClassReg R: ReceiverResultReg. self RetN: 0. jumpZero jmpTarget: (jumpNotSI jmpTarget: self Label). ^0!
Item was changed: ----- Method: StackToRegisterMappingCogit>>genPrimitiveQuo (in category 'primitive generators') ----- genPrimitiveQuo | jumpNotSI jumpZero jumpOverflow | - "this is for primitive 13" <var: #jumpNotSI type: #'AbstractInstruction *'> <var: #jumpZero type: #'AbstractInstruction *'> <var: #jumpOverflow type: #'AbstractInstruction *'> self MoveR: Arg0Reg R: ClassReg. jumpNotSI := objectRepresentation genJumpNotSmallInteger: Arg0Reg scratchReg: TempReg. "We must shift away the tags, not just subtract them, so that the overflow case doesn't actually overflow the machine instruction." objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: ClassReg. (self lastOpcode setsConditionCodesFor: JumpZero) ifFalse: [self CmpCq: 0 R: ClassReg]. jumpZero := self JumpZero: 0. self MoveR: ReceiverResultReg R: TempReg. objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: TempReg. self DivR: ClassReg R: TempReg Quo: TempReg Rem: ClassReg. "test for overflow; the only case is SmallInteger minVal quo: -1" self CmpCq: (1 << (objectRepresentation numSmallIntegerBits - 1)) R: TempReg. jumpOverflow := self JumpGreaterOrEqual: 0. objectRepresentation genConvertIntegerToSmallIntegerInReg: TempReg. self MoveR: TempReg R: ReceiverResultReg. self RetN: 0. jumpOverflow jmpTarget: (jumpZero jmpTarget: (jumpNotSI jmpTarget: self Label)). ^0!
vm-dev@lists.squeakfoundation.org