Skip to content

Commit 6123e0e

Browse files
aamCommit Queue
authored andcommitted
[vm/inlining] Set try-index for inlined function after decision is made.
Delay setting try-index for callee flow graph until the decision to inline is made. This avoids confusing situation when running optimization passes on callee, where InsideTryBlock reports that the instruction is in try block, but there is no try block in the flow graph. TEST=ci Change-Id: Ia9dfa8b53dda9ca259dc73d810e7a4344971b904 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399320 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent dc997e0 commit 6123e0e

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

runtime/vm/compiler/backend/inliner.cc

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,17 +1399,6 @@ class CallSiteInliner : public ValueObject {
13991399
ASSERT(arguments->length() ==
14001400
first_actual_param_index + function.NumParameters());
14011401

1402-
// Update try-index of the callee graph.
1403-
BlockEntryInstr* call_block = call_data->call->GetBlock();
1404-
if (call_block->InsideTryBlock()) {
1405-
intptr_t try_index = call_block->try_index();
1406-
for (BlockIterator it = callee_graph->reverse_postorder_iterator();
1407-
!it.Done(); it.Advance()) {
1408-
BlockEntryInstr* block = it.Current();
1409-
block->set_try_index(try_index);
1410-
}
1411-
}
1412-
14131402
BlockScheduler::AssignEdgeWeights(callee_graph);
14141403

14151404
{
@@ -1574,10 +1563,12 @@ class CallSiteInliner : public ValueObject {
15741563
}
15751564

15761565
{
1577-
COMPILER_TIMINGS_TIMER_SCOPE(thread(), SetInliningId);
1578-
FlowGraphInliner::SetInliningId(
1579-
callee_graph, inliner_->NextInlineId(callee_graph->function(),
1580-
call_data->call->source()));
1566+
COMPILER_TIMINGS_TIMER_SCOPE(thread(), SetInliningIdAndTryIndex);
1567+
FlowGraphInliner::SetInliningIdAndTryIndex(
1568+
callee_graph,
1569+
inliner_->NextInlineId(callee_graph->function(),
1570+
call_data->call->source()),
1571+
call_data->call->GetBlock()->try_index());
15811572
}
15821573
TRACE_INLINING(THR_Print(" Success\n"));
15831574
TRACE_INLINING(THR_Print(
@@ -2449,17 +2440,23 @@ void FlowGraphInliner::CollectGraphInfo(FlowGraph* flow_graph,
24492440
*call_site_count = function.optimized_call_site_count();
24502441
}
24512442

2452-
void FlowGraphInliner::SetInliningId(FlowGraph* flow_graph,
2453-
intptr_t inlining_id) {
2443+
void FlowGraphInliner::SetInliningIdAndTryIndex(FlowGraph* flow_graph,
2444+
intptr_t inlining_id,
2445+
intptr_t caller_try_index) {
24542446
ASSERT(flow_graph->inlining_id() < 0);
24552447
flow_graph->set_inlining_id(inlining_id);
24562448
// We only need to set the inlining ID on instructions that may possibly
24572449
// have token positions, so no need to set it on blocks or internal
24582450
// definitions.
24592451
for (BlockIterator block_it = flow_graph->postorder_iterator();
24602452
!block_it.Done(); block_it.Advance()) {
2461-
for (ForwardInstructionIterator it(block_it.Current()); !it.Done();
2462-
it.Advance()) {
2453+
BlockEntryInstr* block = block_it.Current();
2454+
if (caller_try_index != kInvalidTryIndex) {
2455+
// Inlining of functions with try-blocks is not supported at the moment.
2456+
ASSERT(!block->InsideTryBlock());
2457+
block->set_try_index(caller_try_index);
2458+
}
2459+
for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
24632460
Instruction* current = it.Current();
24642461
current->set_inlining_id(inlining_id);
24652462
}

runtime/vm/compiler/backend/inliner.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ class FlowGraphInliner : ValueObject {
117117
intptr_t* instruction_count,
118118
intptr_t* call_site_count);
119119

120-
static void SetInliningId(FlowGraph* flow_graph, intptr_t inlining_id);
120+
static void SetInliningIdAndTryIndex(FlowGraph* flow_graph,
121+
intptr_t inlining_id,
122+
intptr_t caller_try_index);
121123

122124
bool AlwaysInline(const Function& function);
123125

runtime/vm/compiler/compiler_pass.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,9 @@ COMPILER_PASS(ApplyICData, { state->call_specializer->ApplyICData(); });
390390

391391
COMPILER_PASS(TryOptimizePatterns, { flow_graph->TryOptimizePatterns(); });
392392

393-
COMPILER_PASS(SetOuterInliningId,
394-
{ FlowGraphInliner::SetInliningId(flow_graph, 0); });
393+
COMPILER_PASS(SetOuterInliningId, {
394+
FlowGraphInliner::SetInliningIdAndTryIndex(flow_graph, 0, kInvalidTryIndex);
395+
});
395396

396397
COMPILER_PASS(Inlining, {
397398
FlowGraphInliner inliner(

runtime/vm/compiler/compiler_timings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
V(CollectGraphInfo) \
3838
V(PopulateWithICData) \
3939
V(FindCallSites) \
40-
V(SetInliningId) \
40+
V(SetInliningIdAndTryIndex) \
4141
V(MakeInliningDecision) \
4242
V(CheckForPragma) \
4343
V(InlineCall) \

0 commit comments

Comments
 (0)