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

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

Issue 11783066: Optimize function at its entry instead of at exit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/code_patcher.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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 ic_data.raw(), 1332 ic_data.raw(),
1333 function.usage_counter(), 1333 function.usage_counter(),
1334 ic_data.NumberOfChecks(), 1334 ic_data.NumberOfChecks(),
1335 ic_data.is_closure_call() ? "closure" : "", 1335 ic_data.is_closure_call() ? "closure" : "",
1336 function.ToFullyQualifiedCString()); 1336 function.ToFullyQualifiedCString());
1337 } 1337 }
1338 1338
1339 1339
1340 // This is called from function that needs to be optimized. 1340 // This is called from function that needs to be optimized.
1341 // The requesting function can be already optimized (reoptimization). 1341 // The requesting function can be already optimized (reoptimization).
1342 // Returns the Code object where to continue execution.
1342 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) { 1343 DEFINE_RUNTIME_ENTRY(OptimizeInvokedFunction, 1) {
1343 ASSERT(arguments.ArgCount() == 1344 ASSERT(arguments.ArgCount() ==
1344 kOptimizeInvokedFunctionRuntimeEntry.argument_count()); 1345 kOptimizeInvokedFunctionRuntimeEntry.argument_count());
1345 const intptr_t kLowInvocationCount = -100000000; 1346 const intptr_t kLowInvocationCount = -100000000;
1346 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); 1347 const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
1348 ASSERT(!function.IsNull());
1347 if (isolate->debugger()->HasBreakpoint(function)) { 1349 if (isolate->debugger()->HasBreakpoint(function)) {
1348 // We cannot set breakpoints in optimized code, so do not optimize 1350 // We cannot set breakpoints in optimized code, so do not optimize
1349 // the function. 1351 // the function.
1350 function.set_usage_counter(0); 1352 function.set_usage_counter(0);
1353 arguments.SetReturn(Code::Handle(function.CurrentCode()));
1351 return; 1354 return;
1352 } 1355 }
1353 if (function.deoptimization_counter() >= 1356 if (function.deoptimization_counter() >=
1354 FLAG_deoptimization_counter_threshold) { 1357 FLAG_deoptimization_counter_threshold) {
1355 if (FLAG_trace_failed_optimization_attempts) { 1358 if (FLAG_trace_failed_optimization_attempts) {
1356 PrintCaller("Too Many Deoptimizations"); 1359 PrintCaller("Too Many Deoptimizations");
1357 } 1360 }
1358 // TODO(srdjan): Investigate excessive deoptimization. 1361 // TODO(srdjan): Investigate excessive deoptimization.
1359 function.set_usage_counter(kLowInvocationCount); 1362 function.set_usage_counter(kLowInvocationCount);
1363 arguments.SetReturn(Code::Handle(function.CurrentCode()));
1360 return; 1364 return;
1361 } 1365 }
1362 if ((FLAG_optimization_filter != NULL) && 1366 if ((FLAG_optimization_filter != NULL) &&
1363 (strstr(function.ToFullyQualifiedCString(), 1367 (strstr(function.ToFullyQualifiedCString(),
1364 FLAG_optimization_filter) == NULL)) { 1368 FLAG_optimization_filter) == NULL)) {
1365 function.set_usage_counter(kLowInvocationCount); 1369 function.set_usage_counter(kLowInvocationCount);
1370 arguments.SetReturn(Code::Handle(function.CurrentCode()));
1366 return; 1371 return;
1367 } 1372 }
1368 if (function.is_optimizable()) { 1373 if (function.is_optimizable()) {
1369 const Error& error = 1374 const Error& error =
1370 Error::Handle(Compiler::CompileOptimizedFunction(function)); 1375 Error::Handle(Compiler::CompileOptimizedFunction(function));
1371 if (!error.IsNull()) { 1376 if (!error.IsNull()) {
1372 Exceptions::PropagateError(error); 1377 Exceptions::PropagateError(error);
1373 } 1378 }
1374 const Code& optimized_code = Code::Handle(function.CurrentCode()); 1379 const Code& optimized_code = Code::Handle(function.CurrentCode());
1375 ASSERT(!optimized_code.IsNull()); 1380 ASSERT(!optimized_code.IsNull());
1376 // Set usage counter for reoptimization. 1381 // Set usage counter for reoptimization.
1377 function.set_usage_counter( 1382 function.set_usage_counter(
1378 function.usage_counter() - FLAG_reoptimization_counter_threshold); 1383 function.usage_counter() - FLAG_reoptimization_counter_threshold);
1379 } else { 1384 } else {
1380 if (FLAG_trace_failed_optimization_attempts) { 1385 if (FLAG_trace_failed_optimization_attempts) {
1381 PrintCaller("Not Optimizable"); 1386 PrintCaller("Not Optimizable");
1382 } 1387 }
1383 // TODO(5442338): Abort as this should not happen. 1388 // TODO(5442338): Abort as this should not happen.
1384 function.set_usage_counter(kLowInvocationCount); 1389 function.set_usage_counter(kLowInvocationCount);
1385 } 1390 }
1391 arguments.SetReturn(Code::Handle(function.CurrentCode()));
1386 } 1392 }
1387 1393
1388 1394
1389 // The caller must be a static call in a Dart frame, or an entry frame. 1395 // The caller must be a static call in a Dart frame, or an entry frame.
1390 // Patch static call to point to valid code's entry point. 1396 // Patch static call to point to valid code's entry point.
1391 DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) { 1397 DEFINE_RUNTIME_ENTRY(FixCallersTarget, 0) {
1392 ASSERT(arguments.ArgCount() == 1398 ASSERT(arguments.ArgCount() ==
1393 kFixCallersTargetRuntimeEntry.argument_count()); 1399 kFixCallersTargetRuntimeEntry.argument_count());
1394 1400
1395 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames); 1401 StackFrameIterator iterator(StackFrameIterator::kDontValidateFrames);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 return; 1794 return;
1789 } 1795 }
1790 HeapTrace* heap_trace = Isolate::Current()->heap()->trace(); 1796 HeapTrace* heap_trace = Isolate::Current()->heap()->trace();
1791 heap_trace->TraceStoreIntoObject(RawObject::ToAddr(object), 1797 heap_trace->TraceStoreIntoObject(RawObject::ToAddr(object),
1792 field_addr, 1798 field_addr,
1793 RawObject::ToAddr(value)); 1799 RawObject::ToAddr(value));
1794 } 1800 }
1795 END_LEAF_RUNTIME_ENTRY 1801 END_LEAF_RUNTIME_ENTRY
1796 1802
1797 } // namespace dart 1803 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_patcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698