Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit e7ece61

Browse files
author
Swaroop Sridhar
committed
X86 GcEncode: Support V1 and V2 encodings
The RYU+LegacyBackend Desktop JIT for X86 is still on V1. So, permit both V1 and V2 encodings in gcencode.cpp.
1 parent 20ddf73 commit e7ece61

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/inc/gcdecoder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ PTR_CBYTE FASTCALL decodeHeader(PTR_CBYTE table, UINT32 version, InfoHdr* header
9292

9393
BYTE nextByte = *table++;
9494
BYTE encoding = nextByte & 0x7f;
95-
const BYTE maskHaveMoreBytesBit = MORE_BYTES_TO_FOLLOW - 1;
9695
GetInfoHdr(encoding, header);
9796
while (nextByte & MORE_BYTES_TO_FOLLOW)
9897
{
9998
nextByte = *table++;
100-
encoding = nextByte & maskHaveMoreBytesBit;
99+
encoding = nextByte & ADJ_ENCODING_MAX;
101100
// encoding here always corresponds to codes in InfoHdrAdjust set
102101

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

205204
if (encoding < SET_RET_KIND_MAX)

src/inc/gcinfotypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ enum infoHdrAdjustConstants {
378378
SET_EPILOGCNT_MAX = 4,
379379
SET_UNTRACKED_MAX = 3,
380380
SET_RET_KIND_MAX = 4, // 2 bits for ReturnKind
381+
ADJ_ENCODING_MAX = 0x7f, // Maximum valid encoding in a byte
382+
// Also used to mask off next bit from each encoding byte.
381383
MORE_BYTES_TO_FOLLOW = 0x80 // If the High-bit of a header or adjustment byte
382384
// is set, then there are more adjustments to follow.
383385
};

src/jit/gcencode.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,8 @@ BYTE FASTCALL encodeHeaderNext(const InfoHdr& header, InfoHdr* state, BYTE &code
635635
goto DO_RETURN;
636636
}
637637

638-
if (state->returnKind != header.returnKind)
638+
if (GCInfoEncodesReturnKind() && (state->returnKind != header.returnKind))
639639
{
640-
_ASSERTE(GCInfoEncodesReturnKind());
641640
state->returnKind = header.returnKind;
642641
codeSet = 2; // Two byte encoding
643642
encoding = header.returnKind;
@@ -685,9 +684,8 @@ BYTE FASTCALL encodeHeaderNext(const InfoHdr& header, InfoHdr* state, BYTE &code
685684
}
686685
}
687686

688-
if (state->revPInvokeOffset != header.revPInvokeOffset)
687+
if (GCInfoEncodesRevPInvokeFrame() && (state->revPInvokeOffset != header.revPInvokeOffset))
689688
{
690-
_ASSERTE(GCInfoEncodesRevPInvokeFrame());
691689
assert(state->revPInvokeOffset == INVALID_REV_PINVOKE_OFFSET || state->revPInvokeOffset == HAS_REV_PINVOKE_FRAME_OFFSET);
692690

693691
if (state->revPInvokeOffset == INVALID_REV_PINVOKE_OFFSET)
@@ -1298,13 +1296,17 @@ size_t GCInfo::gcInfoBlockHdrSave(
12981296
header->genericsContext = compiler->lvaReportParamTypeArg();
12991297
header->genericsContextIsMethodDesc =
13001298
header->genericsContext && (compiler->info.compMethodInfo->options & (CORINFO_GENERICS_CTXT_FROM_METHODDESC));
1301-
header->gsCookieOffset = INVALID_GS_COOKIE_OFFSET;
13021299

1303-
ReturnKind returnKind = getReturnKind();
1304-
_ASSERTE(IsValidReturnKind(returnKind) && "Return Kind must be valid");
1305-
_ASSERTE(!IsStructReturnKind(returnKind) && "Struct Return Kinds Unexpected for JIT32");
1306-
header->returnKind = returnKind;
1300+
if (GCInfoEncodesReturnKind())
1301+
{
1302+
ReturnKind returnKind = getReturnKind();
1303+
_ASSERTE(IsValidReturnKind(returnKind) && "Return Kind must be valid");
1304+
_ASSERTE(!IsStructReturnKind(returnKind) && "Struct Return Kinds Unexpected for JIT32");
1305+
_ASSERTE((returnKind < SET_RET_KIND_MAX) && "ReturnKind has no legal encoding");
1306+
header->returnKind = returnKind;
1307+
}
13071308

1309+
header->gsCookieOffset = INVALID_GS_COOKIE_OFFSET;
13081310
if (compiler->getNeedsGSSecurityCookie())
13091311
{
13101312
assert(compiler->lvaGSSecurityCookie != BAD_VAR_NUM);
@@ -1329,6 +1331,7 @@ size_t GCInfo::gcInfoBlockHdrSave(
13291331
// synchronized methods can't have more than 1 epilog
13301332
assert(header->epilogCount <= 1);
13311333
}
1334+
13321335
header->revPInvokeOffset = INVALID_REV_PINVOKE_OFFSET;
13331336

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

0 commit comments

Comments
 (0)