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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // optimizations need deoptimization info for non-deoptable instructions, 365 // optimizations need deoptimization info for non-deoptable instructions,
366 // eg, LICM on GOTOs. 366 // eg, LICM on GOTOs.
367 if (instr->env() != NULL) { 367 if (instr->env() != NULL) {
368 call_->env()->DeepCopyToOuter(callee_graph->zone(), instr); 368 call_->env()->DeepCopyToOuter(callee_graph->zone(), instr);
369 } 369 }
370 } 370 }
371 if (instr->IsGoto()) { 371 if (instr->IsGoto()) {
372 instr->AsGoto()->adjust_edge_weight(scale_factor); 372 instr->AsGoto()->adjust_edge_weight(scale_factor);
373 } 373 }
374 } 374 }
375
376 RemoveUnreachableExits(callee_graph);
375 } 377 }
376 378
377 379
378 void InlineExitCollector::AddExit(ReturnInstr* exit) { 380 void InlineExitCollector::AddExit(ReturnInstr* exit) {
379 Data data = { NULL, exit }; 381 Data data = { NULL, exit };
380 exits_.Add(data); 382 exits_.Add(data);
381 } 383 }
382 384
383 385
384 void InlineExitCollector::Union(const InlineExitCollector* other) { 386 void InlineExitCollector::Union(const InlineExitCollector* other) {
385 // It doesn't make sense to combine different calls or calls from 387 // It doesn't make sense to combine different calls or calls from
386 // different graphs. 388 // different graphs.
387 ASSERT(caller_graph_ == other->caller_graph_); 389 ASSERT(caller_graph_ == other->caller_graph_);
388 ASSERT(call_ == other->call_); 390 ASSERT(call_ == other->call_);
389 exits_.AddArray(other->exits_); 391 exits_.AddArray(other->exits_);
390 } 392 }
391 393
392 394
393 int InlineExitCollector::LowestBlockIdFirst(const Data* a, const Data* b) { 395 int InlineExitCollector::LowestBlockIdFirst(const Data* a, const Data* b) {
394 return (a->exit_block->block_id() - b->exit_block->block_id()); 396 return (a->exit_block->block_id() - b->exit_block->block_id());
395 } 397 }
396 398
397 399
400 void InlineExitCollector::RemoveUnreachableExits(FlowGraph* callee_graph) {
401 const GrowableArray<BlockEntryInstr*>& postorder = callee_graph->postorder();
402 int j = 0;
403 for (int i = 0; i < exits_.length(); ++i) {
404 BlockEntryInstr* block = exits_[i].exit_return->GetBlock();
405 if ((block != NULL) &&
406 (0 <= block->postorder_number()) &&
407 (block->postorder_number() < postorder.length()) &&
408 (postorder[block->postorder_number()] == block)) {
409 if (i != j) {
410 exits_[j] = exits_[i];
411 }
412 j++;
413 }
414 }
415 exits_.TruncateTo(j);
416 }
417
418
398 void InlineExitCollector::SortExits() { 419 void InlineExitCollector::SortExits() {
399 // Assign block entries here because we did not necessarily know them when 420 // Assign block entries here because we did not necessarily know them when
400 // the return exit was added to the array. 421 // the return exit was added to the array.
401 for (int i = 0; i < exits_.length(); ++i) { 422 for (int i = 0; i < exits_.length(); ++i) {
402 exits_[i].exit_block = exits_[i].exit_return->GetBlock(); 423 exits_[i].exit_block = exits_[i].exit_return->GetBlock();
403 } 424 }
404 exits_.Sort(LowestBlockIdFirst); 425 exits_.Sort(LowestBlockIdFirst);
405 } 426 }
406 427
407 428
(...skipping 4184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4592 Report::MessageF(Report::kBailout, 4613 Report::MessageF(Report::kBailout,
4593 Script::Handle(function.script()), 4614 Script::Handle(function.script()),
4594 function.token_pos(), 4615 function.token_pos(),
4595 "FlowGraphBuilder Bailout: %s %s", 4616 "FlowGraphBuilder Bailout: %s %s",
4596 String::Handle(function.name()).ToCString(), 4617 String::Handle(function.name()).ToCString(),
4597 reason); 4618 reason);
4598 UNREACHABLE(); 4619 UNREACHABLE();
4599 } 4620 }
4600 4621
4601 } // namespace dart 4622 } // namespace dart
OLDNEW
« 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