| 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 781 |
| 782 for (intptr_t i = 0; | 782 for (intptr_t i = 0; |
| 783 i < flow_graph->guarded_fields()->length(); | 783 i < flow_graph->guarded_fields()->length(); |
| 784 i++) { | 784 i++) { |
| 785 const Field* field = (*flow_graph->guarded_fields())[i]; | 785 const Field* field = (*flow_graph->guarded_fields())[i]; |
| 786 field->RegisterDependentCode(code); | 786 field->RegisterDependentCode(code); |
| 787 } | 787 } |
| 788 } else { // not optimized. | 788 } else { // not optimized. |
| 789 if (!Compiler::always_optimize() && | 789 if (!Compiler::always_optimize() && |
| 790 (function.ic_data_array() == Array::null())) { | 790 (function.ic_data_array() == Array::null())) { |
| 791 function.SaveICDataMap(graph_compiler.deopt_id_to_ic_data()); | 791 function.SaveICDataMap( |
| 792 graph_compiler.deopt_id_to_ic_data(), |
| 793 Array::Handle(zone, graph_compiler.edge_counters_array())); |
| 792 } | 794 } |
| 793 function.set_unoptimized_code(code); | 795 function.set_unoptimized_code(code); |
| 794 function.AttachCode(code); | 796 function.AttachCode(code); |
| 795 } | 797 } |
| 796 if (parsed_function->HasDeferredPrefixes()) { | 798 if (parsed_function->HasDeferredPrefixes()) { |
| 797 ASSERT(!FLAG_load_deferred_eagerly); | 799 ASSERT(!FLAG_load_deferred_eagerly); |
| 798 ZoneGrowableArray<const LibraryPrefix*>* prefixes = | 800 ZoneGrowableArray<const LibraryPrefix*>* prefixes = |
| 799 parsed_function->deferred_prefixes(); | 801 parsed_function->deferred_prefixes(); |
| 800 for (intptr_t i = 0; i < prefixes->length(); i++) { | 802 for (intptr_t i = 0; i < prefixes->length(); i++) { |
| 801 (*prefixes)[i]->RegisterDependentCode(code); | 803 (*prefixes)[i]->RegisterDependentCode(code); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 LongJumpScope jump; | 1018 LongJumpScope jump; |
| 1017 if (setjmp(*jump.Set()) == 0) { | 1019 if (setjmp(*jump.Set()) == 0) { |
| 1018 Thread* const thread = Thread::Current(); | 1020 Thread* const thread = Thread::Current(); |
| 1019 Isolate* const isolate = thread->isolate(); | 1021 Isolate* const isolate = thread->isolate(); |
| 1020 StackZone stack_zone(thread); | 1022 StackZone stack_zone(thread); |
| 1021 Zone* const zone = stack_zone.GetZone(); | 1023 Zone* const zone = stack_zone.GetZone(); |
| 1022 TIMERSCOPE(thread, time_compilation); | 1024 TIMERSCOPE(thread, time_compilation); |
| 1023 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); | 1025 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); |
| 1024 per_compile_timer.Start(); | 1026 per_compile_timer.Start(); |
| 1025 | 1027 |
| 1026 // Restore unoptimized code if needed. | |
| 1027 if (optimized) { | |
| 1028 if (!Compiler::always_optimize()) { | |
| 1029 const Error& error = Error::Handle( | |
| 1030 zone, Compiler::EnsureUnoptimizedCode(Thread::Current(), function)); | |
| 1031 if (!error.IsNull()) { | |
| 1032 return error.raw(); | |
| 1033 } | |
| 1034 } | |
| 1035 } | |
| 1036 | |
| 1037 ParsedFunction* parsed_function = new(zone) ParsedFunction( | 1028 ParsedFunction* parsed_function = new(zone) ParsedFunction( |
| 1038 thread, Function::ZoneHandle(zone, function.raw())); | 1029 thread, Function::ZoneHandle(zone, function.raw())); |
| 1039 if (FLAG_trace_compiler) { | 1030 if (FLAG_trace_compiler) { |
| 1040 THR_Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", | 1031 THR_Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", |
| 1041 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), | 1032 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
| 1042 (optimized ? "optimized " : ""), | 1033 (optimized ? "optimized " : ""), |
| 1043 function.ToFullyQualifiedCString(), | 1034 function.ToFullyQualifiedCString(), |
| 1044 function.token_pos(), | 1035 function.token_pos(), |
| 1045 (function.end_token_pos() - function.token_pos())); | 1036 (function.end_token_pos() - function.token_pos())); |
| 1046 } | 1037 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 const Object& result = | 1408 const Object& result = |
| 1418 PassiveObject::Handle(isolate->object_store()->sticky_error()); | 1409 PassiveObject::Handle(isolate->object_store()->sticky_error()); |
| 1419 isolate->object_store()->clear_sticky_error(); | 1410 isolate->object_store()->clear_sticky_error(); |
| 1420 return result.raw(); | 1411 return result.raw(); |
| 1421 } | 1412 } |
| 1422 UNREACHABLE(); | 1413 UNREACHABLE(); |
| 1423 return Object::null(); | 1414 return Object::null(); |
| 1424 } | 1415 } |
| 1425 | 1416 |
| 1426 } // namespace dart | 1417 } // namespace dart |
| OLD | NEW |