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

Unified Diff: runtime/vm/compiler.cc

Issue 10857016: Refactored FlowGraphBuilder into a separate FlowGraph representation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revision based on Kevin's review. Created 8 years, 4 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 | « no previous file | runtime/vm/flow_graph.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index da0eeb7d36faa2255836fb5b51324d1583211a72..d6d0326d7679f4451819cdc806ba22d279c23089 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -13,6 +13,7 @@
#include "vm/disassembler.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
+#include "vm/flow_graph.h"
#include "vm/flow_graph_allocator.h"
#include "vm/flow_graph_builder.h"
#include "vm/flow_graph_compiler.h"
@@ -132,7 +133,7 @@ static bool CompileParsedFunctionHelper(
LongJump bailout_jump;
isolate->set_long_jump_base(&bailout_jump);
if (setjmp(*bailout_jump.Set()) == 0) {
- GrowableArray<BlockEntryInstr*> block_order;
+ FlowGraph* flow_graph = NULL;
// TimerScope needs an isolate to be properly terminated in case of a
// LongJump.
{
@@ -156,22 +157,31 @@ static bool CompileParsedFunctionHelper(
ExtractTypeFeedbackArray(unoptimized_code));
}
}
- FlowGraphBuilder graph_builder(parsed_function);
- graph_builder.BuildGraph(optimized, use_ssa);
-
- // The non-optimizing compiler compiles blocks in reverse postorder,
- // because it is a 'natural' order for the human reader of the
- // generated code.
- intptr_t length = graph_builder.postorder_block_entries().length();
- for (intptr_t i = length - 1; i >= 0; --i) {
- block_order.Add(graph_builder.postorder_block_entries()[i]);
+
+ // Build the flow graph.
+ FlowGraphBuilder builder(parsed_function);
+ flow_graph = builder.BuildGraph();
+
+ // Transform to SSA.
+ if (optimized && use_ssa) flow_graph->ComputeSSA();
+
+ if (FLAG_print_flow_graph) {
+ OS::Print("Before Optimizations\n");
+ FlowGraphPrinter printer(*flow_graph);
+ printer.PrintBlocks();
}
+ if (Dart::flow_graph_writer() != NULL) {
+ // Write flow graph to file.
+ FlowGraphVisualizer printer(*flow_graph);
+ printer.PrintFunction();
+ }
+
if (optimized) {
- FlowGraphOptimizer optimizer(block_order);
+ FlowGraphOptimizer optimizer(*flow_graph);
optimizer.ApplyICData();
// Propagate types and eliminate more type tests.
- FlowGraphTypePropagator propagator(parsed_function, block_order);
+ FlowGraphTypePropagator propagator(*flow_graph);
propagator.PropagateTypes();
// Do optimizations that depend on the propagated type information.
@@ -179,12 +189,13 @@ static bool CompileParsedFunctionHelper(
if (use_ssa) {
// Perform register allocation on the SSA graph.
- FlowGraphAllocator allocator(block_order, &graph_builder);
+ FlowGraphAllocator allocator(*flow_graph);
allocator.AllocateRegisters();
}
+
if (FLAG_print_flow_graph) {
OS::Print("After Optimizations:\n");
- FlowGraphPrinter printer(Function::Handle(), block_order);
+ FlowGraphPrinter printer(*flow_graph);
printer.PrintBlocks();
}
}
@@ -192,14 +203,13 @@ static bool CompileParsedFunctionHelper(
bool is_leaf = false;
if (optimized) {
- FlowGraphAnalyzer analyzer(block_order);
+ FlowGraphAnalyzer analyzer(*flow_graph);
analyzer.Analyze();
is_leaf = analyzer.is_leaf();
}
Assembler assembler;
FlowGraphCompiler graph_compiler(&assembler,
- parsed_function,
- block_order,
+ *flow_graph,
optimized,
optimized && use_ssa,
is_leaf);
« no previous file with comments | « no previous file | runtime/vm/flow_graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698