Skip to content

Commit 8aa44c3

Browse files
committed
Phase Two Changes
1 parent 831e6b2 commit 8aa44c3

File tree

4 files changed

+46
-8
lines changed

4 files changed

+46
-8
lines changed

lib/Backend/Func.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Func::Func(JitArenaAllocator *alloc, JITTimeWorkItem * workItem,
6666
m_hasCalls(false),
6767
m_hasInlineArgsOpt(false),
6868
m_canDoInlineArgsOpt(true),
69+
unoptableInlineArgCount(0),
6970
m_doFastPaths(false),
7071
hasBailout(false),
7172
firstIRTemp(0),
@@ -108,6 +109,7 @@ Func::Func(JitArenaAllocator *alloc, JITTimeWorkItem * workItem,
108109
loopCount(0),
109110
callSiteIdInParentFunc(callSiteIdInParentFunc),
110111
isGetterSetter(isGetterSetter),
112+
cachedInlineeFrameInfo(nullptr),
111113
frameInfo(nullptr),
112114
isTJLoopBody(false),
113115
m_nativeCodeDataSym(nullptr),

lib/Backend/Func.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,9 @@ static const unsigned __int64 c_debugFillPattern8 = 0xcececececececece;
725725
StackSym * tempSymDouble;
726726
StackSym * tempSymBool;
727727
uint32 loopCount;
728+
uint32 unoptableInlineArgCount;
728729
Js::ProfileId callSiteIdInParentFunc;
730+
InlineeFrameInfo* cachedInlineeFrameInfo;
729731
bool m_hasCalls: 1; // This is more accurate compared to m_isLeaf
730732
bool m_hasInlineArgsOpt : 1;
731733
bool m_doFastPaths : 1;

lib/Backend/GlobOpt.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,7 @@ GlobOpt::OptArguments(IR::Instr *instr)
15881588
if (CurrentBlockData()->IsArgumentsOpnd(src1))
15891589
{
15901590
instr->usesStackArgumentsObject = true;
1591+
instr->m_func->unoptableInlineArgCount++;
15911592
}
15921593

15931594
if (CurrentBlockData()->IsArgumentsOpnd(src1) &&
@@ -1607,13 +1608,15 @@ GlobOpt::OptArguments(IR::Instr *instr)
16071608
if (builtinFunction == Js::BuiltinFunction::JavascriptFunction_Apply)
16081609
{
16091610
CurrentBlockData()->ClearArgumentsSym(src1->AsRegOpnd());
1611+
instr->m_func->unoptableInlineArgCount--;
16101612
}
16111613
}
16121614
else if (builtinOpnd->IsRegOpnd())
16131615
{
16141616
if (builtinOpnd->AsRegOpnd()->m_sym->m_builtInIndex == Js::BuiltinFunction::JavascriptFunction_Apply)
16151617
{
16161618
CurrentBlockData()->ClearArgumentsSym(src1->AsRegOpnd());
1619+
instr->m_func->unoptableInlineArgCount--;
16171620
}
16181621
}
16191622
}
@@ -13208,10 +13211,10 @@ GlobOpt::OptArgLenAndConst(IR::Instr* instr, Value** src1Val)
1320813211
if (instr->usesStackArgumentsObject && instr->IsInlined())
1320913212
{
1321013213
IR::Opnd* src1 = instr->GetSrc1();
13211-
auto replaceInstr = [&](IR::Opnd* newopnd)
13214+
auto replaceInstr = [&](IR::Opnd* newopnd, Js::OpCode opCode = Js::OpCode::Ld_A)
1321213215
{
1321313216
this->CaptureByteCodeSymUses(instr);
13214-
instr->m_opcode = Js::OpCode::Ld_A;
13217+
instr->m_opcode = opCode;
1321513218
instr->ReplaceSrc1(newopnd);
1321613219
if (instr->HasBailOutInfo())
1321713220
{
@@ -13231,6 +13234,7 @@ GlobOpt::OptArgLenAndConst(IR::Instr* instr, Value** src1Val)
1323113234
}
1323213235

1323313236
case Js::OpCode::LdElemI_A:
13237+
case Js::OpCode::TypeofElem:
1323413238
{
1323513239
IR::IndirOpnd* indirOpndSrc1 = src1->AsIndirOpnd();
1323613240
if (!indirOpndSrc1->GetIndexOpnd())
@@ -13256,8 +13260,17 @@ GlobOpt::OptArgLenAndConst(IR::Instr* instr, Value** src1Val)
1325613260
}
1325713261
else
1325813262
{
13259-
replaceInstr(defInstr->GetSrc1());
13260-
}
13263+
if (instr->m_opcode == Js::OpCode::TypeofElem) {
13264+
replaceInstr(defInstr->GetSrc1(), Js::OpCode::Typeof);
13265+
}
13266+
else {
13267+
replaceInstr(defInstr->GetSrc1());
13268+
}
13269+
}
13270+
}
13271+
else
13272+
{
13273+
instr->m_func->unoptableInlineArgCount++;
1326113274
}
1326213275
break;
1326313276
}

