Index: src/ppc/code-stubs-ppc.cc |
diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc |
index ce6a3b6a02e90d47ea29258580c193f1cda5d0ff..82318685dfd156b54fdcb497d4174cddfc9663c6 100644 |
--- a/src/ppc/code-stubs-ppc.cc |
+++ b/src/ppc/code-stubs-ppc.cc |
@@ -1861,6 +1861,16 @@ 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, Register temp) { |
+ const int count_offset = FixedArray::kHeaderSize + kPointerSize; |
+ __ SmiToPtrArrayOffset(temp, slot); |
+ __ add(feedback_vector, feedback_vector, temp); |
+ __ LoadP(slot, FieldMemOperand(feedback_vector, count_offset)); |
+ __ AddSmiLiteral(slot, slot, Smi::FromInt(1), temp); |
+ __ StoreP(slot, FieldMemOperand(feedback_vector, count_offset), temp); |
+} |
void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
// r4 - function |
@@ -1874,12 +1884,7 @@ void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
__ mov(r3, Operand(arg_count())); |
// Increment the call count for monomorphic function calls. |
- const int count_offset = FixedArray::kHeaderSize + kPointerSize; |
- __ SmiToPtrArrayOffset(r8, r6); |
- __ add(r5, r5, r8); |
- __ LoadP(r6, FieldMemOperand(r5, count_offset)); |
- __ AddSmiLiteral(r6, r6, Smi::FromInt(1), r0); |
- __ StoreP(r6, FieldMemOperand(r5, count_offset), r0); |
+ IncrementCallCount(masm, r5, r6, r0); |
__ mr(r5, r7); |
__ mr(r6, r4); |
@@ -1892,7 +1897,7 @@ void CallICStub::Generate(MacroAssembler* masm) { |
// r4 - function |
// r6 - slot id (Smi) |
// r5 - 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); |
@@ -1923,13 +1928,11 @@ void CallICStub::Generate(MacroAssembler* masm) { |
// convincing us that we have a monomorphic JSFunction. |
__ JumpIfSmi(r4, &extra_checks_or_miss); |
+ __ bind(&call_function); |
+ |
// Increment the call count for monomorphic function calls. |
- const int count_offset = FixedArray::kHeaderSize + kPointerSize; |
- __ LoadP(r6, FieldMemOperand(r9, count_offset)); |
- __ AddSmiLiteral(r6, r6, Smi::FromInt(1), r0); |
- __ StoreP(r6, FieldMemOperand(r9, count_offset), r0); |
+ IncrementCallCount(masm, r5, r6, r0); |
- __ bind(&call_function); |
__ mov(r3, Operand(argc)); |
__ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
tail_call_mode()), |
@@ -1969,6 +1972,11 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ StoreP(ip, FieldMemOperand(r9, FixedArray::kHeaderSize), r0); |
__ bind(&call); |
+ |
+ // Increment the call count for megamorphic function calls. |
+ IncrementCallCount(masm, r5, r6, r0); |
+ |
+ __ bind(&call_count_incremented); |
__ mov(r3, Operand(argc)); |
__ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
RelocInfo::CODE_TARGET); |
@@ -1995,10 +2003,6 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ cmp(r7, ip); |
__ bne(&miss); |
- // Initialize the call counter. |
- __ LoadSmiLiteral(r8, Smi::FromInt(1)); |
- __ StoreP(r8, FieldMemOperand(r9, count_offset), r0); |
- |
// Store the function. Use a stub since we need a frame for allocation. |
// r5 - vector |
// r6 - slot |
@@ -2006,9 +2010,13 @@ void CallICStub::Generate(MacroAssembler* masm) { |
{ |
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
CreateWeakCellStub create_stub(masm->isolate()); |
+ __ Push(r5); |
+ __ Push(r6); |
__ Push(cp, r4); |
__ CallStub(&create_stub); |
__ Pop(cp, r4); |
+ __ Pop(r6); |
+ __ Pop(r5); |
} |
__ b(&call_function); |
@@ -2018,7 +2026,7 @@ void CallICStub::Generate(MacroAssembler* masm) { |
__ bind(&miss); |
GenerateMiss(masm); |
- __ b(&call); |
+ __ b(&call_count_incremented); |
} |