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

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

Issue 2994283002: [VM-Compiler] Don't inline if we don't have inlining budget enough to fully inline.
Patch Set: Do InliningDecision the way Slava suggested Created 3 years, 2 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 | « runtime/vm/compiler/backend/inliner.cc ('k') | runtime/vm/isolate_reload.cc » ('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/jit/compiler.h" 5 #include "vm/compiler/jit/compiler.h"
6 6
7 #include "vm/compiler/assembler/assembler.h" 7 #include "vm/compiler/assembler/assembler.h"
8 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 } 892 }
893 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 893 DEBUG_ASSERT(flow_graph->VerifyUseLists());
894 894
895 // Optimize (a << b) & c patterns, merge operations. 895 // Optimize (a << b) & c patterns, merge operations.
896 // Run early in order to have more opportunity to optimize left shifts. 896 // Run early in order to have more opportunity to optimize left shifts.
897 flow_graph->TryOptimizePatterns(); 897 flow_graph->TryOptimizePatterns();
898 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 898 DEBUG_ASSERT(flow_graph->VerifyUseLists());
899 899
900 FlowGraphInliner::SetInliningId(flow_graph, 0); 900 FlowGraphInliner::SetInliningId(flow_graph, 0);
901 901
902 int inlining_depth = 0;
903
902 // Inlining (mutates the flow graph) 904 // Inlining (mutates the flow graph)
903 if (FLAG_use_inlining) { 905 if (FLAG_use_inlining) {
904 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline, 906 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline,
905 "Inlining")); 907 "Inlining"));
906 CSTAT_TIMER_SCOPE(thread(), graphinliner_timer); 908 CSTAT_TIMER_SCOPE(thread(), graphinliner_timer);
907 // Propagate types to create more inlining opportunities. 909 // Propagate types to create more inlining opportunities.
908 FlowGraphTypePropagator::Propagate(flow_graph); 910 FlowGraphTypePropagator::Propagate(flow_graph);
909 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 911 DEBUG_ASSERT(flow_graph->VerifyUseLists());
910 912
911 // Use propagated class-ids to create more inlining opportunities. 913 // Use propagated class-ids to create more inlining opportunities.
912 call_specializer.ApplyClassIds(); 914 call_specializer.ApplyClassIds();
913 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 915 DEBUG_ASSERT(flow_graph->VerifyUseLists());
914 916
915 FlowGraphInliner inliner(flow_graph, &inline_id_to_function, 917 FlowGraphInliner inliner(flow_graph, &inline_id_to_function,
916 &inline_id_to_token_pos, &caller_inline_id, 918 &inline_id_to_token_pos, &caller_inline_id,
917 use_speculative_inlining, 919 use_speculative_inlining,
918 /*inlining_black_list=*/NULL, 920 /*inlining_black_list=*/NULL,
919 /*precompiler=*/NULL); 921 /*precompiler=*/NULL);
920 inliner.Inline(); 922 inlining_depth = inliner.Inline();
921 // Use lists are maintained and validated by the inliner. 923 // Use lists are maintained and validated by the inliner.
922 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 924 DEBUG_ASSERT(flow_graph->VerifyUseLists());
923 thread()->CheckForSafepoint(); 925 thread()->CheckForSafepoint();
924 } 926 }
925 927
926 // Propagate types and eliminate more type tests. 928 // Propagate types and eliminate more type tests.
927 FlowGraphTypePropagator::Propagate(flow_graph); 929 FlowGraphTypePropagator::Propagate(flow_graph);
928 DEBUG_ASSERT(flow_graph->VerifyUseLists()); 930 DEBUG_ASSERT(flow_graph->VerifyUseLists());
929 931
930 { 932 {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 // Remove all MaterializeObject instructions inserted by allocation 1147 // Remove all MaterializeObject instructions inserted by allocation
1146 // sinking from the flow graph and let them float on the side 1148 // sinking from the flow graph and let them float on the side
1147 // referenced only from environments. Register allocator will consider 1149 // referenced only from environments. Register allocator will consider
1148 // them as part of a deoptimization environment. 1150 // them as part of a deoptimization environment.
1149 sinking->DetachMaterializations(); 1151 sinking->DetachMaterializations();
1150 } 1152 }
1151 1153
1152 // Compute and store graph informations (call & instruction counts) 1154 // Compute and store graph informations (call & instruction counts)
1153 // to be later used by the inliner. 1155 // to be later used by the inliner.
1154 FlowGraphInliner::CollectGraphInfo(flow_graph, true); 1156 FlowGraphInliner::CollectGraphInfo(flow_graph, true);
1157 function.set_inlining_depth(inlining_depth);
1155 1158
1156 flow_graph->RemoveRedefinitions(); 1159 flow_graph->RemoveRedefinitions();
1157 { 1160 {
1158 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline, 1161 NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), compiler_timeline,
1159 "AllocateRegisters")); 1162 "AllocateRegisters"));
1160 // Perform register allocation on the SSA graph. 1163 // Perform register allocation on the SSA graph.
1161 FlowGraphAllocator allocator(*flow_graph); 1164 FlowGraphAllocator allocator(*flow_graph);
1162 allocator.AllocateRegisters(); 1165 allocator.AllocateRegisters();
1163 thread()->CheckForSafepoint(); 1166 thread()->CheckForSafepoint();
1164 } 1167 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 thread()->set_deopt_id(prev_deopt_id); 1258 thread()->set_deopt_id(prev_deopt_id);
1256 } 1259 }
1257 return result->raw(); 1260 return result->raw();
1258 } 1261 }
1259 1262
1260 static RawObject* CompileFunctionHelper(CompilationPipeline* pipeline, 1263 static RawObject* CompileFunctionHelper(CompilationPipeline* pipeline,
1261 const Function& function, 1264 const Function& function,
1262 bool optimized, 1265 bool optimized,
1263 intptr_t osr_id) { 1266 intptr_t osr_id) {
1264 ASSERT(!FLAG_precompiled_mode); 1267 ASSERT(!FLAG_precompiled_mode);
1265 ASSERT(!optimized || function.was_compiled()); 1268 ASSERT(!optimized || function.WasCompiled());
1266 LongJumpScope jump; 1269 LongJumpScope jump;
1267 if (setjmp(*jump.Set()) == 0) { 1270 if (setjmp(*jump.Set()) == 0) {
1268 Thread* const thread = Thread::Current(); 1271 Thread* const thread = Thread::Current();
1269 Isolate* const isolate = thread->isolate(); 1272 Isolate* const isolate = thread->isolate();
1270 StackZone stack_zone(thread); 1273 StackZone stack_zone(thread);
1271 Zone* const zone = stack_zone.GetZone(); 1274 Zone* const zone = stack_zone.GetZone();
1272 const bool trace_compiler = 1275 const bool trace_compiler =
1273 FLAG_trace_compiler || (FLAG_trace_optimizing_compiler && optimized); 1276 FLAG_trace_compiler || (FLAG_trace_optimizing_compiler && optimized);
1274 Timer per_compile_timer(trace_compiler, "Compilation time"); 1277 Timer per_compile_timer(trace_compiler, "Compilation time");
1275 per_compile_timer.Start(); 1278 per_compile_timer.Start();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 // changed while compiling. 1315 // changed while compiling.
1313 Compiler::AbortBackgroundCompilation( 1316 Compiler::AbortBackgroundCompilation(
1314 Thread::kNoDeoptId, 1317 Thread::kNoDeoptId,
1315 "Invalidated state during parsing because of script loading"); 1318 "Invalidated state during parsing because of script loading");
1316 } 1319 }
1317 } 1320 }
1318 1321
1319 const Code& result = Code::Handle(helper.Compile(pipeline)); 1322 const Code& result = Code::Handle(helper.Compile(pipeline));
1320 if (!result.IsNull()) { 1323 if (!result.IsNull()) {
1321 if (!optimized) { 1324 if (!optimized) {
1322 function.set_was_compiled(true); 1325 function.SetWasCompiled(true);
1323 } 1326 }
1324 } else { 1327 } else {
1325 if (optimized) { 1328 if (optimized) {
1326 if (Compiler::IsBackgroundCompilation()) { 1329 if (Compiler::IsBackgroundCompilation()) {
1327 // Try again later, background compilation may abort because of 1330 // Try again later, background compilation may abort because of
1328 // state change during compilation. 1331 // state change during compilation.
1329 if (FLAG_trace_compiler) { 1332 if (FLAG_trace_compiler) {
1330 THR_Print("Aborted background compilation: %s\n", 1333 THR_Print("Aborted background compilation: %s\n",
1331 function.ToFullyQualifiedCString()); 1334 function.ToFullyQualifiedCString());
1332 } 1335 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 } 1423 }
1421 UNREACHABLE(); 1424 UNREACHABLE();
1422 return Object::null(); 1425 return Object::null();
1423 } 1426 }
1424 1427
1425 static RawError* ParseFunctionHelper(CompilationPipeline* pipeline, 1428 static RawError* ParseFunctionHelper(CompilationPipeline* pipeline,
1426 const Function& function, 1429 const Function& function,
1427 bool optimized, 1430 bool optimized,
1428 intptr_t osr_id) { 1431 intptr_t osr_id) {
1429 ASSERT(!FLAG_precompiled_mode); 1432 ASSERT(!FLAG_precompiled_mode);
1430 ASSERT(!optimized || function.was_compiled()); 1433 ASSERT(!optimized || function.WasCompiled());
1431 LongJumpScope jump; 1434 LongJumpScope jump;
1432 if (setjmp(*jump.Set()) == 0) { 1435 if (setjmp(*jump.Set()) == 0) {
1433 Thread* const thread = Thread::Current(); 1436 Thread* const thread = Thread::Current();
1434 StackZone stack_zone(thread); 1437 StackZone stack_zone(thread);
1435 Zone* const zone = stack_zone.GetZone(); 1438 Zone* const zone = stack_zone.GetZone();
1436 const bool trace_compiler = 1439 const bool trace_compiler =
1437 FLAG_trace_compiler || (FLAG_trace_optimizing_compiler && optimized); 1440 FLAG_trace_compiler || (FLAG_trace_optimizing_compiler && optimized);
1438 1441
1439 if (trace_compiler) { 1442 if (trace_compiler) {
1440 const intptr_t token_size = 1443 const intptr_t token_size =
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 } 2324 }
2322 2325
2323 bool BackgroundCompiler::IsDisabled() { 2326 bool BackgroundCompiler::IsDisabled() {
2324 UNREACHABLE(); 2327 UNREACHABLE();
2325 return true; 2328 return true;
2326 } 2329 }
2327 2330
2328 #endif // DART_PRECOMPILED_RUNTIME 2331 #endif // DART_PRECOMPILED_RUNTIME
2329 2332
2330 } // namespace dart 2333 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler/backend/inliner.cc ('k') | runtime/vm/isolate_reload.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698