| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Code::Handle(function.unoptimized_code()).EntryPoint()); | 142 Code::Handle(function.unoptimized_code()).EntryPoint()); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 | 146 |
| 147 // Return false if bailed out. | 147 // Return false if bailed out. |
| 148 static bool CompileWithNewCompiler( | 148 static bool CompileWithNewCompiler( |
| 149 const ParsedFunction& parsed_function, bool optimized) { | 149 const ParsedFunction& parsed_function, bool optimized) { |
| 150 bool is_compiled = false; | 150 bool is_compiled = false; |
| 151 Isolate* isolate = Isolate::Current(); | 151 Isolate* isolate = Isolate::Current(); |
| 152 ASSERT(isolate->ic_data_array() == Array::null()); // Must be reset to null. |
| 152 const intptr_t prev_cid = isolate->computation_id(); | 153 const intptr_t prev_cid = isolate->computation_id(); |
| 153 isolate->set_computation_id(0); | 154 isolate->set_computation_id(0); |
| 154 LongJump* old_base = isolate->long_jump_base(); | 155 LongJump* old_base = isolate->long_jump_base(); |
| 155 LongJump bailout_jump; | 156 LongJump bailout_jump; |
| 156 isolate->set_long_jump_base(&bailout_jump); | 157 isolate->set_long_jump_base(&bailout_jump); |
| 157 if (setjmp(*bailout_jump.Set()) == 0) { | 158 if (setjmp(*bailout_jump.Set()) == 0) { |
| 158 GrowableArray<BlockEntryInstr*> block_order; | 159 GrowableArray<BlockEntryInstr*> block_order; |
| 159 // TimerScope needs an isolate to be properly terminated in case of a | 160 // TimerScope needs an isolate to be properly terminated in case of a |
| 160 // LongJump. | 161 // LongJump. |
| 161 { | 162 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 197 } |
| 197 | 198 |
| 198 Assembler assembler; | 199 Assembler assembler; |
| 199 FlowGraphCompiler graph_compiler(&assembler, parsed_function, | 200 FlowGraphCompiler graph_compiler(&assembler, parsed_function, |
| 200 block_order, optimized); | 201 block_order, optimized); |
| 201 { | 202 { |
| 202 TimerScope timer(FLAG_compiler_stats, | 203 TimerScope timer(FLAG_compiler_stats, |
| 203 &CompilerStats::graphcompiler_timer, | 204 &CompilerStats::graphcompiler_timer, |
| 204 isolate); | 205 isolate); |
| 205 graph_compiler.CompileGraph(); | 206 graph_compiler.CompileGraph(); |
| 206 isolate->set_ic_data_array(Array::null()); | |
| 207 } | 207 } |
| 208 { | 208 { |
| 209 TimerScope timer(FLAG_compiler_stats, | 209 TimerScope timer(FLAG_compiler_stats, |
| 210 &CompilerStats::codefinalizer_timer, | 210 &CompilerStats::codefinalizer_timer, |
| 211 isolate); | 211 isolate); |
| 212 const Function& function = parsed_function.function(); | 212 const Function& function = parsed_function.function(); |
| 213 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); | 213 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); |
| 214 code.set_is_optimized(optimized); | 214 code.set_is_optimized(optimized); |
| 215 graph_compiler.FinalizePcDescriptors(code); | 215 graph_compiler.FinalizePcDescriptors(code); |
| 216 graph_compiler.FinalizeStackmaps(code); | 216 graph_compiler.FinalizeStackmaps(code); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 234 } else { | 234 } else { |
| 235 // We bailed out. | 235 // We bailed out. |
| 236 Error& bailout_error = Error::Handle( | 236 Error& bailout_error = Error::Handle( |
| 237 isolate->object_store()->sticky_error()); | 237 isolate->object_store()->sticky_error()); |
| 238 isolate->object_store()->clear_sticky_error(); | 238 isolate->object_store()->clear_sticky_error(); |
| 239 if (FLAG_trace_bailout) { | 239 if (FLAG_trace_bailout) { |
| 240 OS::Print("%s\n", bailout_error.ToErrorCString()); | 240 OS::Print("%s\n", bailout_error.ToErrorCString()); |
| 241 } | 241 } |
| 242 is_compiled = false; | 242 is_compiled = false; |
| 243 } | 243 } |
| 244 // Reset global isolate state. |
| 245 isolate->set_ic_data_array(Array::null()); |
| 244 isolate->set_long_jump_base(old_base); | 246 isolate->set_long_jump_base(old_base); |
| 245 isolate->set_computation_id(prev_cid); | 247 isolate->set_computation_id(prev_cid); |
| 246 return is_compiled; | 248 return is_compiled; |
| 247 } | 249 } |
| 248 | 250 |
| 249 | 251 |
| 250 static void CompileWithOldCompiler( | 252 static void CompileWithOldCompiler( |
| 251 const ParsedFunction& parsed_function, bool optimized) { | 253 const ParsedFunction& parsed_function, bool optimized) { |
| 252 const Function& function = parsed_function.function(); | 254 const Function& function = parsed_function.function(); |
| 253 Assembler assembler; | 255 Assembler assembler; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 isolate->object_store()->clear_sticky_error(); | 568 isolate->object_store()->clear_sticky_error(); |
| 567 isolate->set_long_jump_base(base); | 569 isolate->set_long_jump_base(base); |
| 568 return result.raw(); | 570 return result.raw(); |
| 569 } | 571 } |
| 570 UNREACHABLE(); | 572 UNREACHABLE(); |
| 571 return Object::null(); | 573 return Object::null(); |
| 572 } | 574 } |
| 573 | 575 |
| 574 | 576 |
| 575 } // namespace dart | 577 } // namespace dart |
| OLD | NEW |