Skip to content

Commit 70866fd

Browse files
committed
[MERGE #5436 @sigatrev] Track bailout restoration based on TypeSpec flag rather than current symbol type
Merge pull request #5436 from sigatrev:users/magardn/typeSpecBailout This provides a more general fix to replace an earlier fix for an issue on ARM64 where an int32 was having it's type changed to int64 to perform math, causing the register allocator to restore it as a var.
2 parents 0cbed34 + 776c225 commit 70866fd

File tree

3 files changed

+29
-39
lines changed

3 files changed

+29
-39
lines changed

lib/Backend/LinearScan.cpp

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,26 @@ LinearScan::EnsureGlobalBailOutRecordTable(Func *func)
13211321
return globalBailOutRecordDataTable;
13221322
}
13231323

1324+
void
1325+
LinearScan::SetBitVectorIfTypeSpec(StackSym * sym, Js::RegSlot regSlot, BVFixed * intSyms, BVFixed * floatSyms)
1326+
{
1327+
if (sym->IsTypeSpec())
1328+
{
1329+
if (IRType_IsNativeInt(sym->m_type))
1330+
{
1331+
intSyms->Set(regSlot);
1332+
}
1333+
else if (IRType_IsFloat(sym->m_type))
1334+
{
1335+
floatSyms->Set(regSlot);
1336+
}
1337+
else
1338+
{
1339+
Assert(UNREACHED);
1340+
}
1341+
}
1342+
}
1343+
13241344
void
13251345
LinearScan::FillBailOutRecord(IR::Instr * instr)
13261346
{
@@ -1463,14 +1483,8 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
14631483

14641484
StackSym * copyStackSym = copyPropSyms.Value();
14651485
this->FillBailOutOffset(&funcBailOutData[index].localOffsets[i], copyStackSym, &state, instr);
1466-
if (copyStackSym->IsInt32())
1467-
{
1468-
funcBailOutData[index].losslessInt32Syms->Set(i);
1469-
}
1470-
else if (copyStackSym->IsFloat64())
1471-
{
1472-
funcBailOutData[index].float64Syms->Set(i);
1473-
}
1486+
SetBitVectorIfTypeSpec(copyStackSym, i, funcBailOutData[index].losslessInt32Syms, funcBailOutData[index].float64Syms);
1487+
14741488
copyPropSymsIter.RemoveCurrent(this->func->m_alloc);
14751489
}
14761490
NEXT_SLISTBASE_ENTRY_EDITING;
@@ -1494,14 +1508,7 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
14941508
AssertMsg(funcBailOutData[index].localOffsets[i] == 0, "Can't have two active lifetime for the same byte code register");
14951509

14961510
this->FillBailOutOffset(&funcBailOutData[index].localOffsets[i], stackSym, &state, instr);
1497-
if (stackSym->IsInt32())
1498-
{
1499-
funcBailOutData[index].losslessInt32Syms->Set(i);
1500-
}
1501-
else if (stackSym->IsFloat64())
1502-
{
1503-
funcBailOutData[index].float64Syms->Set(i);
1504-
}
1511+
SetBitVectorIfTypeSpec(stackSym, i, funcBailOutData[index].losslessInt32Syms, funcBailOutData[index].float64Syms);
15051512
}
15061513
NEXT_BITSET_IN_SPARSEBV;
15071514

@@ -1572,7 +1579,7 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
15721579
funcBailOutData[dataIndex].localOffsets[regSlotId] = this->func->AdjustOffsetValue(offset);
15731580

15741581
// We don't support typespec for debug, rework on the bellow assert once we start support them.
1575-
Assert(!stackSym->IsInt32() && !stackSym->IsFloat64() && !stackSym->IsSimd128());
1582+
Assert(!stackSym->IsTypeSpec());
15761583
}
15771584
}
15781585
}
@@ -1737,14 +1744,7 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
17371744
else
17381745
{
17391746
this->FillBailOutOffset(&outParamOffsets[outParamOffsetIndex], copyStackSym, &state, instr);
1740-
if (copyStackSym->IsInt32())
1741-
{
1742-
argOutLosslessInt32Syms->Set(outParamOffsetIndex);
1743-
}
1744-
else if (copyStackSym->IsFloat64())
1745-
{
1746-
argOutFloat64Syms->Set(outParamOffsetIndex);
1747-
}
1747+
SetBitVectorIfTypeSpec(copyStackSym, outParamOffsetIndex, argOutLosslessInt32Syms, argOutFloat64Syms);
17481748
}
17491749
#if DBG_DUMP
17501750
if (PHASE_DUMP(Js::BailOutPhase, this->func))
@@ -1861,14 +1861,7 @@ LinearScan::FillBailOutRecord(IR::Instr * instr)
18611861
this->FillBailOutOffset(&outParamOffsets[outParamOffsetIndex], sym, &state, instr);
18621862
}
18631863

