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

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

Issue 9730003: Make the CFG depth-first traversal do more work for us. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language.h » ('J')
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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 } 1664 }
1665 const Function& function = parsed_function().function(); 1665 const Function& function = parsed_function().function();
1666 EffectGraphVisitor for_effect(this, 0); 1666 EffectGraphVisitor for_effect(this, 0);
1667 for_effect.AddInstruction(new TargetEntryInstr()); 1667 for_effect.AddInstruction(new TargetEntryInstr());
1668 parsed_function().node_sequence()->Visit(&for_effect); 1668 parsed_function().node_sequence()->Visit(&for_effect);
1669 // Check that the graph is properly terminated. 1669 // Check that the graph is properly terminated.
1670 ASSERT(!for_effect.is_open()); 1670 ASSERT(!for_effect.is_open());
1671 if (for_effect.entry() != NULL) { 1671 if (for_effect.entry() != NULL) {
1672 // Perform a depth-first traversal of the graph to build preorder and 1672 // Perform a depth-first traversal of the graph to build preorder and
1673 // postorder block orders. 1673 // postorder block orders.
1674 for_effect.entry()->DepthFirstSearch(&preorder_block_entries_, 1674 GrowableArray<BlockEntryInstr*> parent;
Kevin Millikin (Google) 2012/03/19 18:05:12 parent is currently ignored.
1675 &postorder_block_entries_); 1675 for_effect.entry()->DiscoverBlocks(NULL, // Entry block predecessor.
1676 &preorder_block_entries_,
1677 &postorder_block_entries_,
1678 &parent);
1676 } 1679 }
1677 if (FLAG_print_flow_graph) { 1680 if (FLAG_print_flow_graph) {
1678 intptr_t length = postorder_block_entries_.length(); 1681 intptr_t length = postorder_block_entries_.length();
1679 GrowableArray<BlockEntryInstr*> reverse_postorder(length); 1682 GrowableArray<BlockEntryInstr*> reverse_postorder(length);
1680 for (intptr_t i = length - 1; i >= 0; --i) { 1683 for (intptr_t i = length - 1; i >= 0; --i) {
1681 reverse_postorder.Add(postorder_block_entries_[i]); 1684 reverse_postorder.Add(postorder_block_entries_[i]);
1682 } 1685 }
1683 FlowGraphPrinter printer(function, reverse_postorder); 1686 FlowGraphPrinter printer(function, reverse_postorder);
1684 printer.VisitBlocks(); 1687 printer.VisitBlocks();
1685 } 1688 }
1686 } 1689 }
1687 1690
1688 1691
1689 void FlowGraphBuilder::Bailout(const char* reason) { 1692 void FlowGraphBuilder::Bailout(const char* reason) {
1690 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; 1693 const char* kFormat = "FlowGraphBuilder Bailout: %s %s";
1691 const char* function_name = parsed_function_.function().ToCString(); 1694 const char* function_name = parsed_function_.function().ToCString();
1692 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 1695 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
1693 char* chars = reinterpret_cast<char*>( 1696 char* chars = reinterpret_cast<char*>(
1694 Isolate::Current()->current_zone()->Allocate(len)); 1697 Isolate::Current()->current_zone()->Allocate(len));
1695 OS::SNPrint(chars, len, kFormat, function_name, reason); 1698 OS::SNPrint(chars, len, kFormat, function_name, reason);
1696 const Error& error = Error::Handle( 1699 const Error& error = Error::Handle(
1697 LanguageError::New(String::Handle(String::New(chars)))); 1700 LanguageError::New(String::Handle(String::New(chars))));
1698 Isolate::Current()->long_jump_base()->Jump(1, error); 1701 Isolate::Current()->long_jump_base()->Jump(1, error);
1699 } 1702 }
1700 1703
1701 1704
1702 } // namespace dart 1705 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | runtime/vm/intermediate_language.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698