| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 LongJump bailout_jump; | 157 LongJump bailout_jump; |
| 158 isolate->set_long_jump_base(&bailout_jump); | 158 isolate->set_long_jump_base(&bailout_jump); |
| 159 if (setjmp(*bailout_jump.Set()) == 0) { | 159 if (setjmp(*bailout_jump.Set()) == 0) { |
| 160 GrowableArray<BlockEntryInstr*> block_order; | 160 GrowableArray<BlockEntryInstr*> block_order; |
| 161 // TimerScope needs an isolate to be properly terminated in case of a | 161 // TimerScope needs an isolate to be properly terminated in case of a |
| 162 // LongJump. | 162 // LongJump. |
| 163 { | 163 { |
| 164 TimerScope timer(FLAG_compiler_stats, | 164 TimerScope timer(FLAG_compiler_stats, |
| 165 &CompilerStats::graphbuilder_timer, | 165 &CompilerStats::graphbuilder_timer, |
| 166 isolate); | 166 isolate); |
| 167 CompilerStats::graphbuilder_timer.Start(); | |
| 168 FlowGraphBuilder graph_builder(parsed_function); | |
| 169 graph_builder.BuildGraph(optimized); | |
| 170 | |
| 171 // The non-optimizing compiler compiles blocks in reverse postorder, | |
| 172 // because it is a 'natural' order for the human reader of the | |
| 173 // generated code. | |
| 174 intptr_t length = graph_builder.postorder_block_entries().length(); | |
| 175 for (intptr_t i = length - 1; i >= 0; --i) { | |
| 176 block_order.Add(graph_builder.postorder_block_entries()[i]); | |
| 177 } | |
| 178 | |
| 179 if (optimized) { | 167 if (optimized) { |
| 180 // Transition to optimized code only from unoptimized code ... | 168 // Transition to optimized code only from unoptimized code ... |
| 181 // for now. | 169 // for now. |
| 182 ASSERT(parsed_function.function().HasCode()); | 170 ASSERT(parsed_function.function().HasCode()); |
| 183 ASSERT(!parsed_function.function().HasOptimizedCode()); | 171 ASSERT(!parsed_function.function().HasOptimizedCode()); |
| 172 // Extract type feedback before the graph is built, as the graph |
| 173 // builder uses it to attach it to nodes. |
| 184 // Do not use type feedback to optimize a function that was | 174 // Do not use type feedback to optimize a function that was |
| 185 // deoptimized too often. | 175 // deoptimized too often. |
| 186 if (parsed_function.function().deoptimization_counter() < | 176 if (parsed_function.function().deoptimization_counter() < |
| 187 FLAG_deoptimization_counter_threshold) { | 177 FLAG_deoptimization_counter_threshold) { |
| 188 const Code& unoptimized_code = | 178 const Code& unoptimized_code = |
| 189 Code::Handle(parsed_function.function().unoptimized_code()); | 179 Code::Handle(parsed_function.function().unoptimized_code()); |
| 190 isolate->set_ic_data_array( | 180 isolate->set_ic_data_array( |
| 191 ExtractTypeFeedbackArray(unoptimized_code)); | 181 ExtractTypeFeedbackArray(unoptimized_code)); |
| 192 } | 182 } |
| 193 } | 183 } |
| 184 FlowGraphBuilder graph_builder(parsed_function); |
| 185 graph_builder.BuildGraph(optimized); |
| 186 |
| 187 // The non-optimizing compiler compiles blocks in reverse postorder, |
| 188 // because it is a 'natural' order for the human reader of the |
| 189 // generated code. |
| 190 intptr_t length = graph_builder.postorder_block_entries().length(); |
| 191 for (intptr_t i = length - 1; i >= 0; --i) { |
| 192 block_order.Add(graph_builder.postorder_block_entries()[i]); |
| 193 } |
| 194 } | 194 } |
| 195 | 195 |
| 196 Assembler assembler; | 196 Assembler assembler; |
| 197 FlowGraphCompiler graph_compiler(&assembler, parsed_function, | 197 FlowGraphCompiler graph_compiler(&assembler, parsed_function, |
| 198 block_order, optimized); | 198 block_order, optimized); |
| 199 { | 199 { |
| 200 TimerScope timer(FLAG_compiler_stats, | 200 TimerScope timer(FLAG_compiler_stats, |
| 201 &CompilerStats::graphcompiler_timer, | 201 &CompilerStats::graphcompiler_timer, |
| 202 isolate); | 202 isolate); |
| 203 graph_compiler.CompileGraph(); | 203 graph_compiler.CompileGraph(); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 isolate->object_store()->clear_sticky_error(); | 533 isolate->object_store()->clear_sticky_error(); |
| 534 isolate->set_long_jump_base(base); | 534 isolate->set_long_jump_base(base); |
| 535 return result.raw(); | 535 return result.raw(); |
| 536 } | 536 } |
| 537 UNREACHABLE(); | 537 UNREACHABLE(); |
| 538 return Object::null(); | 538 return Object::null(); |
| 539 } | 539 } |
| 540 | 540 |
| 541 | 541 |
| 542 } // namespace dart | 542 } // namespace dart |
| OLD | NEW |