| 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 | 8 |
| 9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
| 10 #include "vm/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 isolate->set_long_jump_base(&bailout_jump); | 125 isolate->set_long_jump_base(&bailout_jump); |
| 126 if (setjmp(*bailout_jump.Set()) == 0) { | 126 if (setjmp(*bailout_jump.Set()) == 0) { |
| 127 FlowGraph* flow_graph = NULL; | 127 FlowGraph* flow_graph = NULL; |
| 128 // TimerScope needs an isolate to be properly terminated in case of a | 128 // TimerScope needs an isolate to be properly terminated in case of a |
| 129 // LongJump. | 129 // LongJump. |
| 130 { | 130 { |
| 131 TimerScope timer(FLAG_compiler_stats, | 131 TimerScope timer(FLAG_compiler_stats, |
| 132 &CompilerStats::graphbuilder_timer, | 132 &CompilerStats::graphbuilder_timer, |
| 133 isolate); | 133 isolate); |
| 134 if (optimized) { | 134 if (optimized) { |
| 135 // Transition to optimized code only from unoptimized code ... | |
| 136 // for now. | |
| 137 ASSERT(parsed_function.function().HasCode()); | 135 ASSERT(parsed_function.function().HasCode()); |
| 138 ASSERT(!parsed_function.function().HasOptimizedCode()); | |
| 139 // Extract type feedback before the graph is built, as the graph | 136 // Extract type feedback before the graph is built, as the graph |
| 140 // builder uses it to attach it to nodes. | 137 // builder uses it to attach it to nodes. |
| 141 // Do not use type feedback to optimize a function that was | 138 // Do not use type feedback to optimize a function that was |
| 142 // deoptimized too often. | 139 // deoptimized too often. |
| 143 if (parsed_function.function().deoptimization_counter() < | 140 if (parsed_function.function().deoptimization_counter() < |
| 144 FLAG_deoptimization_counter_threshold) { | 141 FLAG_deoptimization_counter_threshold) { |
| 145 const Code& unoptimized_code = | 142 const Code& unoptimized_code = |
| 146 Code::Handle(parsed_function.function().unoptimized_code()); | 143 Code::Handle(parsed_function.function().unoptimized_code()); |
| 147 isolate->set_ic_data_array( | 144 isolate->set_ic_data_array( |
| 148 unoptimized_code.ExtractTypeFeedbackArray()); | 145 unoptimized_code.ExtractTypeFeedbackArray()); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 const Code& code = Code::Handle( | 270 const Code& code = Code::Handle( |
| 274 Code::FinalizeCode(function, &assembler, optimized)); | 271 Code::FinalizeCode(function, &assembler, optimized)); |
| 275 code.set_is_optimized(optimized); | 272 code.set_is_optimized(optimized); |
| 276 graph_compiler.FinalizePcDescriptors(code); | 273 graph_compiler.FinalizePcDescriptors(code); |
| 277 graph_compiler.FinalizeDeoptInfo(code); | 274 graph_compiler.FinalizeDeoptInfo(code); |
| 278 graph_compiler.FinalizeStackmaps(code); | 275 graph_compiler.FinalizeStackmaps(code); |
| 279 graph_compiler.FinalizeVarDescriptors(code); | 276 graph_compiler.FinalizeVarDescriptors(code); |
| 280 graph_compiler.FinalizeExceptionHandlers(code); | 277 graph_compiler.FinalizeExceptionHandlers(code); |
| 281 graph_compiler.FinalizeComments(code); | 278 graph_compiler.FinalizeComments(code); |
| 282 if (optimized) { | 279 if (optimized) { |
| 280 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode())); |
| 283 function.SetCode(code); | 281 function.SetCode(code); |
| 284 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); | |
| 285 if (FLAG_trace_compiler) { | 282 if (FLAG_trace_compiler) { |
| 286 OS::Print("--> patching entry %#"Px"\n", | 283 OS::Print("--> patching entry %#"Px"\n", |
| 287 Code::Handle(function.unoptimized_code()).EntryPoint()); | 284 Code::Handle(function.unoptimized_code()).EntryPoint()); |
| 288 } | 285 } |
| 289 } else { | 286 } else { |
| 290 function.set_unoptimized_code(code); | 287 function.set_unoptimized_code(code); |
| 291 function.SetCode(code); | 288 function.SetCode(code); |
| 292 ASSERT(CodePatcher::CodeIsPatchable(code)); | 289 ASSERT(CodePatcher::CodeIsPatchable(code)); |
| 293 } | 290 } |
| 294 } | 291 } |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 result = isolate->object_store()->sticky_error(); | 603 result = isolate->object_store()->sticky_error(); |
| 607 isolate->object_store()->clear_sticky_error(); | 604 isolate->object_store()->clear_sticky_error(); |
| 608 isolate->set_long_jump_base(base); | 605 isolate->set_long_jump_base(base); |
| 609 return result.raw(); | 606 return result.raw(); |
| 610 } | 607 } |
| 611 UNREACHABLE(); | 608 UNREACHABLE(); |
| 612 return Object::null(); | 609 return Object::null(); |
| 613 } | 610 } |
| 614 | 611 |
| 615 } // namespace dart | 612 } // namespace dart |
| OLD | NEW |