| 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 CSTAT_TIMER_SCOPE(thread, graphcompiler_timer); | 717 CSTAT_TIMER_SCOPE(thread, graphcompiler_timer); |
| 718 graph_compiler.CompileGraph(); | 718 graph_compiler.CompileGraph(); |
| 719 pipeline->FinalizeCompilation(); | 719 pipeline->FinalizeCompilation(); |
| 720 } | 720 } |
| 721 { | 721 { |
| 722 CSTAT_TIMER_SCOPE(thread, codefinalizer_timer); | 722 CSTAT_TIMER_SCOPE(thread, codefinalizer_timer); |
| 723 // CreateDeoptInfo uses the object pool and needs to be done before | 723 // CreateDeoptInfo uses the object pool and needs to be done before |
| 724 // FinalizeCode. | 724 // FinalizeCode. |
| 725 const Array& deopt_info_array = | 725 const Array& deopt_info_array = |
| 726 Array::Handle(zone, graph_compiler.CreateDeoptInfo(&assembler)); | 726 Array::Handle(zone, graph_compiler.CreateDeoptInfo(&assembler)); |
| 727 INC_STAT(isolate, total_code_size, | 727 INC_STAT(thread, total_code_size, |
| 728 deopt_info_array.Length() * sizeof(uword)); | 728 deopt_info_array.Length() * sizeof(uword)); |
| 729 const Code& code = Code::Handle( | 729 const Code& code = Code::Handle( |
| 730 Code::FinalizeCode(function, &assembler, optimized)); | 730 Code::FinalizeCode(function, &assembler, optimized)); |
| 731 code.set_is_optimized(optimized); | 731 code.set_is_optimized(optimized); |
| 732 | 732 |
| 733 const Array& intervals = graph_compiler.inlined_code_intervals(); | 733 const Array& intervals = graph_compiler.inlined_code_intervals(); |
| 734 INC_STAT(isolate, total_code_size, | 734 INC_STAT(thread, total_code_size, |
| 735 intervals.Length() * sizeof(uword)); | 735 intervals.Length() * sizeof(uword)); |
| 736 code.SetInlinedIntervals(intervals); | 736 code.SetInlinedIntervals(intervals); |
| 737 | 737 |
| 738 const Array& inlined_id_array = | 738 const Array& inlined_id_array = |
| 739 Array::Handle(zone, graph_compiler.InliningIdToFunction()); | 739 Array::Handle(zone, graph_compiler.InliningIdToFunction()); |
| 740 INC_STAT(isolate, total_code_size, | 740 INC_STAT(thread, total_code_size, |
| 741 inlined_id_array.Length() * sizeof(uword)); | 741 inlined_id_array.Length() * sizeof(uword)); |
| 742 code.SetInlinedIdToFunction(inlined_id_array); | 742 code.SetInlinedIdToFunction(inlined_id_array); |
| 743 | 743 |
| 744 const Array& caller_inlining_id_map_array = | 744 const Array& caller_inlining_id_map_array = |
| 745 Array::Handle(zone, graph_compiler.CallerInliningIdMap()); | 745 Array::Handle(zone, graph_compiler.CallerInliningIdMap()); |
| 746 INC_STAT(isolate, total_code_size, | 746 INC_STAT(thread, total_code_size, |
| 747 caller_inlining_id_map_array.Length() * sizeof(uword)); | 747 caller_inlining_id_map_array.Length() * sizeof(uword)); |
| 748 code.SetInlinedCallerIdMap(caller_inlining_id_map_array); | 748 code.SetInlinedCallerIdMap(caller_inlining_id_map_array); |
| 749 | 749 |
| 750 graph_compiler.FinalizePcDescriptors(code); | 750 graph_compiler.FinalizePcDescriptors(code); |
| 751 code.set_deopt_info_array(deopt_info_array); | 751 code.set_deopt_info_array(deopt_info_array); |
| 752 | 752 |
| 753 graph_compiler.FinalizeStackmaps(code); | 753 graph_compiler.FinalizeStackmaps(code); |
| 754 graph_compiler.FinalizeVarDescriptors(code); | 754 graph_compiler.FinalizeVarDescriptors(code); |
| 755 graph_compiler.FinalizeExceptionHandlers(code); | 755 graph_compiler.FinalizeExceptionHandlers(code); |
| 756 graph_compiler.FinalizeStaticCallTargetsTable(code); | 756 graph_compiler.FinalizeStaticCallTargetsTable(code); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 ParsedFunction* parsed_function = new(zone) ParsedFunction( | 1039 ParsedFunction* parsed_function = new(zone) ParsedFunction( |
| 1040 thread, Function::ZoneHandle(zone, function.raw())); | 1040 thread, Function::ZoneHandle(zone, function.raw())); |
| 1041 if (FLAG_trace_compiler) { | 1041 if (FLAG_trace_compiler) { |
| 1042 ISL_Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", | 1042 ISL_Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", |
| 1043 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), | 1043 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), |
| 1044 (optimized ? "optimized " : ""), | 1044 (optimized ? "optimized " : ""), |
| 1045 function.ToFullyQualifiedCString(), | 1045 function.ToFullyQualifiedCString(), |
| 1046 function.token_pos(), | 1046 function.token_pos(), |
| 1047 (function.end_token_pos() - function.token_pos())); | 1047 (function.end_token_pos() - function.token_pos())); |
| 1048 } | 1048 } |
| 1049 INC_STAT(thread, num_functions_compiled, 1); |
| 1050 if (optimized) { |
| 1051 INC_STAT(thread, num_functions_optimized, 1); |
| 1052 } |
| 1049 { | 1053 { |
| 1050 HANDLESCOPE(thread); | 1054 HANDLESCOPE(thread); |
| 1055 const int64_t num_tokens_before = STAT_VALUE(thread, num_tokens_consumed); |
| 1051 pipeline->ParseFunction(parsed_function); | 1056 pipeline->ParseFunction(parsed_function); |
| 1057 const int64_t num_tokens_after = STAT_VALUE(thread, num_tokens_consumed); |
| 1058 INC_STAT(thread, |
| 1059 num_func_tokens_compiled, |
| 1060 num_tokens_after - num_tokens_before); |
| 1052 } | 1061 } |
| 1053 | 1062 |
| 1054 const bool success = CompileParsedFunctionHelper(pipeline, | 1063 const bool success = CompileParsedFunctionHelper(pipeline, |
| 1055 parsed_function, | 1064 parsed_function, |
| 1056 optimized, | 1065 optimized, |
| 1057 osr_id); | 1066 osr_id); |
| 1058 if (!success) { | 1067 if (!success) { |
| 1059 if (optimized) { | 1068 if (optimized) { |
| 1060 ASSERT(!Compiler::always_optimize()); // Optimized is the only code. | 1069 ASSERT(!Compiler::always_optimize()); // Optimized is the only code. |
| 1061 // Optimizer bailed out. Disable optimizations and never try again. | 1070 // Optimizer bailed out. Disable optimizations and never try again. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 const Object& result = | 1415 const Object& result = |
| 1407 PassiveObject::Handle(isolate->object_store()->sticky_error()); | 1416 PassiveObject::Handle(isolate->object_store()->sticky_error()); |
| 1408 isolate->object_store()->clear_sticky_error(); | 1417 isolate->object_store()->clear_sticky_error(); |
| 1409 return result.raw(); | 1418 return result.raw(); |
| 1410 } | 1419 } |
| 1411 UNREACHABLE(); | 1420 UNREACHABLE(); |
| 1412 return Object::null(); | 1421 return Object::null(); |
| 1413 } | 1422 } |
| 1414 | 1423 |
| 1415 } // namespace dart | 1424 } // namespace dart |
| OLD | NEW |