lib/Backend/GlobOptBailOut.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ GlobOpt::CaptureByteCodeSymUses(IR::Instr * instr)
482482
void
483483
GlobOpt::ProcessInlineeEnd(IR::Instr* instr)
484484
{
485+
if (instr->m_func->hasArgLenAndConstOpt && instr->m_func->unoptableInlineArgCount == 0)
486+
{
487+
instr->m_func->hasUnoptimizedArgumentsAccess = false;
488+
if (DoInlineArgsOpt(instr->m_func))
489+
{
490+
instr->m_func->m_hasInlineArgsOpt = true;
491+
instr->m_func->frameInfo = instr->m_func->cachedInlineeFrameInfo;
492+
}
493+
}
494+
485495
if (instr->m_func->m_hasInlineArgsOpt)
486496
{
487497
RecordInlineeFrameInfo(instr);
@@ -570,23 +580,34 @@ GlobOpt::TrackCalls(IR::Instr * instr)
570580
}
571581

572582
case Js::OpCode::InlineeStart:
583+
{
573584
Assert(instr->m_func->GetParentFunc() == this->currentBlock->globOptData.curFunc);
574585
Assert(instr->m_func->GetParentFunc());
575586
this->currentBlock->globOptData.curFunc = instr->m_func;
576587

577588
this->func->UpdateMaxInlineeArgOutSize(this->currentBlock->globOptData.inlinedArgOutSize);
578589
this->EndTrackCall(instr);
579590

580-
if (DoInlineArgsOpt(instr->m_func))
591+
auto createFrameInfo = [&](Func* inlineeFunc)
581592
{
582-
instr->m_func->m_hasInlineArgsOpt = true;
583-
InlineeFrameInfo* frameInfo = InlineeFrameInfo::New(func->m_alloc);
584-
instr->m_func->frameInfo = frameInfo;
593+
InlineeFrameInfo* frameInfo = InlineeFrameInfo::New(inlineeFunc->m_alloc);
585594
frameInfo->floatSyms = CurrentBlockData()->liveFloat64Syms->CopyNew(this->alloc);
586595
frameInfo->intSyms = CurrentBlockData()->liveInt32Syms->MinusNew(CurrentBlockData()->liveLossyInt32Syms, this->alloc);
587596
frameInfo->varSyms = CurrentBlockData()->liveVarSyms->CopyNew(this->alloc);
597+
return frameInfo;
598+
};
599+
600+
if (DoInlineArgsOpt(instr->m_func))
601+
{
602+
instr->m_func->m_hasInlineArgsOpt = true;
603+
instr->m_func->frameInfo = createFrameInfo(func);
604+
}
605+
else
606+
{
607+
instr->m_func->cachedInlineeFrameInfo = createFrameInfo(instr->m_func);
588608
}
589609
break;
610+
}
590611

591612
case Js::OpCode::EndCallForPolymorphicInlinee:
592613
// Have this opcode mimic the functions of both InlineeStart and InlineeEnd in the bailout block of a polymorphic call inlined using fixed methods.

0 commit comments

Comments
 (0)