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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 773183002: Enable inlining inside try-blocks in the VM's optimizing compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler.cc » ('j') | 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/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // Assign block entries here because we did not necessarily know them when 332 // Assign block entries here because we did not necessarily know them when
333 // the return exit was added to the array. 333 // the return exit was added to the array.
334 for (int i = 0; i < exits_.length(); ++i) { 334 for (int i = 0; i < exits_.length(); ++i) {
335 exits_[i].exit_block = exits_[i].exit_return->GetBlock(); 335 exits_[i].exit_block = exits_[i].exit_return->GetBlock();
336 } 336 }
337 exits_.Sort(LowestBlockIdFirst); 337 exits_.Sort(LowestBlockIdFirst);
338 } 338 }
339 339
340 340
341 Definition* InlineExitCollector::JoinReturns(BlockEntryInstr** exit_block, 341 Definition* InlineExitCollector::JoinReturns(BlockEntryInstr** exit_block,
342 Instruction** last_instruction) { 342 Instruction** last_instruction,
343 intptr_t try_index) {
343 // First sort the list of exits by block id (caching return instruction 344 // First sort the list of exits by block id (caching return instruction
344 // block entries as a side effect). 345 // block entries as a side effect).
345 SortExits(); 346 SortExits();
346 intptr_t num_exits = exits_.length(); 347 intptr_t num_exits = exits_.length();
347 if (num_exits == 1) { 348 if (num_exits == 1) {
348 ReturnAt(0)->UnuseAllInputs(); 349 ReturnAt(0)->UnuseAllInputs();
349 *exit_block = ExitBlockAt(0); 350 *exit_block = ExitBlockAt(0);
350 *last_instruction = LastInstructionAt(0); 351 *last_instruction = LastInstructionAt(0);
351 return call_->HasUses() ? ValueAt(0)->definition() : NULL; 352 return call_->HasUses() ? ValueAt(0)->definition() : NULL;
352 } else { 353 } else {
353 ASSERT(num_exits > 1); 354 ASSERT(num_exits > 1);
354 // Create a join of the returns. 355 // Create a join of the returns.
355 intptr_t join_id = caller_graph_->max_block_id() + 1; 356 intptr_t join_id = caller_graph_->max_block_id() + 1;
356 caller_graph_->set_max_block_id(join_id); 357 caller_graph_->set_max_block_id(join_id);
357 JoinEntryInstr* join = 358 JoinEntryInstr* join =
358 new(I) JoinEntryInstr(join_id, CatchClauseNode::kInvalidTryIndex); 359 new(I) JoinEntryInstr(join_id, try_index);
359 join->InheritDeoptTargetAfter(isolate(), call_); 360 join->InheritDeoptTargetAfter(isolate(), call_);
360 361
361 // The dominator set of the join is the intersection of the dominator 362 // The dominator set of the join is the intersection of the dominator
362 // sets of all the predecessors. If we keep the dominator sets ordered 363 // sets of all the predecessors. If we keep the dominator sets ordered
363 // by height in the dominator tree, we can also get the immediate 364 // by height in the dominator tree, we can also get the immediate
364 // dominator of the join node from the intersection. 365 // dominator of the join node from the intersection.
365 // 366 //
366 // block_dominators is the dominator set for each block, ordered from 367 // block_dominators is the dominator set for each block, ordered from
367 // the immediate dominator to the root of the dominator tree. This is 368 // the immediate dominator to the root of the dominator tree. This is
368 // the order we collect them in (adding at the end). 369 // the order we collect them in (adding at the end).
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 479
479 call_->previous()->AppendInstruction(branch); 480 call_->previous()->AppendInstruction(branch);
480 call_block->set_last_instruction(branch); 481 call_block->set_last_instruction(branch);
481 482
482 // Update dominator tree. 483 // Update dominator tree.
483 call_block->AddDominatedBlock(callee_entry); 484 call_block->AddDominatedBlock(callee_entry);
484 call_block->AddDominatedBlock(false_block); 485 call_block->AddDominatedBlock(false_block);
485 486
486 } else { 487 } else {
487 Definition* callee_result = JoinReturns(&callee_exit, 488 Definition* callee_result = JoinReturns(&callee_exit,
488 &callee_last_instruction); 489 &callee_last_instruction,
490 call_block->try_index());
489 if (callee_result != NULL) { 491 if (callee_result != NULL) {
490 call_->ReplaceUsesWith(callee_result); 492 call_->ReplaceUsesWith(callee_result);
491 } 493 }
492 if (callee_last_instruction == callee_entry) { 494 if (callee_last_instruction == callee_entry) {
493 // There are no instructions in the inlined function (e.g., it might be 495 // There are no instructions in the inlined function (e.g., it might be
494 // a return of a parameter or a return of a constant defined in the 496 // a return of a parameter or a return of a constant defined in the
495 // initial definitions). 497 // initial definitions).
496 call_->previous()->LinkTo(call_->next()); 498 call_->previous()->LinkTo(call_->next());
497 } else { 499 } else {
498 call_->previous()->LinkTo(callee_entry->next()); 500 call_->previous()->LinkTo(callee_entry->next());
(...skipping 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 Report::MessageF(Report::kBailout, 4302 Report::MessageF(Report::kBailout,
4301 Script::Handle(function.script()), 4303 Script::Handle(function.script()),
4302 function.token_pos(), 4304 function.token_pos(),
4303 "FlowGraphBuilder Bailout: %s %s", 4305 "FlowGraphBuilder Bailout: %s %s",
4304 String::Handle(function.name()).ToCString(), 4306 String::Handle(function.name()).ToCString(),
4305 reason); 4307 reason);
4306 UNREACHABLE(); 4308 UNREACHABLE();
4307 } 4309 }
4308 4310
4309 } // namespace dart 4311 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698