summaryrefslogtreecommitdiff
path: root/src/jit/emit.cpp
diff options
context:
space:
mode:
authorPat Gavlin <pagavlin@microsoft.com>2016-08-12 15:10:30 -0700
committerPat Gavlin <pagavlin@microsoft.com>2016-08-12 16:57:26 -0700
commit0f44d3011a49d443eb8198234a6e16cdc7772d97 (patch)
treecd7be9e6789ad850c2c3ba491e11bbd86e362653 /src/jit/emit.cpp
parent99d29f3284cdc84df69e1c0a91cba72419751956 (diff)
downloadcoreclr-0f44d3011a49d443eb8198234a6e16cdc7772d97.tar.gz
coreclr-0f44d3011a49d443eb8198234a6e16cdc7772d97.tar.bz2
coreclr-0f44d3011a49d443eb8198234a6e16cdc7772d97.zip
Revert #6686.
The code was accidentally formatted with Clang 3.9. It will be reformatted with Clang 3.8 and a new PR submitted.
Diffstat (limited to 'src/jit/emit.cpp')
-rw-r--r--src/jit/emit.cpp3314
1 files changed, 1625 insertions, 1689 deletions
diff --git a/src/jit/emit.cpp b/src/jit/emit.cpp
index f4128b64b6..6111a2b290 100644
--- a/src/jit/emit.cpp
+++ b/src/jit/emit.cpp
@@ -26,7 +26,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
* Represent an emitter location.
*/
-void emitLocation::CaptureLocation(emitter* emit)
+void emitLocation::CaptureLocation(emitter* emit)
{
ig = emit->emitCurIG;
codePos = emit->emitCurOffset();
@@ -34,19 +34,20 @@ void emitLocation::CaptureLocation(emitter* emit)
assert(Valid());
}
-bool emitLocation::IsCurrentLocation(emitter* emit) const
+bool emitLocation::IsCurrentLocation(emitter* emit) const
{
assert(Valid());
- return (ig == emit->emitCurIG) && (codePos == emit->emitCurOffset());
+ return (ig == emit->emitCurIG) &&
+ (codePos == emit->emitCurOffset());
}
-UNATIVE_OFFSET emitLocation::CodeOffset(emitter* emit) const
+UNATIVE_OFFSET emitLocation::CodeOffset(emitter* emit) const
{
assert(Valid());
return emit->emitCodeOffset(ig, codePos);
}
-int emitLocation::GetInsNum() const
+int emitLocation::GetInsNum() const
{
return emitGetInsNumFromCodePos(codePos);
}
@@ -57,7 +58,7 @@ int emitLocation::GetInsNum() const
// TODO-AMD64-Bug?: We only support a single main function prolog group, but allow for multiple funclet prolog
// groups (not that we actually use that flexibility, since the funclet prolog will be small). How to
// handle that?
-UNATIVE_OFFSET emitLocation::GetFuncletPrologOffset(emitter* emit) const
+UNATIVE_OFFSET emitLocation::GetFuncletPrologOffset(emitter* emit) const
{
assert(ig->igFuncIdx != 0);
assert((ig->igFlags & IGF_FUNCLET_PROLOG) != 0);
@@ -68,7 +69,7 @@ UNATIVE_OFFSET emitLocation::GetFuncletPrologOffset(emitter* emit) const
#endif // _TARGET_AMD64_
#ifdef DEBUG
-void emitLocation::Print() const
+void emitLocation::Print() const
{
unsigned insNum = emitGetInsNumFromCodePos(codePos);
unsigned insOfs = emitGetInsOfsFromCodePos(codePos);
@@ -76,6 +77,7 @@ void emitLocation::Print() const
}
#endif // DEBUG
+
/*****************************************************************************
*
* Return the name of an instruction format.
@@ -83,65 +85,60 @@ void emitLocation::Print() const
#if defined(DEBUG) || EMITTER_STATS
-const char* emitter::emitIfName(unsigned f)
+const char * emitter::emitIfName(unsigned f)
{
- static const char* const ifNames[] = {
-#define IF_DEF(en, op1, op2) "IF_" #en,
-#include "emitfmts.h"
+ static
+ const char * const ifNames[] =
+ {
+ #define IF_DEF(en, op1, op2) "IF_" #en,
+ #include "emitfmts.h"
};
- static char errBuff[32];
+ static
+ char errBuff[32];
- if (f < sizeof(ifNames) / sizeof(*ifNames))
- {
- return ifNames[f];
- }
+ if (f < sizeof(ifNames)/sizeof(*ifNames))
+ return ifNames[f];
sprintf_s(errBuff, sizeof(errBuff), "??%u??", f);
- return errBuff;
+ return errBuff;
}
#endif
-#ifdef TRANSLATE_PDB
+
+#ifdef TRANSLATE_PDB
/* these are protected */
-AddrMap* emitter::emitPDBOffsetTable = 0;
-LocalMap* emitter::emitPDBLocalTable = 0;
-bool emitter::emitIsPDBEnabled = true;
-BYTE* emitter::emitILBaseOfCode = 0;
-BYTE* emitter::emitILMethodBase = 0;
-BYTE* emitter::emitILMethodStart = 0;
-BYTE* emitter::emitImgBaseOfCode = 0;
+AddrMap * emitter::emitPDBOffsetTable = 0;
+LocalMap * emitter::emitPDBLocalTable = 0;
+bool emitter::emitIsPDBEnabled = true;
+BYTE * emitter::emitILBaseOfCode = 0;
+BYTE * emitter::emitILMethodBase = 0;
+BYTE * emitter::emitILMethodStart = 0;
+BYTE * emitter::emitImgBaseOfCode = 0;
-void emitter::MapCode(int ilOffset, BYTE* imgDest)
+void emitter::MapCode( int ilOffset, BYTE *imgDest )
{
- if (emitIsPDBEnabled)
+ if ( emitIsPDBEnabled )
{
- emitPDBOffsetTable->MapSrcToDest(ilOffset, (int)(imgDest - emitImgBaseOfCode));
+ emitPDBOffsetTable->MapSrcToDest( ilOffset, (int)( imgDest - emitImgBaseOfCode ));
}
}
-
-void emitter::MapFunc(int imgOff,
- int procLen,
- int dbgStart,
- int dbgEnd,
- short frameReg,
- int stkAdjust,
- int lvaCount,
- OptJit::LclVarDsc* lvaTable,
- bool framePtr)
+
+void emitter::MapFunc( int imgOff, int procLen, int dbgStart, int dbgEnd, short frameReg,
+ int stkAdjust, int lvaCount, OptJit::LclVarDsc *lvaTable, bool framePtr )
{
- if (emitIsPDBEnabled)
+ if ( emitIsPDBEnabled )
{
// this code stores information about local symbols for the PDB translation
- assert(lvaCount >= 0); // don't allow a negative count
+ assert( lvaCount >=0 ); // don't allow a negative count
- LvaDesc* rgLvaDesc = 0;
+ LvaDesc *rgLvaDesc = 0;
- if (lvaCount > 0)
+ if ( lvaCount > 0 )
{
rgLvaDesc = new LvaDesc[lvaCount];
@@ -149,54 +146,62 @@ void emitter::MapFunc(int imgOff,
{
NOMEM();
}
+
- LvaDesc* pDst = rgLvaDesc;
- OptJit::LclVarDsc* pSrc = lvaTable;
- for (int i = 0; i < lvaCount; ++i, ++pDst, ++pSrc)
+ LvaDesc *pDst = rgLvaDesc;
+ OptJit::LclVarDsc *pSrc = lvaTable;
+ for ( int i = 0; i < lvaCount; ++i, ++pDst, ++pSrc )
{
pDst->slotNum = pSrc->lvSlotNum;
pDst->isReg = pSrc->lvRegister;
- pDst->reg = (pSrc->lvRegister ? pSrc->lvRegNum : frameReg);
- pDst->off = pSrc->lvStkOffs + stkAdjust;
+ pDst->reg = (pSrc->lvRegister ? pSrc->lvRegNum : frameReg );
+ pDst->off = pSrc->lvStkOffs + stkAdjust;
}
}
- emitPDBLocalTable->AddFunc((int)(emitILMethodBase - emitILBaseOfCode), imgOff - (int)emitImgBaseOfCode, procLen,
- dbgStart - imgOff, dbgEnd - imgOff, lvaCount, rgLvaDesc, framePtr);
+ emitPDBLocalTable->AddFunc( (int)(emitILMethodBase - emitILBaseOfCode),
+ imgOff - (int)emitImgBaseOfCode,
+ procLen,
+ dbgStart - imgOff,
+ dbgEnd - imgOff,
+ lvaCount,
+ rgLvaDesc,
+ framePtr );
// do not delete rgLvaDesc here -- responsibility is now on emitPDBLocalTable destructor
}
}
+
/* these are public */
-void emitter::SetILBaseOfCode(BYTE* pTextBase)
+void emitter::SetILBaseOfCode ( BYTE *pTextBase )
{
emitILBaseOfCode = pTextBase;
}
-void emitter::SetILMethodBase(BYTE* pMethodEntry)
+void emitter::SetILMethodBase ( BYTE *pMethodEntry )
{
emitILMethodBase = pMethodEntry;
}
-void emitter::SetILMethodStart(BYTE* pMethodCode)
+void emitter::SetILMethodStart( BYTE *pMethodCode )
{
emitILMethodStart = pMethodCode;
}
-void emitter::SetImgBaseOfCode(BYTE* pTextBase)
+void emitter::SetImgBaseOfCode( BYTE *pTextBase )
{
emitImgBaseOfCode = pTextBase;
}
void emitter::SetIDBaseToProlog()
{
- emitInstrDescILBase = (int)(emitILMethodBase - emitILBaseOfCode);
+ emitInstrDescILBase = (int)( emitILMethodBase - emitILBaseOfCode );
}
-void emitter::SetIDBaseToOffset(int methodOffset)
+void emitter::SetIDBaseToOffset( int methodOffset )
{
- emitInstrDescILBase = methodOffset + (int)(emitILMethodStart - emitILBaseOfCode);
+ emitInstrDescILBase = methodOffset + (int)( emitILMethodStart - emitILBaseOfCode );
}
void emitter::DisablePDBTranslation()
@@ -210,38 +215,41 @@ bool emitter::IsPDBEnabled()
return emitIsPDBEnabled;
}
-void emitter::InitTranslationMaps(int ilCodeSize)
+void emitter::InitTranslationMaps( int ilCodeSize )
{
- if (emitIsPDBEnabled)
+ if ( emitIsPDBEnabled )
{
- emitPDBOffsetTable = AddrMap::Create(ilCodeSize);
- emitPDBLocalTable = LocalMap::Create();
+ emitPDBOffsetTable = AddrMap::Create( ilCodeSize );
+ emitPDBLocalTable = LocalMap::Create();
}
}
void emitter::DeleteTranslationMaps()
{
- if (emitPDBOffsetTable)
+ if ( emitPDBOffsetTable )
{
delete emitPDBOffsetTable;
emitPDBOffsetTable = 0;
}
- if (emitPDBLocalTable)
+ if ( emitPDBLocalTable )
{
delete emitPDBLocalTable;
emitPDBLocalTable = 0;
}
}
-void emitter::InitTranslator(PDBRewriter* pPDB, int* rgSecMap, IMAGE_SECTION_HEADER** rgpHeader, int numSections)
+void emitter::InitTranslator( PDBRewriter * pPDB,
+ int * rgSecMap,
+ IMAGE_SECTION_HEADER ** rgpHeader,
+ int numSections )
{
- if (emitIsPDBEnabled)
+ if ( emitIsPDBEnabled )
{
- pPDB->InitMaps(rgSecMap, // new PE section header order
- rgpHeader, // array of section headers
- numSections, // number of sections
- emitPDBOffsetTable, // code offset translation table
- emitPDBLocalTable); // slot variable translation table
+ pPDB->InitMaps( rgSecMap, // new PE section header order
+ rgpHeader, // array of section headers
+ numSections, // number of sections
+ emitPDBOffsetTable, // code offset translation table
+ emitPDBLocalTable ); // slot variable translation table
}
}
@@ -251,107 +259,107 @@ void emitter::InitTranslator(PDBRewriter* pPDB, int* rgSecMap, IMAGE_SECTION_HEA
#if EMITTER_STATS
-static unsigned totAllocdSize;
-static unsigned totActualSize;
+static unsigned totAllocdSize;
+static unsigned totActualSize;
-unsigned emitter::emitIFcounts[emitter::IF_COUNT];
+ unsigned emitter::emitIFcounts[emitter::IF_COUNT];
-static unsigned emitSizeBuckets[] = {100, 1024 * 1, 1024 * 2, 1024 * 3, 1024 * 4, 1024 * 5, 1024 * 10, 0};
-static Histogram emitSizeTable(HostAllocator::getHostAllocator(), emitSizeBuckets);
+static unsigned emitSizeBuckets[] = { 100, 1024*1, 1024*2, 1024*3, 1024*4, 1024*5, 1024*10, 0 };
+static Histogram emitSizeTable(HostAllocator::getHostAllocator(), emitSizeBuckets);
-static unsigned GCrefsBuckets[] = {0, 1, 2, 5, 10, 20, 50, 128, 256, 512, 1024, 0};
-static Histogram GCrefsTable(HostAllocator::getHostAllocator(), GCrefsBuckets);
+static unsigned GCrefsBuckets[] = { 0, 1, 2, 5, 10, 20, 50, 128, 256, 512, 1024, 0 };
+static Histogram GCrefsTable(HostAllocator::getHostAllocator(), GCrefsBuckets);
-static unsigned stkDepthBuckets[] = {0, 1, 2, 5, 10, 16, 32, 128, 1024, 0};
-static Histogram stkDepthTable(HostAllocator::getHostAllocator(), stkDepthBuckets);
+static unsigned stkDepthBuckets[] = { 0, 1, 2, 5, 10, 16, 32, 128, 1024, 0 };
+static Histogram stkDepthTable(HostAllocator::getHostAllocator(), stkDepthBuckets);
-size_t emitter::emitSizeMethod;
+size_t emitter::emitSizeMethod;
-size_t emitter::emitTotMemAlloc;
-unsigned emitter::emitTotalInsCnt;
-unsigned emitter::emitTotalIGcnt;
-unsigned emitter::emitTotalPhIGcnt;
-unsigned emitter::emitTotalIGjmps;
-unsigned emitter::emitTotalIGptrs;
-unsigned emitter::emitTotalIGicnt;
-size_t emitter::emitTotalIGsize;
-unsigned emitter::emitTotalIGmcnt;
+size_t emitter::emitTotMemAlloc;
+unsigned emitter::emitTotalInsCnt;
+unsigned emitter::emitTotalIGcnt;
+unsigned emitter::emitTotalPhIGcnt;
+unsigned emitter::emitTotalIGjmps;
+unsigned emitter::emitTotalIGptrs;
+unsigned emitter::emitTotalIGicnt;
+size_t emitter::emitTotalIGsize;
+unsigned emitter::emitTotalIGmcnt;
-unsigned emitter::emitSmallDspCnt;
-unsigned emitter::emitLargeDspCnt;
+unsigned emitter::emitSmallDspCnt;
+unsigned emitter::emitLargeDspCnt;
-unsigned emitter::emitSmallCnsCnt;
-unsigned emitter::emitLargeCnsCnt;
-unsigned emitter::emitSmallCns[SMALL_CNS_TSZ];
+unsigned emitter::emitSmallCnsCnt;
+unsigned emitter::emitLargeCnsCnt;
+unsigned emitter::emitSmallCns[SMALL_CNS_TSZ];
-void emitterStaticStats(FILE* fout)
+void emitterStaticStats(FILE* fout)
{
// insGroup members
fprintf(fout, "\n");
fprintf(fout, "insGroup:\n");
- fprintf(fout, "Offset of igNext = %2u\n", offsetof(insGroup, igNext));
+ fprintf(fout, "Offset of igNext = %2u\n", offsetof(insGroup, igNext ));
#ifdef DEBUG
- fprintf(fout, "Offset of igSelf = %2u\n", offsetof(insGroup, igSelf));
-#endif
- fprintf(fout, "Offset of igNum = %2u\n", offsetof(insGroup, igNum));
- fprintf(fout, "Offset of igOffs = %2u\n", offsetof(insGroup, igOffs));
- fprintf(fout, "Offset of igFuncIdx = %2u\n", offsetof(insGroup, igFuncIdx));
- fprintf(fout, "Offset of igFlags = %2u\n", offsetof(insGroup, igFlags));
- fprintf(fout, "Offset of igSize = %2u\n", offsetof(insGroup, igSize));
- fprintf(fout, "Offset of igData = %2u\n", offsetof(insGroup, igData));
+ fprintf(fout, "Offset of igSelf = %2u\n", offsetof(insGroup, igSelf ));
+#endif
+ fprintf(fout, "Offset of igNum = %2u\n", offsetof(insGroup, igNum ));
+ fprintf(fout, "Offset of igOffs = %2u\n", offsetof(insGroup, igOffs ));
+ fprintf(fout, "Offset of igFuncIdx = %2u\n", offsetof(insGroup, igFuncIdx ));
+ fprintf(fout, "Offset of igFlags = %2u\n", offsetof(insGroup, igFlags ));
+ fprintf(fout, "Offset of igSize = %2u\n", offsetof(insGroup, igSize ));
+ fprintf(fout, "Offset of igData = %2u\n", offsetof(insGroup, igData ));
#if EMIT_TRACK_STACK_DEPTH
- fprintf(fout, "Offset of igStkLvl = %2u\n", offsetof(insGroup, igStkLvl));
+ fprintf(fout, "Offset of igStkLvl = %2u\n", offsetof(insGroup, igStkLvl ));
#endif
- fprintf(fout, "Offset of igGCregs = %2u\n", offsetof(insGroup, igGCregs));
- fprintf(fout, "Offset of igInsCnt = %2u\n", offsetof(insGroup, igInsCnt));
- fprintf(fout, "Size of insGroup = %u\n", sizeof(insGroup));
+ fprintf(fout, "Offset of igGCregs = %2u\n", offsetof(insGroup, igGCregs ));
+ fprintf(fout, "Offset of igInsCnt = %2u\n", offsetof(insGroup, igInsCnt ));
+ fprintf(fout, "Size of insGroup = %u\n", sizeof( insGroup ));
// insPlaceholderGroupData members
fprintf(fout, "\n");
fprintf(fout, "insPlaceholderGroupData:\n");
- fprintf(fout, "Offset of igPhNext = %2u\n", offsetof(insPlaceholderGroupData, igPhNext));
- fprintf(fout, "Offset of igPhBB = %2u\n", offsetof(insPlaceholderGroupData, igPhBB));
- fprintf(fout, "Offset of igPhInitGCrefVars = %2u\n", offsetof(insPlaceholderGroupData, igPhInitGCrefVars));
- fprintf(fout, "Offset of igPhInitGCrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhInitGCrefRegs));
- fprintf(fout, "Offset of igPhInitByrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhInitByrefRegs));
- fprintf(fout, "Offset of igPhPrevGCrefVars = %2u\n", offsetof(insPlaceholderGroupData, igPhPrevGCrefVars));
- fprintf(fout, "Offset of igPhPrevGCrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhPrevGCrefRegs));
- fprintf(fout, "Offset of igPhPrevByrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhPrevByrefRegs));
- fprintf(fout, "Offset of igPhType = %2u\n", offsetof(insPlaceholderGroupData, igPhType));
- fprintf(fout, "Size of insPlaceholderGroupData = %u\n", sizeof(insPlaceholderGroupData));
+ fprintf(fout, "Offset of igPhNext = %2u\n", offsetof(insPlaceholderGroupData, igPhNext ));
+ fprintf(fout, "Offset of igPhBB = %2u\n", offsetof(insPlaceholderGroupData, igPhBB ));
+ fprintf(fout, "Offset of igPhInitGCrefVars = %2u\n", offsetof(insPlaceholderGroupData, igPhInitGCrefVars ));
+ fprintf(fout, "Offset of igPhInitGCrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhInitGCrefRegs ));
+ fprintf(fout, "Offset of igPhInitByrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhInitByrefRegs ));
+ fprintf(fout, "Offset of igPhPrevGCrefVars = %2u\n", offsetof(insPlaceholderGroupData, igPhPrevGCrefVars ));
+ fprintf(fout, "Offset of igPhPrevGCrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhPrevGCrefRegs ));
+ fprintf(fout, "Offset of igPhPrevByrefRegs = %2u\n", offsetof(insPlaceholderGroupData, igPhPrevByrefRegs ));
+ fprintf(fout, "Offset of igPhType = %2u\n", offsetof(insPlaceholderGroupData, igPhType ));
+ fprintf(fout, "Size of insPlaceholderGroupData = %u\n", sizeof( insPlaceholderGroupData ));
fprintf(fout, "\n");
fprintf(fout, "Size of tinyID = %2u\n", TINY_IDSC_SIZE);
- fprintf(fout, "Size of instrDesc = %2u\n", sizeof(emitter::instrDesc));
- // fprintf(fout, "Offset of _idIns = %2u\n", offsetof(emitter::instrDesc, _idIns ));
- // fprintf(fout, "Offset of _idInsFmt = %2u\n", offsetof(emitter::instrDesc, _idInsFmt ));
- // fprintf(fout, "Offset of _idOpSize = %2u\n", offsetof(emitter::instrDesc, _idOpSize ));
- // fprintf(fout, "Offset of idSmallCns = %2u\n", offsetof(emitter::instrDesc, idSmallCns ));
- // fprintf(fout, "Offset of _idAddrUnion= %2u\n", offsetof(emitter::instrDesc, _idAddrUnion));
- // fprintf(fout, "\n");
- // fprintf(fout, "Size of _idAddrUnion= %2u\n", sizeof(((emitter::instrDesc*)0)->_idAddrUnion));
+ fprintf(fout, "Size of instrDesc = %2u\n", sizeof( emitter::instrDesc ));
+ //fprintf(fout, "Offset of _idIns = %2u\n", offsetof(emitter::instrDesc, _idIns ));
+ //fprintf(fout, "Offset of _idInsFmt = %2u\n", offsetof(emitter::instrDesc, _idInsFmt ));
+ //fprintf(fout, "Offset of _idOpSize = %2u\n", offsetof(emitter::instrDesc, _idOpSize ));
+ //fprintf(fout, "Offset of idSmallCns = %2u\n", offsetof(emitter::instrDesc, idSmallCns ));
+ //fprintf(fout, "Offset of _idAddrUnion= %2u\n", offsetof(emitter::instrDesc, _idAddrUnion));
+ //fprintf(fout, "\n");
+ //fprintf(fout, "Size of _idAddrUnion= %2u\n", sizeof(((emitter::instrDesc*)0)->_idAddrUnion));
fprintf(fout, "\n");
fprintf(fout, "GCInfo::regPtrDsc:\n");
- fprintf(fout, "Offset of rpdNext = %2u\n", offsetof(GCInfo::regPtrDsc, rpdNext));
- fprintf(fout, "Offset of rpdOffs = %2u\n", offsetof(GCInfo::regPtrDsc, rpdOffs));
+ fprintf(fout, "Offset of rpdNext = %2u\n", offsetof(GCInfo::regPtrDsc, rpdNext ));
+ fprintf(fout, "Offset of rpdOffs = %2u\n", offsetof(GCInfo::regPtrDsc, rpdOffs ));
fprintf(fout, "Offset of <union> = %2u\n", offsetof(GCInfo::regPtrDsc, rpdPtrArg));
- fprintf(fout, "Size of GCInfo::regPtrDsc = %2u\n", sizeof(GCInfo::regPtrDsc));
+ fprintf(fout, "Size of GCInfo::regPtrDsc = %2u\n", sizeof( GCInfo::regPtrDsc ));
fprintf(fout, "\n");
}
-void emitterStats(FILE* fout)
+void emitterStats(FILE* fout)
{
- if (totAllocdSize > 0)
+ if (totAllocdSize > 0)
{
assert(totActualSize <= totAllocdSize);
fprintf(fout, "\nTotal allocated code size = %u\n", totAllocdSize);
- if (totActualSize < totAllocdSize)
+ if (totActualSize < totAllocdSize)
{
fprintf(fout, "Total generated code size = %u ", totActualSize);
@@ -361,13 +369,12 @@ void emitterStats(FILE* fout)
assert(emitter::emitTotalInsCnt);
- fprintf(fout, "Average of %4.2f bytes of code generated per instruction\n",
- (double)totActualSize / emitter::emitTotalInsCnt);
+ fprintf(fout, "Average of %4.2f bytes of code generated per instruction\n", (double)totActualSize / emitter::emitTotalInsCnt);
}
fprintf(fout, "\nInstruction format frequency table:\n\n");
- unsigned f, ic = 0, dc = 0;
+ unsigned f, ic = 0, dc = 0;
for (f = 0; f < emitter::IF_COUNT; f++)
{
@@ -376,9 +383,9 @@ void emitterStats(FILE* fout)
for (f = 0; f < emitter::IF_COUNT; f++)
{
- unsigned c = emitter::emitIFcounts[f];
+ unsigned c = emitter::emitIFcounts[f];
- if ((c > 0) && (1000 * c >= ic))
+ if ((c > 0) && (1000 * c >= ic))
{
dc += c;
fprintf(fout, " %-13s %8u (%5.2f%%)\n", emitter::emitIfName(f), c, 100.0 * c / ic);
@@ -388,39 +395,29 @@ void emitterStats(FILE* fout)
fprintf(fout, " --------------------------------\n");
fprintf(fout, " %-13s %8u (%5.2f%%)\n", "Total shown", dc, 100.0 * dc / ic);
- if (emitter::emitTotalIGmcnt)
+ if (emitter::emitTotalIGmcnt)
{
- fprintf(fout, "Total of %8u methods\n", emitter::emitTotalIGmcnt);
- fprintf(fout, "Total of %8u insGroup\n", emitter::emitTotalIGcnt);
+ fprintf(fout, "Total of %8u methods\n", emitter::emitTotalIGmcnt);
+ fprintf(fout, "Total of %8u insGroup\n", emitter::emitTotalIGcnt);
fprintf(fout, "Total of %8u insPlaceholderGroupData\n", emitter::emitTotalPhIGcnt);
- fprintf(fout, "Total of %8u instructions\n", emitter::emitTotalIGicnt);
- fprintf(fout, "Total of %8u jumps\n", emitter::emitTotalIGjmps);
- fprintf(fout, "Total of %8u GC livesets\n", emitter::emitTotalIGptrs);
+ fprintf(fout, "Total of %8u instructions\n", emitter::emitTotalIGicnt);
+ fprintf(fout, "Total of %8u jumps\n", emitter::emitTotalIGjmps);
+ fprintf(fout, "Total of %8u GC livesets\n", emitter::emitTotalIGptrs);
fprintf(fout, "\n");
- fprintf(fout, "Average of %8.1lf insGroup per method\n",
- (double)emitter::emitTotalIGcnt / emitter::emitTotalIGmcnt);
- fprintf(fout, "Average of %8.1lf insPhGroup per method\n",
- (double)emitter::emitTotalPhIGcnt / emitter::emitTotalIGmcnt);
- fprintf(fout, "Average of %8.1lf instructions per method\n",
- (double)emitter::emitTotalIGicnt / emitter::emitTotalIGmcnt);
- fprintf(fout, "Average of %8.1lf desc. bytes per method\n",
- (double)emitter::emitTotalIGsize / emitter::emitTotalIGmcnt);
- fprintf(fout, "Average of %8.1lf jumps per method\n",
- (double)emitter::emitTotalIGjmps / emitter::emitTotalIGmcnt);
- fprintf(fout, "Average of %8.1lf GC livesets per method\n",
- (double)emitter::emitTotalIGptrs / emitter::emitTotalIGmcnt);
+ fprintf(fout, "Average of %8.1lf insGroup per method\n", (double)emitter::emitTotalIGcnt / emitter::emitTotalIGmcnt);
+ fprintf(fout, "Average of %8.1lf insPhGroup per method\n", (double)emitter::emitTotalPhIGcnt/ emitter::emitTotalIGmcnt);
+ fprintf(fout, "Average of %8.1lf instructions per method\n", (double)emitter::emitTotalIGicnt / emitter::emitTotalIGmcnt);
+ fprintf(fout, "Average of %8.1lf desc. bytes per method\n", (double)emitter::emitTotalIGsize / emitter::emitTotalIGmcnt);
+ fprintf(fout, "Average of %8.1lf jumps per method\n", (double)emitter::emitTotalIGjmps / emitter::emitTotalIGmcnt);
+ fprintf(fout, "Average of %8.1lf GC livesets per method\n", (double)emitter::emitTotalIGptrs / emitter::emitTotalIGmcnt);
fprintf(fout, "\n");
- fprintf(fout, "Average of %8.1lf instructions per group \n",
- (double)emitter::emitTotalIGicnt / emitter::emitTotalIGcnt);
- fprintf(fout, "Average of %8.1lf desc. bytes per group \n",
- (double)emitter::emitTotalIGsize / emitter::emitTotalIGcnt);
- fprintf(fout, "Average of %8.1lf jumps per group \n",
- (double)emitter::emitTotalIGjmps / emitter::emitTotalIGcnt);
+ fprintf(fout, "Average of %8.1lf instructions per group \n", (double)emitter::emitTotalIGicnt / emitter::emitTotalIGcnt);
+ fprintf(fout, "Average of %8.1lf desc. bytes per group \n", (double)emitter::emitTotalIGsize / emitter::emitTotalIGcnt);
+ fprintf(fout, "Average of %8.1lf jumps per group \n", (double)emitter::emitTotalIGjmps / emitter::emitTotalIGcnt);
fprintf(fout, "\n");
- fprintf(fout, "Average of %8.1lf bytes per instrDesc\n",
- (double)emitter::emitTotalIGsize / emitter::emitTotalIGicnt);
+ fprintf(fout, "Average of %8.1lf bytes per instrDesc\n", (double)emitter::emitTotalIGsize / emitter::emitTotalIGicnt);
fprintf(fout, "\n");
- fprintf(fout, "A total of %8u desc. bytes\n", emitter::emitTotalIGsize);
+ fprintf(fout, "A total of %8u desc. bytes\n" , emitter::emitTotalIGsize);
fprintf(fout, "\n");
}
@@ -436,15 +433,14 @@ void emitterStats(FILE* fout)
stkDepthTable.dump(fout);
fprintf(fout, "\n");
- int i;
- unsigned c;
- unsigned m;
+ int i;
+ unsigned c;
+ unsigned m;
- if (emitter::emitSmallCnsCnt || emitter::emitLargeCnsCnt)
+ if (emitter::emitSmallCnsCnt || emitter::emitLargeCnsCnt)
{
- fprintf(fout, "SmallCnsCnt = %6u\n", emitter::emitSmallCnsCnt);
- fprintf(fout, "LargeCnsCnt = %6u (%3u %% of total)\n", emitter::emitLargeCnsCnt,
- 100 * emitter::emitLargeCnsCnt / (emitter::emitLargeCnsCnt + emitter::emitSmallCnsCnt));
+ fprintf(fout, "SmallCnsCnt = %6u\n" , emitter::emitSmallCnsCnt);
+ fprintf(fout, "LargeCnsCnt = %6u (%3u %% of total)\n", emitter::emitLargeCnsCnt, 100*emitter::emitLargeCnsCnt/(emitter::emitLargeCnsCnt+emitter::emitSmallCnsCnt));
}
#if 0
@@ -467,20 +463,22 @@ void emitterStats(FILE* fout)
fprintf(fout, "%8u bytes allocated in the emitter\n", emitter::emitTotMemAlloc);
}
-#endif // EMITTER_STATS
+#endif // EMITTER_STATS
/*****************************************************************************/
-const unsigned short emitTypeSizes[] = {
-#define DEF_TP(tn, nm, jitType, verType, sz, sze, asze, st, al, tf, howUsed) sze,
-#include "typelist.h"
-#undef DEF_TP
+const unsigned short emitTypeSizes[] =
+{
+ #define DEF_TP(tn,nm,jitType,verType,sz,sze,asze,st,al,tf,howUsed) sze,
+ #include "typelist.h"
+ #undef DEF_TP
};
-const unsigned short emitTypeActSz[] = {
-#define DEF_TP(tn, nm, jitType, verType, sz, sze, asze, st, al, tf, howUsed) asze,
-#include "typelist.h"
-#undef DEF_TP
+const unsigned short emitTypeActSz[] =
+{
+ #define DEF_TP(tn,nm,jitType,verType,sz,sze,asze,st,al,tf,howUsed) asze,
+ #include "typelist.h"
+ #undef DEF_TP
};
/*****************************************************************************/
@@ -489,7 +487,7 @@ const unsigned short emitTypeActSz[] = {
* Initialize the emitter - called once, at DLL load time.
*/
-void emitter::emitInit()
+void emitter::emitInit()
{
}
@@ -498,16 +496,17 @@ void emitter::emitInit()
* Shut down the emitter - called once, at DLL exit time.
*/
-void emitter::emitDone()
+void emitter::emitDone()
{
}
+
/*****************************************************************************
*
* Allocate memory.
*/
-void* emitter::emitGetMem(size_t sz)
+void* emitter::emitGetMem(size_t sz)
{
assert(sz % sizeof(int) == 0);
@@ -515,9 +514,10 @@ void* emitter::emitGetMem(size_t sz)
emitTotMemAlloc += sz;
#endif
- return emitComp->compGetMem(sz, CMK_InstDesc);
+ return emitComp->compGetMem(sz, CMK_InstDesc);
}
+
/*****************************************************************************
*
* emitLclVarAddr support methods
@@ -531,54 +531,43 @@ void emitLclVarAddr::initLclVarAddr(int varNum, unsigned offset)
if (offset < 32768)
{
_lvaTag = LVA_STANDARD_ENCODING;
- _lvaExtra = offset; // offset known to be in [0..32767]
- _lvaVarNum = (unsigned)varNum; // varNum known to be in [0..32767]
+ _lvaExtra = offset; // offset known to be in [0..32767]
+ _lvaVarNum = (unsigned) varNum; // varNum known to be in [0..32767]
}
else // offset >= 32768
{
// We could support larger local offsets here at the cost of less varNums
if (offset >= 65536)
- {
IMPL_LIMITATION("JIT doesn't support offsets larger than 65535 into valuetypes\n");
- }
_lvaTag = LVA_LARGE_OFFSET;
- _lvaExtra = (offset - 32768); // (offset-32768) is known to be in [0..32767]
- _lvaVarNum = (unsigned)varNum; // varNum known to be in [0..32767]
+ _lvaExtra = (offset-32768); // (offset-32768) is known to be in [0..32767]
+ _lvaVarNum = (unsigned) varNum; // varNum known to be in [0..32767]
}
}
else // varNum < 0, These are used for Compiler spill temps
{
if (varNum < -32767)
- {
IMPL_LIMITATION("JIT doesn't support more than 32767 Compiler Spill temps\n");
- }
if (offset > 32767)
- {
- IMPL_LIMITATION(
- "JIT doesn't support offsets larger than 32767 into valuetypes for Compiler Spill temps\n");
- }
+ IMPL_LIMITATION("JIT doesn't support offsets larger than 32767 into valuetypes for Compiler Spill temps\n");
- _lvaTag = LVA_COMPILER_TEMP;
- _lvaExtra = offset; // offset known to be in [0..32767]
- _lvaVarNum = (unsigned)(-varNum); // -varNum known to be in [1..32767]
+ _lvaTag = LVA_COMPILER_TEMP;
+ _lvaExtra = offset; // offset known to be in [0..32767]
+ _lvaVarNum = (unsigned) (-varNum); // -varNum known to be in [1..32767]
}
}
else // varNum >= 32768
{
if (offset >= 256)
- {
IMPL_LIMITATION("JIT doesn't support offsets larger than 255 into valuetypes for local vars > 32767\n");
- }
- if (varNum >= 0x00400000)
- { // 0x00400000 == 2^22
+ if (varNum >= 0x00400000) // 0x00400000 == 2^22
IMPL_LIMITATION("JIT doesn't support more than 2^22 variables\n");
- }
_lvaTag = LVA_LARGE_VARNUM;
- _lvaVarNum = varNum & 0x00007FFF; // varNum bits 14 to 0
- _lvaExtra = (varNum & 0x003F8000) >> 15; // varNum bits 21 to 15 in _lvaExtra bits 6 to 0, 7 bits total
- _lvaExtra |= (offset << 7); // offset bits 7 to 0 in _lvaExtra bits 14 to 7, 8 bits total
+ _lvaVarNum = varNum & 0x00007FFF; // varNum bits 14 to 0
+ _lvaExtra = (varNum & 0x003F8000) >> 15; // varNum bits 21 to 15 in _lvaExtra bits 6 to 0, 7 bits total
+ _lvaExtra |= (offset << 7); // offset bits 7 to 0 in _lvaExtra bits 14 to 7, 8 bits total
}
}
@@ -587,27 +576,27 @@ int emitLclVarAddr::lvaVarNum()
{
switch (_lvaTag)
{
- case LVA_COMPILER_TEMP:
- return -((int)_lvaVarNum);
- case LVA_LARGE_VARNUM:
- return (int)(((_lvaExtra & 0x007F) << 15) + _lvaVarNum);
- default: // LVA_STANDARD_ENCODING or LVA_LARGE_OFFSET
- assert((_lvaTag == LVA_STANDARD_ENCODING) || (_lvaTag == LVA_LARGE_OFFSET));
- return (int)_lvaVarNum;
+ case LVA_COMPILER_TEMP:
+ return -((int) _lvaVarNum);
+ case LVA_LARGE_VARNUM:
+ return (int) (((_lvaExtra & 0x007F) << 15) + _lvaVarNum);
+ default: // LVA_STANDARD_ENCODING or LVA_LARGE_OFFSET
+ assert((_lvaTag == LVA_STANDARD_ENCODING) || (_lvaTag == LVA_LARGE_OFFSET));
+ return (int) _lvaVarNum;
}
}
-unsigned emitLclVarAddr::lvaOffset() // returns the offset into the variable to access
+unsigned emitLclVarAddr::lvaOffset() // returns the offset into the variable to access
{
switch (_lvaTag)
{
- case LVA_LARGE_OFFSET:
- return (32768 + _lvaExtra);
- case LVA_LARGE_VARNUM:
- return (_lvaExtra & 0x7F80) >> 7;
- default: // LVA_STANDARD_ENCODING or LVA_COMPILER_TEMP
- assert((_lvaTag == LVA_STANDARD_ENCODING) || (_lvaTag == LVA_COMPILER_TEMP));
- return _lvaExtra;
+ case LVA_LARGE_OFFSET:
+ return (32768 + _lvaExtra);
+ case LVA_LARGE_VARNUM:
+ return (_lvaExtra & 0x7F80) >> 7;
+ default: // LVA_STANDARD_ENCODING or LVA_COMPILER_TEMP
+ assert((_lvaTag == LVA_STANDARD_ENCODING) || (_lvaTag == LVA_COMPILER_TEMP));
+ return _lvaExtra;
}
}
@@ -616,13 +605,14 @@ unsigned emitLclVarAddr::lvaOffset() // returns the offset into the variable to
* Record some info about the method about to be emitted.
*/
-void emitter::emitBegCG(Compiler* comp, COMP_HANDLE cmpHandle)
+void emitter::emitBegCG(Compiler *comp,
+ COMP_HANDLE cmpHandle)
{
emitComp = comp;
emitCmpHandle = cmpHandle;
}
-void emitter::emitEndCG()
+void emitter::emitEndCG()
{
}
@@ -631,24 +621,22 @@ void emitter::emitEndCG()
* Prepare the given IG for emission of code.
*/
-void emitter::emitGenIG(insGroup* ig)
+void emitter::emitGenIG(insGroup *ig)
{
/* Set the "current IG" value */
- emitCurIG = ig;
+ emitCurIG = ig;
#if EMIT_TRACK_STACK_DEPTH
/* Record the stack level on entry to this group */
- ig->igStkLvl = emitCurStackLvl;
+ ig->igStkLvl = emitCurStackLvl;
// If we don't have enough bits in igStkLvl, refuse to compile
if (ig->igStkLvl != emitCurStackLvl)
- {
IMPL_LIMITATION("Too many arguments pushed on stack");
- }
// printf("Start IG #%02u [stk=%02u]\n", ig->igNum, emitCurStackLvl);
@@ -661,16 +649,16 @@ void emitter::emitGenIG(insGroup* ig)
/* Prepare to issue instructions */
- emitCurIGinsCnt = 0;
- emitCurIGsize = 0;
+ emitCurIGinsCnt = 0;
+ emitCurIGsize = 0;
- assert(emitCurIGjmpList == nullptr);
+ assert(emitCurIGjmpList == NULL);
/* Allocate the temp instruction buffer if we haven't done so */
- if (emitCurIGfreeBase == nullptr)
+ if (emitCurIGfreeBase == NULL)
{
- emitIGbuffSize = SC_IG_BUFFER_SIZE;
+ emitIGbuffSize = SC_IG_BUFFER_SIZE;
emitCurIGfreeBase = (BYTE*)emitGetMem(emitIGbuffSize);
}
@@ -685,18 +673,17 @@ void emitter::emitGenIG(insGroup* ig)
insGroup* emitter::emitSavIG(bool emitAdd)
{
- insGroup* ig;
- BYTE* id;
+ insGroup * ig;
+ BYTE * id;
- size_t sz;
- size_t gs;
+ size_t sz;
+ size_t gs;
assert(emitCurIGfreeNext <= emitCurIGfreeEndp);
/* Get hold of the IG descriptor */
- ig = emitCurIG;
- assert(ig);
+ ig = emitCurIG; assert(ig);
/* Compute how much code we've generated */
@@ -708,7 +695,7 @@ insGroup* emitter::emitSavIG(bool emitAdd)
/* Do we need space for GC? */
- if (!(ig->igFlags & IGF_EMIT_ADD))
+ if (!(ig->igFlags & IGF_EMIT_ADD))
{
/* Is the initial set of live GC vars different from the previous one? */
@@ -748,16 +735,16 @@ insGroup* emitter::emitSavIG(bool emitAdd)
{
/* Record the byref regs in front the of the instructions */
- *castto(id, unsigned*)++ = (unsigned)emitInitByrefRegs;
+ *castto(id, unsigned *)++ = (unsigned) emitInitByrefRegs;
}
/* Do we need to store the liveset? */
- if (ig->igFlags & IGF_GC_VARS)
+ if (ig->igFlags & IGF_GC_VARS)
{
/* Record the liveset in front the of the instructions */
- VarSetOps::AssignNoCopy(emitComp, (*castto(id, VARSET_TP*)), VarSetOps::MakeEmpty(emitComp));
- VarSetOps::Assign(emitComp, (*castto(id, VARSET_TP*)++), emitInitGCrefVars);
+ VarSetOps::AssignNoCopy(emitComp, (*castto(id, VARSET_TP *)), VarSetOps::MakeEmpty(emitComp));
+ VarSetOps::Assign(emitComp, (*castto(id, VARSET_TP *)++), emitInitGCrefVars);
}
/* Record the collected instructions */
@@ -773,8 +760,8 @@ insGroup* emitter::emitSavIG(bool emitAdd)
// If there's an error during emission, we may want to connect the post-copy address
// of an instrDesc with the pre-copy address (the one that was originally created). This
// printing enables that.
- printf("copying instruction group from [0x%x..0x%x) to [0x%x..0x%x).\n", dspPtr(emitCurIGfreeBase),
- dspPtr(emitCurIGfreeBase + sz), dspPtr(id), dspPtr(id + sz));
+ printf("copying instruction group from [0x%x..0x%x) to [0x%x..0x%x).\n",
+ dspPtr(emitCurIGfreeBase), dspPtr(emitCurIGfreeBase+sz), dspPtr(id), dspPtr(id+sz));
}
#endif
@@ -783,24 +770,24 @@ insGroup* emitter::emitSavIG(bool emitAdd)
noway_assert((BYTE)emitCurIGinsCnt == emitCurIGinsCnt);
noway_assert((unsigned short)emitCurIGsize == emitCurIGsize);
- ig->igInsCnt = (BYTE)emitCurIGinsCnt;
- ig->igSize = (unsigned short)emitCurIGsize;
+ ig->igInsCnt = (BYTE)emitCurIGinsCnt;
+ ig->igSize = (unsigned short)emitCurIGsize;
emitCurCodeOffset += emitCurIGsize;
assert(IsCodeAligned(emitCurCodeOffset));
#if EMITTER_STATS
- emitTotalIGicnt += emitCurIGinsCnt;
- emitTotalIGsize += sz;
- emitSizeMethod += sz;
+ emitTotalIGicnt += emitCurIGinsCnt;
+ emitTotalIGsize += sz;
+ emitSizeMethod += sz;
#endif
// printf("Group [%08X]%3u has %2u instructions (%4u bytes at %08X)\n", ig, ig->igNum, emitCurIGinsCnt, sz, id);
/* Record the live GC register set - if and only if it is not an emitter added block */
- if (!(ig->igFlags & IGF_EMIT_ADD))
+ if (!(ig->igFlags & IGF_EMIT_ADD))
{
- ig->igGCregs = (regMaskSmall)emitInitGCrefRegs;
+ ig->igGCregs = (regMaskSmall)emitInitGCrefRegs;
}
if (!emitAdd)
@@ -820,17 +807,17 @@ insGroup* emitter::emitSavIG(bool emitAdd)
emitForceStoreGCState = false;
}
-#ifdef DEBUG
- if (emitComp->opts.dspCode)
+#ifdef DEBUG
+ if (emitComp->opts.dspCode)
{
printf("\n G_M%03u_IG%02u:", Compiler::s_compMethodsCount, ig->igNum);
if (emitComp->verbose)
{
- printf(" ; offs=%06XH, funclet=%02u", ig->igOffs, ig->igFuncIdx);
+ printf(" ; offs=%06XH, funclet=%02u", ig->igOffs, ig->igFuncIdx);
}
else
{
- printf(" ; funclet=%02u", ig->igFuncIdx);
+ printf(" ; funclet=%02u", ig->igFuncIdx);
}
printf("\n");
}
@@ -838,10 +825,10 @@ insGroup* emitter::emitSavIG(bool emitAdd)
/* Did we have any jumps in this group? */
- if (emitCurIGjmpList)
+ if (emitCurIGjmpList)
{
- instrDescJmp* list = nullptr;
- instrDescJmp* last = nullptr;
+ instrDescJmp * list = NULL;
+ instrDescJmp * last = NULL;
/* Move jumps to the global list, update their 'next' links */
@@ -854,19 +841,19 @@ insGroup* emitter::emitSavIG(bool emitAdd)
/* Figure out the address of where the jump got copied */
- size_t of = (BYTE*)oj - emitCurIGfreeBase;
+ size_t of = (BYTE*)oj - emitCurIGfreeBase;
instrDescJmp* nj = (instrDescJmp*)(ig->igData + of);
// printf("Jump moved from %08X to %08X\n", oj, nj);
// printf("jmp [%08X] at %08X + %03u\n", nj, ig, nj->idjOffs);
- assert(nj->idjIG == ig);
+ assert(nj->idjIG == ig);
assert(nj->idIns() == oj->idIns());
assert(nj->idjNext == oj->idjNext);
/* Make sure the jumps are correctly ordered */
- assert(last == nullptr || last->idjOffs > nj->idjOffs);
+ assert(last == NULL || last->idjOffs > nj->idjOffs);
if (ig->igFlags & IGF_FUNCLET_PROLOG)
{
@@ -883,32 +870,33 @@ insGroup* emitter::emitSavIG(bool emitAdd)
/* Append the new jump to the list */
nj->idjNext = list;
- list = nj;
+ list = nj;
- if (last == nullptr)
+ if (last == NULL)
{
last = nj;
}
- } while (emitCurIGjmpList);
+ }
+ while (emitCurIGjmpList);
- if (last != nullptr)
+ if (last != NULL)
{
/* Append the jump(s) from this IG to the global list */
bool prologJump = (ig == emitPrologIG);
- if ((emitJumpList == nullptr) || prologJump)
+ if ((emitJumpList == NULL) || prologJump)
{
last->idjNext = emitJumpList;
emitJumpList = list;
}
else
{
- last->idjNext = nullptr;
+ last->idjNext = NULL;
emitJumpLast->idjNext = list;
}
- if (!prologJump || (emitJumpLast == nullptr))
+ if (!prologJump || (emitJumpLast == NULL))
{
- emitJumpLast = last;
+ emitJumpLast = last;
}
}
}
@@ -919,7 +907,7 @@ insGroup* emitter::emitSavIG(bool emitAdd)
{
assert(emitLastIns != nullptr);
assert(emitCurIGfreeBase <= (BYTE*)emitLastIns);
- assert((BYTE*)emitLastIns < emitCurIGfreeBase + sz);
+ assert( (BYTE*)emitLastIns < emitCurIGfreeBase + sz);
emitLastIns = (instrDesc*)((BYTE*)id + ((BYTE*)emitLastIns - (BYTE*)emitCurIGfreeBase));
}
@@ -927,38 +915,39 @@ insGroup* emitter::emitSavIG(bool emitAdd)
emitCurIGfreeNext = emitCurIGfreeBase;
- return ig;
+ return ig;
}
#ifdef LEGACY_BACKEND
-void emitter::emitTmpSizeChanged(unsigned tmpSize)
+void emitter::emitTmpSizeChanged(unsigned tmpSize)
{
assert(emitGrowableMaxByteOffs <= SCHAR_MAX);
#ifdef DEBUG
// Workaround for FP code
- bool bAssert = JitConfig.JitMaxTempAssert() ? true : false;
+ bool bAssert = JitConfig.JitMaxTempAssert()?true:false;
if (tmpSize > emitMaxTmpSize && bAssert)
{
// TODO-Review: We have a known issue involving floating point code and this assert.
- // The generated code will be ok, This is only a warning.
+ // The generated code will be ok, This is only a warning.
// To not receive this assert again you can set the registry key: JITMaxTempAssert=0.
//
assert(!"Incorrect max tmp size set.");
- }
+ }
#endif
-
+
if (tmpSize <= emitMaxTmpSize)
return;
- unsigned change = tmpSize - emitMaxTmpSize;
+ unsigned change = tmpSize - emitMaxTmpSize;
/* If we have used a small offset to access a variable, growing the
temp size is a problem if we should have used a large offset instead.
Detect if such a situation happens and bail */
- if (emitGrowableMaxByteOffs <= SCHAR_MAX && (emitGrowableMaxByteOffs + change) > SCHAR_MAX)
+ if ( emitGrowableMaxByteOffs <= SCHAR_MAX &&
+ (emitGrowableMaxByteOffs + change) > SCHAR_MAX)
{
#ifdef DEBUG
if (emitComp->verbose)
@@ -977,122 +966,126 @@ void emitter::emitTmpSizeChanged(unsigned tmpSize)
* Start generating code to be scheduled; called once per method.
*/
-void emitter::emitBegFN(bool hasFramePtr
+void emitter::emitBegFN(bool hasFramePtr
#if defined(DEBUG)
- ,
- bool chkAlign
+ , bool chkAlign
#endif
#ifdef LEGACY_BACKEND
- ,
- unsigned lclSize
+ , unsigned lclSize
#endif // LEGACY_BACKEND
- ,
- unsigned maxTmpSize)
+ , unsigned maxTmpSize
+ )
{
- insGroup* ig;
+ insGroup * ig;
/* Assume we won't need the temp instruction buffer */
- emitCurIGfreeBase = nullptr;
- emitIGbuffSize = 0;
+ emitCurIGfreeBase = NULL;
+ emitIGbuffSize = 0;
/* Record stack frame info (the temp size is just an estimate) */
- emitHasFramePtr = hasFramePtr;
+ emitHasFramePtr = hasFramePtr;
- emitMaxTmpSize = maxTmpSize;
+ emitMaxTmpSize = maxTmpSize;
#ifdef LEGACY_BACKEND
- emitLclSize = lclSize;
+ emitLclSize = lclSize;
emitGrowableMaxByteOffs = 0;
#ifdef DEBUG
- emitMaxByteOffsIdNum = (unsigned)-1;
+ emitMaxByteOffsIdNum= (unsigned)-1;
#endif // DEBUG
#endif // LEGACY_BACKEND
#ifdef DEBUG
- emitChkAlign = chkAlign;
+ emitChkAlign = chkAlign;
#endif
/* We have no epilogs yet */
- emitEpilogSize = 0;
- emitEpilogCnt = 0;
+ emitEpilogSize = 0;
+ emitEpilogCnt = 0;
#ifdef _TARGET_XARCH_
emitExitSeqBegLoc.Init();
- emitExitSeqSize = INT_MAX;
+ emitExitSeqSize = INT_MAX;
#endif // _TARGET_XARCH_
- emitPlaceholderList = emitPlaceholderLast = nullptr;
+ emitPlaceholderList =
+ emitPlaceholderLast = NULL;
#ifdef JIT32_GCENCODER
- emitEpilogList = emitEpilogLast = NULL;
+ emitEpilogList =
+ emitEpilogLast = NULL;
#endif // JIT32_GCENCODER
/* We don't have any jumps */
- emitJumpList = emitJumpLast = nullptr;
- emitCurIGjmpList = nullptr;
+ emitJumpList =
+ emitJumpLast = NULL;
+ emitCurIGjmpList = NULL;
- emitFwdJumps = false;
- emitNoGCIG = false;
- emitForceNewIG = false;
+ emitFwdJumps = false;
+ emitNoGCIG = false;
+ emitForceNewIG = false;
/* We have not recorded any live sets */
assert(VarSetOps::IsEmpty(emitComp, emitThisGCrefVars));
assert(VarSetOps::IsEmpty(emitComp, emitInitGCrefVars));
assert(VarSetOps::IsEmpty(emitComp, emitPrevGCrefVars));
- emitThisGCrefRegs = RBM_NONE;
- emitInitGCrefRegs = RBM_NONE;
- emitPrevGCrefRegs = RBM_NONE;
- emitThisByrefRegs = RBM_NONE;
- emitInitByrefRegs = RBM_NONE;
- emitPrevByrefRegs = RBM_NONE;
+ emitThisGCrefRegs = RBM_NONE;
+ emitInitGCrefRegs = RBM_NONE;
+ emitPrevGCrefRegs = RBM_NONE;
+ emitThisByrefRegs = RBM_NONE;
+ emitInitByrefRegs = RBM_NONE;
+ emitPrevByrefRegs = RBM_NONE;
emitForceStoreGCState = false;
#ifdef DEBUG
- emitIssuing = false;
+ emitIssuing = false;
#endif
/* Assume there will be no GC ref variables */
- emitGCrFrameOffsMin = emitGCrFrameOffsMax = emitGCrFrameOffsCnt = 0;
-#ifdef DEBUG
- emitGCrFrameLiveTab = nullptr;
+ emitGCrFrameOffsMin =
+ emitGCrFrameOffsMax =
+ emitGCrFrameOffsCnt = 0;
+#ifdef DEBUG
+ emitGCrFrameLiveTab = NULL;
#endif
/* We have no groups / code at this point */
- emitIGlist = emitIGlast = nullptr;
+ emitIGlist =
+ emitIGlast = NULL;
- emitCurCodeOffset = 0;
- emitFirstColdIG = nullptr;
- emitTotalCodeSize = 0;
+ emitCurCodeOffset = 0;
+ emitFirstColdIG = NULL;
+ emitTotalCodeSize = 0;
-#if EMITTER_STATS
+#if EMITTER_STATS
emitTotalIGmcnt++;
- emitSizeMethod = 0;
+ emitSizeMethod = 0;
#endif
- emitInsCount = 0;
+ emitInsCount = 0;
/* The stack is empty now */
- emitCurStackLvl = 0;
+ emitCurStackLvl = 0;
#if EMIT_TRACK_STACK_DEPTH
- emitMaxStackDepth = 0;
- emitCntStackDepth = sizeof(int);
+ emitMaxStackDepth = 0;
+ emitCntStackDepth = sizeof(int);
#endif
/* No data sections have been created */
- emitDataSecCur = nullptr;
+ emitDataSecCur = 0;
memset(&emitConsDsc, 0, sizeof(emitConsDsc));
@@ -1101,27 +1094,31 @@ void emitter::emitBegFN(bool hasFramePtr
emitEnableRandomNops();
emitComp->info.compRNG.Init(emitComp->info.compChecksum);
- emitNextNop = emitNextRandomNop();
+ emitNextNop = emitNextRandomNop();
emitInInstrumentation = false;
#endif // PSEUDORANDOM_NOP_INSERTION
/* Create the first IG, it will be used for the prolog */
- emitNxtIGnum = 1;
+ emitNxtIGnum = 1;
- emitPrologIG = emitIGlist = emitIGlast = emitCurIG = ig = emitAllocIG();
+ emitPrologIG =
+ emitIGlist =
+ emitIGlast =
+ emitCurIG =
+ ig = emitAllocIG();
#ifdef ARM_HAZARD_AVOIDANCE
// This first IG is actually preceeded by the method prolog which may be composed of many T1 instructions
emitCurInstrCntT1 = MAX_INSTR_COUNT_T1;
#endif
- emitLastIns = nullptr;
+ emitLastIns = NULL;
- ig->igNext = nullptr;
+ ig->igNext = NULL;
#ifdef DEBUG
- emitScratchSigInfo = nullptr;
+ emitScratchSigInfo = nullptr;
#endif // DEBUG
/* Append another group, to start generating the method body */
@@ -1132,7 +1129,7 @@ void emitter::emitBegFN(bool hasFramePtr
#ifdef PSEUDORANDOM_NOP_INSERTION
int emitter::emitNextRandomNop()
{
- return emitComp->info.compRNG.Next(1, 9);
+ return emitComp->info.compRNG.Next(1,9);
}
#endif
@@ -1141,7 +1138,7 @@ int emitter::emitNextRandomNop()
* Done generating code to be scheduled; called once per method.
*/
-void emitter::emitEndFN()
+void emitter::emitEndFN()
{
}
@@ -1158,39 +1155,39 @@ int emitter::instrDesc::idAddrUnion::iiaGetJitDataOffset() const
return Compiler::eeGetJitDataOffs(iiaFieldHnd);
}
-void emitter::dispIns(instrDesc* id)
+void emitter::dispIns(instrDesc* id)
{
-#ifdef DEBUG
+#ifdef DEBUG
emitInsSanityCheck(id);
if (emitComp->opts.dspCode)
- {
emitDispIns(id, true, false, false);
- }
-#if EMIT_TRACK_STACK_DEPTH
+#if EMIT_TRACK_STACK_DEPTH
assert((int)emitCurStackLvl >= 0);
#endif
- size_t sz = emitSizeOfInsDsc(id);
- assert(id->idDebugOnlyInfo()->idSize == sz);
-#endif // DEBUG
+ size_t sz = emitSizeOfInsDsc(id);
+ assert(id->idDebugOnlyInfo()->idSize == sz);
+#endif // DEBUG
-#if EMITTER_STATS
+#if EMITTER_STATS
emitIFcounts[id->idInsFmt()]++;
#endif
}
-void emitter::appendToCurIG(instrDesc* id)
+void emitter::appendToCurIG(instrDesc* id)
{
emitCurIGsize += id->idCodeSize();
#ifdef ARM_HAZARD_AVOIDANCE
//
- // Do we have a T1 instruction or an unbound jump instruction?
+ // Do we have a T1 instruction or an unbound jump instruction?
// (it could be bound to a T1 instruction)
if (id->idInstrIsT1() ||
- (((id->idInsFmt() == IF_T2_J2) || (id->idInsFmt() == IF_T2_J1) || (id->idInsFmt() == IF_LARGEJMP)) &&
- (id->idIsBound() == false)))
+ ( ((id->idInsFmt() == IF_T2_J2) ||
+ (id->idInsFmt() == IF_T2_J1) ||
+ (id->idInsFmt() == IF_LARGEJMP) )
+ && (id->idIsBound() == false) ))
{
if (emitCurInstrCntT1 < MAX_INSTR_COUNT_T1)
{
@@ -1210,21 +1207,18 @@ void emitter::appendToCurIG(instrDesc* id)
* Display (optionally) an instruction offset.
*/
-#ifdef DEBUG
+#ifdef DEBUG
-void emitter::emitDispInsOffs(unsigned offs, bool doffs)
+void emitter::emitDispInsOffs(unsigned offs, bool doffs)
{
- if (doffs)
- {
+ if (doffs)
printf("%06X", offs);
- }
else
- {
printf(" ");
- }
}
-#endif // DEBUG
+#endif // DEBUG
+
#ifdef JIT32_GCENCODER
@@ -1235,22 +1229,22 @@ void emitter::emitDispInsOffs(unsigned offs, bool doffs)
* values returned by the callback.
*/
-size_t emitter::emitGenEpilogLst(size_t (*fp)(void*, unsigned), void* cp)
+size_t emitter::emitGenEpilogLst(size_t (*fp)(void *, unsigned),
+ void *cp)
{
- EpilogList* el;
- size_t sz;
+ EpilogList* el;
+ size_t sz;
for (el = emitEpilogList, sz = 0; el; el = el->elNext)
{
assert(el->elIG->igFlags & IGF_EPILOG);
- UNATIVE_OFFSET ofs =
- el->elIG->igOffs; // The epilog starts at the beginning of the IG, so the IG offset is correct
+ 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);
}
- return sz;
+ return sz;
}
#endif // JIT32_GCENCODER
@@ -1260,9 +1254,9 @@ size_t emitter::emitGenEpilogLst(size_t (*fp)(void*, unsigned), void* cp)
* The following series of methods allocates instruction descriptors.
*/
-void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
+void * emitter::emitAllocInstr(size_t sz, emitAttr opsz)
{
- instrDesc* id;
+ instrDesc * id;
#ifdef DEBUG
// Under STRESS_EMITTER, put every instruction in its own instruction group.
@@ -1273,12 +1267,15 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
// these groups cannot be more than a single instruction group. Note that
// the prolog/epilog placeholder groups ARE generated in order, and are
// re-used. But generating additional groups would not work.
- if (emitComp->compStressCompile(Compiler::STRESS_EMITTER, 1) && emitCurIGinsCnt && !emitIGisInProlog(emitCurIG) &&
- !emitIGisInEpilog(emitCurIG)
+ if (emitComp->compStressCompile(Compiler::STRESS_EMITTER, 1)
+ && emitCurIGinsCnt
+ && !emitIGisInProlog(emitCurIG)
+ && !emitIGisInEpilog(emitCurIG)
#if FEATURE_EH_FUNCLETS
- && !emitIGisInFuncletProlog(emitCurIG) && !emitIGisInFuncletEpilog(emitCurIG)
+ && !emitIGisInFuncletProlog(emitCurIG)
+ && !emitIGisInFuncletEpilog(emitCurIG)
#endif // FEATURE_EH_FUNCLETS
- )
+ )
{
emitNxtIG(true);
}
@@ -1289,17 +1286,18 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
// ARM - This is currently broken on _TARGET_ARM_
// When nopSize is odd we misalign emitCurIGsize
//
- if (!(emitComp->opts.eeFlags & CORJIT_FLG_PREJIT) && !emitInInstrumentation &&
- !emitIGisInProlog(emitCurIG) // don't do this in prolog or epilog
- && !emitIGisInEpilog(emitCurIG) &&
- emitRandomNops // sometimes we turn off where exact codegen is needed (pinvoke inline)
+ if (!(emitComp->opts.eeFlags & CORJIT_FLG_PREJIT)
+ && !emitInInstrumentation
+ && !emitIGisInProlog(emitCurIG) // don't do this in prolog or epilog
+ && !emitIGisInEpilog(emitCurIG)
+ && emitRandomNops // sometimes we turn off where exact codegen is needed (pinvoke inline)
)
{
if (emitNextNop == 0)
{
- int nopSize = 4;
+ int nopSize = 4;
emitInInstrumentation = true;
- instrDesc* idnop = emitNewInstr();
+ instrDesc *idnop = emitNewInstr();
emitInInstrumentation = false;
idnop->idInsFmt(IF_NONE);
idnop->idIns(INS_nop);
@@ -1321,7 +1319,8 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
/* Make sure we have enough space for the new instruction */
- if ((emitCurIGfreeNext + sz >= emitCurIGfreeEndp) || emitForceNewIG)
+ if ((emitCurIGfreeNext + sz >= emitCurIGfreeEndp) ||
+ emitForceNewIG)
{
emitNxtIG(true);
}
@@ -1343,39 +1342,41 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
#if HAS_TINY_DESC
/* Is the second area to be cleared actually present? */
- if (sz >= SMALL_IDSC_SIZE)
+ if (sz >= SMALL_IDSC_SIZE)
{
/* Clear the second 4 bytes, or the 'SMALL' part */
*(int*)((BYTE*)id + (SMALL_IDSC_SIZE - sizeof(int))) = 0;
// These fields should have been zero-ed by the above
- assert(id->idIsLargeCns() == false);
- assert(id->idIsLargeDsp() == false);
+ assert(id->idIsLargeCns() == false);
+ assert(id->idIsLargeDsp() == false);
assert(id->idIsLargeCall() == false);
}
#endif
+
// Make sure that idAddrUnion is just a union of various pointer sized things
- C_ASSERT(sizeof(CORINFO_FIELD_HANDLE) <= sizeof(void*));
- C_ASSERT(sizeof(CORINFO_METHOD_HANDLE) <= sizeof(void*));
- C_ASSERT(sizeof(emitter::emitAddrMode) <= sizeof(void*));
- C_ASSERT(sizeof(emitLclVarAddr) <= sizeof(void*));
- C_ASSERT(sizeof(emitter::instrDesc) == (SMALL_IDSC_SIZE + sizeof(void*)));
+ C_ASSERT(sizeof(CORINFO_FIELD_HANDLE) <= sizeof(void*));
+ C_ASSERT(sizeof(CORINFO_METHOD_HANDLE) <= sizeof(void*));
+ C_ASSERT(sizeof(emitter::emitAddrMode) <= sizeof(void*));
+ C_ASSERT(sizeof(emitLclVarAddr) <= sizeof(void*));
+ C_ASSERT(sizeof(emitter::instrDesc) == (SMALL_IDSC_SIZE + sizeof(void*)));
+
emitInsCount++;
#if defined(DEBUG) || defined(LATE_DISASM)
/* In debug mode we clear/set some additional fields */
- instrDescDebugInfo* info = (instrDescDebugInfo*)emitGetMem(sizeof(*info));
+ instrDescDebugInfo * info = (instrDescDebugInfo *) emitGetMem(sizeof(*info));
info->idNum = emitInsCount;
info->idSize = sz;
info->idVarRefOffs = 0;
info->idMemCookie = 0;
- info->idClsCookie = nullptr;
-#ifdef TRANSLATE_PDB
- info->idilStart = emitInstrDescILBase;
+ info->idClsCookie = 0;
+#ifdef TRANSLATE_PDB
+ info->idilStart = emitInstrDescILBase;
#endif
info->idFinallyCall = false;
info->idCatchRet = false;
@@ -1388,14 +1389,14 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
/* Store the size and handle the two special values
that indicate GCref and ByRef */
- if (EA_IS_GCREF(opsz))
+ if (EA_IS_GCREF(opsz))
{
/* A special value indicates a GCref pointer value */
id->idGCref(GCT_GCREF);
id->idOpSize(EA_PTRSIZE);
}
- else if (EA_IS_BYREF(opsz))
+ else if (EA_IS_BYREF(opsz))
{
/* A special value indicates a Byref pointer value */
@@ -1408,13 +1409,14 @@ 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)
+ if (EA_IS_DSP_RELOC(opsz)
#ifndef _TARGET_AMD64_
- && emitComp->opts.compReloc
+ && emitComp->opts.compReloc
#endif //_TARGET_AMD64_
- )
+ )
{
/* Mark idInfo()->idDspReloc to remember that the */
/* address mode has a displacement that is relocatable */
@@ -1429,7 +1431,7 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
}
#endif
-#if EMITTER_STATS
+#if EMITTER_STATS
emitTotalInsCnt++;
#endif
@@ -1437,34 +1439,40 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz)
emitCurIGinsCnt++;
- return id;
+ return id;
}
-#ifdef DEBUG
+
+#ifdef DEBUG
/*****************************************************************************
*
* Make sure the code offsets of all instruction groups look reasonable.
*/
-void emitter::emitCheckIGoffsets()
+void emitter::emitCheckIGoffsets()
{
- insGroup* tempIG;
- size_t offsIG;
+ insGroup * tempIG;
+ size_t offsIG;
- for (tempIG = emitIGlist, offsIG = 0; tempIG; tempIG = tempIG->igNext)
+ for (tempIG = emitIGlist, offsIG = 0;
+ tempIG;
+ tempIG = tempIG->igNext)
{
- if (tempIG->igOffs != offsIG)
+ if (tempIG->igOffs != offsIG)
{
- printf("Block #%u has offset %08X, expected %08X\n", tempIG->igNum, tempIG->igOffs, offsIG);
+ printf("Block #%u has offset %08X, expected %08X\n", tempIG->igNum,
+ tempIG->igOffs,
+ offsIG);
assert(!"bad block offset");
}
offsIG += tempIG->igSize;
}
- if (emitTotalCodeSize && emitTotalCodeSize != offsIG)
+ if (emitTotalCodeSize && emitTotalCodeSize != offsIG)
{
- printf("Total code size is %08X, expected %08X\n", emitTotalCodeSize, offsIG);
+ printf("Total code size is %08X, expected %08X\n", emitTotalCodeSize,
+ offsIG);
assert(!"bad total code size");
}
@@ -1477,7 +1485,7 @@ void emitter::emitCheckIGoffsets()
* Begin generating a method prolog.
*/
-void emitter::emitBegProlog()
+void emitter::emitBegProlog()
{
assert(emitComp->compGeneratingProlog);
@@ -1491,7 +1499,7 @@ void emitter::emitBegProlog()
#endif
- emitNoGCIG = true;
+ emitNoGCIG = true;
emitForceNewIG = false;
/* Switch to the pre-allocated prolog IG */
@@ -1503,10 +1511,10 @@ void emitter::emitBegProlog()
// These were initialized to Empty at the start of compilation.
VarSetOps::ClearD(emitComp, emitInitGCrefVars);
VarSetOps::ClearD(emitComp, emitPrevGCrefVars);
- emitInitGCrefRegs = RBM_NONE;
- emitPrevGCrefRegs = RBM_NONE;
- emitInitByrefRegs = RBM_NONE;
- emitPrevByrefRegs = RBM_NONE;
+ emitInitGCrefRegs = RBM_NONE;
+ emitPrevGCrefRegs = RBM_NONE;
+ emitInitByrefRegs = RBM_NONE;
+ emitPrevByrefRegs = RBM_NONE;
}
/*****************************************************************************
@@ -1514,14 +1522,14 @@ void emitter::emitBegProlog()
* Return the code offset of the current location in the prolog.
*/
-unsigned emitter::emitGetPrologOffsetEstimate()
+unsigned emitter::emitGetPrologOffsetEstimate()
{
/* For now only allow a single prolog ins group */
assert(emitPrologIG);
assert(emitPrologIG == emitCurIG);
- return emitCurIGsize;
+ return emitCurIGsize;
}
/*****************************************************************************
@@ -1530,7 +1538,7 @@ unsigned emitter::emitGetPrologOffsetEstimate()
* so it can be used later to compute the actual size of the prolog.
*/
-void emitter::emitMarkPrologEnd()
+void emitter::emitMarkPrologEnd()
{
assert(emitComp->compGeneratingProlog);
@@ -1547,22 +1555,20 @@ void emitter::emitMarkPrologEnd()
* Finish generating a method prolog.
*/
-void emitter::emitEndProlog()
+void emitter::emitEndProlog()
{
assert(emitComp->compGeneratingProlog);
- size_t prolSz;
+ size_t prolSz;
- insGroup* tempIG;
+ insGroup * tempIG;
emitNoGCIG = false;
/* Save the prolog IG if non-empty or if only one block */
- if (emitCurIGnonEmpty() || emitCurIG == emitPrologIG)
- {
+ if (emitCurIGnonEmpty() || emitCurIG == emitPrologIG)
emitSavIG();
- }
#if EMIT_TRACK_STACK_DEPTH
/* Reset the stack depth values */
@@ -1572,20 +1578,21 @@ void emitter::emitEndProlog()
#endif
}
+
/*****************************************************************************
*
* Create a placeholder instruction group to be used by a prolog or epilog,
* either for the main function, or a funclet.
*/
-void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
- BasicBlock* igBB,
- VARSET_VALARG_TP GCvars,
- regMaskTP gcrefRegs,
- regMaskTP byrefRegs,
- bool last)
+void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
+ BasicBlock* igBB,
+ VARSET_VALARG_TP GCvars,
+ regMaskTP gcrefRegs,
+ regMaskTP byrefRegs,
+ bool last)
{
- assert(igBB != nullptr);
+ assert(igBB != NULL);
bool emitAdd = false;
@@ -1598,14 +1605,12 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
#ifdef _TARGET_AMD64_
emitOutputPreEpilogNOP();
#endif // _TARGET_AMD64_
-
+
emitAdd = true;
}
if (emitCurIGnonEmpty())
- {
emitNxtIG(emitAdd);
- }
/* Update GC tracking for the beginning of the placeholder IG */
@@ -1619,7 +1624,7 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
/* Convert the group to a placeholder group */
- insGroup* igPh = emitCurIG;
+ insGroup * igPh = emitCurIG;
igPh->igFlags |= IGF_PLACEHOLDER;
@@ -1637,9 +1642,9 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
igPh->igPhData = new (emitComp, CMK_InstDesc) insPlaceholderGroupData;
- igPh->igPhData->igPhNext = nullptr;
- igPh->igPhData->igPhType = igType;
- igPh->igPhData->igPhBB = igBB;
+ igPh->igPhData->igPhNext = NULL;
+ igPh->igPhData->igPhType = igType;
+ igPh->igPhData->igPhBB = igBB;
VarSetOps::AssignNoCopy(emitComp, igPh->igPhData->igPhPrevGCrefVars, VarSetOps::UninitVal());
VarSetOps::Assign(emitComp, igPh->igPhData->igPhPrevGCrefVars, emitPrevGCrefVars);
@@ -1679,20 +1684,16 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
/* Link it into the placeholder list */
if (emitPlaceholderList)
- {
emitPlaceholderLast->igPhData->igPhNext = igPh;
- }
else
- {
- emitPlaceholderList = igPh;
- }
+ emitPlaceholderList = igPh;
emitPlaceholderLast = igPh;
// Give an estimated size of this placeholder IG and
// increment emitCurCodeOffset since we are not calling emitNewIG()
//
- emitCurIGsize += MAX_PLACEHOLDER_IG_SIZE;
+ emitCurIGsize += MAX_PLACEHOLDER_IG_SIZE;
emitCurCodeOffset += emitCurIGsize;
#ifdef DEBUGGING_SUPPORT
@@ -1706,11 +1707,11 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
{
if (igType == IGPT_FUNCLET_PROLOG)
{
- codeGen->genIPmappingAdd((IL_OFFSETX)ICorDebugInfo::PROLOG, true);
+ codeGen->genIPmappingAdd((IL_OFFSETX) ICorDebugInfo::PROLOG, true);
}
else if (igType == IGPT_FUNCLET_EPILOG)
{
- codeGen->genIPmappingAdd((IL_OFFSETX)ICorDebugInfo::EPILOG, true);
+ codeGen->genIPmappingAdd((IL_OFFSETX) ICorDebugInfo::EPILOG, true);
}
}
#endif // FEATURE_EH_FUNCLETS
@@ -1721,7 +1722,7 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
if (last)
{
- emitCurIG = nullptr;
+ emitCurIG = NULL;
}
else
{
@@ -1772,24 +1773,26 @@ void emitter::emitCreatePlaceholderIG(insGroupPlaceholderType igType,
* Generate all prologs and epilogs
*/
-void emitter::emitGeneratePrologEpilog()
+void emitter::emitGeneratePrologEpilog()
{
-#ifdef DEBUG
- unsigned prologCnt = 0;
- unsigned epilogCnt = 0;
+#ifdef DEBUG
+ unsigned prologCnt = 0;
+ unsigned epilogCnt = 0;
#if FEATURE_EH_FUNCLETS
- unsigned funcletPrologCnt = 0;
- unsigned funcletEpilogCnt = 0;
+ unsigned funcletPrologCnt = 0;
+ unsigned funcletEpilogCnt = 0;
#endif // FEATURE_EH_FUNCLETS
#endif // DEBUG
- insGroup* igPh;
- insGroup* igPhNext;
+ insGroup* igPh;
+ insGroup* igPhNext;
// Generating the prolog/epilog is going to destroy the placeholder group,
// so save the "next" pointer before that happens.
- for (igPh = emitPlaceholderList; igPh != nullptr; igPh = igPhNext)
+ for (igPh = emitPlaceholderList;
+ igPh != NULL;
+ igPh = igPhNext)
{
assert(igPh->igFlags & IGF_PLACEHOLDER);
@@ -1799,41 +1802,40 @@ void emitter::emitGeneratePrologEpilog()
switch (igPh->igPhData->igPhType)
{
- case IGPT_PROLOG: // currently unused
- INDEBUG(++prologCnt);
- break;
+ case IGPT_PROLOG: // currently unused
+ INDEBUG(++prologCnt);
+ break;
- case IGPT_EPILOG:
- INDEBUG(++epilogCnt);
- emitBegFnEpilog(igPh);
- codeGen->genFnEpilog(igPhBB);
- emitEndFnEpilog();
- break;
+ case IGPT_EPILOG:
+ INDEBUG(++epilogCnt);
+ emitBegFnEpilog(igPh);
+ codeGen->genFnEpilog(igPhBB);
+ emitEndFnEpilog();
+ break;
#if FEATURE_EH_FUNCLETS
- case IGPT_FUNCLET_PROLOG:
- INDEBUG(++funcletPrologCnt);
- emitBegFuncletProlog(igPh);
- codeGen->genFuncletProlog(igPhBB);
- emitEndFuncletProlog();
- break;
+ case IGPT_FUNCLET_PROLOG:
+ INDEBUG(++funcletPrologCnt);
+ emitBegFuncletProlog(igPh);
+ codeGen->genFuncletProlog(igPhBB);
+ emitEndFuncletProlog();
+ break;
- case IGPT_FUNCLET_EPILOG:
- INDEBUG(++funcletEpilogCnt);
- emitBegFuncletEpilog(igPh);
- codeGen->genFuncletEpilog();
- emitEndFuncletEpilog();
- break;
+ case IGPT_FUNCLET_EPILOG:
+ INDEBUG(++funcletEpilogCnt);
+ emitBegFuncletEpilog(igPh);
+ codeGen->genFuncletEpilog();
+ emitEndFuncletEpilog();
+ break;
#endif // FEATURE_EH_FUNCLETS
- default:
- unreached();
+ default: unreached();
}
}
-#ifdef DEBUG
+#ifdef DEBUG
if (emitComp->verbose)
{
printf("%d prologs, %d epilogs", prologCnt, epilogCnt);
@@ -1842,9 +1844,9 @@ void emitter::emitGeneratePrologEpilog()
#endif // FEATURE_EH_FUNCLETS
printf("\n");
-// prolog/epilog code doesn't use this yet
-// noway_assert(prologCnt == 1);
-// noway_assert(epilogCnt == emitEpilogCnt); // Is this correct?
+ // prolog/epilog code doesn't use this yet
+ // noway_assert(prologCnt == 1);
+ // noway_assert(epilogCnt == emitEpilogCnt); // Is this correct?
#if FEATURE_EH_FUNCLETS
assert(funcletPrologCnt == emitComp->ehFuncletCount());
#endif // FEATURE_EH_FUNCLETS
@@ -1852,31 +1854,29 @@ void emitter::emitGeneratePrologEpilog()
#endif // DEBUG
}
+
/*****************************************************************************
*
* Begin all prolog and epilog generation
*/
-void emitter::emitStartPrologEpilogGeneration()
+void emitter::emitStartPrologEpilogGeneration()
{
/* Save the current IG if it's non-empty */
- if (emitCurIGnonEmpty())
- {
+ if (emitCurIGnonEmpty())
emitSavIG();
- }
else
- {
- assert(emitCurIG == nullptr);
- }
+ assert(emitCurIG == NULL);
}
+
/*****************************************************************************
*
* Finish all prolog and epilog generation
*/
-void emitter::emitFinishPrologEpilogGeneration()
+void emitter::emitFinishPrologEpilogGeneration()
{
/* Update the offsets of all the blocks */
@@ -1884,25 +1884,24 @@ void emitter::emitFinishPrologEpilogGeneration()
/* We should not generate any more code after this */
- emitCurIG = nullptr;
+ emitCurIG = NULL;
}
+
/*****************************************************************************
*
* Common code for prolog / epilog beginning. Convert the placeholder group to actual code IG,
* and set it as the current group.
*/
-void emitter::emitBegPrologEpilog(insGroup* igPh)
+void emitter::emitBegPrologEpilog(insGroup* igPh)
{
assert(igPh->igFlags & IGF_PLACEHOLDER);
/* Save the current IG if it's non-empty */
- if (emitCurIGnonEmpty())
- {
+ if (emitCurIGnonEmpty())
emitSavIG();
- }
/* Convert the placeholder group to a normal group.
* We need to be very careful to re-initialize the IG properly.
@@ -1912,7 +1911,7 @@ void emitter::emitBegPrologEpilog(insGroup* igPh)
*/
igPh->igFlags &= ~IGF_PLACEHOLDER;
- emitNoGCIG = true;
+ emitNoGCIG = true;
emitForceNewIG = false;
/* Set up the GC info that we stored in the placeholder */
@@ -1926,7 +1925,7 @@ void emitter::emitBegPrologEpilog(insGroup* igPh)
emitThisGCrefRegs = emitInitGCrefRegs = igPh->igPhData->igPhInitGCrefRegs;
emitThisByrefRegs = emitInitByrefRegs = igPh->igPhData->igPhInitByrefRegs;
- igPh->igPhData = nullptr;
+ igPh->igPhData = NULL;
/* Create a non-placeholder group pointer that we'll now use */
@@ -1956,16 +1955,14 @@ void emitter::emitBegPrologEpilog(insGroup* igPh)
* Common code for end of prolog / epilog
*/
-void emitter::emitEndPrologEpilog()
+void emitter::emitEndPrologEpilog()
{
emitNoGCIG = false;
/* Save the IG if non-empty */
- if (emitCurIGnonEmpty())
- {
+ if (emitCurIGnonEmpty())
emitSavIG();
- }
assert(emitCurIGsize <= MAX_PLACEHOLDER_IG_SIZE);
@@ -1977,12 +1974,13 @@ void emitter::emitEndPrologEpilog()
#endif
}
+
/*****************************************************************************
*
* Begin generating a main function epilog.
*/
-void emitter::emitBegFnEpilog(insGroup* igPh)
+void emitter::emitBegFnEpilog(insGroup* igPh)
{
emitEpilogCnt++;
@@ -1991,8 +1989,8 @@ void emitter::emitBegFnEpilog(insGroup* igPh)
#ifdef JIT32_GCENCODER
EpilogList* el = new (emitComp, CMK_GC) EpilogList;
- el->elNext = NULL;
- el->elIG = emitCurIG;
+ el->elNext = NULL;
+ el->elIG = emitCurIG;
if (emitEpilogLast)
emitEpilogLast->elNext = el;
@@ -2013,16 +2011,16 @@ void emitter::emitBegFnEpilog(insGroup* igPh)
* Finish generating a funclet epilog.
*/
-void emitter::emitEndFnEpilog()
+void emitter::emitEndFnEpilog()
{
emitEndPrologEpilog();
UNATIVE_OFFSET newSize;
- UNATIVE_OFFSET epilogBegCodeOffset = emitEpilogBegLoc.CodeOffset(this);
+ UNATIVE_OFFSET epilogBegCodeOffset = emitEpilogBegLoc.CodeOffset(this);
#ifdef _TARGET_XARCH_
UNATIVE_OFFSET epilogExitSeqStartCodeOffset = emitExitSeqBegLoc.CodeOffset(this);
#else
- UNATIVE_OFFSET epilogExitSeqStartCodeOffset = emitCodeOffset(emitCurIG, emitCurOffset());
+ UNATIVE_OFFSET epilogExitSeqStartCodeOffset = emitCodeOffset(emitCurIG, emitCurOffset());
#endif
newSize = epilogExitSeqStartCodeOffset - epilogBegCodeOffset;
@@ -2032,30 +2030,32 @@ void emitter::emitEndFnEpilog()
/* 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);
newSize = epilogEndCodeOffset - epilogExitSeqStartCodeOffset;
- if (newSize < emitExitSeqSize)
+ if (newSize < emitExitSeqSize)
{
// We expect either the epilog to be the same every time, or that
// one will be a ret or a ret <n> and others will be a jmp addr or jmp [addr];
// we make the epilogs the minimum of these. Note that this ONLY works
- // because the only instruction is the last one and thus a slight
- // underestimation of the epilog size is harmless (since the EIP
+ // because the only instruction is the last one and thus a slight
+ // underestimation of the epilog size is harmless (since the EIP
// can not be between instructions).
- assert(emitEpilogCnt == 1 ||
- (emitExitSeqSize - newSize) <= 5 // delta between size of various forms of jmp (size is either 6 or 5)
+ assert(emitEpilogCnt == 1 ||
+ (emitExitSeqSize - newSize) <= 5 // delta between size of various forms of jmp (size is either 6 or 5)
// and various forms of ret (size is either 1 or 3). The combination can
// be anything been 1 and 5.
- );
+ );
emitExitSeqSize = newSize;
}
#endif // _TARGET_X86_
+
}
+
#if FEATURE_EH_FUNCLETS
/*****************************************************************************
@@ -2063,7 +2063,7 @@ void emitter::emitEndFnEpilog()
* Begin generating a funclet prolog.
*/
-void emitter::emitBegFuncletProlog(insGroup* igPh)
+void emitter::emitBegFuncletProlog(insGroup* igPh)
{
emitBegPrologEpilog(igPh);
}
@@ -2073,7 +2073,7 @@ void emitter::emitBegFuncletProlog(insGroup* igPh)
* Finish generating a funclet prolog.
*/
-void emitter::emitEndFuncletProlog()
+void emitter::emitEndFuncletProlog()
{
emitEndPrologEpilog();
}
@@ -2083,7 +2083,7 @@ void emitter::emitEndFuncletProlog()
* Begin generating a funclet epilog.
*/
-void emitter::emitBegFuncletEpilog(insGroup* igPh)
+void emitter::emitBegFuncletEpilog(insGroup* igPh)
{
emitBegPrologEpilog(igPh);
}
@@ -2093,7 +2093,7 @@ void emitter::emitBegFuncletEpilog(insGroup* igPh)
* Finish generating a funclet epilog.
*/
-void emitter::emitEndFuncletEpilog()
+void emitter::emitEndFuncletEpilog()
{
emitEndPrologEpilog();
}
@@ -2108,12 +2108,12 @@ void emitter::emitEndFuncletEpilog()
* at the very end of the method body.
*/
-bool emitter::emitHasEpilogEnd()
+bool emitter::emitHasEpilogEnd()
{
- if (emitEpilogCnt == 1 && (emitIGlast->igFlags & IGF_EPILOG)) // This wouldn't work for funclets
- return true;
+ if (emitEpilogCnt == 1 && (emitIGlast->igFlags & IGF_EPILOG)) // This wouldn't work for funclets
+ return true;
else
- return false;
+ return false;
}
#endif // JIT32_GCENCODER
@@ -2125,7 +2125,7 @@ bool emitter::emitHasEpilogEnd()
* Mark the beginning of the epilog exit sequence by remembering our position.
*/
-void emitter::emitStartExitSeq()
+void emitter::emitStartExitSeq()
{
assert(emitComp->compGeneratingEpilog);
@@ -2144,12 +2144,12 @@ void emitter::emitStartExitSeq()
* offsHi - The FP offset at which the GC pointer region ends (exclusive).
*/
-void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi)
+void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi)
{
assert(emitComp->compGeneratingProlog);
assert(offsHi > offsLo);
-#ifdef DEBUG
+#ifdef DEBUG
// A total of 47254 methods compiled.
//
@@ -2167,19 +2167,19 @@ void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi)
// 257 .. 512 ===> 4 count (100% of total)
// 513 .. 1024 ===> 0 count (100% of total)
- if (emitComp->verbose)
+ if (emitComp->verbose)
{
unsigned count = (offsHi - offsLo) / sizeof(void*);
printf("%u tracked GC refs are at stack offsets ", count);
- if (offsLo >= 0)
+ if (offsLo >= 0)
{
- printf(" %04X ... %04X\n", offsLo, offsHi);
+ printf(" %04X ... %04X\n", offsLo, offsHi);
assert(offsHi >= 0);
}
else
#if defined(_TARGET_ARM_) && defined(PROFILING_SUPPORTED)
- if (!emitComp->compIsProfilerHookNeeded())
+ if (!emitComp->compIsProfilerHookNeeded())
#endif
{
#ifdef _TARGET_AMD64_
@@ -2189,6 +2189,7 @@ void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi)
printf("-%04X ... -%04X\n", -offsLo, -offsHi);
assert(offsHi <= 0);
#endif
+
}
#if defined(_TARGET_ARM_) && defined(PROFILING_SUPPORTED)
else
@@ -2200,6 +2201,7 @@ void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi)
printf("-%04X ... %04X\n", -offsLo, offsHi);
}
#endif
+
}
#endif // DEBUG
@@ -2219,7 +2221,7 @@ void emitter::emitSetFrameRangeGCRs(int offsLo, int offsHi)
* method.
*/
-void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi)
+void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi)
{
}
@@ -2229,7 +2231,7 @@ void emitter::emitSetFrameRangeLcls(int offsLo, int offsHi)
* method.
*/
-void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi)
+void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi)
{
}
@@ -2239,16 +2241,51 @@ void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi)
* small encoding (0 through 3), and vice versa.
*/
-const emitter::opSize emitter::emitSizeEncode[] = {
- emitter::OPSZ1, emitter::OPSZ2, OPSIZE_INVALID, emitter::OPSZ4, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID,
- emitter::OPSZ8, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID,
- OPSIZE_INVALID, emitter::OPSZ16, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID,
- OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID,
- OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, emitter::OPSZ32,
+const emitter::opSize emitter::emitSizeEncode[] =
+{
+ emitter::OPSZ1,
+ emitter::OPSZ2,
+ OPSIZE_INVALID,
+ emitter::OPSZ4,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ emitter::OPSZ8,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ emitter::OPSZ16,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ OPSIZE_INVALID,
+ emitter::OPSZ32,
};
-const emitAttr emitter::emitSizeDecode[emitter::OPSZ_COUNT] = {EA_1BYTE, EA_2BYTE, EA_4BYTE,
- EA_8BYTE, EA_16BYTE, EA_32BYTE};
+const emitAttr emitter::emitSizeDecode[emitter::OPSZ_COUNT] =
+{
+ EA_1BYTE,
+ EA_2BYTE,
+ EA_4BYTE,
+ EA_8BYTE,
+ EA_16BYTE,
+ EA_32BYTE
+};
/*****************************************************************************
*
@@ -2256,13 +2293,13 @@ const emitAttr emitter::emitSizeDecode[emitter::OPSZ_COUNT] = {EA_1BYTE, EA_2BYT
* a displacement and a constant.
*/
-emitter::instrDesc* emitter::emitNewInstrCnsDsp(emitAttr size, ssize_t cns, int dsp)
+emitter::instrDesc * emitter::emitNewInstrCnsDsp(emitAttr size, ssize_t cns, int dsp)
{
- if (dsp == 0)
+ if (dsp == 0)
{
if (instrDesc::fitsInSmallCns(cns))
{
- instrDesc* id = emitAllocInstr(size);
+ instrDesc *id = emitAllocInstr (size);
id->idSmallCns(cns);
@@ -2272,31 +2309,31 @@ emitter::instrDesc* emitter::emitNewInstrCnsDsp(emitAttr size, ssize_t cns, int
emitSmallDspCnt++;
#endif
- return id;
+ return id;
}
else
{
- instrDescCns* id = emitAllocInstrCns(size);
+ instrDescCns *id = emitAllocInstrCns (size);
id->idSetIsLargeCns();
- id->idcCnsVal = cns;
+ id->idcCnsVal = cns;
#if EMITTER_STATS
emitLargeCnsCnt++;
emitSmallDspCnt++;
#endif
- return id;
+ return id;
}
}
else
{
if (instrDesc::fitsInSmallCns(cns))
{
- instrDescDsp* id = emitAllocInstrDsp(size);
+ instrDescDsp *id = emitAllocInstrDsp (size);
id->idSetIsLargeDsp();
- id->iddDspVal = dsp;
+ id->iddDspVal = dsp;
id->idSmallCns(cns);
@@ -2306,11 +2343,11 @@ emitter::instrDesc* emitter::emitNewInstrCnsDsp(emitAttr size, ssize_t cns, int
emitSmallCns[cns - ID_MIN_SMALL_CNS]++;
#endif
- return id;
+ return id;
}
else
{
- instrDescCnsDsp* id = emitAllocInstrCnsDsp(size);
+ instrDescCnsDsp*id = emitAllocInstrCnsDsp(size);
id->idSetIsLargeCns();
id->iddcCnsVal = cns;
@@ -2323,7 +2360,7 @@ emitter::instrDesc* emitter::emitNewInstrCnsDsp(emitAttr size, ssize_t cns, int
emitLargeCnsCnt++;
#endif
- return id;
+ return id;
}
}
}
@@ -2334,23 +2371,23 @@ emitter::instrDesc* emitter::emitNewInstrCnsDsp(emitAttr size, ssize_t cns, int
* Don't need to record live pointers for such call sites.
*/
-bool emitter::emitNoGChelper(unsigned IHX)
+bool emitter::emitNoGChelper(unsigned IHX)
{
// TODO-Throughput: Make this faster (maybe via a simple table of bools?)
switch (IHX)
{
- case CORINFO_HELP_UNDEF:
- return false;
+ case CORINFO_HELP_UNDEF:
+ return false;
- case CORINFO_HELP_PROF_FCN_LEAVE:
- case CORINFO_HELP_PROF_FCN_ENTER:
+ case CORINFO_HELP_PROF_FCN_LEAVE:
+ case CORINFO_HELP_PROF_FCN_ENTER:
#ifdef _TARGET_AMD64_
- case CORINFO_HELP_PROF_FCN_TAILCALL:
+ case CORINFO_HELP_PROF_FCN_TAILCALL:
#endif
- case CORINFO_HELP_LLSH:
- case CORINFO_HELP_LRSH:
- case CORINFO_HELP_LRSZ:
+ case CORINFO_HELP_LLSH:
+ case CORINFO_HELP_LRSH:
+ case CORINFO_HELP_LRSZ:
// case CORINFO_HELP_LMUL:
// case CORINFO_HELP_LDIV:
@@ -2359,37 +2396,37 @@ bool emitter::emitNoGChelper(unsigned IHX)
// case CORINFO_HELP_ULMOD:
#ifdef _TARGET_X86_
- case CORINFO_HELP_ASSIGN_REF_EAX:
- case CORINFO_HELP_ASSIGN_REF_ECX:
- case CORINFO_HELP_ASSIGN_REF_EBX:
- case CORINFO_HELP_ASSIGN_REF_EBP:
- case CORINFO_HELP_ASSIGN_REF_ESI:
- case CORINFO_HELP_ASSIGN_REF_EDI:
-
- case CORINFO_HELP_CHECKED_ASSIGN_REF_EAX:
- case CORINFO_HELP_CHECKED_ASSIGN_REF_ECX:
- case CORINFO_HELP_CHECKED_ASSIGN_REF_EBX:
- case CORINFO_HELP_CHECKED_ASSIGN_REF_EBP:
- case CORINFO_HELP_CHECKED_ASSIGN_REF_ESI:
- case CORINFO_HELP_CHECKED_ASSIGN_REF_EDI:
-#endif
+ case CORINFO_HELP_ASSIGN_REF_EAX:
+ case CORINFO_HELP_ASSIGN_REF_ECX:
+ case CORINFO_HELP_ASSIGN_REF_EBX:
+ case CORINFO_HELP_ASSIGN_REF_EBP:
+ case CORINFO_HELP_ASSIGN_REF_ESI:
+ case CORINFO_HELP_ASSIGN_REF_EDI:
- case CORINFO_HELP_ASSIGN_REF:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF_EAX:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF_ECX:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF_EBX:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF_EBP:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF_ESI:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF_EDI:
+#endif
- case CORINFO_HELP_CHECKED_ASSIGN_REF:
+ case CORINFO_HELP_ASSIGN_REF:
- case CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR:
+ case CORINFO_HELP_CHECKED_ASSIGN_REF:
- case CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR:
+ case CORINFO_HELP_GETSHARED_GCSTATIC_BASE_NOCTOR:
+
+ case CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR:
- case CORINFO_HELP_ASSIGN_BYREF:
+ case CORINFO_HELP_ASSIGN_BYREF:
- case CORINFO_HELP_INIT_PINVOKE_FRAME:
+ case CORINFO_HELP_INIT_PINVOKE_FRAME:
- return true;
+ return true;
}
- return false;
+ return false;
}
/*****************************************************************************
@@ -2397,14 +2434,15 @@ bool emitter::emitNoGChelper(unsigned IHX)
* Mark the current spot as having a label.
*/
-void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, BOOL isFinallyTarget)
+void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars,
+ regMaskTP gcrefRegs,
+ regMaskTP byrefRegs,
+ BOOL isFinallyTarget)
{
/* Create a new IG if the current one is non-empty */
if (emitCurIGnonEmpty())
- {
emitNxtIG();
- }
VarSetOps::Assign(emitComp, emitThisGCrefVars, GCvars);
VarSetOps::Assign(emitComp, emitInitGCrefVars, GCvars);
@@ -2418,30 +2456,31 @@ void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMas
}
#endif // FEATURE_EH_FUNCLETS && defined(_TARGET_ARM_)
-#ifdef DEBUG
+#ifdef DEBUG
if (EMIT_GC_VERBOSE)
{
printf("Label: IG%02u, GCvars=%s ", emitCurIG->igNum, VarSetOps::ToString(emitComp, GCvars));
dumpConvertedVarSet(emitComp, GCvars);
printf(", gcrefRegs=");
printRegMaskInt(gcrefRegs);
- emitDispRegSet(gcrefRegs);
+ emitDispRegSet (gcrefRegs);
printf(", byrefRegs=");
printRegMaskInt(byrefRegs);
- emitDispRegSet(byrefRegs);
+ emitDispRegSet (byrefRegs);
printf("\n");
}
#endif
return emitCurIG;
}
+
#ifdef _TARGET_ARMARCH_
// Does the argument location point to an IG at the end of a function or funclet?
// We can ignore the codePos part of the location, since it doesn't affect the
// determination. If 'emitLocNextFragment' is non-NULL, it indicates the first
// IG of the next fragment, so it represents a function end.
-bool emitter::emitIsFuncEnd(emitLocation* emitLoc, emitLocation* emitLocNextFragment /* = NULL */)
+bool emitter::emitIsFuncEnd(emitLocation* emitLoc, emitLocation* emitLocNextFragment /* = NULL */)
{
assert(emitLoc);
@@ -2463,7 +2502,8 @@ bool emitter::emitIsFuncEnd(emitLocation* emitLoc, emitLocation* emitLocNextFrag
#if FEATURE_EH_FUNCLETS
// Is the next IG a placeholder group for a funclet prolog?
- if ((ig->igNext->igFlags & IGF_PLACEHOLDER) && (ig->igNext->igPhData->igPhType == IGPT_FUNCLET_PROLOG))
+ if ((ig->igNext->igFlags & IGF_PLACEHOLDER) &&
+ (ig->igNext->igPhData->igPhType == IGPT_FUNCLET_PROLOG))
{
return true;
}
@@ -2473,6 +2513,7 @@ bool emitter::emitIsFuncEnd(emitLocation* emitLoc, emitLocation* emitLocNextFrag
return false;
}
+
/*****************************************************************************
*
* Split the region from 'startLoc' to 'endLoc' into fragments by calling
@@ -2494,23 +2535,20 @@ bool emitter::emitIsFuncEnd(emitLocation* emitLoc, emitLocation* emitLocNextFrag
* If 'endLoc' is NULL, it means the end of the code.
*/
-void emitter::emitSplit(emitLocation* startLoc,
- emitLocation* endLoc,
- UNATIVE_OFFSET maxSplitSize,
- void* context,
- emitSplitCallbackType callbackFunc)
-{
- insGroup* igStart = (startLoc == NULL) ? emitIGlist : startLoc->GetIG();
- insGroup* igEnd = (endLoc == NULL) ? NULL : endLoc->GetIG();
- insGroup* igPrev;
- insGroup* ig;
- insGroup* igLastReported;
- insGroup* igLastCandidate;
- UNATIVE_OFFSET curSize;
- UNATIVE_OFFSET candidateSize;
+void emitter::emitSplit(emitLocation* startLoc, emitLocation* endLoc, UNATIVE_OFFSET maxSplitSize, void* context, emitSplitCallbackType callbackFunc)
+{
+ insGroup* igStart = (startLoc == NULL) ? emitIGlist : startLoc->GetIG();
+ insGroup* igEnd = (endLoc == NULL) ? NULL : endLoc->GetIG();
+ insGroup* igPrev;
+ insGroup* ig;
+ insGroup* igLastReported;
+ insGroup* igLastCandidate;
+ UNATIVE_OFFSET curSize;
+ UNATIVE_OFFSET candidateSize;
for (igPrev = NULL, ig = igLastReported = igStart, igLastCandidate = NULL, candidateSize = 0, curSize = 0;
- ig != igEnd && ig != NULL; igPrev = ig, ig = ig->igNext)
+ ig != igEnd && ig != NULL;
+ igPrev = ig , ig = ig->igNext)
{
// Keep looking until we've gone past the maximum split size
if (curSize >= maxSplitSize)
@@ -2527,8 +2565,7 @@ void emitter::emitSplit(emitLocation* startLoc,
reportCandidate = false;
}
- // Don't report the same thing twice (this also happens for the first block, since igLastReported is
- // initialized to igStart).
+ // Don't report the same thing twice (this also happens for the first block, since igLastReported is initialized to igStart).
if (igLastCandidate == igLastReported)
{
#ifdef DEBUG
@@ -2543,14 +2580,13 @@ void emitter::emitSplit(emitLocation* startLoc,
{
#ifdef DEBUG
if (EMITVERBOSE && (candidateSize >= maxSplitSize))
- printf("emitSplit: split at IG%02u is size %d, larger than requested maximum size of %d\n",
- igLastCandidate->igNum, candidateSize, maxSplitSize);
+ printf("emitSplit: split at IG%02u is size %d, larger than requested maximum size of %d\n", igLastCandidate->igNum, candidateSize, maxSplitSize);
#endif
// hand memory ownership to the callback function
emitLocation* pEmitLoc = new (emitComp, CMK_Unknown) emitLocation(igLastCandidate);
callbackFunc(context, pEmitLoc);
- igLastReported = igLastCandidate;
+ igLastReported = igLastCandidate;
igLastCandidate = NULL;
curSize -= candidateSize;
}
@@ -2561,15 +2597,19 @@ void emitter::emitSplit(emitLocation* startLoc,
// IGs are marked as prolog or epilog. We don't actually know if two adjacent
// IGs are part of the *same* prolog or epilog, so we have to assume they are.
- if (igPrev && (((igPrev->igFlags & IGF_FUNCLET_PROLOG) && (ig->igFlags & IGF_FUNCLET_PROLOG)) ||
- ((igPrev->igFlags & IGF_EPILOG) && (ig->igFlags & IGF_EPILOG))))
+ if (igPrev &&
+ (
+ ((igPrev->igFlags & IGF_FUNCLET_PROLOG) && (ig->igFlags & IGF_FUNCLET_PROLOG)) ||
+ ((igPrev->igFlags & IGF_EPILOG) && (ig->igFlags & IGF_EPILOG))
+ )
+ )
{
// We can't update the candidate
}
else
{
igLastCandidate = ig;
- candidateSize = curSize;
+ candidateSize = curSize;
}
curSize += ig->igSize;
@@ -2577,6 +2617,7 @@ void emitter::emitSplit(emitLocation* startLoc,
} // end for loop
}
+
/*****************************************************************************
*
* Given an instruction group, find the array of instructions (instrDesc) and
@@ -2587,23 +2628,24 @@ void emitter::emitSplit(emitLocation* startLoc,
* This function can't be called for placeholder groups, which have no instrDescs.
*/
-void emitter::emitGetInstrDescs(insGroup* ig, instrDesc** id, int* insCnt)
+void emitter::emitGetInstrDescs(insGroup* ig, instrDesc** id, int* insCnt)
{
assert(!(ig->igFlags & IGF_PLACEHOLDER));
if (ig == emitCurIG)
{
- *id = (instrDesc*)emitCurIGfreeBase;
+ *id = (instrDesc*)emitCurIGfreeBase;
*insCnt = emitCurIGinsCnt;
}
else
{
- *id = (instrDesc*)ig->igData;
+ *id = (instrDesc*)ig->igData;
*insCnt = ig->igInsCnt;
}
assert(*id);
}
+
/*****************************************************************************
*
* Given a location (an 'emitLocation'), find the instruction group (IG) and
@@ -2620,10 +2662,7 @@ void emitter::emitGetInstrDescs(insGroup* ig, instrDesc** id, int* insCnt)
* adding code, namely, the end of currently generated code.
*/
-bool emitter::emitGetLocationInfo(emitLocation* emitLoc,
- insGroup** pig,
- instrDesc** pid,
- int* pinsRemaining /* = NULL */)
+bool emitter::emitGetLocationInfo(emitLocation* emitLoc, insGroup** pig, instrDesc** pid, int* pinsRemaining /* = NULL */)
{
assert(emitLoc != nullptr);
assert(emitLoc->Valid());
@@ -2631,10 +2670,10 @@ bool emitter::emitGetLocationInfo(emitLocation* emitLoc,
assert(pig != nullptr);
assert(pid != nullptr);
- insGroup* ig = emitLoc->GetIG();
- instrDesc* id;
- int insNum = emitLoc->GetInsNum();
- int insCnt;
+ insGroup* ig = emitLoc->GetIG();
+ instrDesc* id;
+ int insNum = emitLoc->GetInsNum();
+ int insCnt;
emitGetInstrDescs(ig, &id, &insCnt);
assert(insNum <= insCnt);
@@ -2686,7 +2725,7 @@ bool emitter::emitGetLocationInfo(emitLocation* emitLoc,
int i;
for (i = 0; i != insNum; ++i)
{
- castto(id, BYTE*) += emitSizeOfInsDsc(id);
+ castto(id, BYTE *) += emitSizeOfInsDsc(id);
}
// Return the info we found
@@ -2702,6 +2741,7 @@ bool emitter::emitGetLocationInfo(emitLocation* emitLoc,
return true;
}
+
/*****************************************************************************
*
* Compute the next instrDesc, either in this IG, or in a subsequent IG. 'id'
@@ -2710,11 +2750,11 @@ bool emitter::emitGetLocationInfo(emitLocation* emitLoc,
* the instructions up to the current instruction (based on 'emitCurIG').
*/
-bool emitter::emitNextID(insGroup*& ig, instrDesc*& id, int& insRemaining)
+bool emitter::emitNextID(insGroup*& ig, instrDesc*& id, int& insRemaining)
{
if (insRemaining > 0)
{
- castto(id, BYTE*) += emitSizeOfInsDsc(id);
+ castto(id, BYTE *) += emitSizeOfInsDsc(id);
--insRemaining;
return true;
}
@@ -2746,6 +2786,7 @@ bool emitter::emitNextID(insGroup*& ig, instrDesc*& id, int& insRemaining)
return false;
}
+
/*****************************************************************************
*
* Walk instrDesc's from the location given by 'locFrom', up to the current location.
@@ -2753,11 +2794,11 @@ bool emitter::emitNextID(insGroup*& ig, instrDesc*& id, int& insRemaining)
* passed through to the callback function.
*/
-void emitter::emitWalkIDs(emitLocation* locFrom, emitProcessInstrFunc_t processFunc, void* context)
+void emitter::emitWalkIDs(emitLocation* locFrom, emitProcessInstrFunc_t processFunc, void* context)
{
- insGroup* ig;
- instrDesc* id;
- int insRemaining;
+ insGroup * ig;
+ instrDesc * id;
+ int insRemaining;
if (!emitGetLocationInfo(locFrom, &ig, &id, &insRemaining))
return; // no instructions at the 'from' location
@@ -2770,12 +2811,13 @@ void emitter::emitWalkIDs(emitLocation* locFrom, emitProcessInstrFunc_t processF
} while (emitNextID(ig, id, insRemaining));
}
+
/*****************************************************************************
*
* A callback function for emitWalkIDs() that calls Compiler::unwindNop().
*/
-void emitter::emitGenerateUnwindNop(instrDesc* id, void* context)
+void emitter::emitGenerateUnwindNop(instrDesc* id, void* context)
{
Compiler* comp = (Compiler*)context;
#if defined(_TARGET_ARM_)
@@ -2785,13 +2827,14 @@ void emitter::emitGenerateUnwindNop(instrDesc* id, void* context)
#endif // defined(_TARGET_ARM64_)
}
+
/*****************************************************************************
*
* emitUnwindNopPadding: call unwindNop() for every instruction from a given
* location 'emitLoc' up to the current location.
*/
-void emitter::emitUnwindNopPadding(emitLocation* locFrom, Compiler* comp)
+void emitter::emitUnwindNopPadding(emitLocation* locFrom, Compiler* comp)
{
emitWalkIDs(locFrom, emitGenerateUnwindNop, comp);
}
@@ -2810,36 +2853,32 @@ void emitter::emitUnwindNopPadding(emitLocation* locFrom, Compiler* comp)
* An instruction must exist at the specified location.
*/
-unsigned emitter::emitGetInstructionSize(emitLocation* emitLoc)
+unsigned emitter::emitGetInstructionSize(emitLocation* emitLoc)
{
- insGroup* ig;
- instrDesc* id;
+ insGroup* ig;
+ instrDesc* id;
bool anyInstrs = emitGetLocationInfo(emitLoc, &ig, &id);
- assert(anyInstrs); // There better be an instruction at this location (otherwise, we're at the end of the
- // instruction list)
+ assert(anyInstrs); // There better be an instruction at this location (otherwise, we're at the end of the instruction list)
return id->idCodeSize();
}
#endif // defined(_TARGET_ARM_)
+
/*****************************************************************************/
-#ifdef DEBUG
+#ifdef DEBUG
/*****************************************************************************
*
* Returns the name for the register to use to access frame based variables
*/
-const char* emitter::emitGetFrameReg()
+const char * emitter::emitGetFrameReg()
{
if (emitHasFramePtr)
- {
return STR_FPBASE;
- }
else
- {
return STR_SPBASE;
- }
}
/*****************************************************************************
@@ -2847,28 +2886,22 @@ const char* emitter::emitGetFrameReg()
* Display a register set in a readable form.
*/
-void emitter::emitDispRegSet(regMaskTP regs)
+void emitter::emitDispRegSet(regMaskTP regs)
{
- regNumber reg;
- bool sp = false;
+ regNumber reg;
+ bool sp = false;
printf(" {");
for (reg = REG_FIRST; reg < ACTUAL_REG_COUNT; reg = REG_NEXT(reg))
{
- if ((regs & genRegMask(reg)) == 0)
- {
+ if ((regs & genRegMask(reg)) == 0)
continue;
- }
- if (sp)
- {
+ if (sp)
printf(" ");
- }
else
- {
sp = true;
- }
printf("%s", emitRegName(reg));
}
@@ -2881,35 +2914,29 @@ void emitter::emitDispRegSet(regMaskTP regs)
* Display the current GC ref variable set in a readable form.
*/
-void emitter::emitDispVarSet()
+void emitter::emitDispVarSet()
{
- unsigned vn;
- int of;
- bool sp = false;
+ unsigned vn;
+ int of;
+ bool sp = false;
- for (vn = 0, of = emitGCrFrameOffsMin; vn < emitGCrFrameOffsCnt; vn += 1, of += sizeof(void*))
+ for (vn = 0, of = emitGCrFrameOffsMin;
+ vn < emitGCrFrameOffsCnt;
+ vn += 1, of += sizeof(void *))
{
- if (emitGCrFrameLiveTab[vn])
+ if (emitGCrFrameLiveTab[vn])
{
- if (sp)
- {
+ if (sp)
printf(" ");
- }
else
- {
sp = true;
- }
printf("[%s", emitGetFrameReg());
- if (of < 0)
- {
+ if (of < 0)
printf("-%02XH", -of);
- }
else if (of > 0)
- {
printf("+%02XH", +of);
- }
printf("]");
}
@@ -2922,21 +2949,21 @@ void emitter::emitDispVarSet()
}
/*****************************************************************************/
-#endif // DEBUG
+#endif//DEBUG
#if MULTIREG_HAS_SECOND_GC_RET
-//------------------------------------------------------------------------
-// emitSetSecondRetRegGCType: Sets the GC type of the second return register for instrDescCGCA struct.
-//
-// Arguments:
-// id - The large call instr descriptor to set the second GC return register type on.
-// secondRetSize - The EA_SIZE for second return register type.
-//
-// Return Value:
-// None
-//
-
-void emitter::emitSetSecondRetRegGCType(instrDescCGCA* id, emitAttr secondRetSize)
+//------------------------------------------------------------------------
+// emitSetSecondRetRegGCType: Sets the GC type of the second return register for instrDescCGCA struct.
+//
+// Arguments:
+// id - The large call instr descriptor to set the second GC return register type on.
+// secondRetSize - The EA_SIZE for second return register type.
+//
+// Return Value:
+// None
+//
+
+void emitter::emitSetSecondRetRegGCType(instrDescCGCA* id, emitAttr secondRetSize)
{
if (EA_IS_GCREF(secondRetSize))
{
@@ -2964,35 +2991,36 @@ void emitter::emitSetSecondRetRegGCType(instrDescCGCA* id, emitAttr secondRetSiz
* address mode displacement.
*/
-emitter::instrDesc* emitter::emitNewInstrCallInd(int argCnt,
- ssize_t disp,
- VARSET_VALARG_TP GCvars,
- regMaskTP gcrefRegs,
- regMaskTP byrefRegs,
- emitAttr retSizeIn
- MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize))
+emitter::instrDesc * emitter::emitNewInstrCallInd(int argCnt,
+ ssize_t disp,
+ VARSET_VALARG_TP GCvars,
+ regMaskTP gcrefRegs,
+ regMaskTP byrefRegs,
+ emitAttr retSizeIn
+ MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize))
{
- emitAttr retSize = (retSizeIn != EA_UNKNOWN) ? retSizeIn : EA_PTRSIZE;
+ emitAttr retSize = (retSizeIn != EA_UNKNOWN) ? retSizeIn : EA_PTRSIZE;
bool gcRefRegsInScratch = ((gcrefRegs & RBM_CALLEE_TRASH) != 0);
-
+
// Allocate a larger descriptor if any GC values need to be saved
// or if we have an absurd number of arguments or a large address
// mode displacement, or we have some byref registers
- //
- // On Amd64 System V OSs a larger descriptor is also needed if the
- // call returns a two-register-returned struct and the second
+ //
+ // On Amd64 System V OSs a larger descriptor is also needed if the
+ // call returns a two-register-returned struct and the second
// register (RDX) is a GCRef or ByRef pointer.
- if (!VarSetOps::IsEmpty(emitComp, GCvars) || // any frame GCvars live
- (gcRefRegsInScratch) || // any register gc refs live in scratch regs
- (byrefRegs != 0) || // any register byrefs live
- (disp < AM_DISP_MIN) || // displacement too negative
- (disp > AM_DISP_MAX) || // displacement too positive
- (argCnt > ID_MAX_SMALL_CNS) || // too many args
- (argCnt < 0) // caller pops arguments
- // There is a second ref/byref return register.
- MULTIREG_HAS_SECOND_GC_RET_ONLY(|| EA_IS_GCREF_OR_BYREF(secondRetSize)))
+
+ if (!VarSetOps::IsEmpty(emitComp, GCvars) || // any frame GCvars live
+ (gcRefRegsInScratch) || // any register gc refs live in scratch regs
+ (byrefRegs != 0) || // any register byrefs live
+ (disp < AM_DISP_MIN) || // displacement too negative
+ (disp > AM_DISP_MAX) || // displacement too positive
+ (argCnt > ID_MAX_SMALL_CNS) || // too many args
+ (argCnt < 0) // caller pops arguments
+ // There is a second ref/byref return register.
+ MULTIREG_HAS_SECOND_GC_RET_ONLY( || EA_IS_GCREF_OR_BYREF(secondRetSize)))
{
instrDescCGCA* id;
@@ -3001,20 +3029,20 @@ emitter::instrDesc* emitter::emitNewInstrCallInd(int argCnt,
id->idSetIsLargeCall();
VarSetOps::Assign(emitComp, id->idcGCvars, GCvars);
- id->idcGcrefRegs = gcrefRegs;
- id->idcByrefRegs = byrefRegs;
- id->idcArgCnt = argCnt;
- id->idcDisp = disp;
+ id->idcGcrefRegs = gcrefRegs;
+ id->idcByrefRegs = byrefRegs;
+ id->idcArgCnt = argCnt;
+ id->idcDisp = disp;
-#if MULTIREG_HAS_SECOND_GC_RET
+#if MULTIREG_HAS_SECOND_GC_RET
emitSetSecondRetRegGCType(id, secondRetSize);
-#endif // MULTIREG_HAS_SECOND_GC_RET
+#endif // MULTIREG_HAS_SECOND_GC_RET
- return id;
+ return id;
}
else
{
- instrDesc* id;
+ instrDesc * id;
id = emitNewInstrCns(retSize, argCnt);
@@ -3022,13 +3050,13 @@ emitter::instrDesc* emitter::emitNewInstrCallInd(int argCnt,
assert(!id->idIsLargeCns());
/* Store the displacement and make sure the value fit */
- id->idAddr()->iiaAddrMode.amDisp = disp;
+ id->idAddr()->iiaAddrMode.amDisp = disp;
assert(id->idAddr()->iiaAddrMode.amDisp == disp);
/* Save the the live GC registers in the unused register fields */
emitEncodeCallGCregs(gcrefRegs, id);
- return id;
+ return id;
}
}
@@ -3043,32 +3071,32 @@ emitter::instrDesc* emitter::emitNewInstrCallInd(int argCnt,
* and an arbitrarily large argument count.
*/
-emitter::instrDesc* emitter::emitNewInstrCallDir(int argCnt,
- VARSET_VALARG_TP GCvars,
- regMaskTP gcrefRegs,
- regMaskTP byrefRegs,
- emitAttr retSizeIn
- MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize))
+emitter::instrDesc *emitter::emitNewInstrCallDir(int argCnt,
+ VARSET_VALARG_TP GCvars,
+ regMaskTP gcrefRegs,
+ regMaskTP byrefRegs,
+ emitAttr retSizeIn
+ MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize))
{
- emitAttr retSize = (retSizeIn != EA_UNKNOWN) ? retSizeIn : EA_PTRSIZE;
+ emitAttr retSize = (retSizeIn != EA_UNKNOWN) ? retSizeIn : EA_PTRSIZE;
// Allocate a larger descriptor if new GC values need to be saved
// or if we have an absurd number of arguments or if we need to
// save the scope.
- //
- // On Amd64 System V OSs a larger descriptor is also needed if the
- // call returns a two-register-returned struct and the second
+ //
+ // On Amd64 System V OSs a larger descriptor is also needed if the
+ // call returns a two-register-returned struct and the second
// register (RDX) is a GCRef or ByRef pointer.
bool gcRefRegsInScratch = ((gcrefRegs & RBM_CALLEE_TRASH) != 0);
- if (!VarSetOps::IsEmpty(emitComp, GCvars) || // any frame GCvars live
- gcRefRegsInScratch || // any register gc refs live in scratch regs
- (byrefRegs != 0) || // any register byrefs live
- (argCnt > ID_MAX_SMALL_CNS) || // too many args
- (argCnt < 0) // caller pops arguments
- // There is a second ref/byref return register.
- MULTIREG_HAS_SECOND_GC_RET_ONLY(|| EA_IS_GCREF_OR_BYREF(secondRetSize)))
+ if (!VarSetOps::IsEmpty(emitComp, GCvars) || // any frame GCvars live
+ gcRefRegsInScratch || // any register gc refs live in scratch regs
+ (byrefRegs != 0) || // any register byrefs live
+ (argCnt > ID_MAX_SMALL_CNS) || // too many args
+ (argCnt < 0) // caller pops arguments
+ // There is a second ref/byref return register.
+ MULTIREG_HAS_SECOND_GC_RET_ONLY( || EA_IS_GCREF_OR_BYREF(secondRetSize)))
{
instrDescCGCA* id = emitAllocInstrCGCA(retSize);
@@ -3077,20 +3105,20 @@ emitter::instrDesc* emitter::emitNewInstrCallDir(int argCnt,
id->idSetIsLargeCall();
VarSetOps::Assign(emitComp, id->idcGCvars, GCvars);
- id->idcGcrefRegs = gcrefRegs;
- id->idcByrefRegs = byrefRegs;
- id->idcDisp = 0;
- id->idcArgCnt = argCnt;
+ id->idcGcrefRegs = gcrefRegs;
+ id->idcByrefRegs = byrefRegs;
+ id->idcDisp = 0;
+ id->idcArgCnt = argCnt;
#if MULTIREG_HAS_SECOND_GC_RET
emitSetSecondRetRegGCType(id, secondRetSize);
#endif // MULTIREG_HAS_SECOND_GC_RET
- return id;
+ return id;
}
else
{
- instrDesc* id = emitNewInstrCns(retSize, argCnt);
+ instrDesc * id = emitNewInstrCns(retSize, argCnt);
// printf("Direct call w/o GC vars / big arg cnt / explicit scope\n");
@@ -3100,37 +3128,35 @@ emitter::instrDesc* emitter::emitNewInstrCallDir(int argCnt,
/* Save the the live GC registers in the unused register fields */
emitEncodeCallGCregs(gcrefRegs, id);
- return id;
+ return id;
}
}
/*****************************************************************************/
-#ifdef DEBUG
+#ifdef DEBUG
/*****************************************************************************
*
* Return a string with the name of the given class field (blank string (not
* NULL) is returned when the name isn't available).
*/
-const char* emitter::emitFldName(CORINFO_FIELD_HANDLE fieldVal)
+const char * emitter::emitFldName(CORINFO_FIELD_HANDLE fieldVal)
{
- if (emitComp->opts.varNames)
+ if (emitComp->opts.varNames)
{
- const char* memberName;
- const char* className;
+ const char * memberName;
+ const char * className;
- const int TEMP_BUFFER_LEN = 1024;
- static char buff[TEMP_BUFFER_LEN];
+ const int TEMP_BUFFER_LEN = 1024;
+ static char buff[TEMP_BUFFER_LEN];
memberName = emitComp->eeGetFieldName(fieldVal, &className);
sprintf_s(buff, TEMP_BUFFER_LEN, "'<%s>.%s'", className, memberName);
- return buff;
+ return buff;
}
else
- {
- return "";
- }
+ return "";
}
/*****************************************************************************
@@ -3139,26 +3165,27 @@ const char* emitter::emitFldName(CORINFO_FIELD_HANDLE fieldVal)
* NULL) is returned when the name isn't available).
*/
-const char* emitter::emitFncName(CORINFO_METHOD_HANDLE methHnd)
+const char * emitter::emitFncName(CORINFO_METHOD_HANDLE methHnd)
{
return emitComp->eeGetMethodFullName(methHnd);
}
/*****************************************************************************/
-#endif // DEBUG
+#endif//DEBUG
/*****************************************************************************
*
* Be very careful, some instruction descriptors are allocated as "tiny" and
* don't have some of the tail fields of instrDesc (in particular, "idInfo").
*/
-const BYTE emitter::emitFmtToOps[] = {
-#define IF_DEF(en, op1, op2) ID_OP_##op2,
-#include "emitfmts.h"
+const BYTE emitter::emitFmtToOps[] =
+{
+ #define IF_DEF(en, op1, op2) ID_OP_##op2,
+ #include "emitfmts.h"
};
-#ifdef DEBUG
-const unsigned emitter::emitFmtCount = sizeof(emitFmtToOps) / sizeof(emitFmtToOps[0]);
+#ifdef DEBUG
+const unsigned emitter::emitFmtCount = sizeof(emitFmtToOps)/sizeof(emitFmtToOps[0]);
#endif
/*****************************************************************************
@@ -3166,9 +3193,9 @@ const unsigned emitter::emitFmtCount = sizeof(emitFmtToOps) / sizeof(emitFmtToOp
* Display the current instruction group list.
*/
-#ifdef DEBUG
+#ifdef DEBUG
-void emitter::emitDispIGflags(unsigned flags)
+void emitter::emitDispIGflags(unsigned flags)
{
if (flags & IGF_GC_VARS)
{
@@ -3210,54 +3237,40 @@ void emitter::emitDispIGflags(unsigned flags)
}
}
-void emitter::emitDispIG(insGroup* ig, insGroup* igPrev, bool verbose)
+
+void emitter::emitDispIG(insGroup* ig, insGroup* igPrev, bool verbose)
{
const int TEMP_BUFFER_LEN = 40;
- char buff[TEMP_BUFFER_LEN];
+ char buff[TEMP_BUFFER_LEN];
sprintf_s(buff, TEMP_BUFFER_LEN, "G_M%03u_IG%02u: ", Compiler::s_compMethodsCount, ig->igNum);
printf("%s; ", buff);
- if ((igPrev == nullptr) || (igPrev->igFuncIdx != ig->igFuncIdx))
+ if ((igPrev == NULL) || (igPrev->igFuncIdx != ig->igFuncIdx))
{
printf("func=%02u, ", ig->igFuncIdx);
}
if (ig->igFlags & IGF_PLACEHOLDER)
{
- insGroup* igPh = ig;
+ insGroup * igPh = ig;
const char* pszType;
switch (igPh->igPhData->igPhType)
{
- case IGPT_PROLOG:
- pszType = "prolog";
- break;
- case IGPT_EPILOG:
- pszType = "epilog";
- break;
+ case IGPT_PROLOG: pszType = "prolog"; break;
+ case IGPT_EPILOG: pszType = "epilog"; break;
#if FEATURE_EH_FUNCLETS
- case IGPT_FUNCLET_PROLOG:
- pszType = "funclet prolog";
- break;
- case IGPT_FUNCLET_EPILOG:
- pszType = "funclet epilog";
- break;
+ case IGPT_FUNCLET_PROLOG: pszType = "funclet prolog"; break;
+ case IGPT_FUNCLET_EPILOG: pszType = "funclet epilog"; break;
#endif // FEATURE_EH_FUNCLETS
- default:
- pszType = "UNKNOWN";
- break;
+ default: pszType = "UNKNOWN"; break;
}
printf("%s placeholder, next placeholder=", pszType);
if (igPh->igPhData->igPhNext)
- {
printf("IG%02u ", igPh->igPhData->igPhNext->igNum);
- }
else
- {
printf("<END>");
- }
- printf(", BB=%08XH (BB%02u)", dspPtr(igPh->igPhData->igPhBB),
- (igPh->igPhData->igPhBB != nullptr) ? igPh->igPhData->igPhBB->bbNum : 0);
+ printf(", BB=%08XH (BB%02u)", dspPtr(igPh->igPhData->igPhBB), (igPh->igPhData->igPhBB != nullptr) ? igPh->igPhData->igPhBB->bbNum : 0 );
emitDispIGflags(igPh->igFlags);
@@ -3275,26 +3288,28 @@ void emitter::emitDispIG(insGroup* ig, insGroup* igPrev, bool verbose)
}
printf("\n");
- printf("%*s; PrevGCVars=%s ", strlen(buff), "",
- VarSetOps::ToString(emitComp, igPh->igPhData->igPhPrevGCrefVars));
+ printf("%*s; PrevGCVars=%s ",
+ strlen(buff), "",
+ VarSetOps::ToString(emitComp, igPh->igPhData->igPhPrevGCrefVars));
dumpConvertedVarSet(emitComp, igPh->igPhData->igPhPrevGCrefVars);
printf(", PrevGCrefRegs=");
printRegMaskInt(igPh->igPhData->igPhPrevGCrefRegs);
- emitDispRegSet(igPh->igPhData->igPhPrevGCrefRegs);
+ emitDispRegSet (igPh->igPhData->igPhPrevGCrefRegs);
printf(", PrevByrefRegs=");
printRegMaskInt(igPh->igPhData->igPhPrevByrefRegs);
- emitDispRegSet(igPh->igPhData->igPhPrevByrefRegs);
+ emitDispRegSet (igPh->igPhData->igPhPrevByrefRegs);
printf("\n");
- printf("%*s; InitGCVars=%s ", strlen(buff), "",
- VarSetOps::ToString(emitComp, igPh->igPhData->igPhInitGCrefVars));
+ printf("%*s; InitGCVars=%s ",
+ strlen(buff), "",
+ VarSetOps::ToString(emitComp, igPh->igPhData->igPhInitGCrefVars));
dumpConvertedVarSet(emitComp, igPh->igPhData->igPhInitGCrefVars);
printf(", InitGCrefRegs=");
printRegMaskInt(igPh->igPhData->igPhInitGCrefRegs);
- emitDispRegSet(igPh->igPhData->igPhInitGCrefRegs);
+ emitDispRegSet (igPh->igPhData->igPhInitGCrefRegs);
printf(", InitByrefRegs=");
printRegMaskInt(igPh->igPhData->igPhInitByrefRegs);
- emitDispRegSet(igPh->igPhData->igPhInitByrefRegs);
+ emitDispRegSet (igPh->igPhData->igPhInitByrefRegs);
printf("\n");
assert(!(ig->igFlags & IGF_GC_VARS));
@@ -3310,18 +3325,18 @@ void emitter::emitDispIG(insGroup* ig, insGroup* igPrev, bool verbose)
dumpConvertedVarSet(emitComp, ig->igGCvars());
}
- if (!(ig->igFlags & IGF_EMIT_ADD))
+ if (!(ig->igFlags & IGF_EMIT_ADD))
{
printf(", gcrefRegs=");
printRegMaskInt(ig->igGCregs);
- emitDispRegSet(ig->igGCregs);
+ emitDispRegSet (ig->igGCregs);
}
if (ig->igFlags & IGF_BYREF_REGS)
{
printf(", byrefRegs=");
printRegMaskInt(ig->igByrefRegs());
- emitDispRegSet(ig->igByrefRegs());
+ emitDispRegSet (ig->igByrefRegs());
}
emitDispIGflags(ig->igFlags);
@@ -3336,25 +3351,26 @@ void emitter::emitDispIG(insGroup* ig, insGroup* igPrev, bool verbose)
}
printf("\n");
- if (verbose)
+ if (verbose)
{
- BYTE* ins = ig->igData;
+ BYTE * ins = ig->igData;
UNATIVE_OFFSET ofs = ig->igOffs;
unsigned cnt = ig->igInsCnt;
- if (cnt)
+ if (cnt)
{
printf("\n");
do
{
- instrDesc* id = (instrDesc*)ins;
+ instrDesc * id = (instrDesc *)ins;
- emitDispIns(id, false, true, false, ofs, nullptr, 0, ig);
+ emitDispIns(id, false, true, false, ofs, NULL, 0, ig);
ins += emitSizeOfInsDsc(id);
- ofs += emitInstCodeSz(id);
- } while (--cnt);
+ ofs += emitInstCodeSz (id);
+ }
+ while (--cnt);
printf("\n");
}
@@ -3362,44 +3378,46 @@ void emitter::emitDispIG(insGroup* ig, insGroup* igPrev, bool verbose)
}
}
-void emitter::emitDispIGlist(bool verbose)
+void emitter::emitDispIGlist(bool verbose)
{
- insGroup* ig;
- insGroup* igPrev;
+ insGroup * ig;
+ insGroup * igPrev;
- for (igPrev = nullptr, ig = emitIGlist; ig; igPrev = ig, ig = ig->igNext)
+ for (igPrev = NULL, ig = emitIGlist;
+ ig;
+ igPrev = ig , ig = ig->igNext)
{
emitDispIG(ig, igPrev, verbose);
}
}
-void emitter::emitDispGCinfo()
+void emitter::emitDispGCinfo()
{
printf("Emitter GC tracking info:");
printf("\n emitPrevGCrefVars(0x%p)=%016llX ", dspPtr(&emitPrevGCrefVars), emitPrevGCrefVars);
- dumpConvertedVarSet(emitComp, emitPrevGCrefVars);
+ dumpConvertedVarSet(emitComp, emitPrevGCrefVars);
printf("\n emitPrevGCrefRegs(0x%p)=", dspPtr(&emitPrevGCrefRegs));
- printRegMaskInt(emitPrevGCrefRegs);
- emitDispRegSet(emitPrevGCrefRegs);
+ printRegMaskInt(emitPrevGCrefRegs);
+ emitDispRegSet (emitPrevGCrefRegs);
printf("\n emitPrevByrefRegs(0x%p)=", dspPtr(&emitPrevByrefRegs));
- printRegMaskInt(emitPrevByrefRegs);
- emitDispRegSet(emitPrevByrefRegs);
+ printRegMaskInt(emitPrevByrefRegs);
+ emitDispRegSet (emitPrevByrefRegs);
printf("\n emitInitGCrefVars(0x%p)=%016llX ", dspPtr(&emitInitGCrefVars), emitInitGCrefVars);
- dumpConvertedVarSet(emitComp, emitInitGCrefVars);
+ dumpConvertedVarSet(emitComp, emitInitGCrefVars);
printf("\n emitInitGCrefRegs(0x%p)=", dspPtr(&emitInitGCrefRegs));
- printRegMaskInt(emitInitGCrefRegs);
- emitDispRegSet(emitInitGCrefRegs);
+ printRegMaskInt(emitInitGCrefRegs);
+ emitDispRegSet (emitInitGCrefRegs);
printf("\n emitInitByrefRegs(0x%p)=", dspPtr(&emitInitByrefRegs));
- printRegMaskInt(emitInitByrefRegs);
- emitDispRegSet(emitInitByrefRegs);
+ printRegMaskInt(emitInitByrefRegs);
+ emitDispRegSet (emitInitByrefRegs);
printf("\n emitThisGCrefVars(0x%p)=%016llX ", dspPtr(&emitThisGCrefVars), emitThisGCrefVars);
- dumpConvertedVarSet(emitComp, emitThisGCrefVars);
+ dumpConvertedVarSet(emitComp, emitThisGCrefVars);
printf("\n emitThisGCrefRegs(0x%p)=", dspPtr(&emitThisGCrefRegs));
- printRegMaskInt(emitThisGCrefRegs);
- emitDispRegSet(emitThisGCrefRegs);
+ printRegMaskInt(emitThisGCrefRegs);
+ emitDispRegSet (emitThisGCrefRegs);
printf("\n emitThisByrefRegs(0x%p)=", dspPtr(&emitThisByrefRegs));
- printRegMaskInt(emitThisByrefRegs);
- emitDispRegSet(emitThisByrefRegs);
+ printRegMaskInt(emitThisByrefRegs);
+ emitDispRegSet (emitThisByrefRegs);
printf("\n\n");
}
@@ -3411,13 +3429,14 @@ void emitter::emitDispGCinfo()
* emitOutputInstr() that does a few debug checks.
*/
-size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
+size_t emitter::emitIssue1Instr(insGroup *ig,
+ instrDesc *id, BYTE **dp)
{
- size_t is;
+ size_t is;
/* Record the beginning offset of the instruction */
- BYTE* curInsAdr = *dp;
+ BYTE * curInsAdr = *dp;
/* Issue the next instruction */
@@ -3425,7 +3444,7 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
is = emitOutputInstr(ig, id, dp);
-// printf("[S=%02u]\n", emitCurStackLvl);
+ // printf("[S=%02u]\n", emitCurStackLvl);
#if EMIT_TRACK_STACK_DEPTH
@@ -3435,7 +3454,9 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
push entries.
*/
- assert(emitFullGCinfo == false || emitCurStackLvl != 0 || u2.emitGcArgTrackCnt == 0);
+ assert(emitFullGCinfo == false ||
+ emitCurStackLvl != 0 ||
+ u2.emitGcArgTrackCnt == 0);
#endif
@@ -3443,9 +3464,9 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
/* Did the size of the instruction match our expectations? */
- UNATIVE_OFFSET csz = (UNATIVE_OFFSET)(*dp - curInsAdr);
+ UNATIVE_OFFSET csz = (UNATIVE_OFFSET)(*dp - curInsAdr);
- if (csz != id->idCodeSize())
+ if (csz != id->idCodeSize())
{
/* It is fatal to under-estimate the instruction size */
noway_assert(emitInstCodeSz(id) >= csz);
@@ -3459,32 +3480,33 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
/* The instruction size estimate wasn't accurate; remember this */
- ig->igFlags |= IGF_UPD_ISZ;
+ ig->igFlags |= IGF_UPD_ISZ;
#if defined(_TARGET_XARCH_)
id->idCodeSize(csz);
#elif defined(_TARGET_ARM_)
-// This is done as part of emitSetShortJump();
-// insSize isz = emitInsSize(id->idInsFmt());
-// id->idInsSize(isz);
+ // This is done as part of emitSetShortJump();
+ // insSize isz = emitInsSize(id->idInsFmt());
+ // id->idInsSize(isz);
#else
/* It is fatal to over-estimate the instruction size */
IMPL_LIMITATION("Over-estimated instruction size");
#endif
}
+
#endif
-#ifdef DEBUG
+#ifdef DEBUG
/* Make sure the instruction descriptor size also matches our expectations */
- if (is != emitSizeOfInsDsc(id))
+ if (is != emitSizeOfInsDsc(id))
{
- printf("%s at %u: Expected size = %u , actual size = %u\n", emitIfName(id->idInsFmt()),
- id->idDebugOnlyInfo()->idNum, is, emitSizeOfInsDsc(id));
+ printf("%s at %u: Expected size = %u , actual size = %u\n",
+ emitIfName(id->idInsFmt()), id->idDebugOnlyInfo()->idNum, is, emitSizeOfInsDsc(id));
assert(is == emitSizeOfInsDsc(id));
}
#endif
- return is;
+ return is;
}
/*****************************************************************************
@@ -3494,12 +3516,14 @@ size_t emitter::emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp)
* groups and thus it isn't cheap).
*/
-void emitter::emitRecomputeIGoffsets()
+void emitter::emitRecomputeIGoffsets()
{
- UNATIVE_OFFSET offs;
- insGroup* ig;
+ UNATIVE_OFFSET offs;
+ insGroup * ig;
- for (ig = emitIGlist, offs = 0; ig; ig = ig->igNext)
+ for (ig = emitIGlist, offs = 0;
+ ig;
+ ig = ig->igNext)
{
ig->igOffs = offs;
assert(IsCodeAligned(ig->igOffs));
@@ -3510,7 +3534,7 @@ void emitter::emitRecomputeIGoffsets()
emitTotalCodeSize = offs;
-#ifdef DEBUG
+#ifdef DEBUG
emitCheckIGoffsets();
#endif
}
@@ -3525,94 +3549,95 @@ void emitter::emitRecomputeIGoffsets()
* NYI).
*/
-void emitter::emitJumpDistBind()
+void emitter::emitJumpDistBind()
{
#ifdef DEBUG
- if (emitComp->verbose)
+ if (emitComp->verbose)
{
printf("*************** In emitJumpDistBind()\n");
}
- if (EMIT_INSTLIST_VERBOSE)
+ if (EMIT_INSTLIST_VERBOSE)
{
printf("\nInstruction list before jump distance binding:\n\n");
emitDispIGlist(true);
}
#endif
- instrDescJmp* jmp;
+ instrDescJmp * jmp;
- UNATIVE_OFFSET minShortExtra; // The smallest offset greater than that required for a jump to be converted
- // to a small jump. If it is small enough, we will iterate in hopes of
- // converting those jumps we missed converting the first (or second...) time.
+ UNATIVE_OFFSET minShortExtra; // The smallest offset greater than that required for a jump to be converted
+ // to a small jump. If it is small enough, we will iterate in hopes of
+ // converting those jumps we missed converting the first (or second...) time.
#if defined(_TARGET_ARM_)
- UNATIVE_OFFSET minMediumExtra; // Same as 'minShortExtra', but for medium-sized jumps.
-#endif // _TARGET_ARM_
+ UNATIVE_OFFSET minMediumExtra; // Same as 'minShortExtra', but for medium-sized jumps.
+#endif // _TARGET_ARM_
- UNATIVE_OFFSET adjIG;
- UNATIVE_OFFSET adjLJ;
- insGroup* lstIG;
+ UNATIVE_OFFSET adjIG;
+ UNATIVE_OFFSET adjLJ;
+ insGroup * lstIG;
#ifdef DEBUG
- insGroup* prologIG = emitPrologIG;
+ insGroup * prologIG = emitPrologIG;
#endif // DEBUG
- int jmp_iteration = 1;
+ int jmp_iteration = 1;
-/*****************************************************************************/
-/* If we iterate to look for more jumps to shorten, we start again here. */
-/*****************************************************************************/
+ /*****************************************************************************/
+ /* If we iterate to look for more jumps to shorten, we start again here. */
+ /*****************************************************************************/
AGAIN:
-#ifdef DEBUG
+#ifdef DEBUG
emitCheckIGoffsets();
#endif
-/*
- In the following loop we convert all jump targets from "BasicBlock *"
- to "insGroup *" values. We also estimate which jumps will be short.
- */
+ /*
+ In the following loop we convert all jump targets from "BasicBlock *"
+ to "insGroup *" values. We also estimate which jumps will be short.
+ */
-#ifdef DEBUG
- insGroup* lastIG = nullptr;
- instrDescJmp* lastLJ = nullptr;
+#ifdef DEBUG
+ insGroup * lastIG = NULL;
+ instrDescJmp * lastLJ = NULL;
#endif
- lstIG = nullptr;
- adjLJ = 0;
- adjIG = 0;
- minShortExtra = (UNATIVE_OFFSET)-1;
+ lstIG = NULL;
+ adjLJ = 0;
+ adjIG = 0;
+ minShortExtra = (UNATIVE_OFFSET)-1;
#if defined(_TARGET_ARM_)
minMediumExtra = (UNATIVE_OFFSET)-1;
#endif // _TARGET_ARM_
- for (jmp = emitJumpList; jmp; jmp = jmp->idjNext)
+ for (jmp = emitJumpList;
+ jmp;
+ jmp = jmp->idjNext)
{
- insGroup* jmpIG;
- insGroup* tgtIG;
+ insGroup * jmpIG;
+ insGroup * tgtIG;
- UNATIVE_OFFSET jsz; // size of the jump instruction in bytes
+ UNATIVE_OFFSET jsz; // size of the jump instruction in bytes
- UNATIVE_OFFSET ssz = 0; // small jump size
- NATIVE_OFFSET nsd = 0; // small jump max. neg distance
- NATIVE_OFFSET psd = 0; // small jump max. pos distance
+ UNATIVE_OFFSET ssz = 0; // small jump size
+ NATIVE_OFFSET nsd = 0; // small jump max. neg distance
+ NATIVE_OFFSET psd = 0; // small jump max. pos distance
#if defined(_TARGET_ARM_)
- UNATIVE_OFFSET msz = 0; // medium jump size
- NATIVE_OFFSET nmd = 0; // medium jump max. neg distance
- NATIVE_OFFSET pmd = 0; // medium jump max. pos distance
- NATIVE_OFFSET mextra; // How far beyond the medium jump range is this jump offset?
-#endif // _TARGET_ARM_
-
- NATIVE_OFFSET extra; // How far beyond the short jump range is this jump offset?
- UNATIVE_OFFSET srcInstrOffs; // offset of the source instruction of the jump
- UNATIVE_OFFSET srcEncodingOffs; // offset of the source used by the instruction set to calculate the relative
- // offset of the jump
- UNATIVE_OFFSET dstOffs;
- NATIVE_OFFSET jmpDist; // the relative jump distance, as it will be encoded
- UNATIVE_OFFSET oldSize;
- UNATIVE_OFFSET sizeDif;
+ UNATIVE_OFFSET msz = 0; // medium jump size
+ NATIVE_OFFSET nmd = 0; // medium jump max. neg distance
+ NATIVE_OFFSET pmd = 0; // medium jump max. pos distance
+ NATIVE_OFFSET mextra; // How far beyond the medium jump range is this jump offset?
+#endif // _TARGET_ARM_
+
+ NATIVE_OFFSET extra; // How far beyond the short jump range is this jump offset?
+ UNATIVE_OFFSET srcInstrOffs; // offset of the source instruction of the jump
+ UNATIVE_OFFSET srcEncodingOffs; // offset of the source used by the instruction set to calculate the relative offset of the jump
+ UNATIVE_OFFSET dstOffs;
+ NATIVE_OFFSET jmpDist; // the relative jump distance, as it will be encoded
+ UNATIVE_OFFSET oldSize;
+ UNATIVE_OFFSET sizeDif;
#ifdef _TARGET_XARCH_
assert(jmp->idInsFmt() == IF_LABEL || jmp->idInsFmt() == IF_RWR_LABEL || jmp->idInsFmt() == IF_SWR_LABEL);
@@ -3621,7 +3646,7 @@ AGAIN:
if (jmp->idInsFmt() == IF_LABEL)
{
- if (emitIsCondJump(jmp))
+ if (emitIsCondJump(jmp))
{
ssz = JCC_SIZE_SMALL;
nsd = JCC_DIST_SMALL_MAX_NEG;
@@ -3637,13 +3662,19 @@ AGAIN:
#endif // _TARGET_XARCH_
#ifdef _TARGET_ARM_
- assert((jmp->idInsFmt() == IF_T2_J1) || (jmp->idInsFmt() == IF_T2_J2) || (jmp->idInsFmt() == IF_T1_I) ||
- (jmp->idInsFmt() == IF_T1_K) || (jmp->idInsFmt() == IF_T1_M) || (jmp->idInsFmt() == IF_T2_M1) ||
- (jmp->idInsFmt() == IF_T2_N1) || (jmp->idInsFmt() == IF_T1_J3) || (jmp->idInsFmt() == IF_LARGEJMP));
+ assert((jmp->idInsFmt() == IF_T2_J1) ||
+ (jmp->idInsFmt() == IF_T2_J2) ||
+ (jmp->idInsFmt() == IF_T1_I) ||
+ (jmp->idInsFmt() == IF_T1_K) ||
+ (jmp->idInsFmt() == IF_T1_M) ||
+ (jmp->idInsFmt() == IF_T2_M1) ||
+ (jmp->idInsFmt() == IF_T2_N1) ||
+ (jmp->idInsFmt() == IF_T1_J3) ||
+ (jmp->idInsFmt() == IF_LARGEJMP) );
/* Figure out the smallest size we can end up with */
- if (emitIsCondJump(jmp))
+ if (emitIsCondJump(jmp))
{
ssz = JCC_SIZE_SMALL;
nsd = JCC_DIST_SMALL_MAX_NEG;
@@ -3653,19 +3684,19 @@ AGAIN:
nmd = JCC_DIST_MEDIUM_MAX_NEG;
pmd = JCC_DIST_MEDIUM_MAX_POS;
}
- else if (emitIsCmpJump(jmp))
+ else if (emitIsCmpJump(jmp))
{
ssz = JMP_SIZE_SMALL;
nsd = 0;
psd = 126;
}
- else if (emitIsUncondJump(jmp))
+ else if (emitIsUncondJump(jmp))
{
ssz = JMP_SIZE_SMALL;
nsd = JMP_DIST_SMALL_MAX_NEG;
psd = JMP_DIST_SMALL_MAX_POS;
}
- else if (emitIsLoadLabel(jmp))
+ else if (emitIsLoadLabel(jmp))
{
ssz = LBL_SIZE_SMALL;
nsd = LBL_DIST_SMALL_MAX_NEG;
@@ -3680,7 +3711,7 @@ AGAIN:
#ifdef _TARGET_ARM64_
/* Figure out the smallest size we can end up with */
- if (emitIsCondJump(jmp))
+ if (emitIsCondJump(jmp))
{
ssz = JCC_SIZE_SMALL;
nsd = JCC_DIST_SMALL_MAX_NEG;
@@ -3714,13 +3745,17 @@ AGAIN:
}
#endif // _TARGET_ARM64_
-/* Make sure the jumps are properly ordered */
+ /* Make sure the jumps are properly ordered */
-#ifdef DEBUG
- assert(lastLJ == nullptr || lastIG != jmp->idjIG || lastLJ->idjOffs < jmp->idjOffs);
- lastLJ = (lastIG == jmp->idjIG) ? jmp : nullptr;
+#ifdef DEBUG
+ assert(lastLJ == NULL ||
+ lastIG != jmp->idjIG ||
+ lastLJ->idjOffs < jmp->idjOffs);
+ lastLJ = (lastIG == jmp->idjIG) ? jmp : NULL;
- assert(lastIG == nullptr || lastIG->igNum <= jmp->idjIG->igNum || jmp->idjIG == prologIG ||
+ assert(lastIG == NULL ||
+ lastIG->igNum <= jmp->idjIG->igNum ||
+ jmp->idjIG == prologIG ||
emitNxtIGnum > unsigned(0xFFFF)); // igNum might overflow
lastIG = jmp->idjIG;
#endif // DEBUG
@@ -3735,23 +3770,23 @@ AGAIN:
/* Are we in a group different from the previous jump? */
- if (lstIG != jmpIG)
+ if (lstIG != jmpIG)
{
/* Were there any jumps before this one? */
- if (lstIG)
+ if (lstIG)
{
/* Adjust the offsets of the intervening blocks */
do
{
- lstIG = lstIG->igNext;
- assert(lstIG);
+ lstIG = lstIG->igNext; assert(lstIG);
// printf("Adjusted offset of block %02u from %04X to %04X\n", lstIG->igNum, lstIG->igOffs,
// lstIG->igOffs - adjIG);
lstIG->igOffs -= adjIG;
assert(IsCodeAligned(lstIG->igOffs));
- } while (lstIG != jmpIG);
+ }
+ while (lstIG != jmpIG);
}
/* We've got the first jump in a new group */
@@ -3779,7 +3814,7 @@ AGAIN:
int doff = jmp->idAddr()->iiaGetJitDataOffset();
assert(doff >= 0);
ssize_t imm = emitGetInsSC(jmp);
- assert((imm >= 0) && (imm < 0x1000)); // 0x1000 is arbitrary, currently 'imm' is always 0
+ assert((imm >= 0) && (imm < 0x1000)); // 0x1000 is arbitrary, currently 'imm' is always 0
unsigned dataOffs = (unsigned)(doff + imm);
assert(dataOffs < emitDataSize());
@@ -3791,7 +3826,7 @@ AGAIN:
// Check if the distance is within the encoding length.
jmpDist = maxDstOffs - srcOffs;
- extra = jmpDist - psd;
+ extra = jmpDist - psd;
if (extra <= 0)
{
goto SHORT_JMP;
@@ -3804,11 +3839,11 @@ AGAIN:
/* Have we bound this jump's target already? */
- if (jmp->idIsBound())
+ if (jmp->idIsBound())
{
/* Does the jump already have the smallest size? */
- if (jmp->idjShort)
+ if (jmp->idjShort)
{
assert(emitSizeOfJump(jmp) == ssz);
@@ -3825,8 +3860,8 @@ AGAIN:
/* First time we've seen this label, convert its target */
CLANG_FORMAT_COMMENT_ANCHOR;
-#ifdef DEBUG
- if (EMITVERBOSE)
+#ifdef DEBUG
+ if (EMITVERBOSE)
{
printf("Binding: ");
emitDispIns(jmp, false, false, false);
@@ -3836,8 +3871,8 @@ AGAIN:
tgtIG = (insGroup*)emitCodeGetCookie(jmp->idAddr()->iiaBBlabel);
-#ifdef DEBUG
- if (EMITVERBOSE)
+#ifdef DEBUG
+ if (EMITVERBOSE)
{
if (tgtIG)
{
@@ -3845,9 +3880,8 @@ AGAIN:
}
else
{
- printf("-- ERROR, no emitter cookie for BB%02u; it is probably missing BBF_JMP_TARGET or "
- "BBF_HAS_LABEL.\n",
- jmp->idAddr()->iiaBBlabel->bbNum);
+ printf("-- ERROR, no emitter cookie for BB%02u; it is probably missing BBF_JMP_TARGET or BBF_HAS_LABEL.\n",
+ jmp->idAddr()->iiaBBlabel->bbNum);
}
}
assert(tgtIG);
@@ -3865,22 +3899,25 @@ AGAIN:
#ifdef _TARGET_XARCH_
/* Done if this is not a variable-sized jump */
- if ((jmp->idIns() == INS_push) || (jmp->idIns() == INS_mov) || (jmp->idIns() == INS_call) ||
- (jmp->idIns() == INS_push_hide))
+ if ( (jmp->idIns() == INS_push) ||
+ (jmp->idIns() == INS_mov) ||
+ (jmp->idIns() == INS_call) ||
+ (jmp->idIns() == INS_push_hide) )
{
continue;
}
#endif
#ifdef _TARGET_ARM_
- if ((jmp->idIns() == INS_push) || (jmp->idIns() == INS_mov) || (jmp->idIns() == INS_movt) ||
- (jmp->idIns() == INS_movw))
+ if ( (jmp->idIns() == INS_push) ||
+ (jmp->idIns() == INS_mov) ||
+ (jmp->idIns() == INS_movt) ||
+ (jmp->idIns() == INS_movw) )
{
continue;
}
#endif
#ifdef _TARGET_ARM64_
- // There is only one size of unconditional branch; we don't support functions larger than 2^28 bytes (our branch
- // range).
+ // There is only one size of unconditional branch; we don't support functions larger than 2^28 bytes (our branch range).
if (emitIsUncondJump(jmp))
{
continue;
@@ -3900,21 +3937,17 @@ AGAIN:
*/
srcInstrOffs = jmpIG->igOffs + jmp->idjOffs;
-
- /* Note that the destination is always the beginning of an IG, so no need for an offset inside it */
- dstOffs = tgtIG->igOffs;
+ dstOffs = tgtIG->igOffs; /* Note that the destination is always the beginning of an IG, so no need for an offset inside it */
#if defined(_TARGET_ARM_)
- srcEncodingOffs =
- srcInstrOffs + 4; // For relative branches, ARM PC is always considered to be the instruction address + 4
+ srcEncodingOffs = srcInstrOffs + 4; // For relative branches, ARM PC is always considered to be the instruction address + 4
#elif defined(_TARGET_ARM64_)
- srcEncodingOffs =
- srcInstrOffs; // For relative branches, ARM64 PC is always considered to be the instruction address
+ srcEncodingOffs = srcInstrOffs; // For relative branches, ARM64 PC is always considered to be the instruction address
#else
- srcEncodingOffs = srcInstrOffs + ssz; // Encoding offset of relative offset for small branch
+ srcEncodingOffs = srcInstrOffs + ssz; // Encoding offset of relative offset for small branch
#endif
- if (jmpIG->igNum < tgtIG->igNum)
+ if (jmpIG->igNum < tgtIG->igNum)
{
/* Forward jump */
@@ -3930,34 +3963,27 @@ AGAIN:
/* How much beyond the max. short distance does the jump go? */
- extra = jmpDist - psd;
+ extra = jmpDist - psd;
#if DEBUG_EMIT
- assert(jmp->idDebugOnlyInfo() != nullptr);
- if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
+ assert(jmp->idDebugOnlyInfo() != NULL);
+ if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
{
- if (INTERESTING_JUMP_NUM == 0)
- {
- printf("[1] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
- }
+ if (INTERESTING_JUMP_NUM == 0)
+ printf("[1] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
printf("[1] Jump block is at %08X\n", jmpIG->igOffs);
printf("[1] Jump reloffset is %04X\n", jmp->idjOffs);
printf("[1] Jump source is at %08X\n", srcEncodingOffs);
printf("[1] Label block is at %08X\n", dstOffs);
printf("[1] Jump dist. is %04X\n", jmpDist);
- if (extra > 0)
- {
- printf("[1] Dist excess [S] = %d \n", extra);
- }
- }
- if (EMITVERBOSE)
- {
- printf("Estimate of fwd jump [%08X/%03u]: %04X -> %04X = %04X\n", dspPtr(jmp),
- jmp->idDebugOnlyInfo()->idNum, srcInstrOffs, dstOffs, jmpDist);
+ if (extra > 0)
+ printf("[1] Dist excess [S] = %d \n", extra);
}
+ if (EMITVERBOSE)
+ printf("Estimate of fwd jump [%08X/%03u]: %04X -> %04X = %04X\n", dspPtr(jmp), jmp->idDebugOnlyInfo()->idNum, srcInstrOffs, dstOffs, jmpDist);
#endif // DEBUG_EMIT
- if (extra <= 0)
+ if (extra <= 0)
{
/* This jump will be a short one */
goto SHORT_JMP;
@@ -3973,34 +3999,27 @@ AGAIN:
/* How much beyond the max. short distance does the jump go? */
- extra = jmpDist + nsd;
+ extra = jmpDist + nsd;
#if DEBUG_EMIT
- assert(jmp->idDebugOnlyInfo() != nullptr);
- if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
+ assert(jmp->idDebugOnlyInfo() != NULL);
+ if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
{
- if (INTERESTING_JUMP_NUM == 0)
- {
- printf("[2] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
- }
+ if (INTERESTING_JUMP_NUM == 0)
+ printf("[2] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
printf("[2] Jump block is at %08X\n", jmpIG->igOffs);
printf("[2] Jump reloffset is %04X\n", jmp->idjOffs);
printf("[2] Jump source is at %08X\n", srcEncodingOffs);
printf("[2] Label block is at %08X\n", dstOffs);
printf("[2] Jump dist. is %04X\n", jmpDist);
- if (extra > 0)
- {
- printf("[2] Dist excess [S] = %d \n", extra);
- }
- }
- if (EMITVERBOSE)
- {
- printf("Estimate of bwd jump [%08X/%03u]: %04X -> %04X = %04X\n", dspPtr(jmp),
- jmp->idDebugOnlyInfo()->idNum, srcInstrOffs, dstOffs, jmpDist);
+ if (extra > 0)
+ printf("[2] Dist excess [S] = %d \n", extra);
}
+ if (EMITVERBOSE)
+ printf("Estimate of bwd jump [%08X/%03u]: %04X -> %04X = %04X\n", dspPtr(jmp), jmp->idDebugOnlyInfo()->idNum, srcInstrOffs, dstOffs, jmpDist);
#endif // DEBUG_EMIT
- if (extra <= 0)
+ if (extra <= 0)
{
/* This jump will be a short one */
goto SHORT_JMP;
@@ -4018,10 +4037,8 @@ AGAIN:
/* Keep track of the closest distance we got */
- if (minShortExtra > (unsigned)extra)
- {
- minShortExtra = (unsigned)extra;
- }
+ if (minShortExtra > (unsigned)extra)
+ minShortExtra = (unsigned)extra;
#if defined(_TARGET_ARM_)
@@ -4030,30 +4047,30 @@ AGAIN:
// 'srcInstrOffs', 'srcEncodingOffs', 'dstOffs', 'jmpDist' have already been computed
// and don't need to be recomputed.
- if (emitIsCondJump(jmp))
+ if (emitIsCondJump(jmp))
{
- if (jmpIG->igNum < tgtIG->igNum)
+ if (jmpIG->igNum < tgtIG->igNum)
{
/* Forward jump */
/* How much beyond the max. medium distance does the jump go? */
- mextra = jmpDist - pmd;
+ mextra = jmpDist - pmd;
#if DEBUG_EMIT
assert(jmp->idDebugOnlyInfo() != NULL);
- if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
+ if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
{
- if (mextra > 0)
+ if (mextra > 0)
{
- if (INTERESTING_JUMP_NUM == 0)
- printf("[6] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
+ if (INTERESTING_JUMP_NUM == 0)
+ printf("[6] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
printf("[6] Dist excess [S] = %d \n", mextra);
}
}
#endif // DEBUG_EMIT
- if (mextra <= 0)
+ if (mextra <= 0)
{
/* This jump will be a medium one */
goto MEDIUM_JMP;
@@ -4065,22 +4082,22 @@ AGAIN:
/* How much beyond the max. medium distance does the jump go? */
- mextra = jmpDist + nmd;
+ mextra = jmpDist + nmd;
#if DEBUG_EMIT
assert(jmp->idDebugOnlyInfo() != NULL);
- if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
+ if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
{
- if (mextra > 0)
+ if (mextra > 0)
{
- if (INTERESTING_JUMP_NUM == 0)
- printf("[7] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
+ if (INTERESTING_JUMP_NUM == 0)
+ printf("[7] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
printf("[7] Dist excess [S] = %d \n", mextra);
}
}
#endif // DEBUG_EMIT
- if (mextra <= 0)
+ if (mextra <= 0)
{
/* This jump will be a medium one */
goto MEDIUM_JMP;
@@ -4091,8 +4108,8 @@ AGAIN:
/* Keep track of the closest distance we got */
- if (minMediumExtra > (unsigned)mextra)
- minMediumExtra = (unsigned)mextra;
+ if (minMediumExtra > (unsigned)mextra)
+ minMediumExtra = (unsigned)mextra;
}
#endif // _TARGET_ARM_
@@ -4104,68 +4121,67 @@ AGAIN:
continue;
- /*****************************************************************************/
- /* Handle conversion to short jump */
- /*****************************************************************************/
+ /*****************************************************************************/
+ /* Handle conversion to short jump */
+ /*****************************************************************************/
SHORT_JMP:
-
+
/* Try to make this jump a short one */
emitSetShortJump(jmp);
if (!jmp->idjShort)
{
- continue; // This jump must be kept long
+ continue; // This jump must be kept long
}
/* This jump is becoming either short or medium */
oldSize = jsz;
- jsz = ssz;
+ jsz = ssz;
assert(oldSize >= jsz);
sizeDif = oldSize - jsz;
#if defined(_TARGET_XARCH_)
jmp->idCodeSize(jsz);
#elif defined(_TARGET_ARM_)
-#if 0
// This is done as part of emitSetShortJump():
- insSize isz = emitInsSize(jmp->idInsFmt());
- jmp->idInsSize(isz);
-#endif
+ // insSize isz = emitInsSize(jmp->idInsFmt());
+ // jmp->idInsSize(isz);
#elif defined(_TARGET_ARM64_)
// The size of IF_LARGEJMP/IF_LARGEADR/IF_LARGELDC are 8 or 12.
// All other code size is 4.
assert((sizeDif == 4) || (sizeDif == 8));
#else
-#error Unsupported or unset target architecture
+ #error Unsupported or unset target architecture
#endif
goto NEXT_JMP;
+
#if defined(_TARGET_ARM_)
- /*****************************************************************************/
- /* Handle conversion to medium jump */
- /*****************************************************************************/
+ /*****************************************************************************/
+ /* Handle conversion to medium jump */
+ /*****************************************************************************/
MEDIUM_JMP:
-
+
/* Try to make this jump a medium one */
emitSetMediumJump(jmp);
if (jmp->idCodeSize() > msz)
{
- continue; // This jump wasn't shortened
+ continue; // This jump wasn't shortened
}
assert(jmp->idCodeSize() == msz);
/* This jump is becoming medium */
oldSize = jsz;
- jsz = msz;
+ jsz = msz;
assert(oldSize >= jsz);
sizeDif = oldSize - jsz;
@@ -4173,7 +4189,7 @@ AGAIN:
#endif // _TARGET_ARM_
- /*****************************************************************************/
+ /*****************************************************************************/
NEXT_JMP:
@@ -4181,28 +4197,26 @@ AGAIN:
assert((0 == (jsz | jmpDist)) || (jsz == emitSizeOfJump(jmp)));
-#ifdef DEBUG
- if (EMITVERBOSE)
- {
+#ifdef DEBUG
+ if (EMITVERBOSE)
printf("Shrinking jump [%08X/%03u]\n", dspPtr(jmp), jmp->idDebugOnlyInfo()->idNum);
- }
#endif
noway_assert((unsigned short)sizeDif == sizeDif);
- adjIG += sizeDif;
- adjLJ += sizeDif;
- jmpIG->igSize -= (unsigned short)sizeDif;
+ adjIG += sizeDif;
+ adjLJ += sizeDif;
+ jmpIG->igSize -= (unsigned short)sizeDif;
emitTotalCodeSize -= sizeDif;
/* The jump size estimate wasn't accurate; flag its group */
- jmpIG->igFlags |= IGF_UPD_ISZ;
+ jmpIG->igFlags |= IGF_UPD_ISZ;
} // end for each jump
/* Did we shorten any jumps? */
- if (adjIG)
+ if (adjIG)
{
/* Adjust offsets of any remaining blocks */
@@ -4211,48 +4225,38 @@ AGAIN:
for (;;)
{
lstIG = lstIG->igNext;
- if (!lstIG)
- {
+ if (!lstIG)
break;
- }
// printf("Adjusted offset of block %02u from %04X to %04X\n", lstIG->igNum, lstIG->igOffs,
// lstIG->igOffs - adjIG);
lstIG->igOffs -= adjIG;
assert(IsCodeAligned(lstIG->igOffs));
}
-#ifdef DEBUG
+#ifdef DEBUG
emitCheckIGoffsets();
#endif
/* Is there a chance of other jumps becoming short? */
CLANG_FORMAT_COMMENT_ANCHOR;
-#ifdef DEBUG
+#ifdef DEBUG
#if defined(_TARGET_ARM_)
- if (EMITVERBOSE)
- printf("Total shrinkage = %3u, min extra short jump size = %3u, min extra medium jump size = %u\n", adjIG,
- minShortExtra, minMediumExtra);
+ if (EMITVERBOSE) printf("Total shrinkage = %3u, min extra short jump size = %3u, min extra medium jump size = %u\n", adjIG, minShortExtra, minMediumExtra);
#else
- if (EMITVERBOSE)
- {
- printf("Total shrinkage = %3u, min extra jump size = %3u\n", adjIG, minShortExtra);
- }
+ if (EMITVERBOSE) printf("Total shrinkage = %3u, min extra jump size = %3u\n", adjIG, minShortExtra);
#endif
#endif
- if ((minShortExtra <= adjIG)
+ if ( (minShortExtra <= adjIG)
#if defined(_TARGET_ARM_)
- || (minMediumExtra <= adjIG)
+ || (minMediumExtra <= adjIG)
#endif // _TARGET_ARM_
- )
+ )
{
jmp_iteration++;
-#ifdef DEBUG
- if (EMITVERBOSE)
- {
- printf("Iterating branch shortening. Iteration = %d\n", jmp_iteration);
- }
+#ifdef DEBUG
+ if (EMITVERBOSE) printf("Iterating branch shortening. Iteration = %d\n", jmp_iteration);
#endif
goto AGAIN;
@@ -4260,9 +4264,9 @@ AGAIN:
}
}
-void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
+void emitter::emitCheckFuncletBranch(instrDesc * jmp, insGroup * jmpIG)
{
-#ifdef DEBUG
+#ifdef DEBUG
// We should not be jumping/branching across funclets/functions
// Except possibly a 'call' to a finally funclet for a local unwind
// or a 'return' from a catch handler (that can go just about anywhere)
@@ -4271,13 +4275,11 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
assert(jmp->idIsBound());
#ifdef _TARGET_AMD64_
- // 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
+ // 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.
if (jmp->idIns() == INS_lea)
- {
return;
- }
#endif
#ifdef _TARGET_ARMARCH_
@@ -4297,7 +4299,7 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
}
#endif // _TARGET_ARM64_
- insGroup* tgtIG = jmp->idAddr()->iiaIGlabel;
+ insGroup * tgtIG = jmp->idAddr()->iiaIGlabel;
assert(tgtIG);
if (tgtIG->igFuncIdx != jmpIG->igFuncIdx)
{
@@ -4308,15 +4310,15 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
// No branches back to the root method
assert(tgtIG->igFuncIdx > 0);
- FuncInfoDsc* tgtFunc = emitComp->funGetFunc(tgtIG->igFuncIdx);
+ FuncInfoDsc * tgtFunc = emitComp->funGetFunc(tgtIG->igFuncIdx);
assert(tgtFunc->funKind == FUNC_HANDLER);
- EHblkDsc* tgtEH = emitComp->ehGetDsc(tgtFunc->funEHIndex);
+ EHblkDsc * tgtEH = emitComp->ehGetDsc(tgtFunc->funEHIndex);
// Only branches to finallys (not faults, catches, filters, etc.)
assert(tgtEH->HasFinallyHandler());
// Only to the first block of the finally (which is properly marked)
- BasicBlock* tgtBlk = tgtEH->ebdHndBeg;
+ BasicBlock * tgtBlk = tgtEH->ebdHndBeg;
assert(tgtBlk->bbFlags & BBF_FUNCLET_BEG);
// And now we made it back to where we started
@@ -4328,14 +4330,14 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
// Again there isn't enough information to prove this correct
// so just allow a 'branch' to any other 'parent' funclet
- FuncInfoDsc* jmpFunc = emitComp->funGetFunc(jmpIG->igFuncIdx);
+ FuncInfoDsc * jmpFunc = emitComp->funGetFunc(jmpIG->igFuncIdx);
assert(jmpFunc->funKind == FUNC_HANDLER);
- EHblkDsc* jmpEH = emitComp->ehGetDsc(jmpFunc->funEHIndex);
+ EHblkDsc * jmpEH = emitComp->ehGetDsc(jmpFunc->funEHIndex);
// Only branches out of catches
assert(jmpEH->HasCatchHandler());
- FuncInfoDsc* tgtFunc = emitComp->funGetFunc(tgtIG->igFuncIdx);
+ FuncInfoDsc * tgtFunc = emitComp->funGetFunc(tgtIG->igFuncIdx);
assert(tgtFunc);
if (tgtFunc->funKind == FUNC_HANDLER)
{
@@ -4361,6 +4363,7 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
#endif // DEBUG
}
+
/*****************************************************************************
*
* Compute the code sizes that we're going to use to allocate the code buffers.
@@ -4373,10 +4376,11 @@ void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG)
* Compiler::info.compTotalColdCodeSize
*/
-void emitter::emitComputeCodeSizes()
+void emitter::emitComputeCodeSizes()
{
- assert((emitComp->fgFirstColdBlock == nullptr) == (emitFirstColdIG == nullptr));
-
+ assert((emitComp->fgFirstColdBlock == NULL) ==
+ (emitFirstColdIG == NULL));
+
if (emitFirstColdIG)
{
emitTotalHotCodeSize = emitFirstColdIG->igOffs;
@@ -4392,50 +4396,48 @@ void emitter::emitComputeCodeSizes()
emitComp->info.compTotalColdCodeSize = emitTotalColdCodeSize;
#ifdef DEBUG
- if (emitComp->verbose)
+ if (emitComp->verbose)
{
- printf("\nHot code size = 0x%X bytes\n", emitTotalHotCodeSize);
- printf("Cold code size = 0x%X bytes\n", emitTotalColdCodeSize);
+ printf("\nHot code size = 0x%X bytes\n", emitTotalHotCodeSize);
+ printf( "Cold code size = 0x%X bytes\n", emitTotalColdCodeSize);
}
#endif
}
+
/*****************************************************************************
*
* Called at the end of code generation, this method creates the code, data
* and GC info blocks for the method. Returns the size of the method (which must fit in an unsigned).
*/
-unsigned emitter::emitEndCodeGen(Compiler* comp,
- bool contTrkPtrLcls,
- bool fullyInt,
- bool fullPtrMap,
- bool returnsGCr,
- unsigned xcptnsCount,
- unsigned* prologSize,
- unsigned* epilogSize,
- void** codeAddr,
- void** coldCodeAddr,
- void** consAddr)
+unsigned emitter::emitEndCodeGen(Compiler *comp,
+ bool contTrkPtrLcls,
+ bool fullyInt,
+ bool fullPtrMap,
+ bool returnsGCr,
+ unsigned xcptnsCount,
+ unsigned *prologSize,
+ unsigned *epilogSize, void **codeAddr,
+ void **coldCodeAddr,
+ void **consAddr)
{
#ifdef DEBUG
- if (emitComp->verbose)
- {
+ if (emitComp->verbose)
printf("*************** In emitEndCodeGen()\n");
- }
#endif
- insGroup* ig;
+ insGroup * ig;
- BYTE* consBlock;
- BYTE* codeBlock;
- BYTE* coldCodeBlock;
- BYTE* cp;
+ BYTE * consBlock;
+ BYTE * codeBlock;
+ BYTE * coldCodeBlock;
+ BYTE * cp;
- assert(emitCurIG == nullptr);
+ assert(emitCurIG == NULL);
- emitCodeBlock = nullptr;
- emitConsBlock = nullptr;
+ emitCodeBlock = NULL;
+ emitConsBlock = NULL;
/* Tell everyone whether we have fully interruptible code or not */
@@ -4450,8 +4452,8 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
// Default values, correct even if EMIT_TRACK_STACK_DEPTH is 0.
emitSimpleStkUsed = true;
- u1.emitSimpleStkMask = 0;
- u1.emitSimpleByrefStkMask = 0;
+ u1.emitSimpleStkMask = 0;
+ u1.emitSimpleByrefStkMask = 0;
#if EMIT_TRACK_STACK_DEPTH
/* Convert max. stack depth from # of bytes to # of entries */
@@ -4460,7 +4462,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Should we use the simple stack */
- if (emitMaxStackDepth > MAX_SIMPLE_STK_DEPTH || emitFullGCinfo)
+ if (emitMaxStackDepth > MAX_SIMPLE_STK_DEPTH || emitFullGCinfo)
{
/* We won't use the "simple" argument table */
@@ -4468,21 +4470,17 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Allocate the argument tracking table */
- if (emitMaxStackDepth <= sizeof(u2.emitArgTrackLcl))
- {
+ if (emitMaxStackDepth <= sizeof(u2.emitArgTrackLcl))
u2.emitArgTrackTab = (BYTE*)u2.emitArgTrackLcl;
- }
else
- {
u2.emitArgTrackTab = (BYTE*)emitGetMem(roundUp(emitMaxStackDepth));
- }
- u2.emitArgTrackTop = u2.emitArgTrackTab;
- u2.emitGcArgTrackCnt = 0;
+ u2.emitArgTrackTop = u2.emitArgTrackTab;
+ u2.emitGcArgTrackCnt = 0;
}
#endif
- if (emitEpilogCnt == 0)
+ if (emitEpilogCnt == 0)
{
/* No epilogs, make sure the epilog size is set to 0 */
@@ -4495,14 +4493,14 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Return the size of the epilog to the caller */
- *epilogSize = emitEpilogSize;
+ *epilogSize = emitEpilogSize;
#ifdef _TARGET_XARCH_
- *epilogSize += emitExitSeqSize;
+ *epilogSize += emitExitSeqSize;
#endif // _TARGET_XARCH_
-#ifdef DEBUG
- if (EMIT_INSTLIST_VERBOSE)
+#ifdef DEBUG
+ if (EMIT_INSTLIST_VERBOSE)
{
printf("\nInstruction list before instruction issue:\n\n");
emitDispIGlist(true);
@@ -4516,21 +4514,21 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
// If we're doing procedure splitting and we found cold blocks, then
// allocate hot and cold buffers. Otherwise only allocate a hot
// buffer.
-
- coldCodeBlock = nullptr;
+
+ coldCodeBlock = NULL;
CorJitAllocMemFlag allocMemFlag = CORJIT_ALLOCMEM_DEFAULT_CODE_ALIGN;
#ifdef _TARGET_X86_
//
// These are the heuristics we use to decide whether or not to force the
- // code to be 16-byte aligned.
+ // code to be 16-byte aligned.
//
// 1. For ngen code with IBC data, use 16-byte alignment if the method
// has been called more than BB_VERY_HOT_WEIGHT times.
// 2. For JITed code and ngen code without IBC data, use 16-byte alignment
- // when the code is 16 bytes or smaller. We align small getters/setters
- // because of they are penalized heavily on certain hardware when not 16-byte
+ // when the code is 16 bytes or smaller. We align small getters/setters
+ // because of they are penalized heavily on certain hardware when not 16-byte
// aligned (VSWhidbey #373938). To minimize size impact of this optimization,
// we do not align large methods because of the penalty is amortized for them.
//
@@ -4566,37 +4564,46 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
roDataAlignmentDelta = (UNATIVE_OFFSET)ALIGN_UP(emitTotalHotCodeSize, roDataAlignment) - emitTotalHotCodeSize;
assert((roDataAlignmentDelta == 0) || (roDataAlignmentDelta == 4));
}
- emitCmpHandle->allocMem(emitTotalHotCodeSize + roDataAlignmentDelta + emitConsDsc.dsdOffs, emitTotalColdCodeSize, 0,
- xcptnsCount, allocMemFlag, (void**)&codeBlock, (void**)&coldCodeBlock, (void**)&consBlock);
+ emitCmpHandle->allocMem(emitTotalHotCodeSize + roDataAlignmentDelta + emitConsDsc.dsdOffs, emitTotalColdCodeSize,
+ 0,
+ xcptnsCount,
+ allocMemFlag,
+ (void**)&codeBlock, (void**)&coldCodeBlock,
+ (void**)&consBlock);
consBlock = codeBlock + emitTotalHotCodeSize + roDataAlignmentDelta;
#else
- emitCmpHandle->allocMem(emitTotalHotCodeSize, emitTotalColdCodeSize, emitConsDsc.dsdOffs, xcptnsCount, allocMemFlag,
- (void**)&codeBlock, (void**)&coldCodeBlock, (void**)&consBlock);
+ emitCmpHandle->allocMem( emitTotalHotCodeSize, emitTotalColdCodeSize,
+ emitConsDsc.dsdOffs,
+ xcptnsCount,
+ allocMemFlag,
+ (void**)&codeBlock, (void**)&coldCodeBlock,
+ (void**)&consBlock);
#endif
+
// if (emitConsDsc.dsdOffs)
// printf("Cons=%08X\n", consBlock);
/* Give the block addresses to the caller and other functions here */
- *codeAddr = emitCodeBlock = codeBlock;
+ *codeAddr = emitCodeBlock = codeBlock;
*coldCodeAddr = emitColdCodeBlock = coldCodeBlock;
- *consAddr = emitConsBlock = consBlock;
+ *consAddr = emitConsBlock = consBlock;
/* Nothing has been pushed on the stack */
CLANG_FORMAT_COMMENT_ANCHOR;
#if EMIT_TRACK_STACK_DEPTH
- emitCurStackLvl = 0;
+ emitCurStackLvl = 0;
#endif
/* Assume no live GC ref variables on entry */
- VarSetOps::ClearD(emitComp, emitThisGCrefVars); // This is initialized to Empty at the start of codegen.
+ VarSetOps::ClearD(emitComp, emitThisGCrefVars); // This is initialized to Empty at the start of codegen.
emitThisGCrefRegs = emitThisByrefRegs = RBM_NONE;
- emitThisGCrefVset = true;
+ emitThisGCrefVset = true;
#ifdef DEBUG
@@ -4605,10 +4612,12 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
// We don't use these after this point
VarSetOps::AssignNoCopy(emitComp, emitPrevGCrefVars, VarSetOps::UninitVal());
- emitPrevGCrefRegs = emitPrevByrefRegs = 0xBAADFEED;
+ emitPrevGCrefRegs =
+ emitPrevByrefRegs = 0xBAADFEED;
VarSetOps::AssignNoCopy(emitComp, emitInitGCrefVars, VarSetOps::UninitVal());
- emitInitGCrefRegs = emitInitByrefRegs = 0xBAADFEED;
+ emitInitGCrefRegs =
+ emitInitByrefRegs = 0xBAADFEED;
#endif
@@ -4616,14 +4625,15 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
codeGen->gcInfo.gcVarPtrSetInit();
- emitSyncThisObjOffs = -1; /* -1 means no offset set */
- emitSyncThisObjReg = REG_NA; /* REG_NA means not set */
+ emitSyncThisObjOffs = -1; /* -1 means no offset set */
+ emitSyncThisObjReg = REG_NA; /* REG_NA means not set */
+
#ifdef JIT32_GCENCODER
- if (emitComp->lvaKeepAliveAndReportThis())
+ if (emitComp->lvaKeepAliveAndReportThis())
{
assert(emitComp->lvaIsOriginalThisArg(0));
- LclVarDsc* thisDsc = &emitComp->lvaTable[0];
+ LclVarDsc * thisDsc = &emitComp->lvaTable[0];
/* If "this" (which is passed in as a register argument in REG_ARG_0)
is enregistered, we normally spot the "mov REG_ARG_0 -> thisReg"
@@ -4637,16 +4647,17 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
we try to save space by avoiding that.
*/
- if (thisDsc->lvRegister)
+ if (thisDsc->lvRegister)
{
emitSyncThisObjReg = thisDsc->lvRegNum;
- if (emitSyncThisObjReg == (int)REG_ARG_0 &&
+ if (emitSyncThisObjReg == (int)REG_ARG_0 &&
(codeGen->intRegState.rsCalleeRegArgMaskLiveIn & genRegMask(REG_ARG_0)))
{
- if (emitFullGCinfo)
+ if (emitFullGCinfo)
{
- emitGCregLiveSet(GCT_GCREF, genRegMask(REG_ARG_0),
+ emitGCregLiveSet(GCT_GCREF,
+ genRegMask(REG_ARG_0),
emitCodeBlock, // from offset 0
true);
}
@@ -4666,13 +4677,13 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Are there any GC ref variables on the stack? */
- if (emitGCrFrameOffsCnt)
+ if (emitGCrFrameOffsCnt)
{
- size_t siz;
- unsigned cnt;
- unsigned num;
- LclVarDsc* dsc;
- int* tab;
+ size_t siz;
+ unsigned cnt;
+ unsigned num;
+ LclVarDsc* dsc;
+ int* tab;
/* Allocate and clear emitGCrFrameLiveTab[]. This is the table
mapping "stkOffs -> varPtrDsc". It holds a pointer to
@@ -4686,7 +4697,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
present, instead of lvaTrackedCount.
*/
- siz = emitGCrFrameOffsCnt * sizeof(*emitGCrFrameLiveTab);
+ siz = emitGCrFrameOffsCnt * sizeof(*emitGCrFrameLiveTab);
emitGCrFrameLiveTab = (varPtrDsc**)emitGetMem(roundUp(siz));
memset(emitGCrFrameLiveTab, 0, siz);
@@ -4696,33 +4707,30 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
Entries of Tracked stack byrefs have the lower bit set to 1.
*/
- emitTrkVarCnt = cnt = emitComp->lvaTrackedCount;
- assert(cnt);
+ emitTrkVarCnt = cnt = emitComp->lvaTrackedCount; assert(cnt);
emitGCrFrameOffsTab = tab = (int*)emitGetMem(cnt * sizeof(int));
memset(emitGCrFrameOffsTab, -1, cnt * sizeof(int));
/* Now fill in all the actual used entries */
- for (num = 0, dsc = emitComp->lvaTable, cnt = emitComp->lvaCount; num < cnt; num++, dsc++)
+ for (num = 0, dsc = emitComp->lvaTable, cnt = emitComp->lvaCount;
+ num < cnt;
+ num++ , dsc++)
{
- if (!dsc->lvOnFrame || (dsc->lvIsParam && !dsc->lvIsRegArg))
- {
+ if (!dsc->lvOnFrame || (dsc->lvIsParam && !dsc->lvIsRegArg))
continue;
- }
#if FEATURE_FIXED_OUT_ARGS
- if (num == emitComp->lvaOutgoingArgSpaceVar)
- {
+ if (num == emitComp->lvaOutgoingArgSpaceVar)
continue;
- }
#endif // FEATURE_FIXED_OUT_ARGS
- int offs = dsc->lvStkOffs;
+ int offs = dsc->lvStkOffs;
/* Is it within the interesting range of offsets */
- if (offs >= emitGCrFrameOffsMin && offs < emitGCrFrameOffsMax)
+ if (offs >= emitGCrFrameOffsMin && offs < emitGCrFrameOffsMax)
{
/* Are tracked stack ptr locals laid out contiguously?
If not, skip non-ptrs. The emitter is optimized to work
@@ -4738,27 +4746,28 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
}
}
- unsigned indx = dsc->lvVarIndex;
+ unsigned indx = dsc->lvVarIndex;
assert(!dsc->lvRegister);
- assert(dsc->lvTracked);
- assert(dsc->lvRefCnt != 0);
+ assert( dsc->lvTracked);
+ assert( dsc->lvRefCnt != 0);
- assert(dsc->TypeGet() == TYP_REF || dsc->TypeGet() == TYP_BYREF);
+ assert( dsc->TypeGet() == TYP_REF ||
+ dsc->TypeGet() == TYP_BYREF);
assert(indx < emitComp->lvaTrackedCount);
-// printf("Variable #%2u/%2u is at stack offset %d\n", num, indx, offs);
-
+ // printf("Variable #%2u/%2u is at stack offset %d\n", num, indx, offs);
+
#ifdef JIT32_GCENCODER
/* Remember the frame offset of the "this" argument for synchronized methods */
- if (emitComp->lvaIsOriginalThisArg(num) && emitComp->lvaKeepAliveAndReportThis())
+ if (emitComp->lvaIsOriginalThisArg(num) && emitComp->lvaKeepAliveAndReportThis())
{
emitSyncThisObjOffs = offs;
offs |= this_OFFSET_FLAG;
}
#endif // JIT32_GCENCODER
-
+
if (dsc->TypeGet() == TYP_BYREF)
{
offs |= byref_OFFSET_FLAG;
@@ -4769,14 +4778,14 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
}
else
{
-#ifdef DEBUG
+#ifdef DEBUG
emitTrkVarCnt = 0;
- emitGCrFrameOffsTab = nullptr;
+ emitGCrFrameOffsTab = NULL;
#endif
}
-#ifdef DEBUG
- if (emitComp->verbose)
+#ifdef DEBUG
+ if (emitComp->verbose)
{
printf("\n***************************************************************************\n");
printf("Instructions as they come out of the scheduler\n\n");
@@ -4788,7 +4797,9 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
#define DEFAULT_CODE_BUFFER_INIT 0xcc
- for (ig = emitIGlist; ig; ig = ig->igNext)
+ for (ig = emitIGlist;
+ ig;
+ ig = ig->igNext)
{
assert(!(ig->igFlags & IGF_PLACEHOLDER)); // There better not be any placeholder groups left
@@ -4806,33 +4817,31 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
assert(coldCodeBlock);
cp = coldCodeBlock;
#ifdef DEBUG
- if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
+ if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
{
printf("\n************** Beginning of cold code **************\n");
}
#endif
}
-
+
/* Are we overflowing? */
if (ig->igNext && ig->igNum + 1 != ig->igNext->igNum)
- {
NO_WAY("Too many instruction groups");
- }
// If this instruction group is returned to from a funclet implementing a finally,
// on architectures where it is necessary generate GC info for the current instruction as
// if it were the instruction following a call.
emitGenGCInfoIfFuncletRetTarget(ig, cp);
-
- instrDesc* id = (instrDesc*)ig->igData;
+
+ instrDesc * id = (instrDesc *)ig->igData;
#ifdef DEBUG
/* Print the IG label, but only if it is a branch label */
- if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
+ if (emitComp->opts.disAsm || emitComp->opts.dspEmit || emitComp->verbose)
{
- if (emitComp->verbose)
+ if (emitComp->verbose)
{
printf("\n");
emitDispIG(ig); // Display the flags, IG data, etc.
@@ -4845,18 +4854,16 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
#endif // DEBUG
- BYTE* bp = cp;
+ BYTE * bp = cp;
/* Record the actual offset of the block, noting the difference */
- emitOffsAdj = ig->igOffs - emitCurCodeOffs(cp);
- assert(emitOffsAdj >= 0);
+ emitOffsAdj = ig->igOffs - emitCurCodeOffs(cp); assert(emitOffsAdj >= 0);
#if DEBUG_EMIT
if ((emitOffsAdj != 0) && emitComp->verbose)
{
- printf("Block predicted offs = %08X, actual = %08X -> size adj = %d\n", ig->igOffs, emitCurCodeOffs(cp),
- emitOffsAdj);
+ printf("Block predicted offs = %08X, actual = %08X -> size adj = %d\n", ig->igOffs, emitCurCodeOffs(cp), emitOffsAdj);
}
#endif // DEBUG_EMIT
@@ -4867,12 +4874,12 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Set the proper stack level if appropriate */
- if (ig->igStkLvl != emitCurStackLvl)
+ if (ig->igStkLvl != emitCurStackLvl)
{
/* We are pushing stuff implicitly at this label */
assert((unsigned)ig->igStkLvl > (unsigned)emitCurStackLvl);
- emitStackPushN(cp, (ig->igStkLvl - (unsigned)emitCurStackLvl) / sizeof(int));
+ emitStackPushN(cp, (ig->igStkLvl - (unsigned)emitCurStackLvl)/sizeof(int));
}
#endif
@@ -4883,21 +4890,17 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
{
/* Is there a new set of live GC ref variables? */
- if (ig->igFlags & IGF_GC_VARS)
- {
+ if (ig->igFlags & IGF_GC_VARS)
emitUpdateLiveGCvars(ig->igGCvars(), cp);
- }
else if (!emitThisGCrefVset)
- {
emitUpdateLiveGCvars(emitThisGCrefVars, cp);
- }
/* Update the set of live GC ref registers */
{
- regMaskTP GCregs = ig->igGCregs;
+ regMaskTP GCregs = ig->igGCregs;
- if (GCregs != emitThisGCrefRegs)
+ if (GCregs != emitThisGCrefRegs)
{
emitUpdateLiveGCregs(GCT_GCREF, GCregs, cp);
}
@@ -4905,11 +4908,11 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Is there a new set of live byref registers? */
- if (ig->igFlags & IGF_BYREF_REGS)
+ if (ig->igFlags & IGF_BYREF_REGS)
{
- unsigned byrefRegs = ig->igByrefRegs();
+ unsigned byrefRegs = ig->igByrefRegs();
- if (byrefRegs != emitThisByrefRegs)
+ if (byrefRegs != emitThisByrefRegs)
{
emitUpdateLiveGCregs(GCT_BYREF, byrefRegs, cp);
}
@@ -4928,13 +4931,13 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
for (unsigned cnt = ig->igInsCnt; cnt; cnt--)
{
- castto(id, BYTE*) += emitIssue1Instr(ig, id, &cp);
+ castto(id, BYTE *) += emitIssue1Instr(ig, id, &cp);
}
- emitCurIG = nullptr;
+ emitCurIG = NULL;
assert(ig->igSize >= cp - bp);
- ig->igSize = (unsigned short)(cp - bp);
+ ig->igSize = (unsigned short)(cp - bp);
}
#if EMIT_TRACK_STACK_DEPTH
@@ -4943,109 +4946,99 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Output any initialized data we may have */
- if (emitConsDsc.dsdOffs)
+ if (emitConsDsc.dsdOffs)
{
emitOutputDataSec(&emitConsDsc, consBlock);
}
/* Make sure all GC ref variables are marked as dead */
- if (emitGCrFrameOffsCnt)
+ if (emitGCrFrameOffsCnt)
{
- unsigned vn;
- int of;
- varPtrDsc** dp;
+ unsigned vn;
+ int of;
+ varPtrDsc * * dp;
- for (vn = 0, of = emitGCrFrameOffsMin, dp = emitGCrFrameLiveTab; vn < emitGCrFrameOffsCnt;
- vn++, of += sizeof(void*), dp++)
+ for (vn = 0, of = emitGCrFrameOffsMin, dp = emitGCrFrameLiveTab;
+ vn < emitGCrFrameOffsCnt;
+ vn++ , of += sizeof(void*) , dp++)
{
- if (*dp)
- {
+ if (*dp)
emitGCvarDeadSet(of, cp, vn);
- }
}
}
/* No GC registers are live any more */
- if (emitThisByrefRegs)
- {
+ if (emitThisByrefRegs)
emitUpdateLiveGCregs(GCT_BYREF, RBM_NONE, cp);
- }
- if (emitThisGCrefRegs)
- {
+ if (emitThisGCrefRegs)
emitUpdateLiveGCregs(GCT_GCREF, RBM_NONE, cp);
- }
/* Patch any forward jumps */
- if (emitFwdJumps)
+ if (emitFwdJumps)
{
- instrDescJmp* jmp;
+ instrDescJmp * jmp;
for (jmp = emitJumpList; jmp; jmp = jmp->idjNext)
{
- insGroup* tgt;
+ insGroup * tgt;
#ifdef _TARGET_XARCH_
assert(jmp->idInsFmt() == IF_LABEL || jmp->idInsFmt() == IF_RWR_LABEL || jmp->idInsFmt() == IF_SWR_LABEL);
#endif
tgt = jmp->idAddr()->iiaIGlabel;
- if (jmp->idjTemp.idjAddr == nullptr)
- {
+ if (jmp->idjTemp.idjAddr == NULL)
continue;
- }
- if (jmp->idjOffs != tgt->igOffs)
+ if (jmp->idjOffs != tgt->igOffs)
{
- BYTE* adr = jmp->idjTemp.idjAddr;
- int adj = jmp->idjOffs - tgt->igOffs;
+ BYTE * adr = jmp->idjTemp.idjAddr;
+ int adj = jmp->idjOffs - tgt->igOffs;
#ifdef _TARGET_ARM_
// On Arm, the offset is encoded in unit of 2 bytes.
adj >>= 1;
#endif
-#if DEBUG_EMIT
- if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
+#if DEBUG_EMIT
+ if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0)
{
#ifdef _TARGET_ARM_
- printf("[5] This output is broken for ARM, since it doesn't properly decode the jump offsets of "
- "the instruction at adr\n");
+ printf("[5] This output is broken for ARM, since it doesn't properly decode the jump offsets of the instruction at adr\n");
#endif
- if (INTERESTING_JUMP_NUM == 0)
- {
+ if (INTERESTING_JUMP_NUM == 0)
printf("[5] Jump %u:\n", jmp->idDebugOnlyInfo()->idNum);
- }
- if (jmp->idjShort)
+ if (jmp->idjShort)
{
- printf("[5] Jump is at %08X\n", (adr + 1 - emitCodeBlock));
- printf("[5] Jump distance is %02X - %02X = %02X\n", *(BYTE*)adr, adj, *(BYTE*)adr - adj);
+ printf("[5] Jump is at %08X\n" , (adr + 1 - emitCodeBlock));
+ printf("[5] Jump distance is %02X - %02X = %02X\n", *(BYTE *)adr, adj, *(BYTE *)adr - adj);
}
else
{
- printf("[5] Jump is at %08X\n", (adr + 4 - emitCodeBlock));
- printf("[5] Jump distance is %08X - %02X = %08X\n", *(int*)adr, adj, *(int*)adr - adj);
+ printf("[5] Jump is at %08X\n" , (adr + 4 - emitCodeBlock));
+ printf("[5] Jump distance is %08X - %02X = %08X\n", *(int *)adr, adj, *(int *)adr - adj);
}
}
#endif // DEBUG_EMIT
- if (jmp->idjShort)
+ if (jmp->idjShort)
{
// Patch Forward Short Jump
CLANG_FORMAT_COMMENT_ANCHOR;
#if defined(_TARGET_XARCH_)
- *(BYTE*)adr -= (BYTE)adj;
+ *(BYTE *)adr -= (BYTE)adj;
#elif defined(_TARGET_ARM_)
// The following works because the jump offset is in the low order bits of the instruction.
// Presumably we could also just call "emitOutputLJ(NULL, adr, jmp)", like for long jumps?
- *(short int*)adr -= (short)adj;
+ *(short int *)adr -= (short)adj;
#elif defined(_TARGET_ARM64_)
assert(!jmp->idAddr()->iiaHasInstrCount());
emitOutputLJ(NULL, adr, jmp);
#else
-#error Unsupported or unset target architecture
+ #error Unsupported or unset target architecture
#endif
}
else
@@ -5053,30 +5046,27 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
// Patch Forward non-Short Jump
CLANG_FORMAT_COMMENT_ANCHOR;
#if defined(_TARGET_XARCH_)
- *(int*)adr -= adj;
+ *(int *)adr -= adj;
#elif defined(_TARGET_ARMARCH_)
assert(!jmp->idAddr()->iiaHasInstrCount());
emitOutputLJ(NULL, adr, jmp);
#else
-#error Unsupported or unset target architecture
+ #error Unsupported or unset target architecture
#endif
}
}
}
}
-#ifdef DEBUG
+#ifdef DEBUG
if (emitComp->opts.disAsm)
- {
printf("\n");
- }
- if (emitComp->verbose)
- {
+ if (emitComp->verbose)
printf("Allocated method code size = %4u , actual size = %4u\n", emitTotalCodeSize, cp - codeBlock);
- }
#endif
+
unsigned actualCodeSize = emitCurCodeOffs(cp);
/* Fill in eventual unused space */
@@ -5109,7 +5099,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
/* Return the amount of code we've generated */
- return actualCodeSize;
+ return actualCodeSize;
}
// See specification comment at the declaration.
@@ -5124,12 +5114,12 @@ void emitter::emitGenGCInfoIfFuncletRetTarget(insGroup* ig, BYTE* cp)
{
// We don't actually have a call instruction in this case, so we don't have
// a real size for that instruction. We'll use 1.
- emitStackPop(cp, /*isCall*/ true, /*callInstrSize*/ 1, /*args*/ 0);
-
+ emitStackPop(cp, /*isCall*/true, /*callInstrSize*/1, /*args*/0);
+
/* Do we need to record a call location for GC purposes? */
- if (!emitFullGCinfo)
+ if (!emitFullGCinfo)
{
- emitRecordGCcall(cp, /*callInstrSize*/ 1);
+ emitRecordGCcall(cp, /*callInstrSize*/1);
}
}
#endif // FEATURE_EH_FUNCLETS && defined(_TARGET_ARM_)
@@ -5141,33 +5131,29 @@ void emitter::emitGenGCInfoIfFuncletRetTarget(insGroup* ig, BYTE* cp)
* instruction number for this instruction
*/
-unsigned emitter::emitFindInsNum(insGroup* ig, instrDesc* idMatch)
+unsigned emitter::emitFindInsNum(insGroup *ig, instrDesc *idMatch)
{
- instrDesc* id = (instrDesc*)ig->igData;
+ instrDesc * id = (instrDesc *)ig->igData;
- // Check if we are the first instruction in the group
- if (id == idMatch)
- {
+ // Check if we are the first instruction in the group
+ if (id == idMatch)
return 0;
- }
/* Walk the list of instructions until we find a match */
- unsigned insNum = 0;
- unsigned insRemaining = ig->igInsCnt;
+ unsigned insNum = 0;
+ unsigned insRemaining = ig->igInsCnt;
while (insRemaining > 0)
{
- castto(id, BYTE*) += emitSizeOfInsDsc(id);
+ castto(id, BYTE *) += emitSizeOfInsDsc(id);
insNum++;
insRemaining--;
if (id == idMatch)
- {
return insNum;
- }
}
assert(!"emitFindInsNum failed");
- return -1;
+ return -1;
}
/*****************************************************************************
@@ -5177,10 +5163,10 @@ unsigned emitter::emitFindInsNum(insGroup* ig, instrDesc* idMatch)
* to find the true offset by looking for the instruction within the group.
*/
-UNATIVE_OFFSET emitter::emitFindOffset(insGroup* ig, unsigned insNum)
+UNATIVE_OFFSET emitter::emitFindOffset(insGroup *ig, unsigned insNum)
{
- instrDesc* id = (instrDesc*)ig->igData;
- UNATIVE_OFFSET of = 0;
+ instrDesc * id = (instrDesc *)ig->igData;
+ UNATIVE_OFFSET of = 0;
#ifdef DEBUG
/* Make sure we were passed reasonable arguments */
@@ -5194,12 +5180,12 @@ UNATIVE_OFFSET emitter::emitFindOffset(insGroup* ig, unsigned insNum)
{
of += emitInstCodeSz(id);
- castto(id, BYTE*) += emitSizeOfInsDsc(id);
+ castto(id, BYTE *) += emitSizeOfInsDsc(id);
insNum--;
}
- return of;
+ return of;
}
/*****************************************************************************
@@ -5209,12 +5195,14 @@ UNATIVE_OFFSET emitter::emitFindOffset(insGroup* ig, unsigned insNum)
* block.
*/
-UNATIVE_OFFSET emitter::emitDataGenBeg(UNATIVE_OFFSET size, bool dblAlign, bool codeLtab)
+UNATIVE_OFFSET emitter::emitDataGenBeg(UNATIVE_OFFSET size,
+ bool dblAlign,
+ bool codeLtab)
{
- unsigned secOffs;
- dataSection* secDesc;
+ unsigned secOffs;
+ dataSection * secDesc;
- assert(emitDataSecCur == nullptr);
+ assert(emitDataSecCur == 0);
/* The size better not be some kind of an odd thing */
@@ -5246,40 +5234,37 @@ UNATIVE_OFFSET emitter::emitDataGenBeg(UNATIVE_OFFSET size, bool dblAlign, bool
/* Allocate a data section descriptor and add it to the list */
- secDesc = emitDataSecCur = (dataSection*)emitGetMem(roundUp(sizeof(*secDesc) + size));
+ secDesc = emitDataSecCur = (dataSection *)emitGetMem(roundUp(sizeof(*secDesc) + size));
secDesc->dsSize = size;
secDesc->dsType = dataSection::data;
+
+ secDesc->dsNext = 0;
- secDesc->dsNext = nullptr;
-
- if (emitConsDsc.dsdLast)
- {
+ if (emitConsDsc.dsdLast)
emitConsDsc.dsdLast->dsNext = secDesc;
- }
else
- {
- emitConsDsc.dsdList = secDesc;
- }
+ emitConsDsc.dsdList = secDesc;
emitConsDsc.dsdLast = secDesc;
- return secOffs;
+ return secOffs;
}
// Start generating a constant data section for the current function
-// populated with BasicBlock references.
-// You can choose the references to be either absolute pointers, or
+// populated with BasicBlock references.
+// You can choose the references to be either absolute pointers, or
// 4-byte relative addresses.
-// Currently the relative references are relative to the start of the
+// Currently the relative references are relative to the start of the
// first block (this is somewhat arbitrary)
-UNATIVE_OFFSET emitter::emitBBTableDataGenBeg(unsigned numEntries, bool relativeAddr)
+UNATIVE_OFFSET emitter::emitBBTableDataGenBeg(unsigned numEntries,
+ bool relativeAddr)
{
- unsigned secOffs;
- dataSection* secDesc;
+ unsigned secOffs;
+ dataSection * secDesc;
- assert(emitDataSecCur == nullptr);
+ assert(emitDataSecCur == 0);
UNATIVE_OFFSET emittedSize;
@@ -5291,7 +5276,7 @@ UNATIVE_OFFSET emitter::emitBBTableDataGenBeg(unsigned numEntries, bool relative
{
emittedSize = numEntries * TARGET_POINTER_SIZE;
}
-
+
/* Get hold of the current offset */
secOffs = emitConsDsc.dsdOffs;
@@ -5302,26 +5287,26 @@ UNATIVE_OFFSET emitter::emitBBTableDataGenBeg(unsigned numEntries, bool relative
/* Allocate a data section descriptor and add it to the list */
- secDesc = emitDataSecCur = (dataSection*)emitGetMem(roundUp(sizeof(*secDesc) + numEntries * sizeof(BasicBlock*)));
-
+ secDesc = emitDataSecCur = (dataSection *)emitGetMem(roundUp(sizeof(*secDesc) + numEntries * sizeof(BasicBlock*)));
+
secDesc->dsSize = emittedSize;
-
+
secDesc->dsType = relativeAddr ? dataSection::blockRelative32 : dataSection::blockAbsoluteAddr;
+
+ secDesc->dsNext = 0;
- secDesc->dsNext = nullptr;
-
- if (emitConsDsc.dsdLast)
+ if (emitConsDsc.dsdLast)
{
emitConsDsc.dsdLast->dsNext = secDesc;
}
else
{
- emitConsDsc.dsdList = secDesc;
+ emitConsDsc.dsdList = secDesc;
}
emitConsDsc.dsdLast = secDesc;
- return secOffs;
+ return secOffs;
}
/*****************************************************************************
@@ -5329,7 +5314,9 @@ UNATIVE_OFFSET emitter::emitBBTableDataGenBeg(unsigned numEntries, bool relative
* Emit the given block of bits into the current data section.
*/
-void emitter::emitDataGenData(unsigned offs, const void* data, size_t size)
+void emitter::emitDataGenData(unsigned offs,
+ const void *data,
+ size_t size)
{
assert(emitDataSecCur && (emitDataSecCur->dsSize >= offs + size));
@@ -5343,7 +5330,8 @@ void emitter::emitDataGenData(unsigned offs, const void* data, size_t size)
* Emit the address of the given basic block into the current data section.
*/
-void emitter::emitDataGenData(unsigned index, BasicBlock* label)
+void emitter::emitDataGenData(unsigned index,
+ BasicBlock *label)
{
assert(emitDataSecCur != nullptr);
assert(emitDataSecCur->dsType == dataSection::blockAbsoluteAddr ||
@@ -5361,13 +5349,13 @@ void emitter::emitDataGenData(unsigned index, BasicBlock* label)
* We're done generating a data section.
*/
-void emitter::emitDataGenEnd()
+void emitter::emitDataGenEnd()
{
#ifdef DEBUG
- assert(emitDataSecCur);
- emitDataSecCur = nullptr;
+ assert(emitDataSecCur); emitDataSecCur = 0;
#endif
+
}
/********************************************************************************
@@ -5400,9 +5388,9 @@ UNATIVE_OFFSET emitter::emitDataConst(const void* cnsAddr, unsigned cnsSize, boo
* Output the given data section at the specified address.
*/
-void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst)
+void emitter::emitOutputDataSec(dataSecDsc *sec, BYTE *dst)
{
-#ifdef DEBUG
+#ifdef DEBUG
if (EMITVERBOSE)
{
printf("\nEmitting data sections: %u total bytes\n", sec->dsdOffs);
@@ -5417,7 +5405,7 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst)
/* Walk and emit the contents of all the data blocks */
- dataSection* dsc;
+ dataSection * dsc;
for (dsc = sec->dsdList; dsc; dsc = dsc->dsNext)
{
@@ -5430,16 +5418,16 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst)
assert(dscSize && dscSize % sizeof(BasicBlock*) == 0);
size_t numElems = dscSize / TARGET_POINTER_SIZE;
- BYTE** bDst = (BYTE**)dst;
- for (unsigned i = 0; i < numElems; i++)
+ BYTE** bDst = (BYTE**) dst;
+ for (unsigned i=0; i<numElems; i++)
{
BasicBlock* block = ((BasicBlock**)dsc->dsCont)[i];
- // Convert the BasicBlock* value to an IG address
- insGroup* lab = (insGroup*)emitCodeGetCookie(block);
+ // Convert the BasicBlock* value to an IG address
+ insGroup* lab = (insGroup*)emitCodeGetCookie(block);
- // Append the appropriate address to the destination
- BYTE* target = emitOffsetToPtr(lab->igOffs);
+ // Append the appropriate address to the destination
+ BYTE* target = emitOffsetToPtr(lab->igOffs);
#ifdef _TARGET_ARM_
target = (BYTE*)((size_t)target | 1); // Or in thumb bit
@@ -5452,35 +5440,37 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst)
JITDUMP(" BB%02u: 0x%p\n", block->bbNum, bDst[i]);
}
+
}
// relative label table
else if (dsc->dsType == dataSection::blockRelative32)
{
JITDUMP(" section %u, size %u, block relative addr\n", secNum++, dscSize);
- unsigned elemSize = 4;
- size_t numElems = dscSize / 4;
- unsigned* uDst = (unsigned*)dst;
+ unsigned elemSize = 4;
+ size_t numElems = dscSize / 4;
+ unsigned* uDst = (unsigned *) dst;
insGroup* labFirst = (insGroup*)emitCodeGetCookie(emitComp->fgFirstBB);
- for (unsigned i = 0; i < numElems; i++)
+ for (unsigned i=0; i<numElems; i++)
{
BasicBlock* block = ((BasicBlock**)dsc->dsCont)[i];
- // Convert the BasicBlock* value to an IG address
- insGroup* lab = (insGroup*)emitCodeGetCookie(block);
+ // Convert the BasicBlock* value to an IG address
+ insGroup* lab = (insGroup*)emitCodeGetCookie(block);
assert(FitsIn<uint32_t>(lab->igOffs - labFirst->igOffs));
- uDst[i] = lab->igOffs - labFirst->igOffs;
+ uDst[i] = lab->igOffs - labFirst->igOffs;
JITDUMP(" BB%02u: 0x%x\n", block->bbNum, uDst[i]);
}
+
}
else
{
JITDUMP(" section %u, size %u, raw data\n", secNum++, dscSize);
- // Simple binary data: copy the bytes to the target
+ // Simple binary data: copy the bytes to the target
assert(dsc->dsType == dataSection::data);
memcpy(dst, dsc->dsCont, dscSize);
@@ -5511,21 +5501,22 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst)
* Record the fact that the given variable now contains a live GC ref.
*/
-void emitter::emitGCvarLiveSet(int offs, GCtype gcType, BYTE* addr, ssize_t disp)
+void emitter::emitGCvarLiveSet(int offs,
+ GCtype gcType,
+ BYTE * addr,
+ ssize_t disp)
{
assert(emitIssuing);
- varPtrDsc* desc;
+ varPtrDsc * desc;
assert((abs(offs) % sizeof(ssize_t)) == 0);
assert(needsGC(gcType));
/* Compute the index into the GC frame table if the caller didn't do it */
- if (disp == -1)
- {
- disp = (offs - emitGCrFrameOffsMin) / sizeof(void*);
- }
+ if (disp == -1)
+ disp = (offs - emitGCrFrameOffsMin) / sizeof(void *);
assert((size_t)disp < emitGCrFrameOffsCnt);
@@ -5540,51 +5531,47 @@ void emitter::emitGCvarLiveSet(int offs, GCtype gcType, BYTE* addr, ssize_t disp
desc->vpdVarNum = offs;
- desc->vpdNext = nullptr;
+ desc->vpdNext = NULL;
/* the lower 2 bits encode props about the stk ptr */
- if (offs == emitSyncThisObjOffs)
+ if (offs == emitSyncThisObjOffs)
{
desc->vpdVarNum |= this_OFFSET_FLAG;
}
- if (gcType == GCT_BYREF)
+ if (gcType == GCT_BYREF)
{
desc->vpdVarNum |= byref_OFFSET_FLAG;
}
/* Append the new entry to the end of the list */
- if (codeGen->gcInfo.gcVarPtrLast == nullptr)
+ if (codeGen->gcInfo.gcVarPtrLast == NULL)
{
- assert(codeGen->gcInfo.gcVarPtrList == nullptr);
+ assert(codeGen->gcInfo.gcVarPtrList == NULL);
codeGen->gcInfo.gcVarPtrList = codeGen->gcInfo.gcVarPtrLast = desc;
}
else
{
- assert(codeGen->gcInfo.gcVarPtrList != nullptr);
+ assert(codeGen->gcInfo.gcVarPtrList != NULL);
codeGen->gcInfo.gcVarPtrLast->vpdNext = desc;
codeGen->gcInfo.gcVarPtrLast = desc;
}
/* Record the variable descriptor in the table */
- assert(emitGCrFrameLiveTab[disp] == nullptr);
- emitGCrFrameLiveTab[disp] = desc;
+ assert(emitGCrFrameLiveTab[disp] == NULL);
+ emitGCrFrameLiveTab[disp] = desc;
-#ifdef DEBUG
- if (EMITVERBOSE)
+#ifdef DEBUG
+ if (EMITVERBOSE)
{
printf("[%08X] %s var born at [%s", dspPtr(desc), GCtypeStr(gcType), emitGetFrameReg());
- if (offs < 0)
- {
+ if (offs < 0)
printf("-%02XH", -offs);
- }
else if (offs > 0)
- {
printf("+%02XH", +offs);
- }
printf("]\n");
}
@@ -5600,53 +5587,50 @@ void emitter::emitGCvarLiveSet(int offs, GCtype gcType, BYTE* addr, ssize_t disp
* Record the fact that the given variable no longer contains a live GC ref.
*/
-void emitter::emitGCvarDeadSet(int offs, BYTE* addr, ssize_t disp)
+void emitter::emitGCvarDeadSet(int offs, BYTE *addr, ssize_t disp)
{
assert(emitIssuing);
- varPtrDsc* desc;
+ varPtrDsc * desc;
assert(abs(offs) % sizeof(int) == 0);
/* Compute the index into the GC frame table if the caller didn't do it */
- if (disp == -1)
- {
- disp = (offs - emitGCrFrameOffsMin) / sizeof(void*);
- }
+ if (disp == -1)
+ disp = (offs - emitGCrFrameOffsMin) / sizeof(void *);
assert((unsigned)disp < emitGCrFrameOffsCnt);
/* Get hold of the lifetime descriptor and clear the entry */
- desc = emitGCrFrameLiveTab[disp];
- emitGCrFrameLiveTab[disp] = nullptr;
+ desc = emitGCrFrameLiveTab[disp];
+ emitGCrFrameLiveTab[disp] = NULL;
- assert(desc);
+ assert( desc);
assert((desc->vpdVarNum & ~OFFSET_MASK) == (unsigned)offs);
/* Record the death code offset */
assert(desc->vpdEndOfs == 0xFACEDEAD);
- desc->vpdEndOfs = emitCurCodeOffs(addr);
+ desc->vpdEndOfs = emitCurCodeOffs(addr);
-#ifdef DEBUG
- if (EMITVERBOSE)
+#ifdef DEBUG
+ if (EMITVERBOSE)
{
- GCtype gcType = (desc->vpdVarNum & byref_OFFSET_FLAG) ? GCT_BYREF : GCT_GCREF;
- bool isThis = (desc->vpdVarNum & this_OFFSET_FLAG) != 0;
+ GCtype gcType = (desc->vpdVarNum & byref_OFFSET_FLAG) ? GCT_BYREF : GCT_GCREF;
+ bool isThis = (desc->vpdVarNum & this_OFFSET_FLAG) != 0;
- printf("[%08X] %s%s var died at [%s", dspPtr(desc), GCtypeStr(gcType), isThis ? "this-ptr" : "",
+ printf("[%08X] %s%s var died at [%s",
+ dspPtr(desc),
+ GCtypeStr(gcType),
+ isThis ? "this-ptr" : "",
emitGetFrameReg());
- if (offs < 0)
- {
+ if (offs < 0)
printf("-%02XH", -offs);
- }
else if (offs > 0)
- {
printf("+%02XH", +offs);
- }
printf("]\n");
}
@@ -5662,25 +5646,21 @@ void emitter::emitGCvarDeadSet(int offs, BYTE* addr, ssize_t disp)
* Record a new set of live GC ref variables.
*/
-void emitter::emitUpdateLiveGCvars(VARSET_VALARG_TP vars, BYTE* addr)
+void emitter::emitUpdateLiveGCvars(VARSET_VALARG_TP vars, BYTE *addr)
{
assert(emitIssuing);
// Don't track GC changes in epilogs
if (emitIGisInEpilog(emitCurIG))
- {
return;
- }
/* Is the current set accurate and unchanged? */
- if (emitThisGCrefVset && VarSetOps::Equal(emitComp, emitThisGCrefVars, vars))
- {
+ if (emitThisGCrefVset && VarSetOps::Equal(emitComp, emitThisGCrefVars, vars))
return;
- }
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
{
printf("New GC ref live vars=%s ", VarSetOps::ToString(emitComp, vars));
dumpConvertedVarSet(emitComp, vars);
@@ -5692,35 +5672,38 @@ void emitter::emitUpdateLiveGCvars(VARSET_VALARG_TP vars, BYTE* addr)
/* Are there any GC ref variables on the stack? */
- if (emitGCrFrameOffsCnt)
+ if (emitGCrFrameOffsCnt)
{
- int* tab;
- unsigned cnt = emitTrkVarCnt;
- unsigned num;
+ int * tab;
+ unsigned cnt = emitTrkVarCnt;
+ unsigned num;
/* Test all the tracked variable bits in the mask */
- for (num = 0, tab = emitGCrFrameOffsTab; num < cnt; num++, tab++)
+ for (num = 0, tab = emitGCrFrameOffsTab;
+ num < cnt;
+ num++ , tab++)
{
- int val = *tab;
+ int val = *tab;
- if (val != -1)
+ if (val != -1)
{
// byref_OFFSET_FLAG and this_OFFSET_FLAG are set
// in the table-offsets for byrefs and this-ptr
- int offs = val & ~OFFSET_MASK;
+ int offs = val & ~OFFSET_MASK;
// printf("var #%2u at %3d is now %s\n", num, offs, (vars & 1) ? "live" : "dead");
- if (VarSetOps::IsMember(emitComp, vars, num))
+ if (VarSetOps::IsMember(emitComp, vars, num))
{
- GCtype gcType = (val & byref_OFFSET_FLAG) ? GCT_BYREF : GCT_GCREF;
+ GCtype gcType = (val & byref_OFFSET_FLAG) ? GCT_BYREF
+ : GCT_GCREF;
emitGCvarLiveUpd(offs, INT_MAX, gcType, addr);
}
else
{
- emitGCvarDeadUpd(offs, addr);
+ emitGCvarDeadUpd(offs, addr);
}
}
}
@@ -5735,31 +5718,32 @@ void emitter::emitUpdateLiveGCvars(VARSET_VALARG_TP vars, BYTE* addr)
* will not be fully interruptible).
*/
-void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
+void emitter::emitRecordGCcall(BYTE * codePos,
+ unsigned char callInstrSize)
{
assert(emitIssuing);
assert(!emitFullGCinfo);
- unsigned offs = emitCurCodeOffs(codePos);
- unsigned regs = (emitThisGCrefRegs | emitThisByrefRegs) & ~RBM_INTRET;
- callDsc* call;
+ unsigned offs = emitCurCodeOffs(codePos);
+ unsigned regs = (emitThisGCrefRegs|emitThisByrefRegs) & ~RBM_INTRET;
+ callDsc * call;
#ifdef JIT32_GCENCODER
- // The JIT32 GCInfo encoder allows us to (as the comment previously here said):
+ // The JIT32 GCInfo encoder allows us to (as the comment previously here said):
// "Bail if this is a totally boring call", but the GCInfoEncoder/Decoder interface
// requires a definition for every call site, so we skip these "early outs" when we're
// using the general encoder.
- if (regs == 0)
+ if (regs == 0)
{
#if EMIT_TRACK_STACK_DEPTH
- if (emitCurStackLvl == 0)
+ if (emitCurStackLvl == 0)
return;
#endif
/* Nope, only interesting calls get recorded */
- if (emitSimpleStkUsed)
+ if (emitSimpleStkUsed)
{
- if (!u1.emitSimpleStkMask)
+ if (!u1.emitSimpleStkMask)
return;
}
else
@@ -5770,22 +5754,22 @@ void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
}
#endif // JIT32_GCENCODER
-#ifdef DEBUG
+#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
+ if (EMIT_GC_VERBOSE)
{
printf("; Call at %04X [stk=%u], GCvars=", offs - callInstrSize, emitCurStackLvl);
emitDispVarSet();
printf(", gcrefRegs=");
printRegMaskInt(emitThisGCrefRegs);
- emitDispRegSet(emitThisGCrefRegs);
- // printRegMaskInt(emitThisGCrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
- // emitDispRegSet (emitThisGCrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
+ emitDispRegSet (emitThisGCrefRegs);
+ //printRegMaskInt(emitThisGCrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
+ //emitDispRegSet (emitThisGCrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
printf(", byrefRegs=");
printRegMaskInt(emitThisByrefRegs);
- emitDispRegSet(emitThisByrefRegs);
- // printRegMaskInt(emitThisByrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
- // emitDispRegSet (emitThisByrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
+ emitDispRegSet (emitThisByrefRegs);
+ //printRegMaskInt(emitThisByrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
+ //emitDispRegSet (emitThisByrefRegs & ~RBM_INTRET & RBM_CALLEE_SAVED); // only display callee-saved
printf("\n");
}
@@ -5795,15 +5779,15 @@ void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
call = new (emitComp, CMK_GC) callDsc;
- call->cdBlock = nullptr;
- call->cdOffs = offs;
+ call->cdBlock = NULL;
+ call->cdOffs = offs;
#ifndef JIT32_GCENCODER
call->cdCallInstrSize = callInstrSize;
#endif
- call->cdNext = nullptr;
+ call->cdNext = NULL;
- call->cdGCrefRegs = (regMaskSmall)emitThisGCrefRegs;
- call->cdByrefRegs = (regMaskSmall)emitThisByrefRegs;
+ call->cdGCrefRegs = (regMaskSmall)emitThisGCrefRegs;
+ call->cdByrefRegs = (regMaskSmall)emitThisByrefRegs;
#if EMIT_TRACK_STACK_DEPTH
#ifndef FEATURE_UNIX_AMD64_STRUCT_PASSING
@@ -5812,21 +5796,21 @@ void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
#endif
// Append the call descriptor to the list */
- if (codeGen->gcInfo.gcCallDescLast == nullptr)
+ if (codeGen->gcInfo.gcCallDescLast == NULL)
{
- assert(codeGen->gcInfo.gcCallDescList == nullptr);
+ assert(codeGen->gcInfo.gcCallDescList == NULL);
codeGen->gcInfo.gcCallDescList = codeGen->gcInfo.gcCallDescLast = call;
}
else
{
- assert(codeGen->gcInfo.gcCallDescList != nullptr);
+ assert(codeGen->gcInfo.gcCallDescList != NULL);
codeGen->gcInfo.gcCallDescLast->cdNext = call;
codeGen->gcInfo.gcCallDescLast = call;
}
/* Record the current "pending" argument list */
- if (emitSimpleStkUsed)
+ if (emitSimpleStkUsed)
{
/* The biggest call is less than MAX_SIMPLE_STK_DEPTH. So use
small format */
@@ -5840,21 +5824,22 @@ void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
/* The current call has too many arguments, so we need to report the
offsets of each individual GC arg. */
- call->cdArgCnt = u2.emitGcArgTrackCnt;
+ call->cdArgCnt = u2.emitGcArgTrackCnt;
if (call->cdArgCnt == 0)
{
- call->u1.cdArgMask = call->u1.cdByrefArgMask = 0;
+ call->u1.cdArgMask =
+ call->u1.cdByrefArgMask = 0;
return;
}
- call->cdArgTable = new (emitComp, CMK_GC) unsigned[u2.emitGcArgTrackCnt];
+ call->cdArgTable = new (emitComp, CMK_GC) unsigned[u2.emitGcArgTrackCnt];
unsigned gcArgs = 0;
- unsigned stkLvl = emitCurStackLvl / sizeof(int);
+ unsigned stkLvl = emitCurStackLvl/sizeof(int);
for (unsigned i = 0; i < stkLvl; i++)
{
- GCtype gcType = (GCtype)u2.emitArgTrackTab[stkLvl - i - 1];
+ GCtype gcType = (GCtype)u2.emitArgTrackTab[stkLvl-i-1];
if (needsGC(gcType))
{
@@ -5878,42 +5863,44 @@ void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
* Record a new set of live GC ref registers.
*/
-void emitter::emitUpdateLiveGCregs(GCtype gcType, regMaskTP regs, BYTE* addr)
+void emitter::emitUpdateLiveGCregs(GCtype gcType,
+ regMaskTP regs,
+ BYTE * addr)
{
assert(emitIssuing);
// Don't track GC changes in epilogs
if (emitIGisInEpilog(emitCurIG))
- {
return;
- }
- regMaskTP life;
- regMaskTP dead;
- regMaskTP chg;
+ regMaskTP life;
+ regMaskTP dead;
+ regMaskTP chg;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
{
printf("New %sReg live regs=", GCtypeStr(gcType));
printRegMaskInt(regs);
- emitDispRegSet(regs);
+ emitDispRegSet (regs);
printf("\n");
}
#endif
assert(needsGC(gcType));
- regMaskTP& emitThisXXrefRegs = (gcType == GCT_GCREF) ? emitThisGCrefRegs : emitThisByrefRegs;
- regMaskTP& emitThisYYrefRegs = (gcType == GCT_GCREF) ? emitThisByrefRegs : emitThisGCrefRegs;
+ regMaskTP & emitThisXXrefRegs = (gcType == GCT_GCREF) ? emitThisGCrefRegs
+ : emitThisByrefRegs;
+ regMaskTP & emitThisYYrefRegs = (gcType == GCT_GCREF) ? emitThisByrefRegs
+ : emitThisGCrefRegs;
assert(emitThisXXrefRegs != regs);
- if (emitFullGCinfo)
+ if (emitFullGCinfo)
{
/* Figure out which GC registers are becoming live/dead at this point */
- dead = (emitThisXXrefRegs & ~regs);
- life = (~emitThisXXrefRegs & regs);
+ dead = ( emitThisXXrefRegs & ~regs);
+ life = (~emitThisXXrefRegs & regs);
/* Can't simultaneously become live and dead at the same time */
@@ -5926,27 +5913,24 @@ void emitter::emitUpdateLiveGCregs(GCtype gcType, regMaskTP regs, BYTE* addr)
do
{
- regMaskTP bit = genFindLowestBit(chg);
- regNumber reg = genRegNumFromMask(bit);
+ regMaskTP bit = genFindLowestBit(chg);
+ regNumber reg = genRegNumFromMask(bit);
- if (life & bit)
- {
+ if (life & bit)
emitGCregLiveUpd(gcType, reg, addr);
- }
else
- {
emitGCregDeadUpd(reg, addr);
- }
chg -= bit;
- } while (chg);
+ }
+ while (chg);
assert(emitThisXXrefRegs == regs);
}
else
{
emitThisYYrefRegs &= ~regs; // Kill the regs from the other GC type (if live)
- emitThisXXrefRegs = regs; // Mark them as live in the requested GC type
+ emitThisXXrefRegs = regs; // Mark them as live in the requested GC type
}
// The 2 GC reg masks can't be overlapping
@@ -5959,23 +5943,26 @@ void emitter::emitUpdateLiveGCregs(GCtype gcType, regMaskTP regs, BYTE* addr)
* Record the fact that the given register now contains a live GC ref.
*/
-void emitter::emitGCregLiveSet(GCtype gcType, regMaskTP regMask, BYTE* addr, bool isThis)
+void emitter::emitGCregLiveSet(GCtype gcType,
+ regMaskTP regMask,
+ BYTE * addr,
+ bool isThis)
{
assert(emitIssuing);
assert(needsGC(gcType));
- regPtrDsc* regPtrNext;
+ regPtrDsc * regPtrNext;
assert(!isThis || emitComp->lvaKeepAliveAndReportThis());
// assert(emitFullyInt || isThis);
assert(emitFullGCinfo);
- assert(((emitThisGCrefRegs | emitThisByrefRegs) & regMask) == 0);
+ assert(((emitThisGCrefRegs|emitThisByrefRegs) & regMask) == 0);
/* Allocate a new regptr entry and fill it in */
- regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
- regPtrNext->rpdGCtype = gcType;
+ regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
+ regPtrNext->rpdGCtype = gcType;
regPtrNext->rpdOffs = emitCurCodeOffs(addr);
regPtrNext->rpdArg = FALSE;
@@ -5990,22 +5977,24 @@ void emitter::emitGCregLiveSet(GCtype gcType, regMaskTP regMask, BYTE* addr, boo
* Record the fact that the given register no longer contains a live GC ref.
*/
-void emitter::emitGCregDeadSet(GCtype gcType, regMaskTP regMask, BYTE* addr)
+void emitter::emitGCregDeadSet(GCtype gcType,
+ regMaskTP regMask,
+ BYTE * addr)
{
assert(emitIssuing);
assert(needsGC(gcType));
- regPtrDsc* regPtrNext;
+ regPtrDsc * regPtrNext;
// assert(emitFullyInt);
assert(emitFullGCinfo);
- assert(((emitThisGCrefRegs | emitThisByrefRegs) & regMask) != 0);
+ assert(((emitThisGCrefRegs|emitThisByrefRegs) & regMask) != 0);
/* Allocate a new regptr entry and fill it in */
- regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
- regPtrNext->rpdGCtype = gcType;
+ regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
+ regPtrNext->rpdGCtype = gcType;
regPtrNext->rpdOffs = emitCurCodeOffs(addr);
regPtrNext->rpdCall = FALSE;
@@ -6020,22 +6009,19 @@ void emitter::emitGCregDeadSet(GCtype gcType, regMaskTP regMask, BYTE* addr)
* Emit an 8-bit integer as code.
*/
-unsigned char emitter::emitOutputByte(BYTE* dst, ssize_t val)
+unsigned char emitter::emitOutputByte(BYTE *dst, ssize_t val)
{
- *castto(dst, unsigned char*) = (unsigned char)val;
+ *castto(dst, unsigned char *) = (unsigned char)val;
-#ifdef DEBUG
- if (emitComp->opts.dspEmit)
- {
- printf("; emit_byte 0%02XH\n", val & 0xFF);
- }
+#ifdef DEBUG
+ if (emitComp->opts.dspEmit) printf("; emit_byte 0%02XH\n", val & 0xFF);
#ifdef _TARGET_AMD64_
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
assert(((val & 0xFF00000000LL) == 0) || ((val & 0xFFFFFFFF00000000LL) == 0xFFFFFFFF00000000LL));
#endif // _TARGET_AMD64_
#endif
- return sizeof(unsigned char);
+ return sizeof(unsigned char);
}
/*****************************************************************************
@@ -6043,22 +6029,19 @@ unsigned char emitter::emitOutputByte(BYTE* dst, ssize_t val)
* Emit a 16-bit integer as code.
*/
-unsigned char emitter::emitOutputWord(BYTE* dst, ssize_t val)
+unsigned char emitter::emitOutputWord(BYTE *dst, ssize_t val)
{
MISALIGNED_WR_I2(dst, (short)val);
-#ifdef DEBUG
- if (emitComp->opts.dspEmit)
- {
- printf("; emit_word 0%02XH,0%02XH\n", (val & 0xFF), (val >> 8) & 0xFF);
- }
+#ifdef DEBUG
+ if (emitComp->opts.dspEmit) printf("; emit_word 0%02XH,0%02XH\n", (val & 0xFF), (val >> 8) & 0xFF);
#ifdef _TARGET_AMD64_
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
assert(((val & 0xFF00000000LL) == 0) || ((val & 0xFFFFFFFF00000000LL) == 0xFFFFFFFF00000000LL));
#endif // _TARGET_AMD64_
#endif
- return sizeof(short);
+ return sizeof(short);
}
/*****************************************************************************
@@ -6066,22 +6049,19 @@ unsigned char emitter::emitOutputWord(BYTE* dst, ssize_t val)
* Emit a 32-bit integer as code.
*/
-unsigned char emitter::emitOutputLong(BYTE* dst, ssize_t val)
+unsigned char emitter::emitOutputLong(BYTE *dst, ssize_t val)
{
MISALIGNED_WR_I4(dst, (int)val);
-#ifdef DEBUG
- if (emitComp->opts.dspEmit)
- {
- printf("; emit_long 0%08XH\n", val);
- }
+#ifdef DEBUG
+ if (emitComp->opts.dspEmit) printf("; emit_long 0%08XH\n", val);
#ifdef _TARGET_AMD64_
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
assert(((val & 0xFF00000000LL) == 0) || ((val & 0xFFFFFFFF00000000LL) == 0xFFFFFFFF00000000LL));
#endif // _TARGET_AMD64_
#endif
- return sizeof(int);
+ return sizeof(int );
}
/*****************************************************************************
@@ -6089,22 +6069,22 @@ unsigned char emitter::emitOutputLong(BYTE* dst, ssize_t val)
* Emit a pointer-sized integer as code.
*/
-unsigned char emitter::emitOutputSizeT(BYTE* dst, ssize_t val)
+unsigned char emitter::emitOutputSizeT(BYTE *dst, ssize_t val)
{
MISALIGNED_WR_ST(dst, val);
-#ifdef DEBUG
+#ifdef DEBUG
if (emitComp->opts.dspEmit)
{
#ifdef _TARGET_AMD64_
printf("; emit_size_t 0%016llXH\n", (size_t)val);
-#else // _TARGET_AMD64_
+#else // _TARGET_AMD64_
printf("; emit_size_t 0%08XH\n", (size_t)val);
#endif // _TARGET_AMD64_
}
#endif // DEBUG
- return sizeof(size_t);
+ return sizeof(size_t );
}
/*****************************************************************************
@@ -6113,12 +6093,12 @@ unsigned char emitter::emitOutputSizeT(BYTE* dst, ssize_t val)
* this can only be called at the end of code generation.
*/
-UNATIVE_OFFSET emitter::emitCodeOffset(void* blockPtr, unsigned codePos)
+UNATIVE_OFFSET emitter::emitCodeOffset(void *blockPtr, unsigned codePos)
{
- insGroup* ig;
+ insGroup * ig;
- UNATIVE_OFFSET of;
- unsigned no = emitGetInsNumFromCodePos(codePos);
+ UNATIVE_OFFSET of;
+ unsigned no = emitGetInsNumFromCodePos(codePos);
/* Make sure we weren't passed some kind of a garbage thing */
@@ -6129,7 +6109,7 @@ UNATIVE_OFFSET emitter::emitCodeOffset(void* blockPtr, unsigned codePos)
/* The first and last offsets are always easy */
- if (no == 0)
+ if (no == 0)
{
of = 0;
}
@@ -6159,7 +6139,7 @@ UNATIVE_OFFSET emitter::emitCodeOffset(void* blockPtr, unsigned codePos)
assert(of == emitFindOffset(ig, emitGetInsNumFromCodePos(codePos)));
}
- return ig->igOffs + of;
+ return ig->igOffs + of;
}
/*****************************************************************************
@@ -6167,52 +6147,46 @@ UNATIVE_OFFSET emitter::emitCodeOffset(void* blockPtr, unsigned codePos)
* Record the fact that the given register now contains a live GC ref.
*/
-void emitter::emitGCregLiveUpd(GCtype gcType, regNumber reg, BYTE* addr)
+void emitter::emitGCregLiveUpd(GCtype gcType, regNumber reg, BYTE *addr)
{
assert(emitIssuing);
// Don't track GC changes in epilogs
if (emitIGisInEpilog(emitCurIG))
- {
return;
- }
assert(needsGC(gcType));
regMaskTP regMask = genRegMask(reg);
- regMaskTP& emitThisXXrefRegs = (gcType == GCT_GCREF) ? emitThisGCrefRegs : emitThisByrefRegs;
- regMaskTP& emitThisYYrefRegs = (gcType == GCT_GCREF) ? emitThisByrefRegs : emitThisGCrefRegs;
+ regMaskTP & emitThisXXrefRegs = (gcType == GCT_GCREF) ? emitThisGCrefRegs
+ : emitThisByrefRegs;
+ regMaskTP & emitThisYYrefRegs = (gcType == GCT_GCREF) ? emitThisByrefRegs
+ : emitThisGCrefRegs;
- if ((emitThisXXrefRegs & regMask) == 0)
+ if ((emitThisXXrefRegs & regMask) == 0)
{
// If the register was holding the other GC type, that type should
// go dead now
if (emitThisYYrefRegs & regMask)
- {
emitGCregDeadUpd(reg, addr);
- }
// For synchronized methods, "this" is always alive and in the same register.
// However, if we generate any code after the epilog block (where "this"
// goes dead), "this" will come alive again. We need to notice that.
// Note that we only expect isThis to be true at an insGroup boundary.
-
+
bool isThis = (reg == emitSyncThisObjReg) ? true : false;
-
- if (emitFullGCinfo)
- {
+
+ if (emitFullGCinfo)
emitGCregLiveSet(gcType, regMask, addr, isThis);
- }
- emitThisXXrefRegs |= regMask;
+ emitThisXXrefRegs |= regMask;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
printf("%sReg +[%s]\n", GCtypeStr(gcType), emitRegName(reg));
- }
#endif
}
@@ -6226,70 +6200,57 @@ void emitter::emitGCregLiveUpd(GCtype gcType, regNumber reg, BYTE* addr)
* Record the fact that the given set of registers no longer contain live GC refs.
*/
-void emitter::emitGCregDeadUpdMask(regMaskTP regs, BYTE* addr)
+void emitter::emitGCregDeadUpdMask(regMaskTP regs, BYTE *addr)
{
assert(emitIssuing);
// Don't track GC changes in epilogs
if (emitIGisInEpilog(emitCurIG))
- {
return;
- }
// First, handle the gcref regs going dead
- regMaskTP gcrefRegs = emitThisGCrefRegs & regs;
+ regMaskTP gcrefRegs = emitThisGCrefRegs & regs;
// "this" can never go dead in synchronized methods, except in the epilog
// after the call to CORINFO_HELP_MON_EXIT.
- assert(emitSyncThisObjReg == REG_NA || (genRegMask(emitSyncThisObjReg) & regs) == 0);
+ assert(emitSyncThisObjReg == REG_NA ||
+ (genRegMask(emitSyncThisObjReg) & regs) == 0);
- if (gcrefRegs)
+ if (gcrefRegs)
{
assert((emitThisByrefRegs & gcrefRegs) == 0);
- if (emitFullGCinfo)
- {
+ if (emitFullGCinfo)
emitGCregDeadSet(GCT_GCREF, gcrefRegs, addr);
- }
emitThisGCrefRegs &= ~gcrefRegs;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
{
- printf("gcrReg ");
- printRegMaskInt(gcrefRegs);
- printf(" -");
- emitDispRegSet(gcrefRegs);
- printf("\n");
+ printf("gcrReg "); printRegMaskInt(gcrefRegs); printf(" -"); emitDispRegSet(gcrefRegs); printf("\n");
}
#endif
}
// Second, handle the byref regs going dead
- regMaskTP byrefRegs = emitThisByrefRegs & regs;
+ regMaskTP byrefRegs = emitThisByrefRegs & regs;
if (byrefRegs)
{
assert((emitThisGCrefRegs & byrefRegs) == 0);
- if (emitFullGCinfo)
- {
+ if (emitFullGCinfo)
emitGCregDeadSet(GCT_BYREF, byrefRegs, addr);
- }
emitThisByrefRegs &= ~byrefRegs;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
{
- printf("byrReg ");
- printRegMaskInt(byrefRegs);
- printf(" -");
- emitDispRegSet(byrefRegs);
- printf("\n");
+ printf("byrReg "); printRegMaskInt(byrefRegs); printf(" -"); emitDispRegSet(byrefRegs); printf("\n");
}
#endif
}
@@ -6300,50 +6261,40 @@ void emitter::emitGCregDeadUpdMask(regMaskTP regs, BYTE* addr)
* Record the fact that the given register no longer contains a live GC ref.
*/
-void emitter::emitGCregDeadUpd(regNumber reg, BYTE* addr)
+void emitter::emitGCregDeadUpd(regNumber reg, BYTE *addr)
{
assert(emitIssuing);
// Don't track GC changes in epilogs
if (emitIGisInEpilog(emitCurIG))
- {
return;
- }
- regMaskTP regMask = genRegMask(reg);
+ regMaskTP regMask = genRegMask(reg);
- if ((emitThisGCrefRegs & regMask) != 0)
+ if ((emitThisGCrefRegs & regMask) != 0)
{
assert((emitThisByrefRegs & regMask) == 0);
- if (emitFullGCinfo)
- {
+ if (emitFullGCinfo)
emitGCregDeadSet(GCT_GCREF, regMask, addr);
- }
emitThisGCrefRegs &= ~regMask;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
printf("%s -[%s]\n", "gcrReg", emitRegName(reg));
- }
#endif
}
else if ((emitThisByrefRegs & regMask) != 0)
{
- if (emitFullGCinfo)
- {
+ if (emitFullGCinfo)
emitGCregDeadSet(GCT_BYREF, regMask, addr);
- }
emitThisByrefRegs &= ~regMask;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
printf("%s -[%s]\n", "byrReg", emitRegName(reg));
- }
#endif
}
}
@@ -6356,7 +6307,10 @@ void emitter::emitGCregDeadUpd(regNumber reg, BYTE* addr)
* need a valid value to check if the variable is tracked or not.
*/
-void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
+void emitter::emitGCvarLiveUpd(int offs,
+ int varNum,
+ GCtype gcType,
+ BYTE* addr)
{
assert(abs(offs) % sizeof(int) == 0);
assert(needsGC(gcType));
@@ -6370,21 +6324,19 @@ void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
outgoing argument space.
Allocate a new ptr arg entry and fill it in */
- regPtrDsc* regPtrNext = gcInfo->gcRegPtrAllocDsc();
- regPtrNext->rpdGCtype = gcType;
- regPtrNext->rpdOffs = emitCurCodeOffs(addr);
- regPtrNext->rpdArg = TRUE;
- regPtrNext->rpdCall = FALSE;
+ regPtrDsc * regPtrNext = gcInfo->gcRegPtrAllocDsc();
+ regPtrNext->rpdGCtype = gcType;
+ regPtrNext->rpdOffs = emitCurCodeOffs(addr);
+ regPtrNext->rpdArg = TRUE;
+ regPtrNext->rpdCall = FALSE;
noway_assert(FitsIn<unsigned short>(offs));
- regPtrNext->rpdPtrArg = (unsigned short)offs;
- regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_PUSH;
- regPtrNext->rpdIsThis = FALSE;
+ regPtrNext->rpdPtrArg = (unsigned short)offs;
+ regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_PUSH;
+ regPtrNext->rpdIsThis = FALSE;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
printf("[%04X] %s arg write\n", offs, GCtypeStr(gcType));
- }
#endif
}
}
@@ -6393,7 +6345,8 @@ void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
{
/* Is the frame offset within the "interesting" range? */
- if (offs >= emitGCrFrameOffsMin && offs < emitGCrFrameOffsMax)
+ if (offs >= emitGCrFrameOffsMin &&
+ offs < emitGCrFrameOffsMax)
{
/* Normally all variables in this range must be tracked stack
pointers. However, for EnC, we relax this condition. So we
@@ -6408,7 +6361,7 @@ void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
{
// This is NOT a spill temp
LclVarDsc* varDsc = &emitComp->lvaTable[varNum];
- isTracked = emitComp->lvaIsGCTracked(varDsc);
+ isTracked = emitComp->lvaIsGCTracked(varDsc);
}
else
{
@@ -6421,8 +6374,7 @@ void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
assert(!emitContTrkPtrLcls ||
// EBP based variables in the double-aligned frames are indeed input arguments.
// and we don't require them to fall into the "interesting" range.
- ((emitComp->rpFrameType == FT_DOUBLE_ALIGN_FRAME) && (varNum >= 0) &&
- (emitComp->lvaTable[varNum].lvFramePointerBased == 1)));
+ ((emitComp->rpFrameType == FT_DOUBLE_ALIGN_FRAME) && (varNum >= 0) && (emitComp->lvaTable[varNum].lvFramePointerBased == 1)));
#else
assert(!emitContTrkPtrLcls);
#endif
@@ -6430,19 +6382,17 @@ void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
}
}
- size_t disp;
+ size_t disp;
/* Compute the index into the GC frame table */
- disp = (offs - emitGCrFrameOffsMin) / sizeof(void*);
+ disp = (offs - emitGCrFrameOffsMin) / sizeof(void *);
assert(disp < emitGCrFrameOffsCnt);
/* If the variable is currently dead, mark it as live */
- if (emitGCrFrameLiveTab[disp] == nullptr)
- {
+ if (emitGCrFrameLiveTab[disp] == NULL)
emitGCvarLiveSet(offs, gcType, addr, disp);
- }
}
}
}
@@ -6452,28 +6402,27 @@ void emitter::emitGCvarLiveUpd(int offs, int varNum, GCtype gcType, BYTE* addr)
* Record the fact that the given variable no longer contains a live GC ref.
*/
-void emitter::emitGCvarDeadUpd(int offs, BYTE* addr)
+void emitter::emitGCvarDeadUpd(int offs, BYTE *addr)
{
assert(emitIssuing);
assert(abs(offs) % sizeof(int) == 0);
/* Is the frame offset within the "interesting" range? */
- if (offs >= emitGCrFrameOffsMin && offs < emitGCrFrameOffsMax)
+ if (offs >= emitGCrFrameOffsMin &&
+ offs < emitGCrFrameOffsMax)
{
- size_t disp;
+ size_t disp;
/* Compute the index into the GC frame table */
- disp = (offs - emitGCrFrameOffsMin) / sizeof(void*);
+ disp = (offs - emitGCrFrameOffsMin) / sizeof(void *);
assert(disp < emitGCrFrameOffsCnt);
/* If the variable is currently live, mark it as dead */
- if (emitGCrFrameLiveTab[disp] != nullptr)
- {
+ if (emitGCrFrameLiveTab[disp] != NULL)
emitGCvarDeadSet(offs, addr, disp);
- }
}
}
@@ -6484,7 +6433,7 @@ void emitter::emitGCvarDeadUpd(int offs, BYTE* addr)
insGroup* emitter::emitAllocAndLinkIG()
{
- insGroup* ig = emitAllocIG();
+ insGroup* ig = emitAllocIG();
assert(emitCurIG);
@@ -6496,7 +6445,7 @@ insGroup* emitter::emitAllocAndLinkIG()
/* Set the new IG as the current IG */
- emitCurIG = ig;
+ emitCurIG = ig;
return ig;
}
@@ -6508,21 +6457,21 @@ insGroup* emitter::emitAllocAndLinkIG()
insGroup* emitter::emitAllocIG()
{
- insGroup* ig;
+ insGroup * ig;
/* Allocate a group descriptor */
size_t sz = sizeof(insGroup);
- ig = (insGroup*)emitGetMem(sz);
+ ig = (insGroup*)emitGetMem(sz);
-#ifdef DEBUG
- ig->igSelf = ig;
+#ifdef DEBUG
+ ig->igSelf = ig;
#endif
#if EMITTER_STATS
emitTotalIGcnt += 1;
emitTotalIGsize += sz;
- emitSizeMethod += sz;
+ emitSizeMethod += sz;
#endif
/* Do basic initialization */
@@ -6537,31 +6486,31 @@ insGroup* emitter::emitAllocIG()
* Initialize an instruction group
*/
-void emitter::emitInitIG(insGroup* ig)
+void emitter::emitInitIG(insGroup* ig)
{
/* Assign the next available index to the instruction group */
- ig->igNum = emitNxtIGnum;
+ ig->igNum = emitNxtIGnum;
emitNxtIGnum++;
/* Record the (estimated) code offset of the group */
- ig->igOffs = emitCurCodeOffset;
+ ig->igOffs = emitCurCodeOffset;
assert(IsCodeAligned(ig->igOffs));
/* Set the current function index */
- ig->igFuncIdx = emitComp->compCurrFuncIdx;
+ ig->igFuncIdx = emitComp->compCurrFuncIdx;
- ig->igFlags = 0;
+ ig->igFlags = 0;
/* Zero out some fields to avoid printing garbage in JitDumps. These
really only need to be set in DEBUG, but do it in all cases to make
sure we act the same in non-DEBUG builds.
*/
- ig->igSize = 0;
+ ig->igSize = 0;
ig->igGCregs = RBM_NONE;
ig->igInsCnt = 0;
}
@@ -6571,13 +6520,13 @@ void emitter::emitInitIG(insGroup* ig)
* Insert instruction group 'ig' after 'igInsertAfterIG'
*/
-void emitter::emitInsertIGAfter(insGroup* insertAfterIG, insGroup* ig)
+void emitter::emitInsertIGAfter(insGroup* insertAfterIG, insGroup* ig)
{
assert(emitIGlist);
assert(emitIGlast);
- ig->igNext = insertAfterIG->igNext;
- insertAfterIG->igNext = ig;
+ ig->igNext = insertAfterIG->igNext;
+ insertAfterIG->igNext = ig;
if (emitIGlast == insertAfterIG)
{
@@ -6591,7 +6540,7 @@ void emitter::emitInsertIGAfter(insGroup* insertAfterIG, insGroup* ig)
* Save the current IG and start a new one.
*/
-void emitter::emitNxtIG(bool emitAdd)
+void emitter::emitNxtIG(bool emitAdd)
{
/* Right now we don't allow multi-IG prologs */
@@ -6604,7 +6553,7 @@ void emitter::emitNxtIG(bool emitAdd)
/* Update the GC live sets for the group's start
* Do it only if not an emitter added block */
- if (!emitAdd)
+ if (!emitAdd)
{
VarSetOps::Assign(emitComp, emitInitGCrefVars, emitThisGCrefVars);
emitInitGCrefRegs = emitThisGCrefRegs;
@@ -6618,29 +6567,27 @@ void emitter::emitNxtIG(bool emitAdd)
/* If this is an emitter added block, flag it */
if (emitAdd)
- {
emitCurIG->igFlags |= IGF_EMIT_ADD;
- }
// We've created a new IG; no need to force another one.
emitForceNewIG = false;
-}
+}
+
/*****************************************************************************
*
* emitGetInsSC: Get the instruction's constant value.
*/
-ssize_t emitter::emitGetInsSC(instrDesc* id)
+ssize_t emitter::emitGetInsSC(instrDesc *id)
{
-#ifdef _TARGET_ARM_ // should it be _TARGET_ARMARCH_? Why do we need this? Note that on ARM64 we store scaled immediates
- // for some formats
+#ifdef _TARGET_ARM_ // should it be _TARGET_ARMARCH_? Why do we need this? Note that on ARM64 we store scaled immediates for some formats
if (id->idIsLclVar())
{
int varNum = id->idAddr()->iiaLclVar.lvaVarNum();
regNumber baseReg;
- int offs = id->idAddr()->iiaLclVar.lvaOffset();
+ int offs = id->idAddr()->iiaLclVar.lvaOffset();
#if defined(_TARGET_ARM_)
int adr = emitComp->lvaFrameAddress(varNum, id->idIsLclFPBase(), &baseReg, offs);
int dsp = adr + offs;
@@ -6649,8 +6596,8 @@ ssize_t emitter::emitGetInsSC(instrDesc* id)
#elif defined(_TARGET_ARM64_)
// TODO-ARM64-Cleanup: this is currently unreachable. Do we need it?
bool FPbased;
- int adr = emitComp->lvaFrameAddress(varNum, &FPbased);
- int dsp = adr + offs;
+ int adr = emitComp->lvaFrameAddress(varNum, &FPbased);
+ int dsp = adr + offs;
if (id->idIns() == INS_sub)
dsp = -dsp;
#endif
@@ -6658,14 +6605,10 @@ ssize_t emitter::emitGetInsSC(instrDesc* id)
}
else
#endif // _TARGET_ARM_
- if (id->idIsLargeCns())
- {
- return ((instrDescCns*)id)->idcCnsVal;
- }
+ if (id->idIsLargeCns())
+ return ((instrDescCns*)id)->idcCnsVal;
else
- {
- return id->idSmallCns();
- }
+ return id->idSmallCns();
}
/*****************************************************************************/
@@ -6675,19 +6618,19 @@ ssize_t emitter::emitGetInsSC(instrDesc* id)
* Record a push of a single dword on the stack.
*/
-void emitter::emitStackPush(BYTE* addr, GCtype gcType)
+void emitter::emitStackPush(BYTE *addr, GCtype gcType)
{
#ifdef DEBUG
assert(IsValidGCtype(gcType));
#endif
- if (emitSimpleStkUsed)
+ if (emitSimpleStkUsed)
{
assert(!emitFullGCinfo); // Simple stk not used for emitFullGCinfo
- assert(emitCurStackLvl / sizeof(int) < MAX_SIMPLE_STK_DEPTH);
+ assert(emitCurStackLvl/sizeof(int) < MAX_SIMPLE_STK_DEPTH);
- u1.emitSimpleStkMask <<= 1;
- u1.emitSimpleStkMask |= (unsigned)needsGC(gcType);
+ u1.emitSimpleStkMask <<= 1;
+ u1.emitSimpleStkMask |= (unsigned)needsGC(gcType);
u1.emitSimpleByrefStkMask <<= 1;
u1.emitSimpleByrefStkMask |= (gcType == GCT_BYREF);
@@ -6707,16 +6650,16 @@ void emitter::emitStackPush(BYTE* addr, GCtype gcType)
* Record a push of a bunch of non-GC dwords on the stack.
*/
-void emitter::emitStackPushN(BYTE* addr, unsigned count)
+void emitter::emitStackPushN(BYTE *addr, unsigned count)
{
assert(count);
- if (emitSimpleStkUsed)
+ if (emitSimpleStkUsed)
{
assert(!emitFullGCinfo); // Simple stk not used for emitFullGCinfo
- u1.emitSimpleStkMask <<= count;
- u1.emitSimpleByrefStkMask <<= count;
+ u1.emitSimpleStkMask <<= count;
+ u1.emitSimpleByrefStkMask <<= count;
}
else
{
@@ -6731,24 +6674,25 @@ void emitter::emitStackPushN(BYTE* addr, unsigned count)
* Record a pop of the given number of dwords from the stack.
*/
-void emitter::emitStackPop(BYTE* addr, bool isCall, unsigned char callInstrSize, unsigned count)
+void emitter::emitStackPop(BYTE *addr, bool isCall, unsigned char callInstrSize, unsigned count)
{
- assert(emitCurStackLvl / sizeof(int) >= count);
+ assert(emitCurStackLvl/sizeof(int) >= count);
assert(!isCall || callInstrSize > 0);
- if (count)
+ if (count)
{
- if (emitSimpleStkUsed)
+ if (emitSimpleStkUsed)
{
assert(!emitFullGCinfo); // Simple stk not used for emitFullGCinfo
- unsigned cnt = count;
+ unsigned cnt = count;
do
{
- u1.emitSimpleStkMask >>= 1;
+ u1.emitSimpleStkMask >>= 1;
u1.emitSimpleByrefStkMask >>= 1;
- } while (--cnt);
+ }
+ while (--cnt);
}
else
{
@@ -6763,11 +6707,11 @@ void emitter::emitStackPop(BYTE* addr, bool isCall, unsigned char callInstrSize,
// For the general encoder we do the call below always when it's a call, to ensure that the call is
// recorded (when we're doing the ptr reg map for a non-fully-interruptible method).
- if (emitFullGCinfo
+ if (emitFullGCinfo
#ifndef JIT32_GCENCODER
- || (emitComp->genFullPtrRegMap && (!emitComp->genInterruptible) && isCall)
+ || (emitComp->genFullPtrRegMap && (!emitComp->genInterruptible) && isCall)
#endif // JIT32_GCENCODER
- )
+ )
{
emitStackPopLargeStk(addr, isCall, callInstrSize, 0);
}
@@ -6779,9 +6723,11 @@ void emitter::emitStackPop(BYTE* addr, bool isCall, unsigned char callInstrSize,
* Record a push of a single word on the stack for a full pointer map.
*/
-void emitter::emitStackPushLargeStk(BYTE* addr, GCtype gcType, unsigned count)
+void emitter::emitStackPushLargeStk (BYTE * addr,
+ GCtype gcType,
+ unsigned count)
{
- S_UINT32 level(emitCurStackLvl / sizeof(int));
+ S_UINT32 level(emitCurStackLvl / sizeof(int));
assert(IsValidGCtype(gcType));
assert(count);
@@ -6794,35 +6740,31 @@ void emitter::emitStackPushLargeStk(BYTE* addr, GCtype gcType, unsigned count)
// printf("Pushed [%d] at lvl %2u [max=%u]\n", isGCref, emitArgTrackTop - emitArgTrackTab, emitMaxStackDepth);
assert(level.IsOverflow() || u2.emitArgTrackTop == u2.emitArgTrackTab + level.Value());
- *u2.emitArgTrackTop++ = (BYTE)gcType;
+ *u2.emitArgTrackTop++ = (BYTE)gcType;
assert(u2.emitArgTrackTop <= u2.emitArgTrackTab + emitMaxStackDepth);
if (!emitHasFramePtr || needsGC(gcType))
{
- if (emitFullGCinfo)
+ if (emitFullGCinfo)
{
/* Append an "arg push" entry if this is a GC ref or
FPO method. Allocate a new ptr arg entry and fill it in */
- regPtrDsc* regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
- regPtrNext->rpdGCtype = gcType;
+ regPtrDsc * regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
+ regPtrNext->rpdGCtype = gcType;
- regPtrNext->rpdOffs = emitCurCodeOffs(addr);
- regPtrNext->rpdArg = TRUE;
- regPtrNext->rpdCall = FALSE;
+ regPtrNext->rpdOffs = emitCurCodeOffs(addr);
+ regPtrNext->rpdArg = TRUE;
+ regPtrNext->rpdCall = FALSE;
if (level.IsOverflow() || !FitsIn<unsigned short>(level.Value()))
- {
IMPL_LIMITATION("Too many/too big arguments to encode GC information");
- }
- regPtrNext->rpdPtrArg = (unsigned short)level.Value();
- regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_PUSH;
- regPtrNext->rpdIsThis = FALSE;
+ regPtrNext->rpdPtrArg = (unsigned short)level.Value();
+ regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_PUSH;
+ regPtrNext->rpdIsThis = FALSE;
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE)
printf("[%08X] %s arg push %u\n", dspPtr(regPtrNext), GCtypeStr(gcType), level.Value());
- }
#endif
}
@@ -6832,22 +6774,27 @@ void emitter::emitStackPushLargeStk(BYTE* addr, GCtype gcType, unsigned count)
}
level += 1;
assert(!level.IsOverflow());
- } while (--count);
+ }
+ while (--count);
}
+
/*****************************************************************************
*
* Record a pop of the given number of words from the stack for a full ptr
* map.
*/
-void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callInstrSize, unsigned count)
+void emitter::emitStackPopLargeStk(BYTE * addr,
+ bool isCall,
+ unsigned char callInstrSize,
+ unsigned count)
{
assert(emitIssuing);
- unsigned argStkCnt;
- S_UINT16 argRecCnt(0); // arg count for ESP, ptr-arg count for EBP
- unsigned gcrefRegs, byrefRegs;
+ unsigned argStkCnt;
+ S_UINT16 argRecCnt(0); // arg count for ESP, ptr-arg count for EBP
+ unsigned gcrefRegs, byrefRegs;
#ifdef JIT32_GCENCODER
// For the general encoder, we always need to record calls, so we make this call
@@ -6857,11 +6804,13 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn
/* Count how many pointer records correspond to this "pop" */
- for (argStkCnt = count; argStkCnt; argStkCnt--)
+ for (argStkCnt = count;
+ argStkCnt;
+ argStkCnt--)
{
assert(u2.emitArgTrackTop > u2.emitArgTrackTab);
- GCtype gcType = (GCtype)(*--u2.emitArgTrackTop);
+ GCtype gcType = (GCtype)(*--u2.emitArgTrackTop);
assert(IsValidGCtype(gcType));
@@ -6869,10 +6818,8 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn
// This is an "interesting" argument
- if (!emitHasFramePtr || needsGC(gcType))
- {
+ if (!emitHasFramePtr || needsGC(gcType))
argRecCnt += 1;
- }
}
assert(u2.emitArgTrackTop >= u2.emitArgTrackTab);
@@ -6891,28 +6838,22 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn
// Do we have any interesting (i.e., callee-saved) registers live here?
- gcrefRegs = byrefRegs = 0;
+ gcrefRegs =
+ byrefRegs = 0;
// We make a bitmask whose bits correspond to callee-saved register indices (in the sequence
// of callee-saved registers only).
for (unsigned calleeSavedRegIdx = 0; calleeSavedRegIdx < CNT_CALLEE_SAVED; calleeSavedRegIdx++)
{
regMaskTP calleeSavedRbm = raRbmCalleeSaveOrder[calleeSavedRegIdx];
- if (emitThisGCrefRegs & calleeSavedRbm)
- {
- gcrefRegs |= (1 << calleeSavedRegIdx);
- }
- if (emitThisByrefRegs & calleeSavedRbm)
- {
- byrefRegs |= (1 << calleeSavedRegIdx);
- }
+ if (emitThisGCrefRegs & calleeSavedRbm) gcrefRegs |= (1 << calleeSavedRegIdx);
+ if (emitThisByrefRegs & calleeSavedRbm) byrefRegs |= (1 << calleeSavedRegIdx);
}
#ifdef JIT32_GCENCODER
- // For the general encoder, we always have to record calls, so we don't take this early return. /* Are there any
- // args to pop at this call site?
+ // For the general encoder, we always have to record calls, so we don't take this early return. /* Are there any args to pop at this call site?
- if (argRecCnt.Value() == 0)
+ if (argRecCnt.Value() == 0)
{
/*
Or do we have a partially interruptible EBP-less frame, and any
@@ -6921,7 +6862,8 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn
CLANG_FORMAT_COMMENT_ANCHOR;
#if !FPO_INTERRUPTIBLE
- if (emitFullyInt || (gcrefRegs == 0 && byrefRegs == 0 && u2.emitGcArgTrackCnt == 0))
+ if (emitFullyInt ||
+ (gcrefRegs == 0 && byrefRegs == 0 && u2.emitGcArgTrackCnt == 0))
#endif
return;
}
@@ -6939,11 +6881,11 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn
/* Allocate a new ptr arg entry and fill it in */
- regPtrDsc* regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
- regPtrNext->rpdGCtype = GCT_GCREF; // Pops need a non-0 value (??)
+ regPtrDsc * regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
+ regPtrNext->rpdGCtype = GCT_GCREF; // Pops need a non-0 value (??)
- regPtrNext->rpdOffs = emitCurCodeOffs(addr);
- regPtrNext->rpdCall = (isCall || isCallRelatedPop);
+ regPtrNext->rpdOffs = emitCurCodeOffs(addr);
+ regPtrNext->rpdCall = (isCall || isCallRelatedPop);
#ifndef JIT32_GCENCODER
if (regPtrNext->rpdCall)
{
@@ -6951,27 +6893,25 @@ void emitter::emitStackPopLargeStk(BYTE* addr, bool isCall, unsigned char callIn
regPtrNext->rpdCallInstrSize = callInstrSize;
}
#endif
- regPtrNext->rpdCallGCrefRegs = gcrefRegs;
- regPtrNext->rpdCallByrefRegs = byrefRegs;
- regPtrNext->rpdArg = TRUE;
- regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_POP;
- regPtrNext->rpdPtrArg = argRecCnt.Value();
+ regPtrNext->rpdCallGCrefRegs= gcrefRegs;
+ regPtrNext->rpdCallByrefRegs= byrefRegs;
+ regPtrNext->rpdArg = TRUE;
+ regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_POP;
+ regPtrNext->rpdPtrArg = argRecCnt.Value();
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
- printf("[%08X] ptr arg pop %u\n", dspPtr(regPtrNext), count);
- }
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE) printf("[%08X] ptr arg pop %u\n", dspPtr(regPtrNext), count);
#endif
}
+
/*****************************************************************************
* For caller-pop arguments, we report the arguments as pending arguments.
* However, any GC arguments are now dead, so we need to report them
* as non-GC.
*/
-void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callInstrSize)
+void emitter::emitStackKillArgs(BYTE *addr, unsigned count, unsigned char callInstrSize)
{
assert(count > 0);
@@ -6982,18 +6922,18 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn
/* We don't need to report this to the GC info, but we do need
to kill mark the ptrs on the stack as non-GC */
- assert(emitCurStackLvl / sizeof(int) >= count);
+ assert(emitCurStackLvl/sizeof(int) >= count);
for (unsigned lvl = 0; lvl < count; lvl++)
{
- u1.emitSimpleStkMask &= ~(1 << lvl);
+ u1.emitSimpleStkMask &= ~(1 << lvl);
u1.emitSimpleByrefStkMask &= ~(1 << lvl);
}
}
else
{
- BYTE* argTrackTop = u2.emitArgTrackTop;
- S_UINT16 gcCnt(0);
+ BYTE * argTrackTop = u2.emitArgTrackTop;
+ S_UINT16 gcCnt(0);
for (unsigned i = 0; i < count; i++)
{
@@ -7001,7 +6941,7 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn
--argTrackTop;
- GCtype gcType = (GCtype)(*argTrackTop);
+ GCtype gcType = (GCtype)(*argTrackTop);
assert(IsValidGCtype(gcType));
if (needsGC(gcType))
@@ -7018,14 +6958,10 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn
/* We're about to kill the corresponding (pointer) arg records */
if (emitHasFramePtr)
- {
u2.emitGcArgTrackCnt -= gcCnt.Value();
- }
if (!emitFullGCinfo)
- {
return;
- }
/* Right after the call, the arguments are still sitting on the
stack, but they are effectively dead. For fully-interruptible
@@ -7035,20 +6971,17 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn
{
/* Allocate a new ptr arg entry and fill it in */
- regPtrDsc* regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
- regPtrNext->rpdGCtype = GCT_GCREF; // Kills need a non-0 value (??)
+ regPtrDsc * regPtrNext = codeGen->gcInfo.gcRegPtrAllocDsc();
+ regPtrNext->rpdGCtype = GCT_GCREF; // Kills need a non-0 value (??)
- regPtrNext->rpdOffs = emitCurCodeOffs(addr);
+ regPtrNext->rpdOffs = emitCurCodeOffs(addr);
- regPtrNext->rpdArg = TRUE;
- regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_KILL;
- regPtrNext->rpdPtrArg = gcCnt.Value();
+ regPtrNext->rpdArg = TRUE;
+ regPtrNext->rpdArgType = (unsigned short)GCInfo::rpdARG_KILL;
+ regPtrNext->rpdPtrArg = gcCnt.Value();
-#ifdef DEBUG
- if (EMIT_GC_VERBOSE)
- {
- printf("[%08X] ptr arg kill %u\n", dspPtr(regPtrNext), count);
- }
+#ifdef DEBUG
+ if (EMIT_GC_VERBOSE) printf("[%08X] ptr arg kill %u\n", dspPtr(regPtrNext), count);
#endif
}
@@ -7062,11 +6995,11 @@ void emitter::emitStackKillArgs(BYTE* addr, unsigned count, unsigned char callIn
/*****************************************************************************
* A helper for recording a relocation with the EE.
*/
-void emitter::emitRecordRelocation(void* location, /* IN */
- void* target, /* IN */
- WORD fRelocType, /* IN */
- WORD slotNum /* = 0 */, /* IN */
- INT32 addlDelta /* = 0 */) /* IN */
+void emitter::emitRecordRelocation(void* location, /* IN */
+ void* target, /* IN */
+ WORD fRelocType, /* IN */
+ WORD slotNum /* = 0 */, /* IN */
+ INT32 addlDelta /* = 0 */) /* IN */
{
// If we're an unmatched altjit, don't tell the VM anything. We still record the relocation for
// late disassembly; maybe we'll need it?
@@ -7082,9 +7015,9 @@ void emitter::emitRecordRelocation(void* location, /* IN */
/*****************************************************************************
* A helper for recording a call site with the EE.
*/
-void emitter::emitRecordCallSite(ULONG instrOffset, /* IN */
- CORINFO_SIG_INFO* callSig, /* IN */
- CORINFO_METHOD_HANDLE methodHandle) /* IN */
+void emitter::emitRecordCallSite(ULONG instrOffset, /* IN */
+ CORINFO_SIG_INFO* callSig, /* IN */
+ CORINFO_METHOD_HANDLE methodHandle) /* IN */
{
#if defined(DEBUG)
// Since CORINFO_SIG_INFO is a heavyweight structure, in most cases we can
@@ -7112,10 +7045,11 @@ void emitter::emitRecordCallSite(ULONG instrOffset, /* IN */
}
/*****************************************************************************/
-#endif // EMIT_TRACK_STACK_DEPTH
+#endif//EMIT_TRACK_STACK_DEPTH
/*****************************************************************************/
/*****************************************************************************/
+
#ifdef DEBUG
/*****************************************************************************
@@ -7128,18 +7062,20 @@ void emitter::emitRecordCallSite(ULONG instrOffset, /* IN */
* printf()).
*/
-const char* emitter::emitOffsetToLabel(unsigned offs)
+const char* emitter::emitOffsetToLabel(unsigned offs)
{
- const size_t TEMP_BUFFER_LEN = 40;
- static unsigned curBuf = 0;
- static char buf[4][TEMP_BUFFER_LEN];
- char* retbuf;
+ const size_t TEMP_BUFFER_LEN = 40;
+ static unsigned curBuf = 0;
+ static char buf[4][TEMP_BUFFER_LEN];
+ char* retbuf;
- insGroup* ig;
+ insGroup* ig;
UNATIVE_OFFSET of;
UNATIVE_OFFSET nextof = 0;
- for (ig = emitIGlist; ig != nullptr; ig = ig->igNext)
+ for (ig = emitIGlist;
+ ig != nullptr;
+ ig = ig->igNext)
{
assert(nextof == ig->igOffs);