Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: runtime/vm/compiler.cc

Issue 1268783002: Fix inlining information: (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: sync Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 INC_STAT(isolate, total_code_size, 737 INC_STAT(isolate, total_code_size,
738 intervals.Length() * sizeof(uword)); 738 intervals.Length() * sizeof(uword));
739 code.SetInlinedIntervals(intervals); 739 code.SetInlinedIntervals(intervals);
740 740
741 const Array& inlined_id_array = 741 const Array& inlined_id_array =
742 Array::Handle(isolate, graph_compiler.InliningIdToFunction()); 742 Array::Handle(isolate, graph_compiler.InliningIdToFunction());
743 INC_STAT(isolate, total_code_size, 743 INC_STAT(isolate, total_code_size,
744 inlined_id_array.Length() * sizeof(uword)); 744 inlined_id_array.Length() * sizeof(uword));
745 code.SetInlinedIdToFunction(inlined_id_array); 745 code.SetInlinedIdToFunction(inlined_id_array);
746 746
747 const Array& caller_inlining_id_map_array =
748 Array::Handle(isolate, graph_compiler.CallerInliningIdMap());
749 INC_STAT(isolate, total_code_size,
750 caller_inlining_id_map_array.Length() * sizeof(uword));
751 code.SetInlinedCallerIdMap(caller_inlining_id_map_array);
752
747 graph_compiler.FinalizePcDescriptors(code); 753 graph_compiler.FinalizePcDescriptors(code);
748 code.set_deopt_info_array(deopt_info_array); 754 code.set_deopt_info_array(deopt_info_array);
749 755
750 graph_compiler.FinalizeStackmaps(code); 756 graph_compiler.FinalizeStackmaps(code);
751 graph_compiler.FinalizeVarDescriptors(code); 757 graph_compiler.FinalizeVarDescriptors(code);
752 graph_compiler.FinalizeExceptionHandlers(code); 758 graph_compiler.FinalizeExceptionHandlers(code);
753 graph_compiler.FinalizeStaticCallTargetsTable(code); 759 graph_compiler.FinalizeStaticCallTargetsTable(code);
754 760
755 if (optimized) { 761 if (optimized) {
756 // We may not have previous code if 'always_optimize' is set. 762 // We may not have previous code if 'always_optimize' is set.
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 } 970 }
965 } 971 }
966 ISL_Print("}\n"); 972 ISL_Print("}\n");
967 } 973 }
968 if (optimized && FLAG_trace_inlining_intervals) { 974 if (optimized && FLAG_trace_inlining_intervals) {
969 code.DumpInlinedIntervals(); 975 code.DumpInlinedIntervals();
970 } 976 }
971 } 977 }
972 978
973 979
980 #if defined(DEBUG)
981 // Verifies that the inliner is always in the list of inlined functions.
982 // If this fails run with --trace-inlining-intervals to get more information.
983 static void CheckInliningIntervals(const Function& function) {
984 const Code& code = Code::Handle(function.CurrentCode());
985 const Array& intervals = Array::Handle(code.GetInlinedIntervals());
986 if (intervals.IsNull() || (intervals.Length() == 0)) return;
987 Smi& start = Smi::Handle();
988 GrowableArray<Function*> inlined_functions;
989 for (intptr_t i = 0; i < intervals.Length(); i += Code::kInlIntNumEntries) {
990 start ^= intervals.At(i + Code::kInlIntStart);
991 ASSERT(!start.IsNull());
992 if (start.IsNull()) continue;
993 code.GetInlinedFunctionsAt(start.Value(), &inlined_functions);
994 ASSERT(inlined_functions[inlined_functions.length() - 1]->raw() ==
995 function.raw());
996 }
997 }
998 #endif
999
1000
974 static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, 1001 static RawError* CompileFunctionHelper(CompilationPipeline* pipeline,
975 const Function& function, 1002 const Function& function,
976 bool optimized, 1003 bool optimized,
977 intptr_t osr_id) { 1004 intptr_t osr_id) {
978 // Check that we optimize if 'Compiler::always_optimize()' is set to true, 1005 // Check that we optimize if 'Compiler::always_optimize()' is set to true,
979 // except if the function is marked as not optimizable. 1006 // except if the function is marked as not optimizable.
980 ASSERT(!function.IsOptimizable() || 1007 ASSERT(!function.IsOptimizable() ||
981 !Compiler::always_optimize() || optimized); 1008 !Compiler::always_optimize() || optimized);
982 ASSERT(Compiler::allow_recompilation() || !function.HasCode()); 1009 ASSERT(Compiler::allow_recompilation() || !function.HasCode());
983 LongJumpScope jump; 1010 LongJumpScope jump;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 if (FLAG_disassemble && FlowGraphPrinter::ShouldPrint(function)) { 1079 if (FLAG_disassemble && FlowGraphPrinter::ShouldPrint(function)) {
1053 DisassembleCode(function, optimized); 1080 DisassembleCode(function, optimized);
1054 } else if (FLAG_disassemble_optimized && 1081 } else if (FLAG_disassemble_optimized &&
1055 optimized && 1082 optimized &&
1056 FlowGraphPrinter::ShouldPrint(function)) { 1083 FlowGraphPrinter::ShouldPrint(function)) {
1057 // TODO(fschneider): Print unoptimized code along with the optimized code. 1084 // TODO(fschneider): Print unoptimized code along with the optimized code.
1058 ISL_Print("*** BEGIN CODE\n"); 1085 ISL_Print("*** BEGIN CODE\n");
1059 DisassembleCode(function, true); 1086 DisassembleCode(function, true);
1060 ISL_Print("*** END CODE\n"); 1087 ISL_Print("*** END CODE\n");
1061 } 1088 }
1089 #if defined(DEBUG)
1090 CheckInliningIntervals(function);
1091 #endif
1062 return Error::null(); 1092 return Error::null();
1063 } else { 1093 } else {
1064 Thread* const thread = Thread::Current(); 1094 Thread* const thread = Thread::Current();
1065 Isolate* const isolate = thread->isolate(); 1095 Isolate* const isolate = thread->isolate();
1066 StackZone stack_zone(isolate); 1096 StackZone stack_zone(isolate);
1067 Error& error = Error::Handle(); 1097 Error& error = Error::Handle();
1068 // We got an error during compilation. 1098 // We got an error during compilation.
1069 error = isolate->object_store()->sticky_error(); 1099 error = isolate->object_store()->sticky_error();
1070 isolate->object_store()->clear_sticky_error(); 1100 isolate->object_store()->clear_sticky_error();
1071 return error.raw(); 1101 return error.raw();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 const Object& result = 1372 const Object& result =
1343 PassiveObject::Handle(isolate->object_store()->sticky_error()); 1373 PassiveObject::Handle(isolate->object_store()->sticky_error());
1344 isolate->object_store()->clear_sticky_error(); 1374 isolate->object_store()->clear_sticky_error();
1345 return result.raw(); 1375 return result.raw();
1346 } 1376 }
1347 UNREACHABLE(); 1377 UNREACHABLE();
1348 return Object::null(); 1378 return Object::null();
1349 } 1379 }
1350 1380
1351 } // namespace dart 1381 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698