| 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/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 Error& error = Error::Handle(isolate); | 233 Error& error = Error::Handle(isolate); |
| 234 error = isolate->object_store()->sticky_error(); | 234 error = isolate->object_store()->sticky_error(); |
| 235 isolate->object_store()->clear_sticky_error(); | 235 isolate->object_store()->clear_sticky_error(); |
| 236 return error.raw(); | 236 return error.raw(); |
| 237 } | 237 } |
| 238 UNREACHABLE(); | 238 UNREACHABLE(); |
| 239 return Error::null(); | 239 return Error::null(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 static void InstallUnoptimizedCode(const Function& function) { | |
| 244 // Disable optimized code. | |
| 245 ASSERT(function.HasOptimizedCode()); | |
| 246 if (FLAG_trace_compiler) { | |
| 247 OS::Print("--> patching entry %#" Px "\n", | |
| 248 Code::Handle(function.CurrentCode()).EntryPoint()); | |
| 249 } | |
| 250 function.SwitchToUnoptimizedCode(); | |
| 251 if (FLAG_trace_compiler) { | |
| 252 OS::Print("--> restoring entry at %#" Px "\n", | |
| 253 Code::Handle(function.unoptimized_code()).EntryPoint()); | |
| 254 } | |
| 255 } | |
| 256 | |
| 257 | |
| 258 // Return false if bailed out. | 243 // Return false if bailed out. |
| 259 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, | 244 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, |
| 260 bool optimized, | 245 bool optimized, |
| 261 intptr_t osr_id) { | 246 intptr_t osr_id) { |
| 262 const Function& function = parsed_function->function(); | 247 const Function& function = parsed_function->function(); |
| 263 if (optimized && !function.IsOptimizable()) { | 248 if (optimized && !function.IsOptimizable()) { |
| 264 return false; | 249 return false; |
| 265 } | 250 } |
| 266 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); | 251 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); |
| 267 bool is_compiled = false; | 252 bool is_compiled = false; |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 } | 750 } |
| 766 } | 751 } |
| 767 | 752 |
| 768 | 753 |
| 769 static RawError* CompileFunctionHelper(const Function& function, | 754 static RawError* CompileFunctionHelper(const Function& function, |
| 770 bool optimized, | 755 bool optimized, |
| 771 intptr_t osr_id) { | 756 intptr_t osr_id) { |
| 772 Isolate* isolate = Isolate::Current(); | 757 Isolate* isolate = Isolate::Current(); |
| 773 StackZone zone(isolate); | 758 StackZone zone(isolate); |
| 774 LongJumpScope jump; | 759 LongJumpScope jump; |
| 775 // Make sure unoptimized code is not collected while we are compiling. | |
| 776 const Code& unoptimized_code = Code::ZoneHandle(function.unoptimized_code()); | |
| 777 // Skips parsing if we need to only install unoptimized code. | |
| 778 if (!optimized && !unoptimized_code.IsNull()) { | |
| 779 InstallUnoptimizedCode(function); | |
| 780 return Error::null(); | |
| 781 } | |
| 782 if (setjmp(*jump.Set()) == 0) { | 760 if (setjmp(*jump.Set()) == 0) { |
| 783 TIMERSCOPE(isolate, time_compilation); | 761 TIMERSCOPE(isolate, time_compilation); |
| 784 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 762 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
| 785 per_compile_timer.Start(); | 763 per_compile_timer.Start(); |
| 786 ParsedFunction* parsed_function = | 764 ParsedFunction* parsed_function = |
| 787 new ParsedFunction(Function::ZoneHandle(function.raw())); | 765 new ParsedFunction(Function::ZoneHandle(function.raw())); |
| 788 if (FLAG_trace_compiler) { | 766 if (FLAG_trace_compiler) { |
| 789 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", | 767 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", |
| 790 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), | 768 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
| 791 (optimized ? "optimized " : ""), | 769 (optimized ? "optimized " : ""), |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 const Object& result = | 971 const Object& result = |
| 994 Object::Handle(isolate->object_store()->sticky_error()); | 972 Object::Handle(isolate->object_store()->sticky_error()); |
| 995 isolate->object_store()->clear_sticky_error(); | 973 isolate->object_store()->clear_sticky_error(); |
| 996 return result.raw(); | 974 return result.raw(); |
| 997 } | 975 } |
| 998 UNREACHABLE(); | 976 UNREACHABLE(); |
| 999 return Object::null(); | 977 return Object::null(); |
| 1000 } | 978 } |
| 1001 | 979 |
| 1002 } // namespace dart | 980 } // namespace dart |
| OLD | NEW |