@@ -1137,9 +1137,9 @@ FlowGraph::MoveBlocksBefore(BasicBlock *blockStart, BasicBlock *blockEnd, BasicB
1137
1137
// We have to update region info for blocks whose predecessors changed
1138
1138
if (assignRegionsBeforeGlobopt)
1139
1139
{
1140
- UpdateRegionForBlockFromEHPred (dstPredBlock, true );
1141
- UpdateRegionForBlockFromEHPred (blockStart, true );
1142
- UpdateRegionForBlockFromEHPred (srcNextBlock, true );
1140
+ UpdateRegionForBlock (dstPredBlock);
1141
+ UpdateRegionForBlock (blockStart);
1142
+ UpdateRegionForBlock (srcNextBlock);
1143
1143
}
1144
1144
}
1145
1145
@@ -1871,30 +1871,6 @@ FlowGraph::Destroy(void)
1871
1871
this ->func ->isFlowGraphValid = false ;
1872
1872
}
1873
1873
1874
- bool FlowGraph::IsEHTransitionInstr (IR::Instr *instr)
1875
- {
1876
- Js::OpCode op = instr->m_opcode ;
1877
- return (op == Js::OpCode::TryCatch || op == Js::OpCode::TryFinally || op == Js::OpCode::Leave || op == Js::OpCode::LeaveNull);
1878
- }
1879
-
1880
- BasicBlock * FlowGraph::GetPredecessorForRegionPropagation (BasicBlock *block)
1881
- {
1882
- BasicBlock *ehPred = nullptr ;
1883
- FOREACH_PREDECESSOR_BLOCK (predBlock, block)
1884
- {
1885
- Region * predRegion = predBlock->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
1886
- if (IsEHTransitionInstr (predBlock->GetLastInstr ()) && predRegion)
1887
- {
1888
- // MGTODO : change this to return, once you know there can exist only one eh transitioning pred
1889
- Assert (ehPred == nullptr );
1890
- ehPred = predBlock;
1891
- }
1892
- AssertMsg (predBlock->GetBlockNum () < this ->blockCount , " Misnumbered block at teardown time?" );
1893
- }
1894
- NEXT_PREDECESSOR_BLOCK;
1895
- return ehPred;
1896
- }
1897
-
1898
1874
// Propagate the region forward from the block's predecessor(s), tracking the effect
1899
1875
// of the flow transition. Record the region in the block-to-region map provided
1900
1876
// and on the label at the entry to the block (if any).
@@ -1958,7 +1934,6 @@ FlowGraph::UpdateRegionForBlock(BasicBlock * block)
1958
1934
}
1959
1935
}
1960
1936
1961
- Assert (region || block->GetPredList ()->Count () == 0 );
1962
1937
if (region && !region->ehBailoutData )
1963
1938
{
1964
1939
region->AllocateEHBailoutData (this ->func , tryInstr);
@@ -1997,106 +1972,6 @@ FlowGraph::UpdateRegionForBlock(BasicBlock * block)
1997
1972
}
1998
1973
}
1999
1974
2000
- void
2001
- FlowGraph::UpdateRegionForBlockFromEHPred (BasicBlock * block, bool reassign)
2002
- {
2003
- Region *region = nullptr ;
2004
- Region * predRegion = nullptr ;
2005
- IR::Instr * tryInstr = nullptr ;
2006
- IR::Instr * firstInstr = block->GetFirstInstr ();
2007
- if (!reassign && firstInstr->IsLabelInstr () && firstInstr->AsLabelInstr ()->GetRegion ())
2008
- {
2009
- Assert (this ->func ->HasTry () && (this ->func ->DoOptimizeTry () || (this ->func ->IsSimpleJit () && this ->func ->hasBailout )));
2010
- return ;
2011
- }
2012
- if (block->isDead || block->isDeleted )
2013
- {
2014
- // We can end up calling this function with such blocks, return doing nothing
2015
- // See test5() in tryfinallytests.js
2016
- return ;
2017
- }
2018
-
2019
- if (block == this ->blockList )
2020
- {
2021
- // Head of the graph: create the root region.
2022
- region = Region::New (RegionTypeRoot, nullptr , this ->func );
2023
- }
2024
- else if (block->GetPredList ()->Count () == 1 )
2025
- {
2026
- BasicBlock *predBlock = block->GetPredList ()->Head ()->GetPred ();
2027
- AssertMsg (predBlock->GetBlockNum () < this ->blockCount , " Misnumbered block at teardown time?" );
2028
- predRegion = predBlock->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
2029
- Assert (predRegion);
2030
- region = this ->PropagateRegionFromPred (block, predBlock, predRegion, tryInstr);
2031
- }
2032
- else
2033
- {
2034
- // Propagate the region forward by finding a predecessor we've already processed.
2035
- // Since we do break block remval after region propagation, we cannot pick the first predecessor which has an assigned region
2036
- // If there is a eh transitioning pred, we pick that
2037
- // There cannot be more than one eh transitioning pred (?)
2038
- BasicBlock *ehPred = this ->GetPredecessorForRegionPropagation (block);
2039
- if (ehPred)
2040
- {
2041
- predRegion = ehPred->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
2042
- Assert (predRegion != nullptr );
2043
- region = this ->PropagateRegionFromPred (block, ehPred, predRegion, tryInstr);
2044
- }
2045
- else
2046
- {
2047
- FOREACH_PREDECESSOR_BLOCK (predBlock, block)
2048
- {
2049
- predRegion = predBlock->GetFirstInstr ()->AsLabelInstr ()->GetRegion ();
2050
- if (predRegion != nullptr )
2051
- {
2052
- if ((predBlock->GetLastInstr ()->m_opcode == Js::OpCode::BrOnException || predBlock->GetLastInstr ()->m_opcode == Js::OpCode::BrOnNoException) &&
2053
- predBlock->GetLastInstr ()->AsBranchInstr ()->m_brFinallyToEarlyExit )
2054
- {
2055
- Assert (predRegion->IsNonExceptingFinally ());
2056
- // BrOnException from finally region to early exit
2057
- // Skip this edge
2058
- continue ;
2059
- }
2060
- if (predBlock->GetLastInstr ()->m_opcode == Js::OpCode::Br &&
2061
- predBlock->GetLastInstr ()->GetPrevRealInstr ()->m_opcode == Js::OpCode::BrOnNoException)
2062
- {
2063
- Assert (predBlock->GetLastInstr ()->GetPrevRealInstr ()->AsBranchInstr ()->m_brFinallyToEarlyExit );
2064
- Assert (predRegion->IsNonExceptingFinally ());
2065
- // BrOnException from finally region to early exit changed to BrOnNoException and Br during break block removal
2066
- continue ;
2067
- }
2068
- region = this ->PropagateRegionFromPred (block, predBlock, predRegion, tryInstr);
2069
- break ;
2070
- }
2071
- }
2072
- NEXT_PREDECESSOR_BLOCK;
2073
- }
2074
- }
2075
-
2076
- Assert (region || block->GetPredList ()->Count () == 0 || block->firstInstr ->AsLabelInstr ()->GetRegion ());
2077
-
2078
- if (region)
2079
- {
2080
- if (!region->ehBailoutData )
2081
- {
2082
- region->AllocateEHBailoutData (this ->func , tryInstr);
2083
- }
2084
-
2085
- Assert (firstInstr->IsLabelInstr ());
2086
- if (firstInstr->IsLabelInstr ())
2087
- {
2088
- // Record the region on the label and make sure it stays around as a region
2089
- // marker if we're entering a region at this point.
2090
- IR::LabelInstr * labelInstr = firstInstr->AsLabelInstr ();
2091
- labelInstr->SetRegion (region);
2092
- if (region != predRegion)
2093
- {
2094
- labelInstr->m_hasNonBranchRef = true ;
2095
- }
2096
- }
2097
- }
2098
- }
2099
-
2100
1975
Region *
2101
1976
FlowGraph::PropagateRegionFromPred (BasicBlock * block, BasicBlock * predBlock, Region * predRegion, IR::Instr * &tryInstr)
2102
1977
{
@@ -2488,7 +2363,7 @@ FlowGraph::InsertCompensationCodeForBlockMove(FlowEdge * edge, bool insertToLoo
2488
2363
2489
2364
if (assignRegionsBeforeGlobopt)
2490
2365
{
2491
- UpdateRegionForBlockFromEHPred (compBlock);
2366
+ UpdateRegionForBlock (compBlock);
2492
2367
}
2493
2368
}
2494
2369
else
0 commit comments