OLD | NEW |
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/compiler.h" | 5 #include "vm/compiler.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "vm/symbols.h" | 28 #include "vm/symbols.h" |
29 #include "vm/timer.h" | 29 #include "vm/timer.h" |
30 | 30 |
31 namespace dart { | 31 namespace dart { |
32 | 32 |
33 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); | 33 DEFINE_FLAG(bool, disassemble, false, "Disassemble dart code."); |
34 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); | 34 DEFINE_FLAG(bool, disassemble_optimized, false, "Disassemble optimized code."); |
35 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); | 35 DEFINE_FLAG(bool, trace_bailout, false, "Print bailout from ssa compiler."); |
36 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); | 36 DEFINE_FLAG(bool, trace_compiler, false, "Trace compiler operations."); |
37 DEFINE_FLAG(bool, use_ssa, true, "Use SSA form"); | 37 DEFINE_FLAG(bool, use_ssa, true, "Use SSA form"); |
| 38 DEFINE_FLAG(bool, local_cse, true, "Do local subexpression elimination."); |
38 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, | 39 DEFINE_FLAG(int, deoptimization_counter_threshold, 5, |
39 "How many times we allow deoptimization before we disallow" | 40 "How many times we allow deoptimization before we disallow" |
40 " certain optimizations"); | 41 " certain optimizations"); |
41 DECLARE_FLAG(bool, print_flow_graph); | 42 DECLARE_FLAG(bool, print_flow_graph); |
42 | 43 |
43 | 44 |
44 // Compile a function. Should call only if the function has not been compiled. | 45 // Compile a function. Should call only if the function has not been compiled. |
45 // Arg0: function object. | 46 // Arg0: function object. |
46 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { | 47 DEFINE_RUNTIME_ENTRY(CompileFunction, 1) { |
47 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); | 48 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 FlowGraphPrinter printer(*flow_graph); | 171 FlowGraphPrinter printer(*flow_graph); |
171 printer.PrintBlocks(); | 172 printer.PrintBlocks(); |
172 } | 173 } |
173 if (Dart::flow_graph_writer() != NULL) { | 174 if (Dart::flow_graph_writer() != NULL) { |
174 // Write flow graph to file. | 175 // Write flow graph to file. |
175 FlowGraphVisualizer printer(*flow_graph); | 176 FlowGraphVisualizer printer(*flow_graph); |
176 printer.PrintFunction(); | 177 printer.PrintFunction(); |
177 } | 178 } |
178 | 179 |
179 if (optimized) { | 180 if (optimized) { |
180 FlowGraphOptimizer optimizer(*flow_graph); | 181 FlowGraphOptimizer optimizer(*flow_graph, use_ssa); |
181 optimizer.ApplyICData(); | 182 optimizer.ApplyICData(); |
182 | 183 |
183 // Propagate types and eliminate more type tests. | 184 // Propagate types and eliminate more type tests. |
184 FlowGraphTypePropagator propagator(*flow_graph, optimized && use_ssa); | 185 FlowGraphTypePropagator propagator(*flow_graph, optimized && use_ssa); |
185 propagator.PropagateTypes(); | 186 propagator.PropagateTypes(); |
186 | 187 |
187 // Do optimizations that depend on the propagated type information. | |
188 optimizer.OptimizeComputations(); | |
189 | 188 |
190 if (use_ssa) { | 189 if (use_ssa) { |
| 190 // Do optimizations that depend on the propagated type information. |
| 191 optimizer.OptimizeComputations(); |
| 192 |
| 193 if (FLAG_local_cse) { |
| 194 LocalCSE local_cse(*flow_graph); |
| 195 local_cse.Optimize(); |
| 196 } |
| 197 |
191 // Perform register allocation on the SSA graph. | 198 // Perform register allocation on the SSA graph. |
192 FlowGraphAllocator allocator(*flow_graph); | 199 FlowGraphAllocator allocator(*flow_graph); |
193 allocator.AllocateRegisters(); | 200 allocator.AllocateRegisters(); |
194 } | 201 } |
195 | 202 |
196 if (FLAG_print_flow_graph) { | 203 if (FLAG_print_flow_graph) { |
197 OS::Print("After Optimizations:\n"); | 204 OS::Print("After Optimizations:\n"); |
198 FlowGraphPrinter printer(*flow_graph); | 205 FlowGraphPrinter printer(*flow_graph); |
199 printer.PrintBlocks(); | 206 printer.PrintBlocks(); |
200 } | 207 } |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 result = isolate->object_store()->sticky_error(); | 548 result = isolate->object_store()->sticky_error(); |
542 isolate->object_store()->clear_sticky_error(); | 549 isolate->object_store()->clear_sticky_error(); |
543 isolate->set_long_jump_base(base); | 550 isolate->set_long_jump_base(base); |
544 return result.raw(); | 551 return result.raw(); |
545 } | 552 } |
546 UNREACHABLE(); | 553 UNREACHABLE(); |
547 return Object::null(); | 554 return Object::null(); |
548 } | 555 } |
549 | 556 |
550 } // namespace dart | 557 } // namespace dart |
OLD | NEW |