diff --git a/platforms/Cross/vm/sqCogStackAlignment.h b/platforms/Cross/vm/sqCogStackAlignment.h index e404ecf2cc..3e689b2878 100644 --- a/platforms/Cross/vm/sqCogStackAlignment.h +++ b/platforms/Cross/vm/sqCogStackAlignment.h @@ -168,10 +168,18 @@ # define STACK_SP_ALIGNMENT 0 #endif #if !defined(assertCStackWellAligned) -# define assertCStackWellAligned() do { \ +# if defined(cFramePointerInUse) +# define assertCStackWellAligned() do { \ + if (cFramePointerInUse) \ + assert((getfp() & STACK_ALIGN_MASK) == STACK_FP_ALIGNMENT); \ + assert((getsp() & STACK_ALIGN_MASK) == STACK_SP_ALIGNMENT); \ +} while (0) +# else +# define assertCStackWellAligned() do { \ extern sqInt cFramePointerInUse; \ if (cFramePointerInUse) \ assert((getfp() & STACK_ALIGN_MASK) == STACK_FP_ALIGNMENT); \ assert((getsp() & STACK_ALIGN_MASK) == STACK_SP_ALIGNMENT); \ } while (0) +# endif #endif diff --git a/src/spur32.cog/cogit.h b/src/spur32.cog/cogit.h index ef514cb146..7c8af1a49e 100644 --- a/src/spur32.cog/cogit.h +++ b/src/spur32.cog/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -118,7 +118,9 @@ extern sqInt ceReturnToInterpreterTrampoline; #if COGMTVM extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) extern sqInt cFramePointerInUse; +#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; diff --git a/src/spur32.cog/cogitARMv5.c b/src/spur32.cog/cogitARMv5.c index b89bc6747b..90a17fd96f 100644 --- a/src/spur32.cog/cogitARMv5.c +++ b/src/spur32.cog/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -916,6 +916,7 @@ static sqInt NoDbgRegParms genPureDoubleComparisoninvert(AbstractInstruction * N static sqInt NoDbgRegParms genSmallIntegerComparison(sqInt jumpOpcode); static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms isUnannotatableConstant(CogSimStackEntry *simStackEntry); +static sqInt NoDbgRegParms maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst); static sqInt NoDbgRegParms classForInlineCacheTag(sqInt inlineCacheTag); static sqInt NoDbgRegParms genAddSmallIntegerTagsTo(sqInt aRegister); static sqInt NoDbgRegParms genClearAndSetSmallIntegerTagsIn(sqInt scratchReg); @@ -2561,7 +2562,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2583,6 +2583,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -7085,8 +7088,7 @@ jumpLongByteSize(AbstractInstruction * self_in_jumpLongByteSize) static sqInt NoDbgRegParms jumpLongConditionalByteSize(AbstractInstruction * self_in_jumpLongConditionalByteSize) { - /* begin jumpLongByteSize */ - return 4; + return jumpLongByteSize(self_in_jumpLongConditionalByteSize); } @@ -7280,7 +7282,7 @@ loadPICLiteralByteSize(AbstractInstruction * self_in_loadPICLiteralByteSize) static sqInt NoDbgRegParms machineCodeWords(AbstractInstruction * self_in_machineCodeWords) { - return 8 /* machineCodeBytes */ / 4; + return (machineCodeBytes(self_in_machineCodeWords)) / 4; } @@ -8242,7 +8244,7 @@ blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction) } } } - pc += 4 /* instructionSizeAt: */; + pc += instructionSizeAt(backEnd, pc); } return 0; } @@ -9088,11 +9090,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 4 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -9100,7 +9102,7 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); @@ -9153,7 +9155,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9163,7 +9165,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9369,7 +9371,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); @@ -10286,10 +10288,10 @@ compileCallFornumArgsargargargargresultRegregsToSave(void *aRoutine, sqInt numAr regMaskCopy = ((regMaskCopy) >> 1); } if ((numRegsPushed == 0) - && (4 /* numIntRegArgs */ >= numArgs)) { + && ((numIntRegArgs(((AbstractInstruction *) backEnd))) >= numArgs)) { goto l4; } - wordsPushedModAlignment = (numRegsPushed + ((((numArgs - 4 /* numIntRegArgs */) < 0) ? 0 : (numArgs - 4 /* numIntRegArgs */)))) % (cStackAlignment / BytesPerWord); + wordsPushedModAlignment = (numRegsPushed + ((((numArgs - (numIntRegArgs(((AbstractInstruction *) backEnd)))) < 0) ? 0 : (numArgs - (numIntRegArgs(((AbstractInstruction *) backEnd))))))) % (cStackAlignment / BytesPerWord); if (wordsPushedModAlignment != 0) { delta = (cStackAlignment / BytesPerWord) - wordsPushedModAlignment; /* begin checkQuickConstant:forInstruction: */ @@ -10749,7 +10751,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod rewriteCPICCaseAttagobjReftarget(caseEndAddress, case1Tag, operand, ((sqInt)((isMNUCase ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); - relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */, addrDelta); + relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)), addrDelta); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); return 0; } @@ -10780,13 +10782,13 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, ? 0 : methodOperand); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + firstCPICCaseOffset, (((sqInt)cPIC)) + (sizeof(CogMethod))); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); - relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */, addrDelta); + relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)), addrDelta); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPICJumpAt:target: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, target); return 0; } @@ -10847,8 +10849,8 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 4 - : (jumpLongConditionalByteSize(backEnd)) + 8 /* cmpC32RTempByteSize */)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -10862,7 +10864,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, pc); return 0; } @@ -10871,7 +10873,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump1, pc - cPICCaseSize); return 0; } @@ -11188,7 +11190,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -11200,7 +11202,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; @@ -11657,12 +11659,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -12080,7 +12082,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -12348,6 +12350,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -12360,6 +12367,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -13408,12 +13416,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -14778,7 +14786,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (8); + return (interpretOffset()) - ((pushLinkRegisterByteSize(backEnd)) + (callInstructionByteSize(backEnd))); } /* Cogit>>#printCogMethodFor: */ @@ -14986,7 +14994,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } } assert(((cPIC->cPICNumCases)) > 0); - relocateMethodReferenceBeforeAddressby(backEnd, (addressOfEndOfCaseinCPIC(2, cPIC)) + 4 /* loadPICLiteralByteSize */, refDelta); + relocateMethodReferenceBeforeAddressby(backEnd, (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)), refDelta); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); } @@ -15210,7 +15218,7 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ @@ -15357,7 +15365,7 @@ subsequentPrototypeMethodOop(void) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 8 /* callFullInstructionByteSize */) + (/* begin pushLinkRegisterByteSize */ 4); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (pushLinkRegisterByteSize(backEnd)); } @@ -17256,8 +17264,7 @@ genDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction *(*p genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(ClassReg); /* begin ConvertR:Rd: */ @@ -17351,8 +17358,7 @@ genDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGenera genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(Arg0Reg); /* begin ConvertR:Rd: */ @@ -17574,6 +17580,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -17595,9 +17604,11 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction1->dependent = locateLiteral(quickConstant)); } /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); @@ -17626,16 +17637,20 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction2->dependent = locateLiteral(quickConstant1)); } /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction3->dependent = locateLiteral(quickConstant2)); } jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); @@ -18340,8 +18355,7 @@ genPureDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jmpTarget(jumpFailAlloc, jmpTarget(jumpFailClass, genoperandoperand(Label, (labelCounter += 1), bytecodePC))); if (!(preOpCheckOrNil == null)) { jmpTarget(jumpFailCheck, ((AbstractInstruction *) (((jumpFailClass->operands))[0]))); @@ -18429,8 +18443,7 @@ genPureDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGe genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jmpTarget(jumpFail, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); return CompletePrimitive; } @@ -18597,6 +18610,19 @@ isUnannotatableConstant(CogSimStackEntry *simStackEntry) } +/* If the receiver supports immediate floats then generate a test for a + smallFloat in oopReg, + converting it to the float value in dpReg and jumping to targetInst. + Otherwise do nothing. */ + + /* CogObjectRepresentation>>#maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ +static sqInt NoDbgRegParms +maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst) +{ + return 0; +} + + /* Character gets mapped to zero. See inlineCacheTagForInstance:. */ /* CogObjectRepresentationFor32BitSpur>>#classForInlineCacheTag: */ @@ -24475,11 +24501,14 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteral(0x3FFFFFFF)); + (anInstruction->dependent = locateLiteral(quickConstant)); } /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); diff --git a/src/spur32.cog/cogitIA32.c b/src/spur32.cog/cogitIA32.c index 520822ea13..3cd618aca6 100644 --- a/src/spur32.cog/cogitIA32.c +++ b/src/spur32.cog/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -494,6 +494,7 @@ static void NoDbgRegParms initializeSharableLiteral(AbstractInstruction * self_i static void NoDbgRegParms initializeUniqueLiteral(AbstractInstruction * self_in_initializeUniqueLiteral, sqInt literal); static sqInt NoDbgRegParms isJump(AbstractInstruction * self_in_isJump); static sqInt NoDbgRegParms isWithinMwOffsetRange(AbstractInstruction * self_in_isWithinMwOffsetRange, sqInt anAddress); +static sqInt NoDbgRegParms literal32BeforeFollowingAddress(AbstractInstruction * self_in_literal32BeforeFollowingAddress, sqInt followingAddress); static void NoDbgRegParms relocateJumpLongBeforeFollowingAddressby(AbstractInstruction * self_in_relocateJumpLongBeforeFollowingAddressby, sqInt pc, sqInt delta); static void NoDbgRegParms relocateJumpLongConditionalBeforeFollowingAddressby(AbstractInstruction * self_in_relocateJumpLongConditionalBeforeFollowingAddressby, sqInt pc, sqInt delta); static void NoDbgRegParms resolveJumpTarget(AbstractInstruction * self_in_resolveJumpTarget); @@ -900,6 +901,7 @@ static sqInt NoDbgRegParms genPureDoubleComparisoninvert(AbstractInstruction * N static sqInt NoDbgRegParms genSmallIntegerComparison(sqInt jumpOpcode); static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms isUnannotatableConstant(CogSimStackEntry *simStackEntry); +static sqInt NoDbgRegParms maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst); static sqInt NoDbgRegParms classForInlineCacheTag(sqInt inlineCacheTag); static sqInt NoDbgRegParms genAddSmallIntegerTagsTo(sqInt aRegister); static sqInt NoDbgRegParms genClearAndSetSmallIntegerTagsIn(sqInt scratchReg); @@ -2517,7 +2519,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2539,6 +2540,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2973,6 +2977,18 @@ isWithinMwOffsetRange(AbstractInstruction * self_in_isWithinMwOffsetRange, sqInt } +/* Answer the constant loaded by the instruction sequence just before this + address: + */ + + /* CogAbstractInstruction>>#literal32BeforeFollowingAddress: */ +static sqInt NoDbgRegParms +literal32BeforeFollowingAddress(AbstractInstruction * self_in_literal32BeforeFollowingAddress, sqInt followingAddress) +{ + return literalBeforeFollowingAddress(self_in_literal32BeforeFollowingAddress, followingAddress); +} + + /* We assume here that calls and jumps look the same as regards their displacement. This works on at least x86, ARM and x86_64. Processors on which that isn't the @@ -7109,8 +7125,7 @@ loadLiteralByteSize(AbstractInstruction * self_in_loadLiteralByteSize) static sqInt NoDbgRegParms loadPICLiteralByteSize(AbstractInstruction * self_in_loadPICLiteralByteSize) { - /* begin loadLiteralByteSize */ - return 5; + return loadLiteralByteSize(self_in_loadPICLiteralByteSize); } /* CogIA32Compiler>>#machineCodeAt: */ @@ -8733,11 +8748,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -8745,11 +8760,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -8798,7 +8813,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -8808,7 +8823,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9013,7 +9028,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -10397,7 +10412,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc, addrDelta); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); return 0; @@ -10429,14 +10444,14 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, ? 0 : methodOperand); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + firstCPICCaseOffset, (((sqInt)cPIC)) + (sizeof(CogMethod))); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc, addrDelta); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), target); return 0; } @@ -10489,13 +10504,13 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (valid) { tags[used] = ((i > 1 ? (/* begin literal32BeforeFollowingAddress: */ - (followingAddress = pc - 6 /* jumpLongConditionalByteSize */), + (followingAddress = pc - (jumpLongConditionalByteSize(backEnd))), literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), followingAddress)) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 5 - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -10509,7 +10524,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), pc); return 0; } for (i = 1; i < used; i += 1) { @@ -10517,7 +10532,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), pc - cPICCaseSize); return 0; } @@ -10536,7 +10551,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 6 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { /* begin literal32BeforeFollowingAddress: */ classIndex = literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); @@ -10659,7 +10674,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -10834,7 +10849,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -10846,12 +10861,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); /* begin literal32BeforeFollowingAddress: */ classTag = literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { @@ -11303,12 +11318,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -11545,13 +11560,9 @@ generateCaptureCStackPointers(sqInt captureFramePointer) anInstruction1 = genoperandoperand(MoveRAw, FPReg, cFramePointerAddress()); } /* begin LoadEffectiveAddressMw:r:R: */ - if (pushedVarBaseReg) { - offset = 4 /* leafCallStackPointerDelta */ + BytesPerWord; - } - else { - /* begin leafCallStackPointerDelta */ - offset = 4; - } + offset = (pushedVarBaseReg + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -11660,7 +11671,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -11926,6 +11937,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -11938,6 +11954,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -12004,6 +12021,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -12025,7 +12043,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 4 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -12909,12 +12929,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -14270,7 +14290,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (/* begin callInstructionByteSize */ 5); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -14486,7 +14506,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } assert(((cPIC->cPICNumCases)) > 0); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)); + pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadLiteralByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc1, refDelta); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); } @@ -14712,11 +14732,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); /* begin storeLiteral32:beforeFollowingAddress: */ storeLiteralbeforeFollowingAddress(((AbstractInstruction *) backEnd), newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); @@ -14850,7 +14870,7 @@ subsequentPrototypeMethodOop(void) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 5 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -16729,8 +16749,7 @@ genDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction *(*p genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(ClassReg); /* begin ConvertR:Rd: */ @@ -16816,8 +16835,7 @@ genDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGenera genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(Arg0Reg); /* begin ConvertR:Rd: */ @@ -17029,6 +17047,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -17047,7 +17068,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -17075,11 +17098,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -17766,8 +17793,7 @@ genPureDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jmpTarget(jumpFailAlloc, jmpTarget(jumpFailClass, genoperandoperand(Label, (labelCounter += 1), bytecodePC))); if (!(preOpCheckOrNil == null)) { jmpTarget(jumpFailCheck, ((AbstractInstruction *) (((jumpFailClass->operands))[0]))); @@ -17847,8 +17873,7 @@ genPureDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGe genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jmpTarget(jumpFail, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); return CompletePrimitive; } @@ -18001,6 +18026,19 @@ isUnannotatableConstant(CogSimStackEntry *simStackEntry) } +/* If the receiver supports immediate floats then generate a test for a + smallFloat in oopReg, + converting it to the float value in dpReg and jumping to targetInst. + Otherwise do nothing. */ + + /* CogObjectRepresentation>>#maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ +static sqInt NoDbgRegParms +maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst) +{ + return 0; +} + + /* Character gets mapped to zero. See inlineCacheTagForInstance:. */ /* CogObjectRepresentationFor32BitSpur>>#classForInlineCacheTag: */ @@ -22705,9 +22743,12 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); } diff --git a/src/spur32.cog/cointerp.c b/src/spur32.cog/cointerp.c index 469be5141e..32005233ce 100644 --- a/src/spur32.cog/cointerp.c +++ b/src/spur32.cog/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1242,7 +1242,7 @@ static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBitsformat(sqInt objOop, sqInt format); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -2597,7 +2597,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -15542,7 +15542,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -16222,7 +16222,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -19100,7 +19115,8 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + sqInt fieldIndex; + usqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -19149,7 +19165,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -19167,10 +19183,12 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + fieldIndex = index - SelectorStart; + /* begin fetchPointer:ofObject: */ + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -20127,11 +20145,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -20354,7 +20378,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - sqInt numTemps; + usqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -38591,7 +38615,7 @@ followForwardedObjectFieldstoDepth(sqInt objOop, sqInt depth) sqInt header1; sqInt i; sqInt numLiterals; - usqInt numSlots; + sqInt numSlots; usqInt numSlots1; sqInt oop; sqInt referent; @@ -45805,7 +45829,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -45837,7 +45861,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS here but that requires access to framePointer. */ /* begin numSlotsOfMarriedContext: */ contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop)); - numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize)); + numMediatedSlots = CtxtTempFrameStart + contextSize; for (i1 = 0; i1 < numMediatedSlots; i1 += 1) { oop = fetchPointerofMarriedContext(i1, objOop); assert(!(isOopForwarded(copy))); @@ -52240,7 +52264,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -55235,7 +55259,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj1))); contextSize = (sp >> 1); l9: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -55268,7 +55292,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l10: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -58480,10 +58504,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -59642,7 +59666,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - sqInt node; + usqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -65362,7 +65386,8 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + sqInt fieldIndex; + usqInt index; usqInt length; sqInt mask; sqInt meth; @@ -65406,7 +65431,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -65424,10 +65449,12 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + fieldIndex = index - SelectorStart; + /* begin fetchPointer:ofObject: */ + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/src/spur32.cog/cointerp.h b/src/spur32.cog/cointerp.h index 36b30434a2..6e645f5177 100644 --- a/src/spur32.cog/cointerp.h +++ b/src/spur32.cog/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -242,7 +242,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/src/spur32.cog/gcc3x-cointerp.c b/src/spur32.cog/gcc3x-cointerp.c index 5645128362..1f1ae9cfa1 100644 --- a/src/spur32.cog/gcc3x-cointerp.c +++ b/src/spur32.cog/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1245,7 +1245,7 @@ static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBitsformat(sqInt objOop, sqInt format); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -2600,7 +2600,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -15551,7 +15551,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -16231,7 +16231,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -19109,7 +19124,8 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + sqInt fieldIndex; + usqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -19158,7 +19174,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -19176,10 +19192,12 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + fieldIndex = index - SelectorStart; + /* begin fetchPointer:ofObject: */ + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -20136,11 +20154,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -20363,7 +20387,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - sqInt numTemps; + usqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -38600,7 +38624,7 @@ followForwardedObjectFieldstoDepth(sqInt objOop, sqInt depth) sqInt header1; sqInt i; sqInt numLiterals; - usqInt numSlots; + sqInt numSlots; usqInt numSlots1; sqInt oop; sqInt referent; @@ -45814,7 +45838,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -45846,7 +45870,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS here but that requires access to framePointer. */ /* begin numSlotsOfMarriedContext: */ contextSize = stackPointerIndexForFrame(frameOfMarriedContext(objOop)); - numMediatedSlots = ((sqInt) (CtxtTempFrameStart + contextSize)); + numMediatedSlots = CtxtTempFrameStart + contextSize; for (i1 = 0; i1 < numMediatedSlots; i1 += 1) { oop = fetchPointerofMarriedContext(i1, objOop); assert(!(isOopForwarded(copy))); @@ -52249,7 +52273,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -55244,7 +55268,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 1))) < (lengthOf(obj1))); contextSize = (sp >> 1); l9: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -55277,7 +55301,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((header & 1)); numLiterals = ((header >> 1)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l10: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -58489,10 +58513,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -59651,7 +59675,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - sqInt node; + usqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; @@ -65371,7 +65395,8 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt index; + sqInt fieldIndex; + usqInt index; usqInt length; sqInt mask; sqInt meth; @@ -65415,7 +65440,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -65433,10 +65458,12 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); + fieldIndex = index - SelectorStart; + /* begin fetchPointer:ofObject: */ + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/src/spur32.sista/cogit.h b/src/spur32.sista/cogit.h index b33667c5a3..b712adc281 100644 --- a/src/spur32.sista/cogit.h +++ b/src/spur32.sista/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -123,7 +123,9 @@ extern sqInt ceReturnToInterpreterTrampoline; #if COGMTVM extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) extern sqInt cFramePointerInUse; +#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; diff --git a/src/spur32.sista/cogitARMv5.c b/src/spur32.sista/cogitARMv5.c index c8e06ebe07..adf461ad6c 100644 --- a/src/spur32.sista/cogitARMv5.c +++ b/src/spur32.sista/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -876,6 +876,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -922,6 +923,7 @@ static sqInt NoDbgRegParms genPureDoubleComparisoninvert(AbstractInstruction * N static sqInt NoDbgRegParms genSmallIntegerComparison(sqInt jumpOpcode); static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms isUnannotatableConstant(CogSimStackEntry *simStackEntry); +static sqInt NoDbgRegParms maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst); static sqInt NoDbgRegParms classForInlineCacheTag(sqInt inlineCacheTag); static sqInt NoDbgRegParms genAddSmallIntegerTagsTo(sqInt aRegister); static sqInt NoDbgRegParms genClearAndSetSmallIntegerTagsIn(sqInt scratchReg); @@ -2653,7 +2655,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2675,6 +2676,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -7184,8 +7188,7 @@ jumpLongByteSize(AbstractInstruction * self_in_jumpLongByteSize) static sqInt NoDbgRegParms jumpLongConditionalByteSize(AbstractInstruction * self_in_jumpLongConditionalByteSize) { - /* begin jumpLongByteSize */ - return 4; + return jumpLongByteSize(self_in_jumpLongConditionalByteSize); } @@ -7379,7 +7382,7 @@ loadPICLiteralByteSize(AbstractInstruction * self_in_loadPICLiteralByteSize) static sqInt NoDbgRegParms machineCodeWords(AbstractInstruction * self_in_machineCodeWords) { - return 8 /* machineCodeBytes */ / 4; + return (machineCodeBytes(self_in_machineCodeWords)) / 4; } @@ -8349,7 +8352,7 @@ blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction) } } } - pc += 4 /* instructionSizeAt: */; + pc += instructionSizeAt(backEnd, pc); } return 0; } @@ -9228,11 +9231,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 4 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -9240,7 +9243,7 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); @@ -9293,7 +9296,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9303,7 +9306,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9509,7 +9512,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); @@ -10484,10 +10487,10 @@ compileCallFornumArgsargargargargresultRegregsToSave(void *aRoutine, sqInt numAr regMaskCopy = ((regMaskCopy) >> 1); } if ((numRegsPushed == 0) - && (4 /* numIntRegArgs */ >= numArgs)) { + && ((numIntRegArgs(((AbstractInstruction *) backEnd))) >= numArgs)) { goto l4; } - wordsPushedModAlignment = (numRegsPushed + ((((numArgs - 4 /* numIntRegArgs */) < 0) ? 0 : (numArgs - 4 /* numIntRegArgs */)))) % (cStackAlignment / BytesPerWord); + wordsPushedModAlignment = (numRegsPushed + ((((numArgs - (numIntRegArgs(((AbstractInstruction *) backEnd)))) < 0) ? 0 : (numArgs - (numIntRegArgs(((AbstractInstruction *) backEnd))))))) % (cStackAlignment / BytesPerWord); if (wordsPushedModAlignment != 0) { delta = (cStackAlignment / BytesPerWord) - wordsPushedModAlignment; /* begin checkQuickConstant:forInstruction: */ @@ -10947,7 +10950,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod rewriteCPICCaseAttagobjReftarget(caseEndAddress, case1Tag, operand, ((sqInt)((isMNUCase ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); - relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */, addrDelta); + relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)), addrDelta); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); return 0; } @@ -10978,13 +10981,13 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, ? 0 : methodOperand); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + firstCPICCaseOffset, (((sqInt)cPIC)) + (sizeof(CogMethod))); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); - relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */, addrDelta); + relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)), addrDelta); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPICJumpAt:target: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, target); return 0; } @@ -11045,8 +11048,8 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 4 - : (jumpLongConditionalByteSize(backEnd)) + 8 /* cmpC32RTempByteSize */)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -11060,7 +11063,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, pc); return 0; } @@ -11069,7 +11072,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump1, pc - cPICCaseSize); return 0; } @@ -11410,7 +11413,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -11422,7 +11425,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; @@ -11819,12 +11822,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -12242,7 +12245,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -12510,6 +12513,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -12522,6 +12530,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -13501,12 +13510,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -14925,7 +14934,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (8); + return (interpretOffset()) - ((pushLinkRegisterByteSize(backEnd)) + (callInstructionByteSize(backEnd))); } /* Cogit>>#printCogMethodFor: */ @@ -15141,7 +15150,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } } assert(((cPIC->cPICNumCases)) > 0); - relocateMethodReferenceBeforeAddressby(backEnd, (addressOfEndOfCaseinCPIC(2, cPIC)) + 4 /* loadPICLiteralByteSize */, refDelta); + relocateMethodReferenceBeforeAddressby(backEnd, (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)), refDelta); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); } @@ -15368,7 +15377,7 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ @@ -15515,7 +15524,7 @@ subsequentPrototypeMethodOop(void) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 8 /* callFullInstructionByteSize */) + (/* begin pushLinkRegisterByteSize */ 4); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (pushLinkRegisterByteSize(backEnd)); } @@ -16421,7 +16430,7 @@ voidCogCompiledCode(void) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; /* begin ensureExecutableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -17389,6 +17398,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -17471,8 +17487,7 @@ genDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction *(*p genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(ClassReg); /* begin ConvertR:Rd: */ @@ -17566,8 +17581,7 @@ genDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGenera genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(Arg0Reg); /* begin ConvertR:Rd: */ @@ -17789,6 +17803,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -17810,9 +17827,11 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction1->dependent = locateLiteral(quickConstant)); } /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); @@ -17841,16 +17860,20 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction2->dependent = locateLiteral(quickConstant1)); } /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction3->dependent = locateLiteral(quickConstant2)); } jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); @@ -18555,8 +18578,7 @@ genPureDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jmpTarget(jumpFailAlloc, jmpTarget(jumpFailClass, genoperandoperand(Label, (labelCounter += 1), bytecodePC))); if (!(preOpCheckOrNil == null)) { jmpTarget(jumpFailCheck, ((AbstractInstruction *) (((jumpFailClass->operands))[0]))); @@ -18644,8 +18666,7 @@ genPureDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGe genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jmpTarget(jumpFail, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); return CompletePrimitive; } @@ -18812,6 +18833,19 @@ isUnannotatableConstant(CogSimStackEntry *simStackEntry) } +/* If the receiver supports immediate floats then generate a test for a + smallFloat in oopReg, + converting it to the float value in dpReg and jumping to targetInst. + Otherwise do nothing. */ + + /* CogObjectRepresentation>>#maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ +static sqInt NoDbgRegParms +maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst) +{ + return 0; +} + + /* Character gets mapped to zero. See inlineCacheTagForInstance:. */ /* CogObjectRepresentationFor32BitSpur>>#classForInlineCacheTag: */ @@ -25233,11 +25267,14 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteral(0x3FFFFFFF)); + (anInstruction->dependent = locateLiteral(quickConstant)); } /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); @@ -34362,7 +34399,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); /* begin maybeGenerateCacheFlush */ /* begin generateVMOwnerLockFunctions */ @@ -34405,7 +34442,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; generateOpenPICPrototype(); } @@ -35221,7 +35258,7 @@ setCogCodeZoneThreshold(double ratio) } thresholdRatio = ratio; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; return 0; } diff --git a/src/spur32.sista/cogitIA32.c b/src/spur32.sista/cogitIA32.c index 8b8920d1c4..b331ac86cc 100644 --- a/src/spur32.sista/cogitIA32.c +++ b/src/spur32.sista/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -500,6 +500,7 @@ static void NoDbgRegParms initializeSharableLiteral(AbstractInstruction * self_i static void NoDbgRegParms initializeUniqueLiteral(AbstractInstruction * self_in_initializeUniqueLiteral, sqInt literal); static sqInt NoDbgRegParms isJump(AbstractInstruction * self_in_isJump); static sqInt NoDbgRegParms isWithinMwOffsetRange(AbstractInstruction * self_in_isWithinMwOffsetRange, sqInt anAddress); +static sqInt NoDbgRegParms literal32BeforeFollowingAddress(AbstractInstruction * self_in_literal32BeforeFollowingAddress, sqInt followingAddress); static void NoDbgRegParms relocateJumpLongBeforeFollowingAddressby(AbstractInstruction * self_in_relocateJumpLongBeforeFollowingAddressby, sqInt pc, sqInt delta); static void NoDbgRegParms relocateJumpLongConditionalBeforeFollowingAddressby(AbstractInstruction * self_in_relocateJumpLongConditionalBeforeFollowingAddressby, sqInt pc, sqInt delta); static void NoDbgRegParms resolveJumpTarget(AbstractInstruction * self_in_resolveJumpTarget); @@ -859,6 +860,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -905,6 +907,7 @@ static sqInt NoDbgRegParms genPureDoubleComparisoninvert(AbstractInstruction * N static sqInt NoDbgRegParms genSmallIntegerComparison(sqInt jumpOpcode); static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms isUnannotatableConstant(CogSimStackEntry *simStackEntry); +static sqInt NoDbgRegParms maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst); static sqInt NoDbgRegParms classForInlineCacheTag(sqInt inlineCacheTag); static sqInt NoDbgRegParms genAddSmallIntegerTagsTo(sqInt aRegister); static sqInt NoDbgRegParms genClearAndSetSmallIntegerTagsIn(sqInt scratchReg); @@ -2608,7 +2611,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2630,6 +2632,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -3064,6 +3069,18 @@ isWithinMwOffsetRange(AbstractInstruction * self_in_isWithinMwOffsetRange, sqInt } +/* Answer the constant loaded by the instruction sequence just before this + address: + */ + + /* CogAbstractInstruction>>#literal32BeforeFollowingAddress: */ +static sqInt NoDbgRegParms +literal32BeforeFollowingAddress(AbstractInstruction * self_in_literal32BeforeFollowingAddress, sqInt followingAddress) +{ + return literalBeforeFollowingAddress(self_in_literal32BeforeFollowingAddress, followingAddress); +} + + /* We assume here that calls and jumps look the same as regards their displacement. This works on at least x86, ARM and x86_64. Processors on which that isn't the @@ -7207,8 +7224,7 @@ loadLiteralByteSize(AbstractInstruction * self_in_loadLiteralByteSize) static sqInt NoDbgRegParms loadPICLiteralByteSize(AbstractInstruction * self_in_loadPICLiteralByteSize) { - /* begin loadLiteralByteSize */ - return 5; + return loadLiteralByteSize(self_in_loadPICLiteralByteSize); } /* CogIA32Compiler>>#machineCodeAt: */ @@ -8872,11 +8888,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -8884,11 +8900,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -8937,7 +8953,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -8947,7 +8963,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9152,7 +9168,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -10594,7 +10610,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc, addrDelta); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); return 0; @@ -10626,14 +10642,14 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, ? 0 : methodOperand); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + firstCPICCaseOffset, (((sqInt)cPIC)) + (sizeof(CogMethod))); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc, addrDelta); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), target); return 0; } @@ -10686,13 +10702,13 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (valid) { tags[used] = ((i > 1 ? (/* begin literal32BeforeFollowingAddress: */ - (followingAddress = pc - 6 /* jumpLongConditionalByteSize */), + (followingAddress = pc - (jumpLongConditionalByteSize(backEnd))), literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), followingAddress)) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 5 - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -10706,7 +10722,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), pc); return 0; } for (i = 1; i < used; i += 1) { @@ -10714,7 +10730,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), pc - cPICCaseSize); return 0; } @@ -10733,7 +10749,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 6 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { /* begin literal32BeforeFollowingAddress: */ classIndex = literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); @@ -10856,7 +10872,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -11054,7 +11070,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -11066,12 +11082,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); /* begin literal32BeforeFollowingAddress: */ classTag = literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { @@ -11463,12 +11479,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -11705,13 +11721,9 @@ generateCaptureCStackPointers(sqInt captureFramePointer) anInstruction1 = genoperandoperand(MoveRAw, FPReg, cFramePointerAddress()); } /* begin LoadEffectiveAddressMw:r:R: */ - if (pushedVarBaseReg) { - offset = 4 /* leafCallStackPointerDelta */ + BytesPerWord; - } - else { - /* begin leafCallStackPointerDelta */ - offset = 4; - } + offset = (pushedVarBaseReg + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -11820,7 +11832,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -12086,6 +12098,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -12098,6 +12115,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -12165,6 +12183,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -12186,7 +12205,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 4 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -12977,12 +12998,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -14392,7 +14413,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (/* begin callInstructionByteSize */ 5); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -14608,7 +14629,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } assert(((cPIC->cPICNumCases)) > 0); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)); + pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadLiteralByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc1, refDelta); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); } @@ -14837,11 +14858,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); /* begin storeLiteral32:beforeFollowingAddress: */ storeLiteralbeforeFollowingAddress(((AbstractInstruction *) backEnd), newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); @@ -14975,7 +14996,7 @@ subsequentPrototypeMethodOop(void) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 5 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -15881,7 +15902,7 @@ voidCogCompiledCode(void) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; /* begin ensureExecutableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -16836,6 +16857,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -16911,8 +16939,7 @@ genDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction *(*p genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(ClassReg); /* begin ConvertR:Rd: */ @@ -16998,8 +17025,7 @@ genDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGenera genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jumpNonInt = genJumpNotSmallInteger(Arg0Reg); genConvertSmallIntegerToIntegerInReg(Arg0Reg); /* begin ConvertR:Rd: */ @@ -17211,6 +17237,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -17229,7 +17258,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -17257,11 +17288,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -17948,8 +17983,7 @@ genPureDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jmpTarget(jumpFailAlloc, jmpTarget(jumpFailClass, genoperandoperand(Label, (labelCounter += 1), bytecodePC))); if (!(preOpCheckOrNil == null)) { jmpTarget(jumpFailCheck, ((AbstractInstruction *) (((jumpFailClass->operands))[0]))); @@ -18029,8 +18063,7 @@ genPureDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGe genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jmpTarget(jumpFail, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); return CompletePrimitive; } @@ -18183,6 +18216,19 @@ isUnannotatableConstant(CogSimStackEntry *simStackEntry) } +/* If the receiver supports immediate floats then generate a test for a + smallFloat in oopReg, + converting it to the float value in dpReg and jumping to targetInst. + Otherwise do nothing. */ + + /* CogObjectRepresentation>>#maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ +static sqInt NoDbgRegParms +maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst) +{ + return 0; +} + + /* Character gets mapped to zero. See inlineCacheTagForInstance:. */ /* CogObjectRepresentationFor32BitSpur>>#classForInlineCacheTag: */ @@ -23347,9 +23393,12 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); } @@ -31499,7 +31548,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ @@ -31560,7 +31609,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; generateOpenPICPrototype(); } @@ -32336,7 +32385,7 @@ populatewithPICInfoForfirstCacheTag(sqInt tuple, CogMethod *cPIC, sqInt firstCac pc = addressOfEndOfCaseinCPIC(i, cPIC); cacheTag = (i == 1 ? firstCacheTag - : literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + : literalBeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); classOop = classForInlineCacheTag(cacheTag); storePointerofObjectwithValue((i * 2) - 1, tuple, classOop); if (i == 1) { @@ -32376,7 +32425,7 @@ setCogCodeZoneThreshold(double ratio) } thresholdRatio = ratio; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; return 0; } diff --git a/src/spur32.sista/cointerp.c b/src/spur32.sista/cointerp.c index c4f725b317..0f6570cbc7 100644 --- a/src/spur32.sista/cointerp.c +++ b/src/spur32.sista/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2612,7 +2612,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -18392,7 +18392,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -19072,7 +19072,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -21955,8 +21970,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -22005,7 +22019,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -22023,12 +22037,10 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -22986,11 +22998,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -23213,7 +23231,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - sqInt numTemps; + usqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -68425,8 +68443,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -68470,7 +68487,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -68488,12 +68505,10 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/src/spur32.sista/cointerp.h b/src/spur32.sista/cointerp.h index 4a80291a46..f74a958d68 100644 --- a/src/spur32.sista/cointerp.h +++ b/src/spur32.sista/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ diff --git a/src/spur32.sista/gcc3x-cointerp.c b/src/spur32.sista/gcc3x-cointerp.c index 55496726cc..4e680d48ce 100644 --- a/src/spur32.sista/gcc3x-cointerp.c +++ b/src/spur32.sista/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2615,7 +2615,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -18401,7 +18401,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -19081,7 +19081,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -21964,8 +21979,7 @@ mnuMethodOrNilFor(sqInt rcvr) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt methodArray; @@ -22014,7 +22028,7 @@ mnuMethodOrNilFor(sqInt rcvr) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { mnuMethod = null; goto l11; @@ -22032,12 +22046,10 @@ mnuMethodOrNilFor(sqInt rcvr) } methodArray = objOop; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } mnuMethod = objOop1; goto l11; @@ -22995,11 +23007,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -23222,7 +23240,7 @@ printFrameWithSP(char *theFP, char *theSP) usqInt index; sqInt methodField; usqInt numArgs; - sqInt numTemps; + usqInt numTemps; char *rcvrAddress; sqInt rcvrOrClosure; CogBlockMethod * self_in_cmHomeMethod; @@ -68434,8 +68452,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt currentClass; sqInt dictionary; - sqInt fieldIndex; - usqInt index; + sqInt index; usqInt length; sqInt mask; sqInt meth; @@ -68479,7 +68496,7 @@ lookupSelectorinClass(sqInt selector, sqInt class) wrapAround = 0; while (1) { /* begin fetchPointer:ofObject: */ - nextSelector = longAt((dictionary + BaseHeaderSize) + (index << (shiftForWord()))); + nextSelector = longAt((dictionary + BaseHeaderSize) + (((sqInt)((usqInt)(index) << (shiftForWord()))))); if (nextSelector == GIV(nilObj)) { meth = null; goto l8; @@ -68497,12 +68514,10 @@ lookupSelectorinClass(sqInt selector, sqInt class) } methodArray = objOop2; /* begin followField:ofObject: */ - fieldIndex = index - SelectorStart; - /* begin fetchPointer:ofObject: */ - objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)(fieldIndex) << (shiftForWord()))))); + objOop1 = longAt((methodArray + BaseHeaderSize) + (((sqInt)((usqInt)((index - SelectorStart)) << (shiftForWord()))))); if (((!(objOop1 & (tagMask())))) && ((!((longAt(objOop1)) & ((classIndexMask()) - (isForwardedObjectClassIndexPun())))))) { - objOop1 = fixFollowedFieldofObjectwithInitialValue(fieldIndex, methodArray, objOop1); + objOop1 = fixFollowedFieldofObjectwithInitialValue(index - SelectorStart, methodArray, objOop1); } meth = objOop1; goto l8; diff --git a/src/spur64.cog/cogit.h b/src/spur64.cog/cogit.h index ef514cb146..7c8af1a49e 100644 --- a/src/spur64.cog/cogit.h +++ b/src/spur64.cog/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -118,7 +118,9 @@ extern sqInt ceReturnToInterpreterTrampoline; #if COGMTVM extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) extern sqInt cFramePointerInUse; +#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; diff --git a/src/spur64.cog/cogitARMv8.c b/src/spur64.cog/cogitARMv8.c index 79c0518ec4..809d5bac89 100644 --- a/src/spur64.cog/cogitARMv8.c +++ b/src/spur64.cog/cogitARMv8.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -943,6 +943,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -1039,7 +1040,10 @@ static sqInt NoDbgRegParms genShiftAwaySmallIntegerTagsInScratchReg(sqInt scratc static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms getLiteralCountOfplusOneinBytesintoscratch(sqInt methodReg, sqInt plusOne, sqInt inBytes, sqInt litCountReg, sqInt scratchReg); static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); +static sqInt log2BytesPerWord(void); static void maybeGenerateSelectorIndexDereferenceRoutine(void); +static sqInt numSmallIntegerBits(void); +static sqInt numSmallIntegerTagBits(void); static sqInt NoDbgRegParms validInlineCacheTag(sqInt classIndexOrTagPattern); static void callStoreCheckTrampoline(void); static sqInt NoDbgRegParms checkValidDerivedObjectReference(sqInt bodyAddress); @@ -1115,6 +1119,7 @@ static void NoDbgRegParms markAndTraceLiteralinat(sqInt literal, CogMethod *cogM static void NoDbgRegParms markAndTraceUpdatedLiteralin(sqInt objOop, CogMethod *cogMethodOrNil); static sqInt NoDbgRegParms maybeCompileRetryOnPrimitiveFail(sqInt primIndex); static sqInt NoDbgRegParms maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg); +static sqInt numCharacterBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt objOop); static sqInt NoDbgRegParms shouldAnnotateObjectReference(sqInt anOop); @@ -2629,7 +2634,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2651,6 +2655,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -7038,7 +7045,7 @@ machineCodeBytes(AbstractInstruction * self_in_machineCodeBytes) static sqInt NoDbgRegParms machineCodeWords(AbstractInstruction * self_in_machineCodeWords) { - return 12 /* machineCodeBytes */ / 4; + return (machineCodeBytes(self_in_machineCodeWords)) / 4; } /* CogARMv8Compiler>>#movern:rd: */ @@ -7274,7 +7281,7 @@ rewriteImm19JumpBeforetarget(AbstractInstruction * self_in_rewriteImm19JumpBefor static sqInt NoDbgRegParms rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBeforetarget, sqInt followingAddress, sqInt targetAddress) { - usqInt instrOpcode; + sqInt instrOpcode; sqInt mcpc; sqInt offset; @@ -7284,7 +7291,7 @@ rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBefor instrOpcode = ((instructionBeforeAddress(self_in_rewriteImm26JumpBeforetarget, followingAddress))) >> 26; assert((instrOpcode == 5) || (instrOpcode == 37)); - codeLong32Atput(mcpc, (instrOpcode << 26) + (((offset) >> 2) & (0x3FFFFFF))); + codeLong32Atput(mcpc, (((sqInt)((usqInt)(instrOpcode) << 26))) + (((offset) >> 2) & (0x3FFFFFF))); return 4; } @@ -8176,7 +8183,7 @@ blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction) } } } - pc += 4 /* instructionSizeAt: */; + pc += instructionSizeAt(backEnd, pc); } return 0; } @@ -9065,11 +9072,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 4 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -9077,11 +9084,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 8 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -9130,7 +9137,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9140,7 +9147,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9348,7 +9355,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); /* begin flushICacheFrom:to: */ @@ -10777,7 +10784,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 4))) || (instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 8)))); /* begin rewriteJumpLongAt:target: */ @@ -10817,18 +10824,18 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, /* begin rewriteJumpLongAt:target: */ callTargetAddress = (((sqInt)cPIC)) + (sizeof(CogMethod)); rewriteImm26JumpBeforetarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + firstCPICCaseOffset, callTargetAddress); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); /* begin rewriteJumpLongAt:target: */ callTargetAddress1 = cPICMissTrampolineFor(numArgs); rewriteImm26JumpBeforetarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + cPICEndOfCodeOffset, callTargetAddress1); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 4))) || (instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 8)))); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPICJumpAt:target: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump, target); return 0; } @@ -10882,12 +10889,12 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) } if (valid) { tags[used] = ((i > 1 - ? literal32BeforeFollowingAddress(backEnd, pc - 8 /* jumpLongConditionalByteSize */) + ? literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd))) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 4 - : 16)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -10901,7 +10908,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump, pc); return 0; } @@ -10910,7 +10917,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump1, pc - cPICCaseSize); return 0; } @@ -10930,7 +10937,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 8 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { classIndex = literal32BeforeFollowingAddress(backEnd, pc); if (isForwardedClassIndex(classIndex)) { @@ -11052,7 +11059,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - 8 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -11227,7 +11234,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -11239,12 +11246,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 8 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); classTag = literal32BeforeFollowingAddress(backEnd, classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { errors = errors | 8; @@ -11719,12 +11726,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -12171,7 +12178,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -12470,6 +12477,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -12482,6 +12494,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE /* begin makeCodeZoneWritable */ @@ -13740,12 +13753,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -15235,7 +15248,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (8); + return (interpretOffset()) - ((pushLinkRegisterByteSize(backEnd)) + (callInstructionByteSize(backEnd))); } /* Cogit>>#previousInstruction */ @@ -15454,7 +15467,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } assert(((cPIC->cPICNumCases)) > 0); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + 4 /* loadPICLiteralByteSize */; + pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)); assert((instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc1 - 4))) || (instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc1 - 8)))); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); @@ -15703,11 +15716,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 8 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); storeLiteral32beforeFollowingAddress(backEnd, newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); } @@ -15870,7 +15883,7 @@ gTstCqR(sqInt quickConstant, sqInt reg) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 8 /* callFullInstructionByteSize */) + (/* begin pushLinkRegisterByteSize */ 4); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (pushLinkRegisterByteSize(backEnd)); } @@ -17843,6 +17856,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -18089,6 +18109,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -18108,9 +18131,11 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteralsize(61 /* numSmallIntegerBits */, BytesPerOop)); + (anInstruction1->dependent = locateLiteralsize(quickConstant, BytesPerOop)); } /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); @@ -18139,16 +18164,20 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteralsize(61 /* numSmallIntegerBits */, BytesPerOop)); + (anInstruction2->dependent = locateLiteralsize(quickConstant1, BytesPerOop)); } /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteralsize(61 /* numSmallIntegerBits */, BytesPerOop)); + (anInstruction3->dependent = locateLiteralsize(quickConstant2, BytesPerOop)); } jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); @@ -18457,9 +18486,9 @@ genPrimitiveHighBit(void) /* remove excess tag bits from the receiver oop */ - gOrCqRR(7, ReceiverResultReg, TempReg); + gOrCqRR((1U << (numSmallIntegerTagBits())) - 1, ReceiverResultReg, TempReg); /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 2; + quickConstant = (numSmallIntegerTagBits()) - 1; genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */ /* begin genHighBitClzIn:ofSmallIntegerOopWithSingleTagBit: */ @@ -20844,7 +20873,7 @@ genPrimitiveAtSigned(sqInt signedVersion) /* c.f. Spur64BitMemoryManager>>#isIntegerValue: */ /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 61 /* numSmallIntegerBits */; + quickConstant = numSmallIntegerBits(); genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction = genoperandoperand(AndCqR, 15, TempReg); @@ -20877,7 +20906,7 @@ genPrimitiveAtSigned(sqInt signedVersion) } else { /* begin LogicalShiftRightCq:R: */ - quickConstant1 = 60; + quickConstant1 = (numSmallIntegerBits()) - 1; genoperandoperand(LogicalShiftRightCqR, quickConstant1, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperand(CmpCqR, 0, TempReg); @@ -21391,7 +21420,7 @@ genPrimitiveNewWithArg(void) jumpNElementsNonInt = genJumpNotSmallInteger(Arg0Reg); genLoadSlotsourceRegdestReg(InstanceSpecificationIndex, ReceiverResultReg, instSpecReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = (fixedFieldsFieldWidth()) + 3 /* numSmallIntegerTagBits */; + quickConstant = (fixedFieldsFieldWidth()) + (numSmallIntegerTagBits()); genoperandoperand(LogicalShiftRightCqR, quickConstant, instSpecReg); /* begin checkQuickConstant:forInstruction: */ literal = formatMask(); @@ -22045,7 +22074,7 @@ genPrimitiveStringAtPut(void) /* begin JumpAboveOrEqual: */ jumpIsShorts = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0)); /* begin CmpCq:R: */ - quickConstant = characterObjectOf(0x3FFFFFFF); + quickConstant = characterObjectOf((1U << (numCharacterBits())) - 1); /* begin checkQuickConstant:forInstruction: */ anInstruction5 = genoperandoperand(CmpCqR, quickConstant, Arg1Reg); if (usesOutOfLineLiteral(anInstruction5)) { @@ -22552,6 +22581,13 @@ inlineCacheTagForInstance(sqInt oop) : classIndexOf(oop)); } + /* CogObjectRepresentationFor64BitSpur>>#log2BytesPerWord */ +static sqInt +log2BytesPerWord(void) +{ + return 3; +} + /* Generate the routine that converts selector indices into selector objects. It is called from the send trampolines. @@ -22612,8 +22648,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) /* begin JumpZero: */ jumpNotBlock = genConditionalBranchoperand(JumpZero, ((sqInt)0)); /* begin checkQuickConstant:forInstruction: */ - literal = -8 /* zoneAlignment */; - anInstruction6 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + literal = -(zoneAlignment()); + anInstruction6 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); if (usesOutOfLineLiteral(anInstruction6)) { (anInstruction6->dependent = locateLiteralsize(literal, BytesPerOop)); } @@ -22641,8 +22677,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) jmpTarget(jumpNotBlock, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); jmpTarget(jumpFullBlock, ((AbstractInstruction *) (((jumpNotBlock->operands))[0]))); /* begin checkQuickConstant:forInstruction: */ - literal1 = -8 /* zoneAlignment */; - anInstruction8 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + literal1 = -(zoneAlignment()); + anInstruction8 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); if (usesOutOfLineLiteral(anInstruction8)) { (anInstruction8->dependent = locateLiteralsize(literal1, BytesPerOop)); } @@ -22686,6 +22722,20 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) recordRunTimeObjectReferences(); } + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 61; +} + + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerTagBits */ +static sqInt +numSmallIntegerTagBits(void) +{ + return 3; +} + /* The three valid tag patterns are 1 (SmallInteger), 2 (Character) and 3 (SmallFloat64). @@ -23395,7 +23445,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock) } gSubRRR(SPReg, FPReg, TempReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = 3 /* log2BytesPerWord */; + quickConstant = log2BytesPerWord(); genoperandoperand(LogicalShiftRightCqR, quickConstant, TempReg); /* begin SubCq:R: */ quickConstant1 = 3; @@ -25670,11 +25720,14 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteralsize(0x3FFFFFFF, BytesPerOop)); + (anInstruction->dependent = locateLiteralsize(quickConstant, BytesPerOop)); } /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); @@ -25820,6 +25873,13 @@ maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg) return 0; } + /* CogObjectRepresentationForSpur>>#numCharacterBits */ +static sqInt +numCharacterBits(void) +{ + return 30; +} + /* CogObjectRepresentationForSpur>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) diff --git a/src/spur64.cog/cogitX64SysV.c b/src/spur64.cog/cogitX64SysV.c index e1df44d839..df35dd1932 100644 --- a/src/spur64.cog/cogitX64SysV.c +++ b/src/spur64.cog/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -815,6 +815,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -911,7 +912,10 @@ static sqInt NoDbgRegParms genShiftAwaySmallIntegerTagsInScratchReg(sqInt scratc static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms getLiteralCountOfplusOneinBytesintoscratch(sqInt methodReg, sqInt plusOne, sqInt inBytes, sqInt litCountReg, sqInt scratchReg); static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); +static sqInt log2BytesPerWord(void); static void maybeGenerateSelectorIndexDereferenceRoutine(void); +static sqInt numSmallIntegerBits(void); +static sqInt numSmallIntegerTagBits(void); static sqInt NoDbgRegParms validInlineCacheTag(sqInt classIndexOrTagPattern); static void callStoreCheckTrampoline(void); static sqInt NoDbgRegParms checkValidDerivedObjectReference(sqInt bodyAddress); @@ -987,6 +991,7 @@ static void NoDbgRegParms markAndTraceLiteralinat(sqInt literal, CogMethod *cogM static void NoDbgRegParms markAndTraceUpdatedLiteralin(sqInt objOop, CogMethod *cogMethodOrNil); static sqInt NoDbgRegParms maybeCompileRetryOnPrimitiveFail(sqInt primIndex); static sqInt NoDbgRegParms maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg); +static sqInt numCharacterBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt objOop); static sqInt NoDbgRegParms shouldAnnotateObjectReference(sqInt anOop); @@ -2563,7 +2568,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2585,6 +2589,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -4504,11 +4511,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -4516,11 +4523,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -4569,7 +4576,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4579,7 +4586,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4784,7 +4791,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -6176,7 +6183,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) @@ -6217,19 +6224,19 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, /* begin rewriteJumpLongAt:target: */ jumpTargetAddr = (((sqInt)cPIC)) + (sizeof(CogMethod)); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + firstCPICCaseOffset, jumpTargetAddr); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); /* begin rewriteJumpLongAt:target: */ jumpTargetAddr1 = cPICMissTrampolineFor(numArgs); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + cPICEndOfCodeOffset, jumpTargetAddr1); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) && (((byteAt(pc - 7)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7))))); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, target); return 0; } @@ -6280,12 +6287,12 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) } if (valid) { tags[used] = ((i > 1 - ? literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */) + ? literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd))) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? 5 /* jumpLongByteSize */ - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -6299,7 +6306,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc); return 0; } for (i = 1; i < used; i += 1) { @@ -6307,7 +6314,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); return 0; } @@ -6326,7 +6333,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 6 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { classIndex = literal32BeforeFollowingAddress(backEnd, pc); if (isForwardedClassIndex(classIndex)) { @@ -6448,7 +6455,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -6623,7 +6630,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -6635,12 +6642,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); classTag = literal32BeforeFollowingAddress(backEnd, classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { errors = errors | 8; @@ -7091,12 +7098,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -7361,8 +7368,8 @@ generateCaptureCStackPointers(sqInt captureFramePointer) } /* begin LoadEffectiveAddressMw:r:R: */ offset = (pushedVarBaseReg - ? 8 /* leafCallStackPointerDelta */ + BytesPerWord - : 8 /* leafCallStackPointerDelta */); + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -7480,7 +7487,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -7746,6 +7753,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -7758,6 +7770,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -7825,6 +7838,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -7846,7 +7860,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 8 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -8848,12 +8864,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -10208,7 +10224,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (5 /* callInstructionByteSize */); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -10651,11 +10667,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); storeLiteral32beforeFollowingAddress(backEnd, newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); } @@ -10799,7 +10815,7 @@ gTstCqR(sqInt quickConstant, sqInt reg) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 12 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -12609,6 +12625,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -12836,6 +12859,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -12854,7 +12880,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -12882,11 +12910,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -13183,9 +13215,9 @@ genPrimitiveHighBit(void) /* remove excess tag bits from the receiver oop */ - gOrCqRR(7, ReceiverResultReg, TempReg); + gOrCqRR((1U << (numSmallIntegerTagBits())) - 1, ReceiverResultReg, TempReg); /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 2; + quickConstant = (numSmallIntegerTagBits()) - 1; genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */ self_in_genHighBitInofSmallIntegerOopWithSingleTagBit = ((AbstractInstruction *) (backEnd())); @@ -15197,7 +15229,7 @@ genPrimitiveAtSigned(sqInt signedVersion) /* c.f. Spur64BitMemoryManager>>#isIntegerValue: */ /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 61 /* numSmallIntegerBits */; + quickConstant = numSmallIntegerBits(); genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction = genoperandoperand(AndCqR, 15, TempReg); @@ -15224,7 +15256,7 @@ genPrimitiveAtSigned(sqInt signedVersion) } else { /* begin LogicalShiftRightCq:R: */ - quickConstant1 = 60; + quickConstant1 = (numSmallIntegerBits()) - 1; genoperandoperand(LogicalShiftRightCqR, quickConstant1, TempReg); if (!(setsConditionCodesFor(lastOpcode(), JumpZero))) { /* begin checkQuickConstant:forInstruction: */ @@ -15670,7 +15702,7 @@ genPrimitiveNewWithArg(void) jumpNElementsNonInt = genJumpNotSmallInteger(Arg0Reg); genLoadSlotsourceRegdestReg(InstanceSpecificationIndex, ReceiverResultReg, instSpecReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = (fixedFieldsFieldWidth()) + 3 /* numSmallIntegerTagBits */; + quickConstant = (fixedFieldsFieldWidth()) + (numSmallIntegerTagBits()); genoperandoperand(LogicalShiftRightCqR, quickConstant, instSpecReg); /* begin checkQuickConstant:forInstruction: */ formatMask(); @@ -16152,7 +16184,7 @@ genPrimitiveStringAtPut(void) /* begin JumpAboveOrEqual: */ jumpIsShorts = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0)); /* begin CmpCq:R: */ - quickConstant = characterObjectOf(0x3FFFFFFF); + quickConstant = characterObjectOf((1U << (numCharacterBits())) - 1); /* begin checkQuickConstant:forInstruction: */ anInstruction5 = genoperandoperand(CmpCqR, quickConstant, Arg1Reg); /* begin JumpAbove: */ @@ -16603,6 +16635,13 @@ inlineCacheTagForInstance(sqInt oop) : classIndexOf(oop)); } + /* CogObjectRepresentationFor64BitSpur>>#log2BytesPerWord */ +static sqInt +log2BytesPerWord(void) +{ + return 3; +} + /* Generate the routine that converts selector indices into selector objects. It is called from the send trampolines. @@ -16649,8 +16688,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) /* begin JumpZero: */ jumpNotBlock = genConditionalBranchoperand(JumpZero, ((sqInt)0)); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction6 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction6 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin bitAndByteOffsetOfIsFullBlockBitInto: */ byteOffset = BaseHeaderSize + 1; /* begin checkQuickConstant:forInstruction: */ @@ -16666,8 +16705,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) jmpTarget(jumpNotBlock, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); jmpTarget(jumpFullBlock, ((AbstractInstruction *) (((jumpNotBlock->operands))[0]))); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction8 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction8 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin MoveMw:r:R: */ offset = offsetof(CogMethod, methodObject); /* begin checkQuickConstant:forInstruction: */ @@ -16698,6 +16737,20 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) recordRunTimeObjectReferences(); } + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 61; +} + + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerTagBits */ +static sqInt +numSmallIntegerTagBits(void) +{ + return 3; +} + /* The three valid tag patterns are 1 (SmallInteger), 2 (Character) and 3 (SmallFloat64). @@ -17274,7 +17327,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock) anInstruction24 = genoperandoperandoperand(MoveRMwr, ReceiverResultReg, FoxThisContext, FPReg); gSubRRR(SPReg, FPReg, TempReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = 3 /* log2BytesPerWord */; + quickConstant = log2BytesPerWord(); genoperandoperand(LogicalShiftRightCqR, quickConstant, TempReg); /* begin SubCq:R: */ quickConstant1 = 4; @@ -19153,9 +19206,12 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); } @@ -19286,6 +19342,13 @@ maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg) return 0; } + /* CogObjectRepresentationForSpur>>#numCharacterBits */ +static sqInt +numCharacterBits(void) +{ + return 30; +} + /* CogObjectRepresentationForSpur>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) diff --git a/src/spur64.cog/cogitX64WIN64.c b/src/spur64.cog/cogitX64WIN64.c index bc9b41452d..776dd90fff 100644 --- a/src/spur64.cog/cogitX64WIN64.c +++ b/src/spur64.cog/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -815,6 +815,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -911,7 +912,10 @@ static sqInt NoDbgRegParms genShiftAwaySmallIntegerTagsInScratchReg(sqInt scratc static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms getLiteralCountOfplusOneinBytesintoscratch(sqInt methodReg, sqInt plusOne, sqInt inBytes, sqInt litCountReg, sqInt scratchReg); static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); +static sqInt log2BytesPerWord(void); static void maybeGenerateSelectorIndexDereferenceRoutine(void); +static sqInt numSmallIntegerBits(void); +static sqInt numSmallIntegerTagBits(void); static sqInt NoDbgRegParms validInlineCacheTag(sqInt classIndexOrTagPattern); static void callStoreCheckTrampoline(void); static sqInt NoDbgRegParms checkValidDerivedObjectReference(sqInt bodyAddress); @@ -987,6 +991,7 @@ static void NoDbgRegParms markAndTraceLiteralinat(sqInt literal, CogMethod *cogM static void NoDbgRegParms markAndTraceUpdatedLiteralin(sqInt objOop, CogMethod *cogMethodOrNil); static sqInt NoDbgRegParms maybeCompileRetryOnPrimitiveFail(sqInt primIndex); static sqInt NoDbgRegParms maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg); +static sqInt numCharacterBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt objOop); static sqInt NoDbgRegParms shouldAnnotateObjectReference(sqInt anOop); @@ -2563,7 +2568,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2585,6 +2589,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -4504,11 +4511,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -4516,11 +4523,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -4569,7 +4576,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4579,7 +4586,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4784,7 +4791,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -6184,7 +6191,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) @@ -6225,19 +6232,19 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, /* begin rewriteJumpLongAt:target: */ jumpTargetAddr = (((sqInt)cPIC)) + (sizeof(CogMethod)); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + firstCPICCaseOffset, jumpTargetAddr); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); /* begin rewriteJumpLongAt:target: */ jumpTargetAddr1 = cPICMissTrampolineFor(numArgs); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + cPICEndOfCodeOffset, jumpTargetAddr1); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) && (((byteAt(pc - 7)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7))))); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, target); return 0; } @@ -6288,12 +6295,12 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) } if (valid) { tags[used] = ((i > 1 - ? literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */) + ? literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd))) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? 5 /* jumpLongByteSize */ - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -6307,7 +6314,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc); return 0; } for (i = 1; i < used; i += 1) { @@ -6315,7 +6322,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); return 0; } @@ -6334,7 +6341,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 6 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { classIndex = literal32BeforeFollowingAddress(backEnd, pc); if (isForwardedClassIndex(classIndex)) { @@ -6456,7 +6463,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -6631,7 +6638,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -6643,12 +6650,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); classTag = literal32BeforeFollowingAddress(backEnd, classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { errors = errors | 8; @@ -7099,12 +7106,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -7369,8 +7376,8 @@ generateCaptureCStackPointers(sqInt captureFramePointer) } /* begin LoadEffectiveAddressMw:r:R: */ offset = (pushedVarBaseReg - ? 8 /* leafCallStackPointerDelta */ + BytesPerWord - : 8 /* leafCallStackPointerDelta */); + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -7488,7 +7495,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -7754,6 +7761,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -7766,6 +7778,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -7833,6 +7846,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -7854,7 +7868,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 8 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -8866,12 +8882,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -10226,7 +10242,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (5 /* callInstructionByteSize */); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -10669,11 +10685,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); storeLiteral32beforeFollowingAddress(backEnd, newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); } @@ -10817,7 +10833,7 @@ gTstCqR(sqInt quickConstant, sqInt reg) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 12 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -12627,6 +12643,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -12854,6 +12877,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -12872,7 +12898,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -12900,11 +12928,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -13201,9 +13233,9 @@ genPrimitiveHighBit(void) /* remove excess tag bits from the receiver oop */ - gOrCqRR(7, ReceiverResultReg, TempReg); + gOrCqRR((1U << (numSmallIntegerTagBits())) - 1, ReceiverResultReg, TempReg); /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 2; + quickConstant = (numSmallIntegerTagBits()) - 1; genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */ self_in_genHighBitInofSmallIntegerOopWithSingleTagBit = ((AbstractInstruction *) (backEnd())); @@ -15215,7 +15247,7 @@ genPrimitiveAtSigned(sqInt signedVersion) /* c.f. Spur64BitMemoryManager>>#isIntegerValue: */ /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 61 /* numSmallIntegerBits */; + quickConstant = numSmallIntegerBits(); genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction = genoperandoperand(AndCqR, 15, TempReg); @@ -15242,7 +15274,7 @@ genPrimitiveAtSigned(sqInt signedVersion) } else { /* begin LogicalShiftRightCq:R: */ - quickConstant1 = 60; + quickConstant1 = (numSmallIntegerBits()) - 1; genoperandoperand(LogicalShiftRightCqR, quickConstant1, TempReg); if (!(setsConditionCodesFor(lastOpcode(), JumpZero))) { /* begin checkQuickConstant:forInstruction: */ @@ -15688,7 +15720,7 @@ genPrimitiveNewWithArg(void) jumpNElementsNonInt = genJumpNotSmallInteger(Arg0Reg); genLoadSlotsourceRegdestReg(InstanceSpecificationIndex, ReceiverResultReg, instSpecReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = (fixedFieldsFieldWidth()) + 3 /* numSmallIntegerTagBits */; + quickConstant = (fixedFieldsFieldWidth()) + (numSmallIntegerTagBits()); genoperandoperand(LogicalShiftRightCqR, quickConstant, instSpecReg); /* begin checkQuickConstant:forInstruction: */ formatMask(); @@ -16170,7 +16202,7 @@ genPrimitiveStringAtPut(void) /* begin JumpAboveOrEqual: */ jumpIsShorts = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0)); /* begin CmpCq:R: */ - quickConstant = characterObjectOf(0x3FFFFFFF); + quickConstant = characterObjectOf((1U << (numCharacterBits())) - 1); /* begin checkQuickConstant:forInstruction: */ anInstruction5 = genoperandoperand(CmpCqR, quickConstant, Arg1Reg); /* begin JumpAbove: */ @@ -16621,6 +16653,13 @@ inlineCacheTagForInstance(sqInt oop) : classIndexOf(oop)); } + /* CogObjectRepresentationFor64BitSpur>>#log2BytesPerWord */ +static sqInt +log2BytesPerWord(void) +{ + return 3; +} + /* Generate the routine that converts selector indices into selector objects. It is called from the send trampolines. @@ -16667,8 +16706,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) /* begin JumpZero: */ jumpNotBlock = genConditionalBranchoperand(JumpZero, ((sqInt)0)); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction6 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction6 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin bitAndByteOffsetOfIsFullBlockBitInto: */ byteOffset = BaseHeaderSize + 1; /* begin checkQuickConstant:forInstruction: */ @@ -16684,8 +16723,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) jmpTarget(jumpNotBlock, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); jmpTarget(jumpFullBlock, ((AbstractInstruction *) (((jumpNotBlock->operands))[0]))); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction8 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction8 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin MoveMw:r:R: */ offset = offsetof(CogMethod, methodObject); /* begin checkQuickConstant:forInstruction: */ @@ -16716,6 +16755,20 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) recordRunTimeObjectReferences(); } + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 61; +} + + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerTagBits */ +static sqInt +numSmallIntegerTagBits(void) +{ + return 3; +} + /* The three valid tag patterns are 1 (SmallInteger), 2 (Character) and 3 (SmallFloat64). @@ -17292,7 +17345,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock) anInstruction24 = genoperandoperandoperand(MoveRMwr, ReceiverResultReg, FoxThisContext, FPReg); gSubRRR(SPReg, FPReg, TempReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = 3 /* log2BytesPerWord */; + quickConstant = log2BytesPerWord(); genoperandoperand(LogicalShiftRightCqR, quickConstant, TempReg); /* begin SubCq:R: */ quickConstant1 = 4; @@ -19171,9 +19224,12 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); } @@ -19304,6 +19360,13 @@ maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg) return 0; } + /* CogObjectRepresentationForSpur>>#numCharacterBits */ +static sqInt +numCharacterBits(void) +{ + return 30; +} + /* CogObjectRepresentationForSpur>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) diff --git a/src/spur64.cog/cointerp.c b/src/spur64.cog/cointerp.c index efad02312b..62e907bfbd 100644 --- a/src/spur64.cog/cointerp.c +++ b/src/spur64.cog/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1266,7 +1266,7 @@ static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBitsformat(sqInt objOop, sqInt format); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -2617,7 +2617,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -15765,7 +15765,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -16445,7 +16445,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -20208,11 +20223,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -32897,7 +32918,7 @@ primitiveInvokeObjectAsMethod(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt i; sqInt lookupClassTag; - sqInt runArgs; + usqInt runArgs; sqInt runReceiver; char *sp; char *sp1; @@ -39343,7 +39364,7 @@ followForwardedObjectFieldstoDepth(sqInt objOop, sqInt depth) sqInt header1; sqInt i; sqInt numLiterals; - usqInt numSlots; + sqInt numSlots; usqInt numSlots1; sqInt oop; sqInt referent; @@ -46682,7 +46703,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -53203,7 +53224,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -56213,7 +56234,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj1))); contextSize = (sp >> 3); l9: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -56246,7 +56267,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l10: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59509,10 +59530,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -60090,7 +60111,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -60120,7 +60141,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -60671,7 +60692,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.cog/cointerp.h b/src/spur64.cog/cointerp.h index 6e9bbc7304..245978f907 100644 --- a/src/spur64.cog/cointerp.h +++ b/src/spur64.cog/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -244,7 +244,7 @@ extern sqInt minSlotsForShortening(void); extern sqInt nilObject(void); extern sqInt nonIndexablePointerFormat(void); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); extern sqInt numStrongSlotsOfWeakling(sqInt objOop); extern sqInt objectAfter(sqInt objOop); diff --git a/src/spur64.cog/gcc3x-cointerp.c b/src/spur64.cog/gcc3x-cointerp.c index c12e76f825..157a8fbb5a 100644 --- a/src/spur64.cog/gcc3x-cointerp.c +++ b/src/spur64.cog/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -1269,7 +1269,7 @@ static sqInt noUnscannedEphemerons(void); static sqInt NoDbgRegParms numBytesOfBitsformat(sqInt objOop, sqInt format); static sqInt NoDbgRegParms numBytesOfBytes(sqInt objOop); extern sqInt numBytesOf(sqInt objOop); -extern usqInt numPointerSlotsOf(sqInt objOop); +extern sqInt numPointerSlotsOf(sqInt objOop); static usqInt NoDbgRegParms numSlotsOfAny(sqInt objOop); extern usqInt numSlotsOf(sqInt objOop); static sqInt NoDbgRegParms numStrongSlotsOfInephemeral(sqInt objOop); @@ -2620,7 +2620,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -15774,7 +15774,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -16454,7 +16454,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -20217,11 +20232,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -32906,7 +32927,7 @@ primitiveInvokeObjectAsMethod(void) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt i; sqInt lookupClassTag; - sqInt runArgs; + usqInt runArgs; sqInt runReceiver; char *sp; char *sp1; @@ -39352,7 +39373,7 @@ followForwardedObjectFieldstoDepth(sqInt objOop, sqInt depth) sqInt header1; sqInt i; sqInt numLiterals; - usqInt numSlots; + sqInt numSlots; usqInt numSlots1; sqInt oop; sqInt referent; @@ -46691,7 +46712,7 @@ copyObjtoAddrstopAtsavedFirstFieldsindex(sqInt objOop, sqInt segAddr, sqInt endS sqInt iLimiT; sqInt methodHeader; sqInt numLiterals; - usqInt numMediatedSlots; + sqInt numMediatedSlots; usqInt numSlots; usqInt numSlots1; sqInt oop; @@ -53212,7 +53233,7 @@ numBytesOf(sqInt objOop) Works with CompiledMethods, as well as ordinary objects. */ /* SpurMemoryManager>>#numPointerSlotsOf: */ -usqInt +sqInt numPointerSlotsOf(sqInt objOop) { DECL_MAYBE_SQ_GLOBAL_STRUCT sqInt contextSize; @@ -56222,7 +56243,7 @@ printReferencesTo(sqInt anOop) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj1))); contextSize = (sp >> 3); l9: /* end fetchStackPointerOf: */; - i = ((usqInt) (CtxtTempFrameStart + contextSize)); + i = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -56255,7 +56276,7 @@ printReferencesTo(sqInt anOop) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - i = ((usqInt) (numLiterals + LiteralStart)); + i = numLiterals + LiteralStart; l10: /* end numPointerSlotsOf: */; while (((i -= 1)) >= 0) { if (anOop == (longAt((obj1 + BaseHeaderSize) + (((sqInt)((usqInt)(i) << (shiftForWord()))))))) { @@ -59518,10 +59539,10 @@ updatePointers(void) sqInt numLiterals1; sqInt numLiterals2; sqInt numLiterals3; - usqInt numPointerSlots; - usqInt numPointerSlots1; - usqInt numPointerSlots2; - usqInt numPointerSlots3; + sqInt numPointerSlots; + sqInt numPointerSlots1; + sqInt numPointerSlots2; + sqInt numPointerSlots3; usqInt numSlots; usqInt numSlots1; usqInt numSlots11; @@ -60099,7 +60120,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -60129,7 +60150,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -60680,7 +60701,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.sista/cogit.h b/src/spur64.sista/cogit.h index b33667c5a3..b712adc281 100644 --- a/src/spur64.sista/cogit.h +++ b/src/spur64.sista/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -123,7 +123,9 @@ extern sqInt ceReturnToInterpreterTrampoline; #if COGMTVM extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) extern sqInt cFramePointerInUse; +#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; diff --git a/src/spur64.sista/cogitARMv8.c b/src/spur64.sista/cogitARMv8.c index fe1bad478e..38a3ef75d0 100644 --- a/src/spur64.sista/cogitARMv8.c +++ b/src/spur64.sista/cogitARMv8.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -949,6 +949,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -1052,8 +1053,11 @@ static sqInt NoDbgRegParms genShiftAwaySmallIntegerTagsInScratchReg(sqInt scratc static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms getLiteralCountOfplusOneinBytesintoscratch(sqInt methodReg, sqInt plusOne, sqInt inBytes, sqInt litCountReg, sqInt scratchReg); static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); +static sqInt log2BytesPerWord(void); static void maybeGenerateSelectorIndexDereferenceRoutine(void); static usqInt NoDbgRegParms numCountersFor(usqInt theCounters); +static sqInt numSmallIntegerBits(void); +static sqInt numSmallIntegerTagBits(void); static sqInt NoDbgRegParms validInlineCacheTag(sqInt classIndexOrTagPattern); static sqInt NoDbgRegParms branchIfinstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms branchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); @@ -1144,6 +1148,7 @@ static sqInt NoDbgRegParms mixedbranchIfinstanceOfBehaviorstarget(sqInt numNonIm static sqInt NoDbgRegParms mixedbranchIfnotInstanceOfBehaviorstarget(sqInt numNonImmediates, sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms noneImmediateBranchIfinstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms noneImmediateBranchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); +static sqInt numCharacterBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt objOop); extern void resetCountersIn(CogMethod *cogMethod); @@ -2727,7 +2732,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2749,6 +2753,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -7143,7 +7150,7 @@ machineCodeBytes(AbstractInstruction * self_in_machineCodeBytes) static sqInt NoDbgRegParms machineCodeWords(AbstractInstruction * self_in_machineCodeWords) { - return 12 /* machineCodeBytes */ / 4; + return (machineCodeBytes(self_in_machineCodeWords)) / 4; } /* CogARMv8Compiler>>#movern:rd: */ @@ -7379,7 +7386,7 @@ rewriteImm19JumpBeforetarget(AbstractInstruction * self_in_rewriteImm19JumpBefor static sqInt NoDbgRegParms rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBeforetarget, sqInt followingAddress, sqInt targetAddress) { - usqInt instrOpcode; + sqInt instrOpcode; sqInt mcpc; sqInt offset; @@ -7389,7 +7396,7 @@ rewriteImm26JumpBeforetarget(AbstractInstruction * self_in_rewriteImm26JumpBefor instrOpcode = ((instructionBeforeAddress(self_in_rewriteImm26JumpBeforetarget, followingAddress))) >> 26; assert((instrOpcode == 5) || (instrOpcode == 37)); - codeLong32Atput(mcpc, (instrOpcode << 26) + (((offset) >> 2) & (0x3FFFFFF))); + codeLong32Atput(mcpc, (((sqInt)((usqInt)(instrOpcode) << 26))) + (((offset) >> 2) & (0x3FFFFFF))); return 4; } @@ -8289,7 +8296,7 @@ blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction) } } } - pc += 4 /* instructionSizeAt: */; + pc += instructionSizeAt(backEnd, pc); } return 0; } @@ -9211,11 +9218,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 4 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -9223,11 +9230,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 8 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -9276,7 +9283,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9286,7 +9293,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -9494,7 +9501,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); /* begin flushICacheFrom:to: */ @@ -10981,7 +10988,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 4))) || (instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 8)))); /* begin rewriteJumpLongAt:target: */ @@ -11021,18 +11028,18 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, /* begin rewriteJumpLongAt:target: */ callTargetAddress = (((sqInt)cPIC)) + (sizeof(CogMethod)); rewriteImm26JumpBeforetarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + firstCPICCaseOffset, callTargetAddress); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); /* begin rewriteJumpLongAt:target: */ callTargetAddress1 = cPICMissTrampolineFor(numArgs); rewriteImm26JumpBeforetarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + cPICEndOfCodeOffset, callTargetAddress1); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 4))) || (instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc - 8)))); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPICJumpAt:target: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump, target); return 0; } @@ -11086,12 +11093,12 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) } if (valid) { tags[used] = ((i > 1 - ? literal32BeforeFollowingAddress(backEnd, pc - 8 /* jumpLongConditionalByteSize */) + ? literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd))) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 4 - : 16)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -11105,7 +11112,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump, pc); return 0; } @@ -11114,7 +11121,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteImm19JumpBeforetarget(((AbstractInstruction *) backEnd), addressFollowingJump1, pc - cPICCaseSize); return 0; } @@ -11134,7 +11141,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 8 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { classIndex = literal32BeforeFollowingAddress(backEnd, pc); if (isForwardedClassIndex(classIndex)) { @@ -11256,7 +11263,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - 8 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -11454,7 +11461,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -11466,12 +11473,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 8 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); classTag = literal32BeforeFollowingAddress(backEnd, classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { errors = errors | 8; @@ -11881,12 +11888,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -12333,7 +12340,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -12632,6 +12639,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -12644,6 +12656,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE /* begin makeCodeZoneWritable */ @@ -13683,12 +13696,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -15232,7 +15245,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (8); + return (interpretOffset()) - ((pushLinkRegisterByteSize(backEnd)) + (callInstructionByteSize(backEnd))); } /* Cogit>>#previousInstruction */ @@ -15459,7 +15472,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } assert(((cPIC->cPICNumCases)) > 0); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + 4 /* loadPICLiteralByteSize */; + pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)); assert((instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc1 - 4))) || (instructionIsADR(((AbstractInstruction *) backEnd), instructionAt(((AbstractInstruction *) backEnd), pc1 - 8)))); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); @@ -15711,11 +15724,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 8 /* jumpLongConditionalByteSize */) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 8 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); storeLiteral32beforeFollowingAddress(backEnd, newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); } @@ -15878,7 +15891,7 @@ gTstCqR(sqInt quickConstant, sqInt reg) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 8 /* callFullInstructionByteSize */) + (/* begin pushLinkRegisterByteSize */ 4); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (pushLinkRegisterByteSize(backEnd)); } @@ -16928,7 +16941,7 @@ voidCogCompiledCode(void) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; /* begin ensureExecutableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE /* begin makeCodeZoneExecutable */ @@ -17908,6 +17921,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -18154,6 +18174,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -18173,9 +18196,11 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteralsize(61 /* numSmallIntegerBits */, BytesPerOop)); + (anInstruction1->dependent = locateLiteralsize(quickConstant, BytesPerOop)); } /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); @@ -18204,16 +18229,20 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteralsize(61 /* numSmallIntegerBits */, BytesPerOop)); + (anInstruction2->dependent = locateLiteralsize(quickConstant1, BytesPerOop)); } /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteralsize(61 /* numSmallIntegerBits */, BytesPerOop)); + (anInstruction3->dependent = locateLiteralsize(quickConstant2, BytesPerOop)); } jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); @@ -18522,9 +18551,9 @@ genPrimitiveHighBit(void) /* remove excess tag bits from the receiver oop */ - gOrCqRR(7, ReceiverResultReg, TempReg); + gOrCqRR((1U << (numSmallIntegerTagBits())) - 1, ReceiverResultReg, TempReg); /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 2; + quickConstant = (numSmallIntegerTagBits()) - 1; genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */ /* begin genHighBitClzIn:ofSmallIntegerOopWithSingleTagBit: */ @@ -21041,7 +21070,7 @@ genPrimitiveAtSigned(sqInt signedVersion) /* c.f. Spur64BitMemoryManager>>#isIntegerValue: */ /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 61 /* numSmallIntegerBits */; + quickConstant = numSmallIntegerBits(); genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction = genoperandoperand(AndCqR, 15, TempReg); @@ -21074,7 +21103,7 @@ genPrimitiveAtSigned(sqInt signedVersion) } else { /* begin LogicalShiftRightCq:R: */ - quickConstant1 = 60; + quickConstant1 = (numSmallIntegerBits()) - 1; genoperandoperand(LogicalShiftRightCqR, quickConstant1, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperand(CmpCqR, 0, TempReg); @@ -21588,7 +21617,7 @@ genPrimitiveNewWithArg(void) jumpNElementsNonInt = genJumpNotSmallInteger(Arg0Reg); genLoadSlotsourceRegdestReg(InstanceSpecificationIndex, ReceiverResultReg, instSpecReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = (fixedFieldsFieldWidth()) + 3 /* numSmallIntegerTagBits */; + quickConstant = (fixedFieldsFieldWidth()) + (numSmallIntegerTagBits()); genoperandoperand(LogicalShiftRightCqR, quickConstant, instSpecReg); /* begin checkQuickConstant:forInstruction: */ literal = formatMask(); @@ -22242,7 +22271,7 @@ genPrimitiveStringAtPut(void) /* begin JumpAboveOrEqual: */ jumpIsShorts = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0)); /* begin CmpCq:R: */ - quickConstant = characterObjectOf(0x3FFFFFFF); + quickConstant = characterObjectOf((1U << (numCharacterBits())) - 1); /* begin checkQuickConstant:forInstruction: */ anInstruction5 = genoperandoperand(CmpCqR, quickConstant, Arg1Reg); if (usesOutOfLineLiteral(anInstruction5)) { @@ -22749,6 +22778,13 @@ inlineCacheTagForInstance(sqInt oop) : classIndexOf(oop)); } + /* CogObjectRepresentationFor64BitSpur>>#log2BytesPerWord */ +static sqInt +log2BytesPerWord(void) +{ + return 3; +} + /* Generate the routine that converts selector indices into selector objects. It is called from the send trampolines. @@ -22809,8 +22845,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) /* begin JumpZero: */ jumpNotBlock = genConditionalBranchoperand(JumpZero, ((sqInt)0)); /* begin checkQuickConstant:forInstruction: */ - literal = -8 /* zoneAlignment */; - anInstruction6 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + literal = -(zoneAlignment()); + anInstruction6 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); if (usesOutOfLineLiteral(anInstruction6)) { (anInstruction6->dependent = locateLiteralsize(literal, BytesPerOop)); } @@ -22838,8 +22874,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) jmpTarget(jumpNotBlock, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); jmpTarget(jumpFullBlock, ((AbstractInstruction *) (((jumpNotBlock->operands))[0]))); /* begin checkQuickConstant:forInstruction: */ - literal1 = -8 /* zoneAlignment */; - anInstruction8 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + literal1 = -(zoneAlignment()); + anInstruction8 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); if (usesOutOfLineLiteral(anInstruction8)) { (anInstruction8->dependent = locateLiteralsize(literal1, BytesPerOop)); } @@ -22896,6 +22932,20 @@ numCountersFor(usqInt theCounters) return 2 * (numSlotsOf(objOop)); } + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 61; +} + + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerTagBits */ +static sqInt +numSmallIntegerTagBits(void) +{ + return 3; +} + /* The three valid tag patterns are 1 (SmallInteger), 2 (Character) and 3 (SmallFloat64). @@ -23715,7 +23765,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock) } gSubRRR(SPReg, FPReg, TempReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = 3 /* log2BytesPerWord */; + quickConstant = log2BytesPerWord(); genoperandoperand(LogicalShiftRightCqR, quickConstant, TempReg); /* begin SubCq:R: */ quickConstant1 = 3; @@ -26345,11 +26395,14 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); if (usesOutOfLineLiteral(anInstruction)) { - (anInstruction->dependent = locateLiteralsize(0x3FFFFFFF, BytesPerOop)); + (anInstruction->dependent = locateLiteralsize(quickConstant, BytesPerOop)); } /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); @@ -26770,6 +26823,13 @@ noneImmediateBranchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, Abs return 0; } + /* CogObjectRepresentationForSpur>>#numCharacterBits */ +static sqInt +numCharacterBits(void) +{ + return 30; +} + /* CogObjectRepresentationForSpur>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) @@ -35223,7 +35283,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); /* begin detectFeatures */ # if __APPLE__ @@ -35396,7 +35456,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; generateOpenPICPrototype(); } @@ -36174,7 +36234,7 @@ populatewithPICInfoForfirstCacheTag(sqInt tuple, CogMethod *cPIC, sqInt firstCac pc = addressOfEndOfCaseinCPIC(i, cPIC); cacheTag = (i == 1 ? firstCacheTag - : literalBeforeFollowingAddress(backEnd, pc - 8 /* jumpLongConditionalByteSize */)); + : literalBeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); classOop = classForInlineCacheTag(cacheTag); storePointerofObjectwithValue((i * 2) - 1, tuple, classOop); if (i == 1) { @@ -36214,7 +36274,7 @@ setCogCodeZoneThreshold(double ratio) } thresholdRatio = ratio; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; return 0; } diff --git a/src/spur64.sista/cogitX64SysV.c b/src/spur64.sista/cogitX64SysV.c index 5250a8429f..073d096fd7 100644 --- a/src/spur64.sista/cogitX64SysV.c +++ b/src/spur64.sista/cogitX64SysV.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -818,6 +818,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -921,8 +922,11 @@ static sqInt NoDbgRegParms genShiftAwaySmallIntegerTagsInScratchReg(sqInt scratc static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms getLiteralCountOfplusOneinBytesintoscratch(sqInt methodReg, sqInt plusOne, sqInt inBytes, sqInt litCountReg, sqInt scratchReg); static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); +static sqInt log2BytesPerWord(void); static void maybeGenerateSelectorIndexDereferenceRoutine(void); static usqInt NoDbgRegParms numCountersFor(usqInt theCounters); +static sqInt numSmallIntegerBits(void); +static sqInt numSmallIntegerTagBits(void); static sqInt NoDbgRegParms validInlineCacheTag(sqInt classIndexOrTagPattern); static sqInt NoDbgRegParms branchIfinstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms branchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); @@ -1013,6 +1017,7 @@ static sqInt NoDbgRegParms mixedbranchIfinstanceOfBehaviorstarget(sqInt numNonIm static sqInt NoDbgRegParms mixedbranchIfnotInstanceOfBehaviorstarget(sqInt numNonImmediates, sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms noneImmediateBranchIfinstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms noneImmediateBranchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); +static sqInt numCharacterBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt objOop); extern void resetCountersIn(CogMethod *cogMethod); @@ -2659,7 +2664,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2681,6 +2685,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -4641,11 +4648,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -4653,11 +4660,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -4706,7 +4713,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4716,7 +4723,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4921,7 +4928,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -6371,7 +6378,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) @@ -6412,19 +6419,19 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, /* begin rewriteJumpLongAt:target: */ jumpTargetAddr = (((sqInt)cPIC)) + (sizeof(CogMethod)); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + firstCPICCaseOffset, jumpTargetAddr); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); /* begin rewriteJumpLongAt:target: */ jumpTargetAddr1 = cPICMissTrampolineFor(numArgs); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + cPICEndOfCodeOffset, jumpTargetAddr1); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) && (((byteAt(pc - 7)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7))))); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, target); return 0; } @@ -6475,12 +6482,12 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) } if (valid) { tags[used] = ((i > 1 - ? literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */) + ? literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd))) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? 5 /* jumpLongByteSize */ - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -6494,7 +6501,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc); return 0; } for (i = 1; i < used; i += 1) { @@ -6502,7 +6509,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); return 0; } @@ -6521,7 +6528,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 6 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { classIndex = literal32BeforeFollowingAddress(backEnd, pc); if (isForwardedClassIndex(classIndex)) { @@ -6643,7 +6650,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -6841,7 +6848,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -6853,12 +6860,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); classTag = literal32BeforeFollowingAddress(backEnd, classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { errors = errors | 8; @@ -7249,12 +7256,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -7519,8 +7526,8 @@ generateCaptureCStackPointers(sqInt captureFramePointer) } /* begin LoadEffectiveAddressMw:r:R: */ offset = (pushedVarBaseReg - ? 8 /* leafCallStackPointerDelta */ + BytesPerWord - : 8 /* leafCallStackPointerDelta */); + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -7638,7 +7645,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -7904,6 +7911,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -7916,6 +7928,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -7984,6 +7997,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -8005,7 +8019,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 8 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -8906,12 +8922,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -10320,7 +10336,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (5 /* callInstructionByteSize */); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -10773,11 +10789,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); storeLiteral32beforeFollowingAddress(backEnd, newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); } @@ -10921,7 +10937,7 @@ gTstCqR(sqInt quickConstant, sqInt reg) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 12 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -11833,7 +11849,7 @@ voidCogCompiledCode(void) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; /* begin ensureExecutableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -12788,6 +12804,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -13015,6 +13038,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -13033,7 +13059,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -13061,11 +13089,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -13362,9 +13394,9 @@ genPrimitiveHighBit(void) /* remove excess tag bits from the receiver oop */ - gOrCqRR(7, ReceiverResultReg, TempReg); + gOrCqRR((1U << (numSmallIntegerTagBits())) - 1, ReceiverResultReg, TempReg); /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 2; + quickConstant = (numSmallIntegerTagBits()) - 1; genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */ self_in_genHighBitInofSmallIntegerOopWithSingleTagBit = ((AbstractInstruction *) (backEnd())); @@ -15497,7 +15529,7 @@ genPrimitiveAtSigned(sqInt signedVersion) /* c.f. Spur64BitMemoryManager>>#isIntegerValue: */ /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 61 /* numSmallIntegerBits */; + quickConstant = numSmallIntegerBits(); genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction = genoperandoperand(AndCqR, 15, TempReg); @@ -15524,7 +15556,7 @@ genPrimitiveAtSigned(sqInt signedVersion) } else { /* begin LogicalShiftRightCq:R: */ - quickConstant1 = 60; + quickConstant1 = (numSmallIntegerBits()) - 1; genoperandoperand(LogicalShiftRightCqR, quickConstant1, TempReg); if (!(setsConditionCodesFor(lastOpcode(), JumpZero))) { /* begin checkQuickConstant:forInstruction: */ @@ -15970,7 +16002,7 @@ genPrimitiveNewWithArg(void) jumpNElementsNonInt = genJumpNotSmallInteger(Arg0Reg); genLoadSlotsourceRegdestReg(InstanceSpecificationIndex, ReceiverResultReg, instSpecReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = (fixedFieldsFieldWidth()) + 3 /* numSmallIntegerTagBits */; + quickConstant = (fixedFieldsFieldWidth()) + (numSmallIntegerTagBits()); genoperandoperand(LogicalShiftRightCqR, quickConstant, instSpecReg); /* begin checkQuickConstant:forInstruction: */ formatMask(); @@ -16452,7 +16484,7 @@ genPrimitiveStringAtPut(void) /* begin JumpAboveOrEqual: */ jumpIsShorts = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0)); /* begin CmpCq:R: */ - quickConstant = characterObjectOf(0x3FFFFFFF); + quickConstant = characterObjectOf((1U << (numCharacterBits())) - 1); /* begin checkQuickConstant:forInstruction: */ anInstruction5 = genoperandoperand(CmpCqR, quickConstant, Arg1Reg); /* begin JumpAbove: */ @@ -16903,6 +16935,13 @@ inlineCacheTagForInstance(sqInt oop) : classIndexOf(oop)); } + /* CogObjectRepresentationFor64BitSpur>>#log2BytesPerWord */ +static sqInt +log2BytesPerWord(void) +{ + return 3; +} + /* Generate the routine that converts selector indices into selector objects. It is called from the send trampolines. @@ -16949,8 +16988,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) /* begin JumpZero: */ jumpNotBlock = genConditionalBranchoperand(JumpZero, ((sqInt)0)); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction6 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction6 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin bitAndByteOffsetOfIsFullBlockBitInto: */ byteOffset = BaseHeaderSize + 1; /* begin checkQuickConstant:forInstruction: */ @@ -16966,8 +17005,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) jmpTarget(jumpNotBlock, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); jmpTarget(jumpFullBlock, ((AbstractInstruction *) (((jumpNotBlock->operands))[0]))); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction8 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction8 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin MoveMw:r:R: */ offset = offsetof(CogMethod, methodObject); /* begin checkQuickConstant:forInstruction: */ @@ -17011,6 +17050,20 @@ numCountersFor(usqInt theCounters) return 2 * (numSlotsOf(objOop)); } + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 61; +} + + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerTagBits */ +static sqInt +numSmallIntegerTagBits(void) +{ + return 3; +} + /* The three valid tag patterns are 1 (SmallInteger), 2 (Character) and 3 (SmallFloat64). @@ -17695,7 +17748,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock) anInstruction24 = genoperandoperandoperand(MoveRMwr, ReceiverResultReg, FoxThisContext, FPReg); gSubRRR(SPReg, FPReg, TempReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = 3 /* log2BytesPerWord */; + quickConstant = log2BytesPerWord(); genoperandoperand(LogicalShiftRightCqR, quickConstant, TempReg); /* begin SubCq:R: */ quickConstant1 = 4; @@ -19872,9 +19925,12 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); } @@ -20277,6 +20333,13 @@ noneImmediateBranchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, Abs return 0; } + /* CogObjectRepresentationForSpur>>#numCharacterBits */ +static sqInt +numCharacterBits(void) +{ + return 30; +} + /* CogObjectRepresentationForSpur>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) @@ -33717,7 +33780,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ @@ -33785,7 +33848,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; generateOpenPICPrototype(); } @@ -34563,7 +34626,7 @@ populatewithPICInfoForfirstCacheTag(sqInt tuple, CogMethod *cPIC, sqInt firstCac pc = addressOfEndOfCaseinCPIC(i, cPIC); cacheTag = (i == 1 ? firstCacheTag - : literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + : literalBeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); classOop = classForInlineCacheTag(cacheTag); storePointerofObjectwithValue((i * 2) - 1, tuple, classOop); if (i == 1) { @@ -34603,7 +34666,7 @@ setCogCodeZoneThreshold(double ratio) } thresholdRatio = ratio; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; return 0; } diff --git a/src/spur64.sista/cogitX64WIN64.c b/src/spur64.sista/cogitX64WIN64.c index 64a3592cb9..2535055044 100644 --- a/src/spur64.sista/cogitX64WIN64.c +++ b/src/spur64.sista/cogitX64WIN64.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "SistaCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -818,6 +818,7 @@ static void voidOpenPICList(void); static void voidUnpairedMethodList(void); static void voidYoungReferrersPostTenureAll(void); EXPORT(char *) whereIsMaybeCodeThing(sqInt anOop); +static sqInt zoneAlignment(void); static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop); static AbstractInstruction * NoDbgRegParms genCmpClassFloatCompactIndexR(sqInt reg); static AbstractInstruction * NoDbgRegParms genCmpClassMethodContextCompactIndexR(sqInt reg); @@ -921,8 +922,11 @@ static sqInt NoDbgRegParms genShiftAwaySmallIntegerTagsInScratchReg(sqInt scratc static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt NoDbgRegParms getLiteralCountOfplusOneinBytesintoscratch(sqInt methodReg, sqInt plusOne, sqInt inBytes, sqInt litCountReg, sqInt scratchReg); static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); +static sqInt log2BytesPerWord(void); static void maybeGenerateSelectorIndexDereferenceRoutine(void); static usqInt NoDbgRegParms numCountersFor(usqInt theCounters); +static sqInt numSmallIntegerBits(void); +static sqInt numSmallIntegerTagBits(void); static sqInt NoDbgRegParms validInlineCacheTag(sqInt classIndexOrTagPattern); static sqInt NoDbgRegParms branchIfinstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms branchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); @@ -1013,6 +1017,7 @@ static sqInt NoDbgRegParms mixedbranchIfinstanceOfBehaviorstarget(sqInt numNonIm static sqInt NoDbgRegParms mixedbranchIfnotInstanceOfBehaviorstarget(sqInt numNonImmediates, sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms noneImmediateBranchIfinstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); static sqInt NoDbgRegParms noneImmediateBranchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, AbstractInstruction *targetFixUp); +static sqInt numCharacterBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt objOop); extern void resetCountersIn(CogMethod *cogMethod); @@ -2659,7 +2664,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2681,6 +2685,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -4641,11 +4648,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -4653,11 +4660,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -4706,7 +4713,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4716,7 +4723,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -4921,7 +4928,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -6379,7 +6386,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) @@ -6420,19 +6427,19 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, /* begin rewriteJumpLongAt:target: */ jumpTargetAddr = (((sqInt)cPIC)) + (sizeof(CogMethod)); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + firstCPICCaseOffset, jumpTargetAddr); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); /* begin rewriteJumpLongAt:target: */ jumpTargetAddr1 = cPICMissTrampolineFor(numArgs); rewriteCallAttarget(((AbstractInstruction *) backEnd), (((sqInt)cPIC)) + cPICEndOfCodeOffset, jumpTargetAddr1); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); assert((((byteAt(pc - 6)) == 141) && (((byteAt(pc - 5)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7)))) || (((byteAt(pc - 8)) == 141) && (((byteAt(pc - 7)) | (modRMRO(((AbstractInstruction *) backEnd), 0, 0, 7))) == (modRMRO(((AbstractInstruction *) backEnd), ModRegInd, 5, 7))))); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, target); return 0; } @@ -6483,12 +6490,12 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) } if (valid) { tags[used] = ((i > 1 - ? literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */) + ? literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd))) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? 5 /* jumpLongByteSize */ - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -6502,7 +6509,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc); return 0; } for (i = 1; i < used; i += 1) { @@ -6510,7 +6517,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - 11 /* moveCwRByteSize */, pc - cPICCaseSize); return 0; } @@ -6529,7 +6536,7 @@ cPICHasForwardedClass(CogMethod *cPIC) /* start by finding the address of the topmost case, the cPICNumCases'th one */ - pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - 6 /* jumpLongConditionalByteSize */; + pc = (addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC)) - (jumpLongConditionalByteSize(backEnd)); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { classIndex = literal32BeforeFollowingAddress(backEnd, pc); if (isForwardedClassIndex(classIndex)) { @@ -6651,7 +6658,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -6849,7 +6856,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -6861,12 +6868,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); classTag = literal32BeforeFollowingAddress(backEnd, classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { errors = errors | 8; @@ -7257,12 +7264,12 @@ followMethodReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = followMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = followMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (followMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (followMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -7527,8 +7534,8 @@ generateCaptureCStackPointers(sqInt captureFramePointer) } /* begin LoadEffectiveAddressMw:r:R: */ offset = (pushedVarBaseReg - ? 8 /* leafCallStackPointerDelta */ + BytesPerWord - : 8 /* leafCallStackPointerDelta */); + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -7646,7 +7653,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -7912,6 +7919,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -7924,6 +7936,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -7992,6 +8005,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -8013,7 +8027,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 8 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -8924,12 +8940,12 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -10338,7 +10354,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (5 /* callInstructionByteSize */); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -10791,11 +10807,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); storeLiteral32beforeFollowingAddress(backEnd, newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); } @@ -10939,7 +10955,7 @@ gTstCqR(sqInt quickConstant, sqInt reg) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 12 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -11851,7 +11867,7 @@ voidCogCompiledCode(void) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; /* begin ensureExecutableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -12806,6 +12822,13 @@ whereIsMaybeCodeThing(sqInt anOop) return null; } + /* CogMethodZone>>#zoneAlignment */ +static sqInt +zoneAlignment(void) +{ + return 8; +} + /* CogObjectRepresentation>>#checkValidObjectReference: */ static sqInt NoDbgRegParms checkValidObjectReference(sqInt anOop) @@ -13033,6 +13056,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -13051,7 +13077,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -13079,11 +13107,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 61 /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -13380,9 +13412,9 @@ genPrimitiveHighBit(void) /* remove excess tag bits from the receiver oop */ - gOrCqRR(7, ReceiverResultReg, TempReg); + gOrCqRR((1U << (numSmallIntegerTagBits())) - 1, ReceiverResultReg, TempReg); /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 2; + quickConstant = (numSmallIntegerTagBits()) - 1; genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin genHighBitIn:ofSmallIntegerOopWithSingleTagBit: */ self_in_genHighBitInofSmallIntegerOopWithSingleTagBit = ((AbstractInstruction *) (backEnd())); @@ -15515,7 +15547,7 @@ genPrimitiveAtSigned(sqInt signedVersion) /* c.f. Spur64BitMemoryManager>>#isIntegerValue: */ /* begin ArithmeticShiftRightCq:R: */ - quickConstant = 61 /* numSmallIntegerBits */; + quickConstant = numSmallIntegerBits(); genoperandoperand(ArithmeticShiftRightCqR, quickConstant, TempReg); /* begin checkQuickConstant:forInstruction: */ anInstruction = genoperandoperand(AndCqR, 15, TempReg); @@ -15542,7 +15574,7 @@ genPrimitiveAtSigned(sqInt signedVersion) } else { /* begin LogicalShiftRightCq:R: */ - quickConstant1 = 60; + quickConstant1 = (numSmallIntegerBits()) - 1; genoperandoperand(LogicalShiftRightCqR, quickConstant1, TempReg); if (!(setsConditionCodesFor(lastOpcode(), JumpZero))) { /* begin checkQuickConstant:forInstruction: */ @@ -15988,7 +16020,7 @@ genPrimitiveNewWithArg(void) jumpNElementsNonInt = genJumpNotSmallInteger(Arg0Reg); genLoadSlotsourceRegdestReg(InstanceSpecificationIndex, ReceiverResultReg, instSpecReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = (fixedFieldsFieldWidth()) + 3 /* numSmallIntegerTagBits */; + quickConstant = (fixedFieldsFieldWidth()) + (numSmallIntegerTagBits()); genoperandoperand(LogicalShiftRightCqR, quickConstant, instSpecReg); /* begin checkQuickConstant:forInstruction: */ formatMask(); @@ -16470,7 +16502,7 @@ genPrimitiveStringAtPut(void) /* begin JumpAboveOrEqual: */ jumpIsShorts = genConditionalBranchoperand(JumpAboveOrEqual, ((sqInt)0)); /* begin CmpCq:R: */ - quickConstant = characterObjectOf(0x3FFFFFFF); + quickConstant = characterObjectOf((1U << (numCharacterBits())) - 1); /* begin checkQuickConstant:forInstruction: */ anInstruction5 = genoperandoperand(CmpCqR, quickConstant, Arg1Reg); /* begin JumpAbove: */ @@ -16921,6 +16953,13 @@ inlineCacheTagForInstance(sqInt oop) : classIndexOf(oop)); } + /* CogObjectRepresentationFor64BitSpur>>#log2BytesPerWord */ +static sqInt +log2BytesPerWord(void) +{ + return 3; +} + /* Generate the routine that converts selector indices into selector objects. It is called from the send trampolines. @@ -16967,8 +17006,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) /* begin JumpZero: */ jumpNotBlock = genConditionalBranchoperand(JumpZero, ((sqInt)0)); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction6 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction6 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin bitAndByteOffsetOfIsFullBlockBitInto: */ byteOffset = BaseHeaderSize + 1; /* begin checkQuickConstant:forInstruction: */ @@ -16984,8 +17023,8 @@ maybeGenerateSelectorIndexDereferenceRoutine(void) jmpTarget(jumpNotBlock, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); jmpTarget(jumpFullBlock, ((AbstractInstruction *) (((jumpNotBlock->operands))[0]))); /* begin checkQuickConstant:forInstruction: */ - -8 /* zoneAlignment */; - anInstruction8 = genoperandoperand(AndCqR, -8 /* zoneAlignment */, Extra0Reg); + -(zoneAlignment()); + anInstruction8 = genoperandoperand(AndCqR, -(zoneAlignment()), Extra0Reg); /* begin MoveMw:r:R: */ offset = offsetof(CogMethod, methodObject); /* begin checkQuickConstant:forInstruction: */ @@ -17029,6 +17068,20 @@ numCountersFor(usqInt theCounters) return 2 * (numSlotsOf(objOop)); } + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 61; +} + + /* CogObjectRepresentationFor64BitSpur>>#numSmallIntegerTagBits */ +static sqInt +numSmallIntegerTagBits(void) +{ + return 3; +} + /* The three valid tag patterns are 1 (SmallInteger), 2 (Character) and 3 (SmallFloat64). @@ -17713,7 +17766,7 @@ genGetActiveContextLargeinBlock(sqInt isLarge, sqInt isInBlock) anInstruction24 = genoperandoperandoperand(MoveRMwr, ReceiverResultReg, FoxThisContext, FPReg); gSubRRR(SPReg, FPReg, TempReg); /* begin LogicalShiftRightCq:R: */ - quickConstant = 3 /* log2BytesPerWord */; + quickConstant = log2BytesPerWord(); genoperandoperand(LogicalShiftRightCqR, quickConstant, TempReg); /* begin SubCq:R: */ quickConstant1 = 4; @@ -19890,9 +19943,12 @@ static AbstractInstruction * NoDbgRegParms jumpNotCharacterUnsignedValueInRegister(sqInt reg) { AbstractInstruction *anInstruction; + sqInt quickConstant; /* begin CmpCq:R: */ - anInstruction = genoperandoperand(CmpCqR, 0x3FFFFFFF, reg); + quickConstant = (1U << (numCharacterBits())) - 1; + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(CmpCqR, quickConstant, reg); /* begin JumpAbove: */ return genConditionalBranchoperand(JumpAbove, ((sqInt)0)); } @@ -20295,6 +20351,13 @@ noneImmediateBranchIfnotInstanceOfBehaviorstarget(sqInt reg, sqInt arrayObj, Abs return 0; } + /* CogObjectRepresentationForSpur>>#numCharacterBits */ +static sqInt +numCharacterBits(void) +{ + return 30; +} + /* CogObjectRepresentationForSpur>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) @@ -33781,7 +33844,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; assertValidDualZone(); detectFeatures(backEnd); /* begin maybeGenerateCacheFlush */ @@ -33849,7 +33912,7 @@ initializeCodeZoneFromupTo(sqInt startAddress, sqInt endAddress) methodBytesFreedSinceLastCompaction = 0; methodCount = 0; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; generateOpenPICPrototype(); } @@ -34627,7 +34690,7 @@ populatewithPICInfoForfirstCacheTag(sqInt tuple, CogMethod *cPIC, sqInt firstCac pc = addressOfEndOfCaseinCPIC(i, cPIC); cacheTag = (i == 1 ? firstCacheTag - : literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + : literalBeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); classOop = classForInlineCacheTag(cacheTag); storePointerofObjectwithValue((i * 2) - 1, tuple, classOop); if (i == 1) { @@ -34667,7 +34730,7 @@ setCogCodeZoneThreshold(double ratio) } thresholdRatio = ratio; /* begin computeAllocationThreshold */ - allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + (7)) & ~7)) + baseAddress; + allocationThreshold = ((((((usqInt)((limitAddress - baseAddress) * thresholdRatio))) + ((zoneAlignment()) - 1)) & ~7)) + baseAddress; return 0; } diff --git a/src/spur64.sista/cointerp.c b/src/spur64.sista/cointerp.c index e24b8f2590..64fc156b84 100644 --- a/src/spur64.sista/cointerp.c +++ b/src/spur64.sista/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2631,7 +2631,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -18536,7 +18536,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -19216,7 +19216,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -22985,11 +23000,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -63043,7 +63064,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -63073,7 +63094,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -63624,7 +63645,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/spur64.sista/cointerp.h b/src/spur64.sista/cointerp.h index f8ad1a2529..84a1d9c2e8 100644 --- a/src/spur64.sista/cointerp.h +++ b/src/spur64.sista/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ diff --git a/src/spur64.sista/gcc3x-cointerp.c b/src/spur64.sista/gcc3x-cointerp.c index 58f15494f6..f04744c86e 100644 --- a/src/spur64.sista/gcc3x-cointerp.c +++ b/src/spur64.sista/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2634,7 +2634,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[Spur] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; int displayWidth; int displayDepth; @@ -18545,7 +18545,7 @@ checkForAndFollowForwardedPrimitiveState(void) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -19225,7 +19225,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -22994,11 +23009,17 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((addressCouldBeObj((cogMethod->methodObject))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + if (addressCouldBeObj((cogMethod->methodObject))) { + if ((cogMethod->cpicHasMNUCaseOrCMIsFullBlock)) { + print(" [full]"); + } + else { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -63052,7 +63073,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) assert((ReceiverIndex + ((sp >> 3))) < (lengthOf(obj))); contextSize = (sp >> 3); l6: /* end fetchStackPointerOf: */; - numPointerSlots = ((usqInt) (CtxtTempFrameStart + contextSize)); + numPointerSlots = CtxtTempFrameStart + contextSize; goto l10; } /* begin numSlotsOf: */ @@ -63082,7 +63103,7 @@ updatePointersInsavedFirstFieldPointer(sqInt obj, sqInt firstFieldPtr) /* begin literalCountOfMethodHeader: */ assert((((header) & 7) == 1)); numLiterals = ((header >> 3)) & AlternateHeaderNumLiteralsMask; - numPointerSlots = ((usqInt) (numLiterals + LiteralStart)); + numPointerSlots = numLiterals + LiteralStart; l10: /* end numPointerSlotsWhileCompactingOf:withFormat:savedFirstFieldPointer: */; if ((fmt <= 5 /* lastPointerFormat */) && (numPointerSlots > 0)) { @@ -63633,7 +63654,7 @@ prepareForSnapshot(void) sqInt limit; sqInt newEndOfMemory; sqInt next; - usqInt node; + sqInt node; SpurSegmentInfo *seg; sqInt smallChild; sqInt treeNode; diff --git a/src/v3.cog/cogit.h b/src/v3.cog/cogit.h index e882bacdac..d470456c66 100644 --- a/src/v3.cog/cogit.h +++ b/src/v3.cog/cogit.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ @@ -112,7 +112,9 @@ extern sqInt ceReturnToInterpreterTrampoline; #if COGMTVM extern usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) extern sqInt cFramePointerInUse; +#endif extern sqInt cmEntryOffset; extern sqInt cmNoCheckEntryOffset; extern usqInt methodZoneBase; diff --git a/src/v3.cog/cogitARMv5.c b/src/v3.cog/cogitARMv5.c index 95623c9d57..7ab4d9e2d9 100644 --- a/src/v3.cog/cogitARMv5.c +++ b/src/v3.cog/cogitARMv5.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -895,6 +895,8 @@ static sqInt NoDbgRegParms genSmallIntegerComparison(sqInt jumpOpcode); static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt getActiveContextAllocatesInMachineCode(void); static sqInt NoDbgRegParms isUnannotatableConstant(CogSimStackEntry *simStackEntry); +static sqInt NoDbgRegParms maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst); +static sqInt NoDbgRegParms maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg); static sqInt NoDbgRegParms cacheTagIsMarked(sqInt cacheTag); static sqInt NoDbgRegParms checkValidOopReference(sqInt anOop); static sqInt NoDbgRegParms classForInlineCacheTag(sqInt inlineCacheTag); @@ -939,6 +941,7 @@ static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); static sqInt NoDbgRegParms inlineCacheTagIsYoung(sqInt cacheTag); static void NoDbgRegParms markAndTraceLiteralIfYoung(sqInt literal); static void NoDbgRegParms markAndTraceLiteral(sqInt literal); +static sqInt numSmallIntegerBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt oop); static sqInt NoDbgRegParms shouldAnnotateObjectReference(sqInt anOop); @@ -2169,7 +2172,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2191,6 +2193,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -6679,8 +6684,7 @@ jumpLongByteSize(AbstractInstruction * self_in_jumpLongByteSize) static sqInt NoDbgRegParms jumpLongConditionalByteSize(AbstractInstruction * self_in_jumpLongConditionalByteSize) { - /* begin jumpLongByteSize */ - return 4; + return jumpLongByteSize(self_in_jumpLongConditionalByteSize); } @@ -6874,7 +6878,7 @@ loadPICLiteralByteSize(AbstractInstruction * self_in_loadPICLiteralByteSize) static sqInt NoDbgRegParms machineCodeWords(AbstractInstruction * self_in_machineCodeWords) { - return 8 /* machineCodeBytes */ / 4; + return (machineCodeBytes(self_in_machineCodeWords)) / 4; } @@ -7736,7 +7740,7 @@ blockDispatchTargetsForperformarg(CogMethod *cogMethod, usqInt (*binaryFunction) } } } - pc += 4 /* instructionSizeAt: */; + pc += instructionSizeAt(backEnd, pc); } return 0; } @@ -8530,11 +8534,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 4 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -8546,11 +8550,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex((pc - (jumpLongConditionalByteSize(backEnd))) - 4 /* loadLiteralByteSize */); + printHex((pc - (jumpLongConditionalByteSize(backEnd))) - (loadLiteralByteSize(backEnd))); cr(); ok = 0; } - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); @@ -8603,7 +8607,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -8618,7 +8622,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } } - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -8824,7 +8828,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); @@ -9685,10 +9689,10 @@ compileCallFornumArgsargargargargresultRegregsToSave(void *aRoutine, sqInt numAr regMaskCopy = ((regMaskCopy) >> 1); } if ((numRegsPushed == 0) - && (4 /* numIntRegArgs */ >= numArgs)) { + && ((numIntRegArgs(((AbstractInstruction *) backEnd))) >= numArgs)) { goto l4; } - wordsPushedModAlignment = (numRegsPushed + ((((numArgs - 4 /* numIntRegArgs */) < 0) ? 0 : (numArgs - 4 /* numIntRegArgs */)))) % (cStackAlignment / BytesPerWord); + wordsPushedModAlignment = (numRegsPushed + ((((numArgs - (numIntRegArgs(((AbstractInstruction *) backEnd)))) < 0) ? 0 : (numArgs - (numIntRegArgs(((AbstractInstruction *) backEnd))))))) % (cStackAlignment / BytesPerWord); if (wordsPushedModAlignment != 0) { delta = (cStackAlignment / BytesPerWord) - wordsPushedModAlignment; /* begin checkQuickConstant:forInstruction: */ @@ -10069,7 +10073,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod rewriteCPICCaseAttagobjReftarget(caseEndAddress, case1Tag, operand, ((sqInt)((isMNUCase ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); - relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */, addrDelta); + relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)), addrDelta); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); return 0; } @@ -10100,13 +10104,13 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, ? 0 : methodOperand); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + firstCPICCaseOffset, (((sqInt)cPIC)) + (sizeof(CogMethod))); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); - relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 4 /* jumpLongByteSize */, addrDelta); + relocateMethodReferenceBeforeAddressby(backEnd, ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)), addrDelta); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPICJumpAt:target: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, target); return 0; } @@ -10167,8 +10171,8 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 4 - : (jumpLongConditionalByteSize(backEnd)) + 8 /* cmpC32RTempByteSize */)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -10182,7 +10186,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump, pc); return 0; } @@ -10191,7 +10195,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - 4 /* jumpLongByteSize */) - 4 /* loadLiteralByteSize */; + addressFollowingJump1 = (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)); rewriteTransferAttarget(((AbstractInstruction *) backEnd), addressFollowingJump1, pc - cPICCaseSize); return 0; } @@ -10481,7 +10485,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 4 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -10493,7 +10497,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; @@ -11091,7 +11095,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 4 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -11312,6 +11316,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -11324,6 +11333,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -12353,7 +12363,7 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 4 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); @@ -12361,7 +12371,7 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) if (remapMaybeObjRefInClosedPICAt(pc - (jumpLongConditionalByteSize(backEnd)))) { refersToYoung = 1; } - if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -13707,7 +13717,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (8); + return (interpretOffset()) - ((pushLinkRegisterByteSize(backEnd)) + (callInstructionByteSize(backEnd))); } /* Cogit>>#printCogMethodFor: */ @@ -13913,7 +13923,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } } assert(((cPIC->cPICNumCases)) > 0); - relocateMethodReferenceBeforeAddressby(backEnd, (addressOfEndOfCaseinCPIC(2, cPIC)) + 4 /* loadPICLiteralByteSize */, refDelta); + relocateMethodReferenceBeforeAddressby(backEnd, (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)), refDelta); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); } @@ -14113,7 +14123,7 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - 8 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ @@ -14244,7 +14254,7 @@ subsequentPrototypeMethodOop(void) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 8 /* callFullInstructionByteSize */) + (/* begin pushLinkRegisterByteSize */ 4); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (pushLinkRegisterByteSize(backEnd)); } @@ -15908,8 +15918,7 @@ genDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction *(*p genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); genConvertSmallIntegerToIntegerInReg(ClassReg); /* begin ConvertR:Rd: */ genoperandoperand(ConvertRRd, ClassReg, DPFPReg1); @@ -15999,8 +16008,7 @@ genDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGenera genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); genConvertSmallIntegerToIntegerInReg(Arg0Reg); /* begin ConvertR:Rd: */ genoperandoperand(ConvertRRd, Arg0Reg, DPFPReg1); @@ -16210,6 +16218,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -16231,9 +16242,11 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); if (usesOutOfLineLiteral(anInstruction1)) { - (anInstruction1->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction1->dependent = locateLiteral(quickConstant)); } /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); @@ -16262,16 +16275,20 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); if (usesOutOfLineLiteral(anInstruction2)) { - (anInstruction2->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction2->dependent = locateLiteral(quickConstant1)); } /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); if (usesOutOfLineLiteral(anInstruction3)) { - (anInstruction3->dependent = locateLiteral(0x1F /* numSmallIntegerBits */)); + (anInstruction3->dependent = locateLiteral(quickConstant2)); } jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); @@ -17086,8 +17103,7 @@ genPureDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jmpTarget(jumpFailAlloc, jmpTarget(jumpFailClass, genoperandoperand(Label, (labelCounter += 1), bytecodePC))); if (!(preOpCheckOrNil == null)) { jmpTarget(jumpFailCheck, ((AbstractInstruction *) (((jumpFailClass->operands))[0]))); @@ -17175,8 +17191,7 @@ genPureDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGe genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jmpTarget(jumpFail, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); return CompletePrimitive; } @@ -17353,6 +17368,31 @@ isUnannotatableConstant(CogSimStackEntry *simStackEntry) } +/* If the receiver supports immediate floats then generate a test for a + smallFloat in oopReg, + converting it to the float value in dpReg and jumping to targetInst. + Otherwise do nothing. */ + + /* CogObjectRepresentation>>#maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ +static sqInt NoDbgRegParms +maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst) +{ + return 0; +} + + +/* If required, generate a shift of the register containing the class tag in + a method cache probe. + By default this is a no-op. Subclasses redefine as required. */ + + /* CogObjectRepresentation>>#maybeShiftClassTagRegisterForMethodCacheProbe: */ +static sqInt NoDbgRegParms +maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg) +{ + return 0; +} + + /* Answer if the cacheTag is not unmarked, i.e. answer true for compact class indices and immediates; only answer false for unmarked objects */ @@ -19047,6 +19087,13 @@ markAndTraceLiteral(sqInt literal) } } + /* CogObjectRepresentationForSqueakV3>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 0x1F; +} + /* CogObjectRepresentationForSqueakV3>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) @@ -20357,7 +20404,7 @@ compileOpenPICMethodCacheProbeForwithShiftbaseRegOrNone(sqInt selector, sqInt sh /* begin MoveR:R: */ genoperandoperand(MoveRR, SendNumArgsReg, ClassReg); - /* begin maybeShiftClassTagRegisterForMethodCacheProbe: */ + maybeShiftClassTagRegisterForMethodCacheProbe(ClassReg); annotateobjRef(gXorCwR(selector, ClassReg), selector); assert(shift <= (shiftForWord())); if (shift < (shiftForWord())) { @@ -20493,7 +20540,7 @@ compilePerformMethodCacheProbeForwithShiftbaseRegOrNone(sqInt selectorReg, sqInt /* begin MoveR:R: */ genoperandoperand(MoveRR, SendNumArgsReg, ClassReg); - /* begin maybeShiftClassTagRegisterForMethodCacheProbe: */ + maybeShiftClassTagRegisterForMethodCacheProbe(ClassReg); /* begin XorR:R: */ genoperandoperand(XorRR, selectorReg, ClassReg); assert(shift <= (shiftForWord())); diff --git a/src/v3.cog/cogitIA32.c b/src/v3.cog/cogitIA32.c index 227379ccd6..97f002533b 100644 --- a/src/v3.cog/cogitIA32.c +++ b/src/v3.cog/cogitIA32.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGenerator VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGenerator VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "StackToRegisterMappingCogit VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__cogitBuildInfo = __buildInfo; @@ -482,6 +482,7 @@ static sqInt NoDbgRegParms hasVarBaseRegister(AbstractInstruction * self_in_hasV static void NoDbgRegParms initializeSharableLiteral(AbstractInstruction * self_in_initializeSharableLiteral, sqInt literal); static void NoDbgRegParms initializeUniqueLiteral(AbstractInstruction * self_in_initializeUniqueLiteral, sqInt literal); static sqInt NoDbgRegParms isJump(AbstractInstruction * self_in_isJump); +static sqInt NoDbgRegParms literal32BeforeFollowingAddress(AbstractInstruction * self_in_literal32BeforeFollowingAddress, sqInt followingAddress); static void NoDbgRegParms relocateJumpLongBeforeFollowingAddressby(AbstractInstruction * self_in_relocateJumpLongBeforeFollowingAddressby, sqInt pc, sqInt delta); static void NoDbgRegParms relocateJumpLongConditionalBeforeFollowingAddressby(AbstractInstruction * self_in_relocateJumpLongConditionalBeforeFollowingAddressby, sqInt pc, sqInt delta); static void NoDbgRegParms resolveJumpTarget(AbstractInstruction * self_in_resolveJumpTarget); @@ -877,6 +878,8 @@ static sqInt NoDbgRegParms genSmallIntegerComparison(sqInt jumpOpcode); static sqInt NoDbgRegParms genSmallIntegerComparisonorDoubleComparisoninvert(sqInt jumpOpcode, AbstractInstruction * NoDbgRegParms (*jumpFPOpcodeGenerator)(void *), sqInt invertComparison); static sqInt getActiveContextAllocatesInMachineCode(void); static sqInt NoDbgRegParms isUnannotatableConstant(CogSimStackEntry *simStackEntry); +static sqInt NoDbgRegParms maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst); +static sqInt NoDbgRegParms maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg); static sqInt NoDbgRegParms cacheTagIsMarked(sqInt cacheTag); static sqInt NoDbgRegParms checkValidOopReference(sqInt anOop); static sqInt NoDbgRegParms classForInlineCacheTag(sqInt inlineCacheTag); @@ -921,6 +924,7 @@ static sqInt NoDbgRegParms inlineCacheTagForInstance(sqInt oop); static sqInt NoDbgRegParms inlineCacheTagIsYoung(sqInt cacheTag); static void NoDbgRegParms markAndTraceLiteralIfYoung(sqInt literal); static void NoDbgRegParms markAndTraceLiteral(sqInt literal); +static sqInt numSmallIntegerBits(void); static sqInt NoDbgRegParms remapObject(sqInt objOop); static sqInt NoDbgRegParms remapOop(sqInt oop); static sqInt NoDbgRegParms shouldAnnotateObjectReference(sqInt anOop); @@ -2123,7 +2127,6 @@ sqInt ceBaseFrameReturnTrampoline; sqInt ceCannotResumeTrampoline; sqInt ceCheckForInterruptTrampoline; sqInt ceReturnToInterpreterTrampoline; -sqInt cFramePointerInUse; sqInt cmEntryOffset; sqInt cmNoCheckEntryOffset; usqInt methodZoneBase; @@ -2145,6 +2148,9 @@ void (*ceInvokeInterpret)(void); #if COGMTVM usqIntptr_t (*ceTryLockVMOwner)(usqIntptr_t); #endif +#if !defined(cFramePointerInUse) +sqInt cFramePointerInUse; +#endif void (*realCECallCogCodePopReceiverAndClassRegs)(void); void (*realCECallCogCodePopReceiverArg0Regs)(void); void (*realCECallCogCodePopReceiverArg1Arg0Regs)(void); @@ -2565,6 +2571,18 @@ isJump(AbstractInstruction * self_in_isJump) } +/* Answer the constant loaded by the instruction sequence just before this + address: + */ + + /* CogAbstractInstruction>>#literal32BeforeFollowingAddress: */ +static sqInt NoDbgRegParms +literal32BeforeFollowingAddress(AbstractInstruction * self_in_literal32BeforeFollowingAddress, sqInt followingAddress) +{ + return literalBeforeFollowingAddress(self_in_literal32BeforeFollowingAddress, followingAddress); +} + + /* We assume here that calls and jumps look the same as regards their displacement. This works on at least x86, ARM and x86_64. Processors on which that isn't the @@ -6699,8 +6717,7 @@ loadLiteralByteSize(AbstractInstruction * self_in_loadLiteralByteSize) static sqInt NoDbgRegParms loadPICLiteralByteSize(AbstractInstruction * self_in_loadPICLiteralByteSize) { - /* begin loadLiteralByteSize */ - return 5; + return loadLiteralByteSize(self_in_loadPICLiteralByteSize); } /* CogIA32Compiler>>#machineCodeAt: */ @@ -8200,11 +8217,11 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* first we check the obj ref at the beginning of the CPIC */ pc = (((sqInt)cPIC)) + firstCPICCaseOffset; - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 5 /* jumpLongByteSize */); + printHex(pc - (jumpLongByteSize(backEnd))); cr(); ok = 0; } @@ -8212,19 +8229,19 @@ checkValidObjectReferencesInClosedPIC(CogMethod *cPIC) /* For each case we check any object reference at the end address - sizeof(conditional instruction) and then increment the end address by case size */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* loadLiteralByteSize */); + printHex((pc - (jumpLongConditionalByteSize(backEnd))) - (loadLiteralByteSize(backEnd))); cr(); ok = 0; } - if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (!(checkMaybeObjRefInClosedPIC(literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { print("object leak in CPIC "); printHex(((sqInt)cPIC)); print(" @ "); - printHex(pc - 6 /* jumpLongConditionalByteSize */); + printHex(pc - (jumpLongConditionalByteSize(backEnd))); cr(); ok = 0; } @@ -8273,7 +8290,7 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) return 1; } pc = addressOfEndOfCaseinCPIC(1, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -8283,12 +8300,12 @@ closedPICRefersToUnmarkedObject(CogMethod *cPIC) } for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { pc = addressOfEndOfCaseinCPIC(i, cPIC); - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)))) { + if (couldBeObject((object = literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } } - if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)))) { + if (couldBeObject((object = literalBeforeFollowingAddress(backEnd, (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))))) { if (!(isMarked(object))) { return 1; } @@ -8493,7 +8510,7 @@ cogExtendPICCaseNMethodtagisMNUCase(CogMethod *cPIC, sqInt caseNMethod, sqInt ca address = addressOfEndOfCaseinCPIC(((cPIC->cPICNumCases)) + 1, cPIC); rewriteCPICCaseAttagobjReftarget(address, caseNTag, operand, target); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, address - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), address - cPICCaseSize); ((((CogMethod *) ((((usqInt)cPIC)) + codeToDataDelta)))->cPICNumCases = ((cPIC->cPICNumCases)) + 1); flushICacheFromto(backEnd, ((usqInt)cPIC), (((usqInt)cPIC)) + closedPICSize); /* begin assertValidDualZoneFrom:to: */ @@ -9750,7 +9767,7 @@ configureCPICCase0Case1MethodtagisMNUCasenumArgsdelta(CogMethod *cPIC, CogMethod ? (((sqInt)cPIC)) + (sizeof(CogMethod)) : targetEntry)))); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc, addrDelta); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); return 0; @@ -9782,14 +9799,14 @@ configureMNUCPICmethodOperandnumArgsdelta(CogMethod *cPIC, sqInt methodOperand, ? 0 : methodOperand); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + firstCPICCaseOffset, (((sqInt)cPIC)) + (sizeof(CogMethod))); - storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, operand, ((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))); rewriteJumpLongAttarget(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, cPICMissTrampolineFor(numArgs)); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - 5 /* jumpLongByteSize */; + pc = ((((sqInt)cPIC)) + cPICEndOfCodeOffset) - (jumpLongByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc, addrDelta); /* begin rewriteCPIC:caseJumpTo: */ target = addressOfEndOfCaseinCPIC(2, cPIC); - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, target); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), target); return 0; } @@ -9842,13 +9859,13 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (valid) { tags[used] = ((i > 1 ? (/* begin literal32BeforeFollowingAddress: */ - (followingAddress = pc - 6 /* jumpLongConditionalByteSize */), + (followingAddress = pc - (jumpLongConditionalByteSize(backEnd))), literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), followingAddress)) : 0)); targets[used] = entryPoint; methods[used] = (literalBeforeFollowingAddress(backEnd, pc - ((i == 1 - ? /* begin jumpLongByteSize */ 5 - : 11)))); + ? jumpLongByteSize(backEnd) + : (jumpLongConditionalByteSize(backEnd)) + (cmpC32RTempByteSize(backEnd)))))); used += 1; } } @@ -9862,7 +9879,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) if (used == 1) { pc = addressOfEndOfCaseinCPIC(2, cPIC); /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, pc); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), pc); return 0; } for (i = 1; i < used; i += 1) { @@ -9870,7 +9887,7 @@ cPICCompactAndIsNowEmpty(CogMethod *cPIC) rewriteCPICCaseAttagobjReftarget(pc, tags[i], methods[i], targets[i]); } /* begin rewriteCPIC:caseJumpTo: */ - rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - 5 /* jumpLongByteSize */) - 5 /* loadLiteralByteSize */, pc - cPICCaseSize); + rewriteCPICJumpAttarget(backEnd, (((((sqInt)cPIC)) + firstCPICCaseOffset) - (jumpLongByteSize(backEnd))) - (loadLiteralByteSize(backEnd)), pc - cPICCaseSize); return 0; } @@ -9985,7 +10002,7 @@ createCPICData(CogMethod *cPIC) entryPoint = jumpLongTargetBeforeFollowingAddress(backEnd, pc); } else { - class = classForInlineCacheTag(literalBeforeFollowingAddress(backEnd, pc - 6 /* jumpLongConditionalByteSize */)); + class = classForInlineCacheTag(literal32BeforeFollowingAddress(backEnd, pc - (jumpLongConditionalByteSize(backEnd)))); /* begin jumpLongConditionalTargetBeforeFollowingAddress: */ entryPoint = jumpLongTargetBeforeFollowingAddress(((AbstractInstruction *) backEnd), pc); } @@ -10160,7 +10177,7 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* First jump is unconditional; subsequent ones are conditional */ pc = (((usqInt)cPIC)) + firstCPICCaseOffset; - object = literalBeforeFollowingAddress(backEnd, pc - 5 /* jumpLongByteSize */); + object = literalBeforeFollowingAddress(backEnd, pc - (jumpLongByteSize(backEnd))); if (!(asserta(object == (firstPrototypeMethodOop())))) { errors = 1; } @@ -10172,12 +10189,12 @@ expectedClosedPICPrototype(CogMethod *cPIC) /* verify information in case is as expected. */ pc += cPICCaseSize; - methodObjPC = (pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); object = literalBeforeFollowingAddress(backEnd, methodObjPC); if (!(asserta(object == ((subsequentPrototypeMethodOop()) + i)))) { errors = errors | 4; } - classTagPC = pc - 6 /* jumpLongConditionalByteSize */; + classTagPC = pc - (jumpLongConditionalByteSize(backEnd)); /* begin literal32BeforeFollowingAddress: */ classTag = literalBeforeFollowingAddress(((AbstractInstruction *) backEnd), classTagPC); if (!(asserta(classTag == (3133021973U + i)))) { @@ -10589,13 +10606,9 @@ generateCaptureCStackPointers(sqInt captureFramePointer) anInstruction1 = genoperandoperand(MoveRAw, FPReg, cFramePointerAddress()); } /* begin LoadEffectiveAddressMw:r:R: */ - if (pushedVarBaseReg) { - offset = 4 /* leafCallStackPointerDelta */ + BytesPerWord; - } - else { - /* begin leafCallStackPointerDelta */ - offset = 4; - } + offset = (pushedVarBaseReg + ? (leafCallStackPointerDelta(backEnd)) + BytesPerWord + : leafCallStackPointerDelta(backEnd)); /* begin checkQuickConstant:forInstruction: */ anInstruction2 = genoperandoperandoperand(LoadEffectiveAddressMwrR, offset, NativeSPReg, TempReg); /* begin checkLiteral:forInstruction: */ @@ -10704,7 +10717,7 @@ generateClosedPICPrototype(void) closedPICSize = roundUpToMethodAlignment(backEnd(), closedPICSize); assert(((picInterpretAbort->address)) == (((methodLabel->address)) + (picInterpretAbortOffset()))); assert((expectedClosedPICPrototype(cPIC)) == 0); - storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - 5 /* jumpLongByteSize */); + storeLiteralbeforeFollowingAddress(backEnd, 0, ((endCPICCase0->address)) - (jumpLongByteSize(backEnd))); methodZoneBase = alignUptoRoutineBoundary(endAddress); cPICPrototype = cPIC; } @@ -10923,6 +10936,11 @@ generateStackPointerCapture(void) sqInt oldTrampolineTableIndex; +# if defined(cFramePointerInUse) + assertCStackWellAligned(); + generateCaptureCStackPointers(cFramePointerInUse); +# else + /* For the benefit of the following assert, assume the minimum at first. */ cFramePointerInUse = 0; assertCStackWellAligned(); @@ -10935,6 +10953,7 @@ generateStackPointerCapture(void) trampolineTableIndex = oldTrampolineTableIndex; generateCaptureCStackPointers(0); } +# endif // defined(cFramePointerInUse) /* begin ensureWritableCodeZone */ # if !DUAL_MAPPED_CODE_ZONE @@ -11001,6 +11020,7 @@ genGetLeafCallStackPointers(void) AbstractInstruction *anInstruction; sqInt fixupSize; sqInt opcodeSize; + sqInt quickConstant; usqInt startAddress; /* begin allocateOpcodes:bytecodes: */ @@ -11022,7 +11042,9 @@ genGetLeafCallStackPointers(void) zeroOpcodeIndex(); genoperandoperand(MoveRR, NativeSPReg, ABIResultReg); /* begin AddCq:R: */ - anInstruction = genoperandoperand(AddCqR, 4 /* leafCallStackPointerDelta */, ABIResultReg); + quickConstant = leafCallStackPointerDelta(backEnd); + /* begin checkQuickConstant:forInstruction: */ + anInstruction = genoperandoperand(AddCqR, quickConstant, ABIResultReg); genoperand(RetN, 0); outputInstructionsForGeneratedRuntimeAt(startAddress); recordGeneratedRunTimeaddress("ceGetSP", startAddress); @@ -11885,15 +11907,15 @@ mapObjectReferencesInClosedPIC(CogMethod *cPIC) pc = addressOfEndOfCaseinCPIC(1, cPIC); /* We find the end address of the cPICNumCases'th case and can then just step forward by the case size thereafter */ - refersToYoung = remapMaybeObjRefInClosedPICAt(pc - 5 /* jumpLongByteSize */); + refersToYoung = remapMaybeObjRefInClosedPICAt(pc - (jumpLongByteSize(backEnd))); /* Next we check the potential class ref in the compare instruction, and the potential method oop load for each case. */ pc = addressOfEndOfCaseinCPIC((cPIC->cPICNumCases), cPIC); for (i = 2; i <= ((cPIC->cPICNumCases)); i += 1) { - if (remapMaybeObjRefInClosedPICAt(pc - 6 /* jumpLongConditionalByteSize */)) { + if (remapMaybeObjRefInClosedPICAt(pc - (jumpLongConditionalByteSize(backEnd)))) { refersToYoung = 1; } - if (remapMaybeObjRefInClosedPICAt((pc - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */)) { + if (remapMaybeObjRefInClosedPICAt((pc - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)))) { refersToYoung = 1; } pc += cPICCaseSize; @@ -13230,7 +13252,7 @@ picAbortDiscriminatorValue(void) static sqInt picInterpretAbortOffset(void) { - return (interpretOffset()) - (/* begin callInstructionByteSize */ 5); + return (interpretOffset()) - (callInstructionByteSize(backEnd)); } /* Cogit>>#printCogMethodFor: */ @@ -13444,7 +13466,7 @@ relocateCallsInClosedPIC(CogMethod *cPIC) } assert(((cPIC->cPICNumCases)) > 0); /* begin relocateMethodReferenceBeforeAddress:by: */ - pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadPICLiteralByteSize(backEnd)); + pc1 = (addressOfEndOfCaseinCPIC(2, cPIC)) + (loadLiteralByteSize(backEnd)); relocateCallBeforeReturnPCby(((AbstractInstruction *) backEnd), pc1, refDelta); relocateJumpLongBeforeFollowingAddressby(backEnd, (((sqInt)cPIC)) + cPICEndOfCodeOffset, -callDelta); } @@ -13646,11 +13668,11 @@ rewriteCPICCaseAttagobjReftarget(sqInt followingAddress, sqInt newTag, sqInt new sqInt classTagPC; sqInt methodObjPC; - methodObjPC = (followingAddress - 6 /* jumpLongConditionalByteSize */) - 5 /* cmpC32RTempByteSize */; + methodObjPC = (followingAddress - (jumpLongConditionalByteSize(backEnd))) - (cmpC32RTempByteSize(backEnd)); storeLiteralbeforeFollowingAddress(backEnd, newObjRef, methodObjPC); /* rewite the tag via the first ldr */ - classTagPC = followingAddress - 6 /* jumpLongConditionalByteSize */; + classTagPC = followingAddress - (jumpLongConditionalByteSize(backEnd)); /* begin storeLiteral32:beforeFollowingAddress: */ storeLiteralbeforeFollowingAddress(((AbstractInstruction *) backEnd), newTag, classTagPC); rewriteConditionalJumpLongAttarget(backEnd, followingAddress, newTarget); @@ -13769,7 +13791,7 @@ subsequentPrototypeMethodOop(void) sqInt traceLinkedSendOffset(void) { - return (cmNoCheckEntryOffset + 5 /* callFullInstructionByteSize */) + (0); + return (cmNoCheckEntryOffset + (callFullInstructionByteSize(backEnd))) + (0); } @@ -15413,8 +15435,7 @@ genDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction *(*p genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); genConvertSmallIntegerToIntegerInReg(ClassReg); /* begin ConvertR:Rd: */ genoperandoperand(ConvertRRd, ClassReg, DPFPReg1); @@ -15496,8 +15517,7 @@ genDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGenera genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); genConvertSmallIntegerToIntegerInReg(Arg0Reg); /* begin ConvertR:Rd: */ genoperandoperand(ConvertRRd, Arg0Reg, DPFPReg1); @@ -15703,6 +15723,9 @@ genPrimitiveBitShift(void) AbstractInstruction *jumpNotSI; AbstractInstruction *jumpOvfl; AbstractInstruction *jumpTooBig; + sqInt quickConstant; + sqInt quickConstant1; + sqInt quickConstant2; if (!(mclassIsSmallInteger())) { return UnimplementedPrimitive; @@ -15721,7 +15744,9 @@ genPrimitiveBitShift(void) /* begin JumpNegative: */ jumpNegative = genConditionalBranchoperand(JumpNegative, ((sqInt)0)); /* begin CmpCq:R: */ - anInstruction1 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction1 = genoperandoperand(CmpCqR, quickConstant, ClassReg); /* begin JumpGreaterOrEqual: */ jumpTooBig = genConditionalBranchoperand(JumpGreaterOrEqual, ((sqInt)0)); /* begin MoveR:R: */ @@ -15749,11 +15774,15 @@ genPrimitiveBitShift(void) } jmpTarget(jumpNegative, genoperand(NegateR, ClassReg)); /* begin CmpCq:R: */ - anInstruction2 = genoperandoperand(CmpCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant1 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction2 = genoperandoperand(CmpCqR, quickConstant1, ClassReg); /* begin JumpLessOrEqual: */ jumpInRange = genConditionalBranchoperand(JumpLessOrEqual, ((sqInt)0)); /* begin MoveCq:R: */ - anInstruction3 = genoperandoperand(MoveCqR, 0x1F /* numSmallIntegerBits */, ClassReg); + quickConstant2 = numSmallIntegerBits(); + /* begin checkQuickConstant:forInstruction: */ + anInstruction3 = genoperandoperand(MoveCqR, quickConstant2, ClassReg); jmpTarget(jumpInRange, genoperandoperand(ArithmeticShiftRightRR, ClassReg, ReceiverResultReg)); genClearAndSetSmallIntegerTagsIn(ReceiverResultReg); if (methodOrBlockNumArgs <= (numRegArgs())) { @@ -16550,8 +16579,7 @@ genPureDoubleArithmeticpreOpCheck(sqInt arithmeticOperator, AbstractInstruction genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, doOp); jmpTarget(jumpFailAlloc, jmpTarget(jumpFailClass, genoperandoperand(Label, (labelCounter += 1), bytecodePC))); if (!(preOpCheckOrNil == null)) { jmpTarget(jumpFailCheck, ((AbstractInstruction *) (((jumpFailClass->operands))[0]))); @@ -16631,8 +16659,7 @@ genPureDoubleComparisoninvert(AbstractInstruction * NoDbgRegParms (*jumpOpcodeGe genoperand(RetN, (methodOrBlockNumArgs + 1) * BytesPerWord); } jmpTarget(jumpImmediate, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); - - /* maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ + maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(Arg0Reg, TempReg, DPFPReg1, compare); jmpTarget(jumpFail, genoperandoperand(Label, (labelCounter += 1), bytecodePC)); return CompletePrimitive; } @@ -16795,6 +16822,31 @@ isUnannotatableConstant(CogSimStackEntry *simStackEntry) } +/* If the receiver supports immediate floats then generate a test for a + smallFloat in oopReg, + converting it to the float value in dpReg and jumping to targetInst. + Otherwise do nothing. */ + + /* CogObjectRepresentation>>#maybeGenConvertIfSmallFloatIn:scratchReg:into:andJumpTo: */ +static sqInt NoDbgRegParms +maybeGenConvertIfSmallFloatInscratchRegintoandJumpTo(sqInt oopReg, sqInt scratch, sqInt dpReg, AbstractInstruction *targetInst) +{ + return 0; +} + + +/* If required, generate a shift of the register containing the class tag in + a method cache probe. + By default this is a no-op. Subclasses redefine as required. */ + + /* CogObjectRepresentation>>#maybeShiftClassTagRegisterForMethodCacheProbe: */ +static sqInt NoDbgRegParms +maybeShiftClassTagRegisterForMethodCacheProbe(sqInt classTagReg) +{ + return 0; +} + + /* Answer if the cacheTag is not unmarked, i.e. answer true for compact class indices and immediates; only answer false for unmarked objects */ @@ -18170,6 +18222,13 @@ markAndTraceLiteral(sqInt literal) } } + /* CogObjectRepresentationForSqueakV3>>#numSmallIntegerBits */ +static sqInt +numSmallIntegerBits(void) +{ + return 0x1F; +} + /* CogObjectRepresentationForSqueakV3>>#remapObject: */ static sqInt NoDbgRegParms remapObject(sqInt objOop) @@ -18776,7 +18835,7 @@ compileOpenPICMethodCacheProbeForwithShiftbaseRegOrNone(sqInt selector, sqInt sh /* begin MoveR:R: */ genoperandoperand(MoveRR, SendNumArgsReg, ClassReg); - /* begin maybeShiftClassTagRegisterForMethodCacheProbe: */ + maybeShiftClassTagRegisterForMethodCacheProbe(ClassReg); annotateobjRef(checkLiteralforInstruction(selector, genoperandoperand(XorCwR, selector, ClassReg)), selector); assert(shift <= (shiftForWord())); if (shift < (shiftForWord())) { @@ -18891,7 +18950,7 @@ compilePerformMethodCacheProbeForwithShiftbaseRegOrNone(sqInt selectorReg, sqInt /* begin MoveR:R: */ genoperandoperand(MoveRR, SendNumArgsReg, ClassReg); - /* begin maybeShiftClassTagRegisterForMethodCacheProbe: */ + maybeShiftClassTagRegisterForMethodCacheProbe(ClassReg); /* begin XorR:R: */ genoperandoperand(XorRR, selectorReg, ClassReg); assert(shift <= (shiftForWord())); diff --git a/src/v3.cog/cointerp.c b/src/v3.cog/cointerp.c index c080bc464c..26a5fd7444 100644 --- a/src/v3.cog/cointerp.c +++ b/src/v3.cog/cointerp.c @@ -1,9 +1,9 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2218,7 +2218,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -10764,7 +10764,7 @@ checkCodeIntegrity(sqInt gcModes) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -11501,7 +11501,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -14756,14 +14771,15 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((((((cogMethod->methodObject)) & 3) == 0) + if (((((cogMethod->methodObject)) & 3) == 0) && (((((usqInt)((cogMethod->methodObject)))) >= (startOfMemory())) && (((((usqInt)((cogMethod->methodObject)))) < GIV(freeStart)) - && (((longAt((cogMethod->methodObject))) & TypeMask) != HeaderTypeGC)))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + && (((longAt((cogMethod->methodObject))) & TypeMask) != HeaderTypeGC)))) { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -32665,7 +32681,7 @@ static sqInt NoDbgRegParms eeInstantiateMethodContextSlots(sqInt numSlots) { DECL_MAYBE_SQ_GLOBAL_STRUCT usqInt hash; - sqInt header1; + usqInt header1; usqInt newChunk; usqInt newFreeStart; sqInt newObj; @@ -32802,7 +32818,7 @@ eeInstantiateSmallClassnumSlots(sqInt classPointer, sqInt numSlots) { DECL_MAYBE_SQ_GLOBAL_STRUCT usqInt hash; int hdrSize; - sqInt header1; + usqInt header1; sqInt header2; usqInt newChunk; usqInt newFreeStart; diff --git a/src/v3.cog/cointerp.h b/src/v3.cog/cointerp.h index cf39c26f5e..64baf49789 100644 --- a/src/v3.cog/cointerp.h +++ b/src/v3.cog/cointerp.h @@ -1,5 +1,5 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ diff --git a/src/v3.cog/gcc3x-cointerp.c b/src/v3.cog/gcc3x-cointerp.c index e2dfc7a543..6159486fe0 100644 --- a/src/v3.cog/gcc3x-cointerp.c +++ b/src/v3.cog/gcc3x-cointerp.c @@ -2,11 +2,11 @@ /* Automatically generated by - CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CCodeGeneratorGlobalStructure VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd from - CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 + CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd */ -static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3066 uuid: 8db97a47-7e9e-4784-8cf2-db4fc404ed95 " __DATE__ ; +static char __buildInfo[] = "CoInterpreter VMMaker.oscog-eem.3071 uuid: ae226d69-be9f-4f7a-a138-0c85163277dd " __DATE__ ; char *__interpBuildInfo = __buildInfo; @@ -2221,7 +2221,7 @@ sqInt debugCallbackInvokes; sqInt debugCallbackReturns; sqInt ffiExceptionResponse; sqInt checkedPluginName; -const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3066]"; +const char *interpreterVersion = "Open Smalltalk Cog[SqueakV3] VM [CoInterpreterPrimitives VMMaker.oscog-eem.3071]"; sqInt minBackwardJumpCountForCompile = MinBackwardJumpCountForCompile /* 40 */; char primitiveDoMixedArithmetic = 1; char expensiveAsserts = 0; @@ -10773,7 +10773,7 @@ checkCodeIntegrity(sqInt gcModes) /* Necessary because we very much want CStackPointer and CFramePointer to be static/private and grouped with other interpreter variables which will hence be accessed via - VarBaseReg on platforms trhat have one. + VarBaseReg on platforms that have one. */ /* CoInterpreter>>#checkIfCFramePointerInUse */ @@ -11510,7 +11510,22 @@ ensureContextIsExecutionSafeAfterAssignToStackPointer(sqInt aContext) level. This is the actual implementation, separated from enterSmalltalkExecutive so the simulator can wrap it in an exception handler and hence simulate the - setjmp/longjmp. */ + Cogit's jump + back into C code on interpreting; see ceInvokeInterpret. + + Conceptually, an invocation of interpret exists at each level of execution + from the + initial invocation through each callback. Entry to each execution level is + through this function. It captures the C stack & frame pointers for this + level of execution + and then either invokes machine code or interpret, depending on whether + the current frame (the effective entry-point into Smalltalk execution) is + a machine code + or interpreted frame. In addition, interpret captures the return address + of its caller + (this funciton). The Cogit then uses the captured C stack pointers and + return address to invoke interpret as if it had been called from this + function. */ /* CoInterpreter>>#enterSmalltalkExecutiveImplementation */ static sqInt @@ -14765,14 +14780,15 @@ printCogMethod(CogMethod *cogMethod) print(" prim "); printNum(primitive); } - if ((((((cogMethod->methodObject)) & 3) == 0) + if (((((cogMethod->methodObject)) & 3) == 0) && (((((usqInt)((cogMethod->methodObject)))) >= (startOfMemory())) && (((((usqInt)((cogMethod->methodObject)))) < GIV(freeStart)) - && (((longAt((cogMethod->methodObject))) & TypeMask) != HeaderTypeGC)))) - && (addressCouldBeObj(methodClassOf((cogMethod->methodObject))))) { - /* begin space */ - putchar(' '); - printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + && (((longAt((cogMethod->methodObject))) & TypeMask) != HeaderTypeGC)))) { + if (addressCouldBeObj(methodClassOf((cogMethod->methodObject)))) { + /* begin space */ + putchar(' '); + printNameOfClasscount(methodClassOf((cogMethod->methodObject)), 2); + } } } if (((cogMethod->cmType)) == CMBlock) { @@ -32674,7 +32690,7 @@ static sqInt NoDbgRegParms eeInstantiateMethodContextSlots(sqInt numSlots) { DECL_MAYBE_SQ_GLOBAL_STRUCT usqInt hash; - sqInt header1; + usqInt header1; usqInt newChunk; usqInt newFreeStart; sqInt newObj; @@ -32811,7 +32827,7 @@ eeInstantiateSmallClassnumSlots(sqInt classPointer, sqInt numSlots) { DECL_MAYBE_SQ_GLOBAL_STRUCT usqInt hash; int hdrSize; - sqInt header1; + usqInt header1; sqInt header2; usqInt newChunk; usqInt newFreeStart;