Skip to content

Commit 37feadb

Browse files
committed
Resolved issues
1 parent c89ab41 commit 37feadb

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7832,10 +7832,12 @@ BackwardPass::ProcessInlineeEnd(IR::Instr* instr)
78327832
}
78337833
if (this->tag == Js::BackwardPhase)
78347834
{
7835-
if (!GlobOpt::DoInlineArgsOpt(instr->m_func))
7835+
// Commenting out to allow for argument length and argument[constant] optimization
7836+
// Will revisit in phase two
7837+
/*if (!GlobOpt::DoInlineArgsOpt(instr->m_func))
78367838
{
78377839
return;
7838-
}
7840+
}*/
78397841

78407842
// This adds a use for function sym as part of InlineeStart & all the syms referenced by the args.
78417843
// It ensure they do not get cleared from the copy prop sym map.

lib/Backend/GlobOpt.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ GlobOpt::ToTypeSpec(BVSparse<JitArenaAllocator> *bv, BasicBlock *block, IRType t
883883
// instruction itself should disable arguments object optimization.
884884
if(block->globOptData.argObjSyms && block->globOptData.IsArgumentsSymID(id))
885885
{
886-
CannotAllocateArgumentsObjectOnStack(insertBeforeInstr->m_func);
886+
CannotAllocateArgumentsObjectOnStack(nullptr);
887887
}
888888

889889
if (block->globOptData.liveVarSyms->Test(id))
@@ -13087,10 +13087,10 @@ GlobOpt::OptArraySrc(IR::Instr ** const instrRef, Value ** src1Val, Value ** src
1308713087
void
1308813088
GlobOpt::OptArgLenAndConst(IR::Instr* instr, Value** src1Val)
1308913089
{
13090-
if (instr->m_func->IsStackArgsEnabled() && instr->IsInlined())
13090+
if (instr->usesStackArgumentsObject && instr->IsInlined())
1309113091
{
1309213092
IR::Opnd* src1 = instr->GetSrc1();
13093-
auto replaceInstr = [&](IR::Instr* instr, IR::Opnd* newopnd, Value** src1Val)
13093+
auto replaceInstr = [&](IR::Opnd* newopnd)
1309413094
{
1309513095
this->CaptureByteCodeSymUses(instr);
1309613096
instr->m_opcode = Js::OpCode::Ld_A;
@@ -13102,22 +13102,20 @@ GlobOpt::OptArgLenAndConst(IR::Instr* instr, Value** src1Val)
1310213102
*src1Val = this->OptSrc(instr->GetSrc1(), &instr);
1310313103
instr->m_func->hasArgLenAndConstOpt = true;
1310413104
};
13105+
Assert(CurrentBlockData()->IsArgumentsOpnd(src1));
1310513106
switch(instr->m_opcode)
1310613107
{
1310713108
case Js::OpCode::LdLen_A:
1310813109
{
13109-
if (CurrentBlockData()->IsArgumentsOpnd(src1))
13110-
{
13111-
IR::AddrOpnd* newopnd = IR::AddrOpnd::New(Js::TaggedInt::ToVarUnchecked(instr->m_func->actualCount - 1), IR::AddrOpndKindConstantVar, instr->m_func);
13112-
replaceInstr(instr, newopnd, src1Val);
13113-
}
13110+
IR::AddrOpnd* newopnd = IR::AddrOpnd::New(Js::TaggedInt::ToVarUnchecked(instr->m_func->actualCount - 1), IR::AddrOpndKindConstantVar, instr->m_func);
13111+
replaceInstr(newopnd);
1311413112
break;
1311513113
}
1311613114

1311713115
case Js::OpCode::LdElemI_A:
1311813116
{
1311913117
IR::IndirOpnd* indirOpndSrc1 = src1->AsIndirOpnd();
13120-
if (!indirOpndSrc1->GetIndexOpnd() && CurrentBlockData()->IsArgumentsOpnd(src1))
13118+
if (!indirOpndSrc1->GetIndexOpnd())
1312113119
{
1312213120
int argIndex = indirOpndSrc1->GetOffset() + 1;
1312313121
IR::Instr* defInstr = nullptr;
@@ -13131,7 +13129,17 @@ GlobOpt::OptArgLenAndConst(IR::Instr* instr, Value** src1Val)
1313113129
}
1313213130
return false;
1313313131
});
13134-
replaceInstr(instr, defInstr->GetSrc1(), src1Val);
13132+
// If we cannot find the right instruction. I.E. When calling arguments[2] and no arguments were passed to the func
13133+
if (defInstr == nullptr)
13134+
{
13135+
IR::Opnd * undefined = IR::AddrOpnd::New(instr->m_func->GetScriptContextInfo()->GetUndefinedAddr(), IR::AddrOpndKindDynamicVar, instr->m_func, true);
13136+
undefined->SetValueType(ValueType::Undefined);
13137+
replaceInstr(undefined);
13138+
}
13139+
else
13140+
{
13141+
replaceInstr(defInstr->GetSrc1());
13142+
}
1313513143
}
1313613144
break;
1313713145
}

0 commit comments

Comments
 (0)