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

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@d4fb4df5b9
Browse files Browse the repository at this point in the history
[MERGE #6009 @MikeHolman] disable switch opt when breaking out of loops

Merge pull request #6009 from MikeHolman:switchbug1_11

Cherry-picking to release/1.11 from master.

Switch opt gets confused when we need to branch to labels outside the loop, so just disabling it in this case.
Fixes #5985

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
MikeHolman authored and chakrabot committed Mar 12, 2019
1 parent ecab999 commit 24d596d
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions deps/chakrashim/core/lib/Backend/SwitchIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,24 +260,29 @@ SwitchIRBuilder::OnCase(IR::RegOpnd * src1Opnd, IR::Opnd * src2Opnd, uint32 offs
//
// For optimizing, the Load instruction corresponding to the switch instruction is profiled in the interpreter.
// Based on the dynamic profile data, optimization technique is decided.
if (m_switchIntDynProfile && isIntConst && GlobOpt::IsSwitchOptEnabledForIntTypeSpec(m_func->GetTopFunc()))
{
CaseNode* caseNode = JitAnew(m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
m_caseNodes->Add(caseNode);
}
else if (m_switchStrDynProfile && isStrConst && GlobOpt::IsSwitchOptEnabled(m_func->GetTopFunc()))
{
CaseNode* caseNode = JitAnew(m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
m_caseNodes->Add(caseNode);
m_seenOnlySingleCharStrCaseNodes = m_seenOnlySingleCharStrCaseNodes && caseNode->GetUpperBoundStringConstLocal()->GetLength() == 1;
}
else

// TODO: support switch opt when breaking out of loops
if (!m_func->IsLoopBody() || (targetOffset < m_func->m_workItem->GetLoopHeader()->endOffset && targetOffset >= m_func->m_workItem->GetLoopHeader()->startOffset))
{
// Otherwise, there are no optimizations to defer, so add the branch for
// this case instruction now
FlushCases(offset);
m_adapter->AddBranchInstr(branchInstr, offset, targetOffset);
if (m_switchIntDynProfile && isIntConst && GlobOpt::IsSwitchOptEnabledForIntTypeSpec(m_func->GetTopFunc()))
{
CaseNode* caseNode = JitAnew(m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
m_caseNodes->Add(caseNode);
return;
}
else if (m_switchStrDynProfile && isStrConst && GlobOpt::IsSwitchOptEnabled(m_func->GetTopFunc()))
{
CaseNode* caseNode = JitAnew(m_tempAlloc, CaseNode, branchInstr, offset, targetOffset, src2Opnd);
m_caseNodes->Add(caseNode);
m_seenOnlySingleCharStrCaseNodes = m_seenOnlySingleCharStrCaseNodes && caseNode->GetUpperBoundStringConstLocal()->GetLength() == 1;
return;
}
}

// Otherwise, there are no optimizations to defer, so add the branch for
// this case instruction now
FlushCases(offset);
m_adapter->AddBranchInstr(branchInstr, offset, targetOffset);
}


Expand Down

0 comments on commit 24d596d

Please sign in to comment.