Skip to content

Commit 91d82e1

Browse files
author
Meghana Gupta
committed
Do PathDepBranchFolding at the end of OptBlock, this will avoid redandant creation of values in local table in addition to global table for the initial block.
Also fix bug - when LdFld value was not found in the value table, it means its value was killed due to call which can be calling Object.defineProperty, dont skip such a LdFld
1 parent 9172709 commit 91d82e1

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

lib/Backend/FlowGraph.cpp

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4524,9 +4524,7 @@ static bool IsCopyTypeInstr(IR::Instr *instr)
45244524
case Js::OpCode::LdC_A_I4:
45254525
case Js::OpCode::Ld_I4:
45264526
case Js::OpCode::Ld_A:
4527-
case Js::OpCode::StFld:
4528-
case Js::OpCode::LdFld:
4529-
case Js::OpCode::InitFld: return true;
4527+
case Js::OpCode::LdFld: return true;
45304528
default:
45314529
return false;
45324530
}
@@ -4686,30 +4684,6 @@ BasicBlock::CheckLegalityAndFoldPathDepBranches(GlobOpt* globOpt)
46864684
{
46874685
unskippedInlineeEnd = currentInlineeEnd = instr;
46884686
}
4689-
else if (instr->GetDst())
4690-
{
4691-
if (instr->GetDst()->GetSym())
4692-
{
4693-
if (IsCopyTypeInstr(instr))
4694-
{
4695-
UpdateValueForCopyTypeInstr(instr);
4696-
}
4697-
else if(instr->m_opcode == Js::OpCode::NewScObjectLiteral)
4698-
{
4699-
Value **localValue = localSymToValueMap->FindOrInsertNew(instr->GetDst()->GetSym());
4700-
if (instr->GetDst()->GetValueType() == ValueType::UninitializedObject)
4701-
{
4702-
*localValue = globOpt->NewGenericValue(ValueType::UninitializedObject, instr->GetDst());
4703-
}
4704-
}
4705-
else
4706-
{
4707-
// complex instr, can't track value, insert nullptr
4708-
Value **localValue = localSymToValueMap->FindOrInsertNew(instr->GetDst()->GetSym());
4709-
*localValue = nullptr;
4710-
}
4711-
}
4712-
}
47134687
} NEXT_INSTR_IN_BLOCK;
47144688

47154689
IR::Instr * instr = this->GetLastInstr();
@@ -4750,6 +4724,13 @@ BasicBlock::CheckLegalityAndFoldPathDepBranches(GlobOpt* globOpt)
47504724
if (IsCopyTypeInstr(instr))
47514725
{
47524726
UpdateValueForCopyTypeInstr(instr);
4727+
4728+
Value *dstValue = UpdateValueForCopyTypeInstr(instr);
4729+
if (instr->m_opcode == Js::OpCode::LdFld && !dstValue)
4730+
{
4731+
// We cannot skip a LdFld if we didnt find its valueInfo in the localValueTable
4732+
return;
4733+
}
47534734
}
47544735
else
47554736
{
@@ -4850,6 +4831,14 @@ BasicBlock::CheckLegalityAndFoldPathDepBranches(GlobOpt* globOpt)
48504831
if (currentInlineeEnd != nullptr && currentInlineeEnd != unskippedInlineeEnd)
48514832
{
48524833
this->GetLastInstr()->InsertBefore(currentInlineeEnd->Copy());
4834+
if (currentInlineeEnd->m_func->m_hasInlineArgsOpt)
4835+
{
4836+
globOpt->RecordInlineeFrameInfo(currentInlineeEnd);
4837+
}
4838+
globOpt->EndTrackingOfArgObjSymsForInlinee();
4839+
4840+
Assert(globOpt->currentBlock->globOptData.inlinedArgOutSize >= currentInlineeEnd->GetArgOutSize(/*getInterpreterArgOutCount*/ false));
4841+
globOpt->currentBlock->globOptData.inlinedArgOutSize -= currentInlineeEnd->GetArgOutSize(/*getInterpreterArgOutCount*/ false);
48534842
currentInlineeEnd = nullptr;
48544843
}
48554844
// We are adding an unconditional branch, go over all the current successors and remove the ones that are dead now

lib/Backend/GlobOpt.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ GlobOpt::OptBlock(BasicBlock *block)
475475
PrepareLoopArrayCheckHoist();
476476

477477
block->MergePredBlocksValueMaps(this);
478-
block->PathDepBranchFolding(this);
479478

480479
this->intOverflowCurrentlyMattersInRange = true;
481480
this->intOverflowDoesNotMatterRange = this->currentBlock->intOverflowDoesNotMatterRange;
@@ -613,6 +612,8 @@ GlobOpt::OptBlock(BasicBlock *block)
613612
}
614613
}
615614

615+
block->PathDepBranchFolding(this);
616+
616617
#if DBG
617618
// The set of live lossy int32 syms should be a subset of all live int32 syms
618619
this->tempBv->And(block->globOptData.liveInt32Syms, block->globOptData.liveLossyInt32Syms);
@@ -6776,8 +6777,6 @@ GlobOpt::CanProveConditionalBranch(IR::Instr *instr, Value *src1Val, Value *src2
67766777
}
67776778
case Js::OpCode::BrFalse_I4:
67786779
{
6779-
// this path would probably work outside of asm.js, but we should verify that if we ever hit this scenario
6780-
Assert(GetIsAsmJSFunc());
67816780
constVal = 0;
67826781
if (!src1Val->GetValueInfo()->TryGetIntConstantValue(&constVal))
67836782
{

0 commit comments

Comments
 (0)