Skip to content

Commit 8354bbc

Browse files
committed
[1.10>master] [MERGE #5490 @rajatd] Fix field types in InlineeCallInfo. OS #15566165
Merge pull request #5490 from rajatd:inlineeCallInfo-type
2 parents 0051d4a + a9358ce commit 8354bbc

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

lib/Backend/InlineeFrameInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ void InlineeFrameRecord::PopulateParent(Func* func)
172172
void InlineeFrameRecord::Finalize(Func* inlinee, uint32 currentOffset)
173173
{
174174
this->PopulateParent(inlinee);
175+
#if TARGET_32
176+
const uint32 offsetMask = (~(uint32)0) >> (sizeof(uint) * CHAR_BIT - Js::InlineeCallInfo::ksizeofInlineeStartOffset);
177+
AssertOrFailFast(currentOffset == (currentOffset & offsetMask));
178+
#endif
175179
this->inlineeStartOffset = currentOffset;
176180
this->inlineDepth = inlinee->inlineDepth;
177181

lib/Backend/amd64/EncoderMD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,11 +1518,11 @@ EncoderMD::FixRelocListEntry(uint32 index, int totalBytesSaved, BYTE *buffStart,
15181518
// ptr points to imm32 offset of the instruction that needs to be adjusted
15191519
// offset is in top 28-bits, arg count in bottom 4
15201520
size_t field = *((size_t*) relocRecord.m_origPtr);
1521-
size_t offset = field >> 4;
1521+
size_t offset = field >> Js::InlineeCallInfo::inlineeStartOffsetShiftCount;
15221522
uint32 count = field & 0xf;
15231523

15241524
AssertMsg(offset < (size_t)(buffEnd - buffStart), "Inlinee entry offset out of range");
1525-
relocRecord.SetInlineOffset(((offset - totalBytesSaved) << 4) | count);
1525+
relocRecord.SetInlineOffset(((offset - totalBytesSaved) << Js::InlineeCallInfo::inlineeStartOffsetShiftCount) | count);
15261526
}
15271527
// adjust the ptr to the buffer itself
15281528
relocRecord.m_ptr = (BYTE*) relocRecord.m_ptr - totalBytesSaved;
@@ -1777,7 +1777,7 @@ EncoderMD::EncodeInlineeCallInfo(IR::Instr *instr, uint32 codeOffset)
17771777
// than can fit in as many bits.
17781778
const bool encodeResult = Js::InlineeCallInfo::Encode(inlineeCallInfo,
17791779
instr->GetSrc1()->AsIntConstOpnd()->GetValue(), codeOffset);
1780-
Assert(encodeResult);
1780+
AssertOrFailFast(encodeResult);
17811781

17821782
instr->GetSrc1()->AsIntConstOpnd()->SetValue(inlineeCallInfo);
17831783
}

lib/Backend/i386/EncoderMD.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,11 +1354,11 @@ EncoderMD::FixRelocListEntry(uint32 index, int32 totalBytesSaved, BYTE *buffStar
13541354
// ptr points to imm32 offset of the instruction that needs to be adjusted
13551355
// offset is in top 28-bits, arg count in bottom 4
13561356
uint32 field = *((uint32*) relocRecord.m_origPtr);
1357-
uint32 offset = field >> 4;
1357+
uint32 offset = field >> Js::InlineeCallInfo::inlineeStartOffsetShiftCount;
13581358
uint32 count = field & 0xf;
13591359

13601360
AssertMsg(offset < (uint32)(buffEnd - buffStart), "Inlinee entry offset out of range");
1361-
relocRecord.SetInlineOffset(((offset - totalBytesSaved) << 4) | count);
1361+
relocRecord.SetInlineOffset(((offset - totalBytesSaved) << Js::InlineeCallInfo::inlineeStartOffsetShiftCount) | count);
13621362
}
13631363
// adjust the ptr to the buffer itself
13641364
relocRecord.m_ptr = (BYTE*) relocRecord.m_ptr - totalBytesSaved;
@@ -1588,7 +1588,7 @@ EncoderMD::EncodeInlineeCallInfo(IR::Instr *instr, uint32 codeOffset)
15881588
// offset of the start of the inlinee. We shouldn't have gotten here with more arguments
15891589
// than can fit in as many bits.
15901590
const bool encodeResult = Js::InlineeCallInfo::Encode(inlineeCallInfo, (uint32)instr->GetSrc1()->AsIntConstOpnd()->GetValue(), codeOffset);
1591-
Assert(encodeResult);
1591+
AssertOrFailFast(encodeResult);
15921592

15931593
instr->GetSrc1()->AsIntConstOpnd()->SetValue(inlineeCallInfo);
15941594
}

lib/Runtime/Base/CallInfo.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,24 @@ namespace Js
145145
struct InlineeCallInfo
146146
{
147147
// Assumes big-endian layout.
148-
size_t Count: 4;
149-
size_t InlineeStartOffset: sizeof(void*) * CHAR_BIT - 4;
148+
uint Count : 4;
149+
#if TARGET_32
150+
uint InlineeStartOffset : 28;
151+
#else
152+
uint unused : 28;
153+
uint InlineeStartOffset;
154+
#endif
150155
static size_t const MaxInlineeArgoutCount = 0xF;
156+
#if TARGET_32
157+
static uint const ksizeofInlineeStartOffset = 28;
158+
#else
159+
static uint const ksizeofInlineeStartOffset = 32;
160+
#endif
161+
static uint const inlineeStartOffsetShiftCount = (sizeof(void*) * CHAR_BIT - Js::InlineeCallInfo::ksizeofInlineeStartOffset);
151162

152163
static bool Encode(intptr_t &callInfo, size_t count, size_t offset)
153164
{
154-
const size_t offsetMask = (~(size_t)0) >> 4;
165+
const size_t offsetMask = ~(uint)0 >> (sizeof(uint) * CHAR_BIT - ksizeofInlineeStartOffset);
155166
const size_t countMask = 0x0000000F;
156167
if (count != (count & countMask))
157168
{
@@ -163,8 +174,7 @@ namespace Js
163174
return false;
164175
}
165176

166-
callInfo = (offset << 4) | count;
167-
177+
callInfo = (offset << inlineeStartOffsetShiftCount) | count;
168178
return true;
169179
}
170180

lib/Runtime/Language/JavascriptStackWalker.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,20 +1461,15 @@ namespace Js
14611461
{
14621462
Assert(!IsTopMostFrame());
14631463
Assert(currentIndex);
1464-
#pragma warning(push)
1465-
#pragma warning(disable: 4254)
1464+
14661465
return GetFrameAtIndex(currentIndex - 1)->callInfo.InlineeStartOffset;
1467-
#pragma warning(pop)
14681466
}
14691467

14701468
uint32 InlinedFrameWalker::GetBottomMostInlineeOffset() const
14711469
{
14721470
Assert(frameCount);
14731471

1474-
#pragma warning(push)
1475-
#pragma warning(disable: 4254)
14761472
return GetFrameAtIndex(frameCount - 1)->callInfo.InlineeStartOffset;
1477-
#pragma warning(pop)
14781473
}
14791474

14801475
Js::JavascriptFunction *InlinedFrameWalker::GetBottomMostFunctionObject() const

0 commit comments

Comments
 (0)