Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(645)

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 1563703005: Remove unreachable exits from the list collected by InlineExitCollector. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix bug: graph can change between RemoveUnreachableExits and SortExits Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index 97cf73521e5800a378d3404dcaa8174f180047be..2e451e1780721aad4d49a1dda2f7547ed1cdf363 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -372,6 +372,8 @@ void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) {
instr->AsGoto()->adjust_edge_weight(scale_factor);
}
}
+
+ RemoveUnreachableExits(callee_graph);
}
@@ -395,6 +397,25 @@ int InlineExitCollector::LowestBlockIdFirst(const Data* a, const Data* b) {
}
+void InlineExitCollector::RemoveUnreachableExits(FlowGraph* callee_graph) {
+ const GrowableArray<BlockEntryInstr*>& postorder = callee_graph->postorder();
+ int j = 0;
+ for (int i = 0; i < exits_.length(); ++i) {
+ BlockEntryInstr* block = exits_[i].exit_return->GetBlock();
+ if ((block != NULL) &&
+ (0 <= block->postorder_number()) &&
+ (block->postorder_number() < postorder.length()) &&
+ (postorder[block->postorder_number()] == block)) {
+ if (i != j) {
+ exits_[j] = exits_[i];
+ }
+ j++;
+ }
+ }
+ exits_.TruncateTo(j);
+}
+
+
void InlineExitCollector::SortExits() {
// Assign block entries here because we did not necessarily know them when
// the return exit was added to the array.
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698