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

Unified Diff: src/x64/code-stubs-x64.cc

Issue 2325083003: Record call counts also for megamorphic calls. (Closed)
Patch Set: Code comments. Created 4 years, 3 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 | « src/type-feedback-vector.cc ('k') | test/cctest/test-feedback-vector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/code-stubs-x64.cc
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
index 8b236fb03168bcbbb7aa713a56905331dad96ffc..93f26fc8d2dcfd7c88ea06385f3d836c0f8c03c7 100644
--- a/src/x64/code-stubs-x64.cc
+++ b/src/x64/code-stubs-x64.cc
@@ -1321,6 +1321,12 @@ void CallConstructStub::Generate(MacroAssembler* masm) {
__ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
}
+static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector,
+ Register slot) {
+ __ SmiAddConstant(FieldOperand(feedback_vector, slot, times_pointer_size,
+ FixedArray::kHeaderSize + kPointerSize),
+ Smi::FromInt(1));
+}
void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) {
// rdi - function
@@ -1334,9 +1340,7 @@ void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) {
__ movp(rax, Immediate(arg_count()));
// Increment the call count for monomorphic function calls.
- __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
- FixedArray::kHeaderSize + kPointerSize),
- Smi::FromInt(1));
+ IncrementCallCount(masm, rbx, rdx);
__ movp(rbx, rcx);
__ movp(rdx, rdi);
@@ -1352,7 +1356,7 @@ void CallICStub::Generate(MacroAssembler* masm) {
// -- rbx - vector
// -----------------------------------
Isolate* isolate = masm->isolate();
- Label extra_checks_or_miss, call, call_function;
+ Label extra_checks_or_miss, call, call_function, call_count_incremented;
int argc = arg_count();
StackArgumentsAccessor args(rsp, argc);
ParameterCount actual(argc);
@@ -1383,12 +1387,10 @@ void CallICStub::Generate(MacroAssembler* masm) {
// convincing us that we have a monomorphic JSFunction.
__ JumpIfSmi(rdi, &extra_checks_or_miss);
+ __ bind(&call_function);
// Increment the call count for monomorphic function calls.
- __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
- FixedArray::kHeaderSize + kPointerSize),
- Smi::FromInt(1));
+ IncrementCallCount(masm, rbx, rdx);
- __ bind(&call_function);
__ Set(rax, argc);
__ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(),
tail_call_mode()),
@@ -1428,6 +1430,11 @@ void CallICStub::Generate(MacroAssembler* masm) {
TypeFeedbackVector::MegamorphicSentinel(isolate));
__ bind(&call);
+
+ // Increment the call count for megamorphic function calls.
+ IncrementCallCount(masm, rbx, rdx);
+
+ __ bind(&call_count_incremented);
__ Set(rax, argc);
__ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()),
RelocInfo::CODE_TARGET);
@@ -1453,11 +1460,6 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ cmpp(rcx, NativeContextOperand());
__ j(not_equal, &miss);
- // Initialize the call counter.
- __ Move(FieldOperand(rbx, rdx, times_pointer_size,
- FixedArray::kHeaderSize + kPointerSize),
- Smi::FromInt(1));
-
// Store the function. Use a stub since we need a frame for allocation.
// rbx - vector
// rdx - slot (needs to be in smi form)
@@ -1467,11 +1469,16 @@ void CallICStub::Generate(MacroAssembler* masm) {
CreateWeakCellStub create_stub(isolate);
__ Integer32ToSmi(rdx, rdx);
+ __ Push(rbx);
+ __ Push(rdx);
__ Push(rdi);
__ Push(rsi);
__ CallStub(&create_stub);
__ Pop(rsi);
__ Pop(rdi);
+ __ Pop(rdx);
+ __ Pop(rbx);
+ __ SmiToInteger32(rdx, rdx);
}
__ jmp(&call_function);
@@ -1481,20 +1488,19 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ bind(&miss);
GenerateMiss(masm);
- __ jmp(&call);
+ __ jmp(&call_count_incremented);
// Unreachable
__ int3();
}
-
void CallICStub::GenerateMiss(MacroAssembler* masm) {
FrameScope scope(masm, StackFrame::INTERNAL);
// Push the receiver and the function and feedback info.
+ __ Integer32ToSmi(rdx, rdx);
__ Push(rdi);
__ Push(rbx);
- __ Integer32ToSmi(rdx, rdx);
__ Push(rdx);
// Call the entry.
@@ -1504,7 +1510,6 @@ void CallICStub::GenerateMiss(MacroAssembler* masm) {
__ movp(rdi, rax);
}
-
bool CEntryStub::NeedsImmovableCode() {
return false;
}
« no previous file with comments | « src/type-feedback-vector.cc ('k') | test/cctest/test-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698