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