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

Unified Diff: runtime/vm/stub_code_ia32.cc

Issue 9460015: Do not count invocations but usage of a function, i.e., increment a function's counter at IC calls … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/stub_code_ia32.cc
===================================================================
--- runtime/vm/stub_code_ia32.cc (revision 4582)
+++ runtime/vm/stub_code_ia32.cc (working copy)
@@ -21,6 +21,7 @@
DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
DEFINE_FLAG(bool, use_slow_path, false,
"Set to true for debugging & verifying the slow paths.");
+DECLARE_FLAG(int, optimization_counter_threshold);
// Input parameters:
// ESP : points to return address.
@@ -268,28 +269,6 @@
}
-// Called when number of invocations exceeds
-// --optimization_invocation_threshold.
-// EAX: target function.
-// EDX: arguments descriptor array (num_args is first Smi element).
-void StubCode::GenerateOptimizeInvokedFunctionStub(Assembler* assembler) {
- __ EnterFrame(0);
- __ pushl(EDX); // Preserve arguments descriptor array.
- __ pushl(EAX); // Preserve target function.
- __ pushl(EAX); // Target function.
- __ CallRuntimeFromStub(kOptimizeInvokedFunctionRuntimeEntry);
- __ popl(EAX); // discard argument.
- __ popl(EAX); // Restore function.
- __ popl(EDX); // Restore arguments descriptor array.
- __ movl(EAX, FieldAddress(EAX, Function::code_offset()));
- __ movl(EAX, FieldAddress(EAX, Code::instructions_offset()));
- __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
- __ LeaveFrame();
- __ jmp(EAX);
- __ int3();
-}
-
-
// Called from a static call only when an invalid code has been entered
// (invalid because its function was optimized or deoptimized).
// ECX: function object.
@@ -1546,6 +1525,25 @@
// - Match not found -> jump to IC miss.
void StubCode::GenerateNArgsCheckInlineCacheStub(Assembler* assembler,
intptr_t num_args) {
+ __ movl(EBX, FieldAddress(ECX, ICData::function_offset()));
+ __ incl(FieldAddress(EBX, Function::usage_counter_offset()));
+ if (CodeGenerator::CanOptimize()) {
+ __ cmpl(FieldAddress(EBX, Function::usage_counter_offset()),
+ Immediate(FLAG_optimization_counter_threshold));
+ Label not_yet_hot;
+ __ j(LESS_EQUAL, &not_yet_hot);
+ __ EnterFrame(0);
+ __ pushl(ECX); // Preserve inline cache data object.
+ __ pushl(EDX); // Preserve arguments array.
+ __ pushl(EBX); // Argument for runtime: function object.
+ __ CallRuntimeFromStub(kOptimizeInvokedFunctionRuntimeEntry);
+ __ popl(EBX); // Remove argument.
+ __ popl(EDX); // Restore arguments array.
+ __ popl(ECX); // Restore inline cache data object.
+ __ LeaveFrame();
+ __ Bind(&not_yet_hot);
+ }
+
ASSERT(num_args > 0);
// Get receiver.
__ movl(EAX, FieldAddress(EDX, Array::data_offset()));
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698