diff options
Diffstat (limited to 'src/jit/emit.cpp')
-rw-r--r-- | src/jit/emit.cpp | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/src/jit/emit.cpp b/src/jit/emit.cpp index 1e566b2e76..3b765b9db2 100644 --- a/src/jit/emit.cpp +++ b/src/jit/emit.cpp @@ -1027,7 +1027,7 @@ void emitter::emitBegFN(bool hasFramePtr emitPlaceholderList = emitPlaceholderLast = nullptr; #ifdef JIT32_GCENCODER - emitEpilogList = emitEpilogLast = NULL; + emitEpilogList = emitEpilogLast = nullptr; #endif // JIT32_GCENCODER /* We don't have any jumps */ @@ -1215,14 +1215,12 @@ size_t emitter::emitGenEpilogLst(size_t (*fp)(void*, unsigned), void* cp) EpilogList* el; size_t sz; - for (el = emitEpilogList, sz = 0; el; el = el->elNext) + for (el = emitEpilogList, sz = 0; el != nullptr; el = el->elNext) { - assert(el->elIG->igFlags & IGF_EPILOG); + assert(el->elLoc.GetIG()->igFlags & IGF_EPILOG); - UNATIVE_OFFSET ofs = - el->elIG->igOffs; // The epilog starts at the beginning of the IG, so the IG offset is correct - - sz += fp(cp, ofs); + // The epilog starts at the location recorded in the epilog list. + sz += fp(cp, el->elLoc.CodeOffset(this)); } return sz; @@ -1383,7 +1381,6 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz) id->idOpSize(EA_SIZE(opsz)); } -#if RELOC_SUPPORT // Amd64: ip-relative addressing is supported even when not generating relocatable ngen code if (EA_IS_DSP_RELOC(opsz) #ifndef _TARGET_AMD64_ @@ -1402,7 +1399,6 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz) /* instruction has an immediate constant that is relocatable */ id->idSetIsCnsReloc(); } -#endif #if EMITTER_STATS emitTotalInsCnt++; @@ -1957,22 +1953,20 @@ void emitter::emitBegFnEpilog(insGroup* igPh) #ifdef JIT32_GCENCODER - EpilogList* el = new (emitComp, CMK_GC) EpilogList; - el->elNext = NULL; - el->elIG = emitCurIG; + EpilogList* el = new (emitComp, CMK_GC) EpilogList(); - if (emitEpilogLast) + if (emitEpilogLast != nullptr) + { emitEpilogLast->elNext = el; + } else + { emitEpilogList = el; + } emitEpilogLast = el; #endif // JIT32_GCENCODER - - /* Remember current position so that we can compute total epilog size */ - - emitEpilogBegLoc.CaptureLocation(this); } /***************************************************************************** @@ -1984,22 +1978,17 @@ void emitter::emitEndFnEpilog() { emitEndPrologEpilog(); - UNATIVE_OFFSET newSize; - UNATIVE_OFFSET epilogBegCodeOffset = emitEpilogBegLoc.CodeOffset(this); -#ifdef _TARGET_XARCH_ - UNATIVE_OFFSET epilogExitSeqStartCodeOffset = emitExitSeqBegLoc.CodeOffset(this); -#else - UNATIVE_OFFSET epilogExitSeqStartCodeOffset = emitCodeOffset(emitCurIG, emitCurOffset()); -#endif - - newSize = epilogExitSeqStartCodeOffset - epilogBegCodeOffset; +#ifdef JIT32_GCENCODER + assert(emitEpilogLast != nullptr); -#ifdef _TARGET_X86_ + UNATIVE_OFFSET epilogBegCodeOffset = emitEpilogLast->elLoc.CodeOffset(this); + UNATIVE_OFFSET epilogExitSeqStartCodeOffset = emitExitSeqBegLoc.CodeOffset(this); + UNATIVE_OFFSET newSize = epilogExitSeqStartCodeOffset - epilogBegCodeOffset; /* Compute total epilog size */ - assert(emitEpilogSize == 0 || emitEpilogSize == newSize); // All epilogs must be identical - emitEpilogSize = newSize; + emitEpilogSize = newSize; + UNATIVE_OFFSET epilogEndCodeOffset = emitCodeOffset(emitCurIG, emitCurOffset()); assert(epilogExitSeqStartCodeOffset != epilogEndCodeOffset); @@ -2019,8 +2008,7 @@ void emitter::emitEndFnEpilog() ); emitExitSeqSize = newSize; } - -#endif // _TARGET_X86_ +#endif // JIT32_GCENCODER } #if FEATURE_EH_FUNCLETS @@ -2069,6 +2057,16 @@ void emitter::emitEndFuncletEpilog() #ifdef JIT32_GCENCODER +// +// emitter::emitStartEpilog: +// Mark the current position so that we can later compute the total epilog size. +// +void emitter::emitStartEpilog() +{ + assert(emitEpilogLast != nullptr); + emitEpilogLast->elLoc.CaptureLocation(this); +} + /***************************************************************************** * * Return non-zero if the current method only has one epilog, which is @@ -4233,7 +4231,7 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG) // meets one of those criteria... assert(jmp->idIsBound()); -#ifdef _TARGET_AMD64_ +#ifdef _TARGET_XARCH_ // An lea of a code address (for constant data stored with the code) // is treated like a jump for emission purposes but is not really a jump so // we don't have to check anything here. @@ -4405,6 +4403,12 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, emitFullyInt = fullyInt; emitFullGCinfo = fullPtrMap; +#ifndef UNIX_X86_ABI + emitFullArgInfo = !emitHasFramePtr; +#else + emitFullArgInfo = fullPtrMap; +#endif + #if EMITTER_STATS GCrefsTable.record(emitGCrFrameOffsCnt); emitSizeTable.record(static_cast<unsigned>(emitSizeMethod)); @@ -4419,7 +4423,10 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, #if EMIT_TRACK_STACK_DEPTH /* Convert max. stack depth from # of bytes to # of entries */ - emitMaxStackDepth /= sizeof(int); + unsigned maxStackDepthIn4ByteElements = emitMaxStackDepth / sizeof(int); + JITDUMP("Converting emitMaxStackDepth from bytes (%d) to elements (%d)\n", emitMaxStackDepth, + maxStackDepthIn4ByteElements); + emitMaxStackDepth = maxStackDepthIn4ByteElements; /* Should we use the simple stack */ @@ -4499,7 +4506,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, // if (emitComp->fgHaveProfileData()) { - if (emitComp->fgCalledWeight > (BB_VERY_HOT_WEIGHT * emitComp->fgNumProfileRuns)) + if (emitComp->fgCalledCount > (BB_VERY_HOT_WEIGHT * emitComp->fgProfileRunsCount())) { allocMemFlag = CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN; } @@ -6814,7 +6821,7 @@ void emitter::emitStackPushLargeStk(BYTE* addr, GCtype gcType, unsigned count) *u2.emitArgTrackTop++ = (BYTE)gcType; assert(u2.emitArgTrackTop <= u2.emitArgTrackTab + emitMaxStackDepth); - if (!emitHasFramePtr || needsGC(gcType)) + if (emitFullArgInfo || needsGC(gcType)) { if (emitFullGCinfo) { @@ -6886,7 +6893,7 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn // This is an "interesting" argument - if (!emitHasFramePtr || needsGC(gcType)) + if (emitFullArgInfo || needsGC(gcType)) { argRecCnt += 1; } @@ -7034,7 +7041,7 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn /* We're about to kill the corresponding (pointer) arg records */ - if (emitHasFramePtr) + if (!emitFullArgInfo) { u2.emitGcArgTrackCnt -= gcCnt.Value(); } |