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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 DEFINE_FLAG(bool, verify_compiler, false, | 64 DEFINE_FLAG(bool, verify_compiler, false, |
65 "Enable compiler verification assertions"); | 65 "Enable compiler verification assertions"); |
66 | 66 |
67 DECLARE_FLAG(bool, trace_failed_optimization_attempts); | 67 DECLARE_FLAG(bool, trace_failed_optimization_attempts); |
68 DECLARE_FLAG(bool, trace_inlining_intervals); | 68 DECLARE_FLAG(bool, trace_inlining_intervals); |
69 DECLARE_FLAG(bool, trace_irregexp); | 69 DECLARE_FLAG(bool, trace_irregexp); |
70 DECLARE_FLAG(bool, trace_patching); | 70 DECLARE_FLAG(bool, trace_patching); |
71 | 71 |
72 | 72 |
73 bool Compiler::always_optimize_ = false; | 73 bool Compiler::always_optimize_ = false; |
| 74 bool Compiler::allow_recompilation_ = true; |
74 | 75 |
75 | 76 |
76 // TODO(zerny): Factor out unoptimizing/optimizing pipelines and remove | 77 // TODO(zerny): Factor out unoptimizing/optimizing pipelines and remove |
77 // separate helpers functions & `optimizing` args. | 78 // separate helpers functions & `optimizing` args. |
78 class CompilationPipeline : public ZoneAllocated { | 79 class CompilationPipeline : public ZoneAllocated { |
79 public: | 80 public: |
80 static CompilationPipeline* New(Zone* zone, const Function& function); | 81 static CompilationPipeline* New(Zone* zone, const Function& function); |
81 | 82 |
82 virtual void ParseFunction(ParsedFunction* parsed_function) = 0; | 83 virtual void ParseFunction(ParsedFunction* parsed_function) = 0; |
83 virtual FlowGraph* BuildFlowGraph( | 84 virtual FlowGraph* BuildFlowGraph( |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 if (optimized && FLAG_trace_inlining_intervals) { | 966 if (optimized && FLAG_trace_inlining_intervals) { |
966 code.DumpInlinedIntervals(); | 967 code.DumpInlinedIntervals(); |
967 } | 968 } |
968 } | 969 } |
969 | 970 |
970 | 971 |
971 static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, | 972 static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, |
972 const Function& function, | 973 const Function& function, |
973 bool optimized, | 974 bool optimized, |
974 intptr_t osr_id) { | 975 intptr_t osr_id) { |
| 976 // Check that we optimize if 'Compiler::always_optimize()' is set to true, |
| 977 // except if the function is marked as not optimizable. |
| 978 ASSERT(!function.IsOptimizable() || |
| 979 !Compiler::always_optimize() || optimized); |
| 980 ASSERT(Compiler::allow_recompilation() || !function.HasCode()); |
975 LongJumpScope jump; | 981 LongJumpScope jump; |
976 if (setjmp(*jump.Set()) == 0) { | 982 if (setjmp(*jump.Set()) == 0) { |
977 Thread* const thread = Thread::Current(); | 983 Thread* const thread = Thread::Current(); |
978 Isolate* const isolate = thread->isolate(); | 984 Isolate* const isolate = thread->isolate(); |
979 StackZone stack_zone(isolate); | 985 StackZone stack_zone(isolate); |
980 Zone* const zone = stack_zone.GetZone(); | 986 Zone* const zone = stack_zone.GetZone(); |
981 TIMERSCOPE(isolate, time_compilation); | 987 TIMERSCOPE(isolate, time_compilation); |
982 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 988 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
983 per_compile_timer.Start(); | 989 per_compile_timer.Start(); |
984 | 990 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1334 const Object& result = | 1340 const Object& result = |
1335 PassiveObject::Handle(isolate->object_store()->sticky_error()); | 1341 PassiveObject::Handle(isolate->object_store()->sticky_error()); |
1336 isolate->object_store()->clear_sticky_error(); | 1342 isolate->object_store()->clear_sticky_error(); |
1337 return result.raw(); | 1343 return result.raw(); |
1338 } | 1344 } |
1339 UNREACHABLE(); | 1345 UNREACHABLE(); |
1340 return Object::null(); | 1346 return Object::null(); |
1341 } | 1347 } |
1342 | 1348 |
1343 } // namespace dart | 1349 } // namespace dart |
OLD | NEW |