Skip to content

Commit

Permalink
Merge pull request dotnet#7237 from swaroop-sridhar/gc86legacy
Browse files Browse the repository at this point in the history
X86 GcEncode: Support V1 and V2 encodings
  • Loading branch information
swaroop-sridhar authored Sep 19, 2016
2 parents 20ddf73 + e7ece61 commit 217ba4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/inc/gcdecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,11 @@ PTR_CBYTE FASTCALL decodeHeader(PTR_CBYTE table, UINT32 version, InfoHdr* header

BYTE nextByte = *table++;
BYTE encoding = nextByte & 0x7f;
const BYTE maskHaveMoreBytesBit = MORE_BYTES_TO_FOLLOW - 1;
GetInfoHdr(encoding, header);
while (nextByte & MORE_BYTES_TO_FOLLOW)
{
nextByte = *table++;
encoding = nextByte & maskHaveMoreBytesBit;
encoding = nextByte & ADJ_ENCODING_MAX;
// encoding here always corresponds to codes in InfoHdrAdjust set

if (encoding < NEXT_FOUR_START)
Expand Down Expand Up @@ -199,7 +198,7 @@ PTR_CBYTE FASTCALL decodeHeader(PTR_CBYTE table, UINT32 version, InfoHdr* header
case NEXT_OPCODE:
_ASSERTE((nextByte & MORE_BYTES_TO_FOLLOW) && "Must have another code");
nextByte = *table++;
encoding = nextByte & maskHaveMoreBytesBit;
encoding = nextByte & ADJ_ENCODING_MAX;
// encoding here always corresponds to codes in InfoHdrAdjust2 set

if (encoding < SET_RET_KIND_MAX)
Expand Down
2 changes: 2 additions & 0 deletions src/inc/gcinfotypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ enum infoHdrAdjustConstants {
SET_EPILOGCNT_MAX = 4,
SET_UNTRACKED_MAX = 3,
SET_RET_KIND_MAX = 4, // 2 bits for ReturnKind
ADJ_ENCODING_MAX = 0x7f, // Maximum valid encoding in a byte
// Also used to mask off next bit from each encoding byte.
MORE_BYTES_TO_FOLLOW = 0x80 // If the High-bit of a header or adjustment byte
// is set, then there are more adjustments to follow.
};
Expand Down
21 changes: 12 additions & 9 deletions src/jit/gcencode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,8 @@ BYTE FASTCALL encodeHeaderNext(const InfoHdr& header, InfoHdr* state, BYTE &code
goto DO_RETURN;
}

if (state->returnKind != header.returnKind)
if (GCInfoEncodesReturnKind() && (state->returnKind != header.returnKind))
{
_ASSERTE(GCInfoEncodesReturnKind());
state->returnKind = header.returnKind;
codeSet = 2; // Two byte encoding
encoding = header.returnKind;
Expand Down Expand Up @@ -685,9 +684,8 @@ BYTE FASTCALL encodeHeaderNext(const InfoHdr& header, InfoHdr* state, BYTE &code
}
}

if (state->revPInvokeOffset != header.revPInvokeOffset)
if (GCInfoEncodesRevPInvokeFrame() && (state->revPInvokeOffset != header.revPInvokeOffset))
{
_ASSERTE(GCInfoEncodesRevPInvokeFrame());
assert(state->revPInvokeOffset == INVALID_REV_PINVOKE_OFFSET || state->revPInvokeOffset == HAS_REV_PINVOKE_FRAME_OFFSET);

if (state->revPInvokeOffset == INVALID_REV_PINVOKE_OFFSET)
Expand Down Expand Up @@ -1298,13 +1296,17 @@ size_t GCInfo::gcInfoBlockHdrSave(
header->genericsContext = compiler->lvaReportParamTypeArg();
header->genericsContextIsMethodDesc =
header->genericsContext && (compiler->info.compMethodInfo->options & (CORINFO_GENERICS_CTXT_FROM_METHODDESC));
header->gsCookieOffset = INVALID_GS_COOKIE_OFFSET;

ReturnKind returnKind = getReturnKind();
_ASSERTE(IsValidReturnKind(returnKind) && "Return Kind must be valid");
_ASSERTE(!IsStructReturnKind(returnKind) && "Struct Return Kinds Unexpected for JIT32");
header->returnKind = returnKind;
if (GCInfoEncodesReturnKind())
{
ReturnKind returnKind = getReturnKind();
_ASSERTE(IsValidReturnKind(returnKind) && "Return Kind must be valid");
_ASSERTE(!IsStructReturnKind(returnKind) && "Struct Return Kinds Unexpected for JIT32");
_ASSERTE((returnKind < SET_RET_KIND_MAX) && "ReturnKind has no legal encoding");
header->returnKind = returnKind;
}

header->gsCookieOffset = INVALID_GS_COOKIE_OFFSET;
if (compiler->getNeedsGSSecurityCookie())
{
assert(compiler->lvaGSSecurityCookie != BAD_VAR_NUM);
Expand All @@ -1329,6 +1331,7 @@ size_t GCInfo::gcInfoBlockHdrSave(
// synchronized methods can't have more than 1 epilog
assert(header->epilogCount <= 1);
}

header->revPInvokeOffset = INVALID_REV_PINVOKE_OFFSET;

assert((compiler->compArgSize & 0x3) == 0);
Expand Down

0 comments on commit 217ba4d

Please sign in to comment.