Index: src/arm/code-stubs-arm.cc |
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc |
index 826e1055c9885523fa3f3cf366ff7ff2cf100d82..d90979170581d27c21a681f302c304c527853610 100644 |
--- a/src/arm/code-stubs-arm.cc |
+++ b/src/arm/code-stubs-arm.cc |
@@ -1785,6 +1785,17 @@ void CallConstructStub::Generate(MacroAssembler* masm) { |
__ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
} |
+// Note: feedback_vector and slot are clobbered after the call. |
+static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector, |
+ Register slot) { |
+ __ add(feedback_vector, feedback_vector, |
+ Operand::PointerOffsetFromSmiKey(slot)); |
+ __ add(feedback_vector, feedback_vector, |
+ Operand(FixedArray::kHeaderSize + kPointerSize)); |
+ __ ldr(slot, FieldMemOperand(feedback_vector, 0)); |
+ __ add(slot, slot, Operand(Smi::FromInt(1))); |
+ __ str(slot, FieldMemOperand(feedback_vector, 0)); |
+} |
void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
// r1 - function |
@@ -1798,11 +1809,7 @@ void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
__ mov(r0, Operand(arg_count())); |
// Increment the call count for monomorphic function calls. |
- __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3)); |
- __ add(r2, r2, Operand(FixedArray::kHeaderSize + kPointerSize)); |
- __ ldr(r3, FieldMemOperand(r2, 0)); |
- __ add(r3, r3, Operand(Smi::FromInt(1))); |
- __ str(r3, FieldMemOperand(r2, 0)); |
+ IncrementCallCount(masm, r2, r3); |
__ mov(r2, r4); |
__ mov(r3, r1); |
@@ -1815,7 +1822,7 @@ void CallICStub::Generate(MacroAssembler* masm) { |
// r1 - function |
// r3 - slot id (Smi) |
// r2 - vector |
- Label extra_checks_or_miss, call, call_function; |
+ Label extra_checks_or_miss, call, call_function, call_count_incremented; |
int argc = arg_count(); |
ParameterCount actual(argc); |
@@ -1845,14 +1852,11 @@ void CallICStub::Generate(MacroAssembler* masm) { |
// convincing us that we have a monomorphic JSFunction. |
__ JumpIfSmi(r1, &extra_checks_or_miss); |
+ __ bind(&call_function); |
+ |
// Increment the call count for monomorphic function calls. |
- __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3)); |
- __ add(r2, r2, Operand(FixedArray::kHeaderSize + kPointerSize)); |
- __ ldr(r3, FieldMemOperand(r2, 0)); |
- __ add(r3, r3, Operand(Smi::FromInt(1))); |
- __ str(r3, FieldMemOperand(r2, 0)); |
+ IncrementCallCount(masm, r2, r3); |
- __ bind(&call_function); |
__ mov(r0, Operand(argc)); |
__ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
tail_call_mode()), |
@@ -1893,6 +1897,11 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); |
__ bind(&call); |
+ |
+ // Increment the call count for megamorphic function calls. |
+ IncrementCallCount(masm, r2, r3); |
+ |
+ __ bind(&call_count_incremented); |
__ mov(r0, Operand(argc)); |
__ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
RelocInfo::CODE_TARGET); |
@@ -1919,11 +1928,6 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ cmp(r4, ip); |
__ b(ne, &miss); |
- // Initialize the call counter. |
- __ Move(r5, Operand(Smi::FromInt(1))); |
- __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); |
- __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + kPointerSize)); |
- |
// Store the function. Use a stub since we need a frame for allocation. |
// r2 - vector |
// r3 - slot |
@@ -1931,9 +1935,13 @@ void CallICStub::Generate(MacroAssembler* masm) { |
{ |
FrameScope scope(masm, StackFrame::INTERNAL); |
CreateWeakCellStub create_stub(masm->isolate()); |
+ __ Push(r2); |
+ __ Push(r3); |
__ Push(cp, r1); |
__ CallStub(&create_stub); |
__ Pop(cp, r1); |
+ __ Pop(r3); |
+ __ Pop(r2); |
} |
__ jmp(&call_function); |
@@ -1943,7 +1951,7 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ bind(&miss); |
GenerateMiss(masm); |
- __ jmp(&call); |
+ __ jmp(&call_count_incremented); |
} |