1864-
if (sym->IsFloat64())
1865-
{
1866-
argOutFloat64Syms->Set(outParamOffsetIndex);
1867-
}
1868-
else if (sym->IsInt32())
1869-
{
1870-
argOutLosslessInt32Syms->Set(outParamOffsetIndex);
1871-
}
1864+
SetBitVectorIfTypeSpec(sym, outParamOffsetIndex, argOutLosslessInt32Syms, argOutFloat64Syms);
18721865
#if DBG_DUMP
18731866
if (PHASE_DUMP(Js::BailOutPhase, this->func))
18741867
{

lib/Backend/LinearScan.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class LinearScan
178178

179179
GlobalBailOutRecordDataTable * EnsureGlobalBailOutRecordTable(Func *func);
180180

181+
static void SetBitVectorIfTypeSpec(StackSym * sym, Js::RegSlot regSlot, BVFixed * intSyms, BVFixed * floatSyms);
181182
void FillBailOutRecord(IR::Instr * instr);
182183
void FillBailOutOffset(int * offset, StackSym * stackSym, FillBailOutState * state, IR::Instr * instr);
183184
void FillStackLiteralBailOutRecord(IR::Instr * instr, BailOutInfo * bailOutInfo, struct FuncBailOutData * funcBailOutData, uint funcCount);

lib/Backend/arm64/LegalizeMD.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,7 @@ void LegalizeMD::LegalizeIndirOffset(IR::Instr * instr, IR::IndirOpnd * indirOpn
333333
Assert(IRType_IsSignedInt(largerType) || IRType_IsUnsignedInt(largerType));
334334
IRType sourceType = baseOpnd->GetType();
335335
IRType targetType = IRType_IsSignedInt(sourceType) ? IRType_EnsureSigned(largerType) : IRType_EnsureUnsigned(largerType);
336-
IR::RegOpnd * tmpOpnd = IR::RegOpnd::New(sourceType, instr->m_func);
337-
Lowerer::InsertMove(tmpOpnd, baseOpnd, instr, false);
338-
IR::Instr* movInstr = Lowerer::InsertMove(tmpOpnd->UseWithNewType(targetType, instr->m_func), tmpOpnd, instr, false);
336+
IR::Instr* movInstr = Lowerer::InsertMove(baseOpnd->UseWithNewType(targetType, instr->m_func), baseOpnd, instr, false);
339337
indirOpnd->SetBaseOpnd(movInstr->GetDst()->AsRegOpnd());
340338
}
341339
else
@@ -345,9 +343,7 @@ void LegalizeMD::LegalizeIndirOffset(IR::Instr * instr, IR::IndirOpnd * indirOpn
345343
Assert(IRType_IsSignedInt(largerType) || IRType_IsUnsignedInt(largerType));
346344
IRType sourceType = indexOpnd->GetType();
347345
IRType targetType = IRType_IsSignedInt(sourceType) ? IRType_EnsureSigned(largerType) : IRType_EnsureUnsigned(largerType);
348-
IR::RegOpnd * tmpOpnd = IR::RegOpnd::New(sourceType, instr->m_func);
349-
Lowerer::InsertMove(tmpOpnd, indexOpnd, instr, false);
350-
IR::Instr* movInstr = Lowerer::InsertMove(tmpOpnd->UseWithNewType(targetType, instr->m_func), tmpOpnd, instr, false);
346+
IR::Instr* movInstr = Lowerer::InsertMove(indexOpnd->UseWithNewType(targetType, instr->m_func), indexOpnd, instr, false);
351347
indirOpnd->SetIndexOpnd(movInstr->GetDst()->AsRegOpnd());
352348
}
353349
}

0 commit comments

Comments
 (0)