Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit e41955f

Browse files
meg-guptachakrabot
authored andcommitted
deps: update ChakraCore to chakra-core/ChakraCore@965f77965c
[1.8>1.9] [MERGE #4627 @meg-gupta] Fix missed copyprop opportunity due to unhandled InitFld case Merge pull request #4627 from meg-gupta:fixopt ```var num = 50; function inlineCall(tnum) { return {x : tnum}; // InitFld } function foo (obj) { var tnum = num; var sum = 0; while (tnum >= 0) { var retObj = inlineCall(tnum); if (tnum > 10) { sum += retObj.x; // missed copy prop opportunity } tnum--; } return sum; } var obj = {}; foo(obj); foo(obj); foo(obj) ``` We were not setting a property initialized from InitFld instruction on the liveFields bit vector, this led to returning null valueInfo when we queried through GlobOptBlockData::FindPropertyValue, because that function checks if the property is live first and then queries its valauenumber from the symToValue map. This pattern comes up in forof on array iterators, the constructor returns an object literal and we miss copy proping Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
1 parent d626720 commit e41955f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

deps/chakrashim/core/lib/Backend/GlobOpt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,6 @@ GlobOpt::CopyProp(IR::Opnd *opnd, IR::Instr *instr, Value *val, IR::IndirOpnd *p
36623662

36633663
ValueInfo *valueInfo = val->GetValueInfo();
36643664

3665-
36663665
if (this->func->HasFinally())
36673666
{
36683667
// s0 = undefined was added on functions with early exit in try-finally functions, that can get copy-proped and case incorrect results
@@ -4847,6 +4846,8 @@ GlobOpt::ValueNumberDst(IR::Instr **pInstr, Value *src1Val, Value *src2Val)
48474846
case Js::OpCode::StRootFld:
48484847
case Js::OpCode::StFldStrict:
48494848
case Js::OpCode::StRootFldStrict:
4849+
case Js::OpCode::InitFld:
4850+
case Js::OpCode::InitComputedProperty:
48504851
if (DoFieldCopyProp())
48514852
{
48524853
if (src1Val == nullptr)

deps/chakrashim/core/lib/Backend/GlobOptFields.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ GlobOpt::ProcessFieldKills(IR::Instr *instr, BVSparse<JitArenaAllocator> *bv, bo
473473
KillLiveElems(dstOpnd->AsIndirOpnd(), bv, inGlobOpt, instr->m_func);
474474
break;
475475

476+
case Js::OpCode::InitComputedProperty:
477+
KillLiveElems(dstOpnd->AsIndirOpnd(), bv, inGlobOpt, instr->m_func);
478+
break;
479+
476480
case Js::OpCode::DeleteElemI_A:
477481
case Js::OpCode::DeleteElemIStrict_A:
478482
Assert(dstOpnd != nullptr);
@@ -504,7 +508,7 @@ GlobOpt::ProcessFieldKills(IR::Instr *instr, BVSparse<JitArenaAllocator> *bv, bo
504508
this->KillAllObjectTypes(bv);
505509
}
506510
break;
507-
511+
case Js::OpCode::InitFld:
508512
case Js::OpCode::StFld:
509513
case Js::OpCode::StRootFld:
510514
case Js::OpCode::StFldStrict:

0 commit comments

Comments
 (0)