| 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_index_table.h" | 10 #include "vm/code_index_table.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 error = isolate->object_store()->sticky_error(); | 104 error = isolate->object_store()->sticky_error(); |
| 105 isolate->object_store()->clear_sticky_error(); | 105 isolate->object_store()->clear_sticky_error(); |
| 106 } | 106 } |
| 107 isolate->set_long_jump_base(base); | 107 isolate->set_long_jump_base(base); |
| 108 return error.raw(); | 108 return error.raw(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 static RawError* CompileFunctionHelper(const Function& function, | 112 static RawError* CompileFunctionHelper(const Function& function, |
| 113 bool optimized) { | 113 bool optimized) { |
| 114 if (function.is_compiling()) { |
| 115 ASSERT(function.is_const() && function.IsConstructor()); |
| 116 const String& msg = String::Handle(String::NewFormatted( |
| 117 "Illegal recursion in const constructor '%s'.", |
| 118 String::Handle(function.name()).ToCString())); |
| 119 return LanguageError::New(msg); |
| 120 } |
| 121 function.set_is_compiling(true); |
| 114 Isolate* isolate = Isolate::Current(); | 122 Isolate* isolate = Isolate::Current(); |
| 115 Error& error = Error::Handle(); | 123 Error& error = Error::Handle(); |
| 116 LongJump* base = isolate->long_jump_base(); | 124 LongJump* base = isolate->long_jump_base(); |
| 117 LongJump jump; | 125 LongJump jump; |
| 118 isolate->set_long_jump_base(&jump); | 126 isolate->set_long_jump_base(&jump); |
| 119 if (setjmp(*jump.Set()) == 0) { | 127 if (setjmp(*jump.Set()) == 0) { |
| 120 TIMERSCOPE(time_compilation); | 128 TIMERSCOPE(time_compilation); |
| 121 ParsedFunction parsed_function(function); | 129 ParsedFunction parsed_function(function); |
| 122 const char* function_fullname = function.ToFullyQualifiedCString(); | 130 const char* function_fullname = function.ToFullyQualifiedCString(); |
| 123 if (FLAG_trace_compiler) { | 131 if (FLAG_trace_compiler) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 ExceptionHandlers::Handle(code.exception_handlers()); | 304 ExceptionHandlers::Handle(code.exception_handlers()); |
| 297 OS::Print("%s", handlers.ToCString()); | 305 OS::Print("%s", handlers.ToCString()); |
| 298 OS::Print("}\n"); | 306 OS::Print("}\n"); |
| 299 } | 307 } |
| 300 } else { | 308 } else { |
| 301 // We got an error during compilation. | 309 // We got an error during compilation. |
| 302 error = isolate->object_store()->sticky_error(); | 310 error = isolate->object_store()->sticky_error(); |
| 303 isolate->object_store()->clear_sticky_error(); | 311 isolate->object_store()->clear_sticky_error(); |
| 304 } | 312 } |
| 305 isolate->set_long_jump_base(base); | 313 isolate->set_long_jump_base(base); |
| 314 function.set_is_compiling(false); |
| 306 return error.raw(); | 315 return error.raw(); |
| 307 } | 316 } |
| 308 | 317 |
| 309 | 318 |
| 310 RawError* Compiler::CompileFunction(const Function& function) { | 319 RawError* Compiler::CompileFunction(const Function& function) { |
| 311 return CompileFunctionHelper(function, false); | 320 return CompileFunctionHelper(function, false); |
| 312 } | 321 } |
| 313 | 322 |
| 314 | 323 |
| 315 RawError* Compiler::CompileOptimizedFunction(const Function& function) { | 324 RawError* Compiler::CompileOptimizedFunction(const Function& function) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } else { | 405 } else { |
| 397 result = isolate->object_store()->sticky_error(); | 406 result = isolate->object_store()->sticky_error(); |
| 398 isolate->object_store()->clear_sticky_error(); | 407 isolate->object_store()->clear_sticky_error(); |
| 399 } | 408 } |
| 400 isolate->set_long_jump_base(base); | 409 isolate->set_long_jump_base(base); |
| 401 return result.raw(); | 410 return result.raw(); |
| 402 } | 411 } |
| 403 | 412 |
| 404 | 413 |
| 405 } // namespace dart | 414 } // namespace dart |
| OLD | NEW |