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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 | 253 |
254 // Return false if bailed out. | 254 // Return false if bailed out. |
255 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, | 255 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, |
256 bool optimized, | 256 bool optimized, |
257 intptr_t osr_id) { | 257 intptr_t osr_id) { |
258 const Function& function = parsed_function->function(); | 258 const Function& function = parsed_function->function(); |
259 if (optimized && !function.IsOptimizable()) { | 259 if (optimized && !function.IsOptimizable()) { |
260 return false; | 260 return false; |
261 } | 261 } |
262 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); | 262 Isolate* isolate = Isolate::Current(); |
| 263 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer, isolate); |
263 bool is_compiled = false; | 264 bool is_compiled = false; |
264 Isolate* isolate = Isolate::Current(); | |
265 HANDLESCOPE(isolate); | 265 HANDLESCOPE(isolate); |
266 isolate->set_cha_used(false); | 266 isolate->set_cha_used(false); |
267 | 267 |
268 // We may reattempt compilation if the function needs to be assembled using | 268 // We may reattempt compilation if the function needs to be assembled using |
269 // far branches on ARM and MIPS. In the else branch of the setjmp call, | 269 // far branches on ARM and MIPS. In the else branch of the setjmp call, |
270 // done is set to false, and use_far_branches is set to true if there is a | 270 // done is set to false, and use_far_branches is set to true if there is a |
271 // longjmp from the ARM or MIPS assemblers. In all other paths through this | 271 // longjmp from the ARM or MIPS assemblers. In all other paths through this |
272 // while loop, done is set to true. use_far_branches is always false on ia32 | 272 // while loop, done is set to true. use_far_branches is always false on ia32 |
273 // and x64. | 273 // and x64. |
274 bool done = false; | 274 bool done = false; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 347 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
348 | 348 |
349 // Optimize (a << b) & c patterns, merge operations. | 349 // Optimize (a << b) & c patterns, merge operations. |
350 // Run early in order to have more opportunity to optimize left shifts. | 350 // Run early in order to have more opportunity to optimize left shifts. |
351 optimizer.TryOptimizePatterns(); | 351 optimizer.TryOptimizePatterns(); |
352 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 352 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
353 | 353 |
354 // Inlining (mutates the flow graph) | 354 // Inlining (mutates the flow graph) |
355 if (FLAG_use_inlining) { | 355 if (FLAG_use_inlining) { |
356 TimerScope timer(FLAG_compiler_stats, | 356 TimerScope timer(FLAG_compiler_stats, |
357 &CompilerStats::graphinliner_timer); | 357 &CompilerStats::graphinliner_timer, |
| 358 isolate); |
358 // Propagate types to create more inlining opportunities. | 359 // Propagate types to create more inlining opportunities. |
359 FlowGraphTypePropagator::Propagate(flow_graph); | 360 FlowGraphTypePropagator::Propagate(flow_graph); |
360 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 361 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
361 | 362 |
362 // Use propagated class-ids to create more inlining opportunities. | 363 // Use propagated class-ids to create more inlining opportunities. |
363 optimizer.ApplyClassIds(); | 364 optimizer.ApplyClassIds(); |
364 DEBUG_ASSERT(flow_graph->VerifyUseLists()); | 365 DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
365 | 366 |
366 FlowGraphInliner inliner(flow_graph); | 367 FlowGraphInliner inliner(flow_graph); |
367 inliner.Inline(); | 368 inliner.Inline(); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 StackZone zone(isolate); | 745 StackZone zone(isolate); |
745 LongJumpScope jump; | 746 LongJumpScope jump; |
746 // Make sure unoptimized code is not collected while we are compiling. | 747 // Make sure unoptimized code is not collected while we are compiling. |
747 const Code& unoptimized_code = Code::ZoneHandle(function.unoptimized_code()); | 748 const Code& unoptimized_code = Code::ZoneHandle(function.unoptimized_code()); |
748 // Skips parsing if we need to only install unoptimized code. | 749 // Skips parsing if we need to only install unoptimized code. |
749 if (!optimized && !unoptimized_code.IsNull()) { | 750 if (!optimized && !unoptimized_code.IsNull()) { |
750 InstallUnoptimizedCode(function); | 751 InstallUnoptimizedCode(function); |
751 return Error::null(); | 752 return Error::null(); |
752 } | 753 } |
753 if (setjmp(*jump.Set()) == 0) { | 754 if (setjmp(*jump.Set()) == 0) { |
754 TIMERSCOPE(time_compilation); | 755 TIMERSCOPE(isolate, time_compilation); |
755 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 756 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
756 per_compile_timer.Start(); | 757 per_compile_timer.Start(); |
757 ParsedFunction* parsed_function = | 758 ParsedFunction* parsed_function = |
758 new ParsedFunction(Function::ZoneHandle(function.raw())); | 759 new ParsedFunction(Function::ZoneHandle(function.raw())); |
759 if (FLAG_trace_compiler) { | 760 if (FLAG_trace_compiler) { |
760 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", | 761 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", |
761 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), | 762 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
762 (optimized ? "optimized " : ""), | 763 (optimized ? "optimized " : ""), |
763 function.ToFullyQualifiedCString(), | 764 function.ToFullyQualifiedCString(), |
764 function.token_pos(), | 765 function.token_pos(), |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 const Object& result = | 947 const Object& result = |
947 Object::Handle(isolate->object_store()->sticky_error()); | 948 Object::Handle(isolate->object_store()->sticky_error()); |
948 isolate->object_store()->clear_sticky_error(); | 949 isolate->object_store()->clear_sticky_error(); |
949 return result.raw(); | 950 return result.raw(); |
950 } | 951 } |
951 UNREACHABLE(); | 952 UNREACHABLE(); |
952 return Object::null(); | 953 return Object::null(); |
953 } | 954 } |
954 | 955 |
955 } // namespace dart | 956 } // namespace dart |
OLD | NEW |