Commit 8ea83438 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: Provide call counts for constructor calls, surface them as a vector IC.

Port 66d5a9df

Original commit message:
    CallIC and CallConstructStub look so alike, at least in the feedback
    they gather even if the implementation differs...and CallIC has such
    a nice way of surfacing the feedback (CallICNexus), that there is a
    request to make CallConstructStub look analogous. Enter ConstructICStub.

R=mvstanton@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1485303002

Cr-Commit-Position: refs/heads/master@{#32481}
parent ec5590dc
...@@ -3017,8 +3017,8 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { ...@@ -3017,8 +3017,8 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
__ EmitLoadTypeFeedbackVector(r5); __ EmitLoadTypeFeedbackVector(r5);
__ LoadSmiLiteral(r6, SmiFromSlot(expr->CallNewFeedbackSlot())); __ LoadSmiLiteral(r6, SmiFromSlot(expr->CallNewFeedbackSlot()));
CallConstructStub stub(isolate()); Handle<Code> code = CodeFactory::ConstructIC(isolate()).code();
__ Call(stub.GetCode(), RelocInfo::CODE_TARGET); __ Call(code, RelocInfo::CODE_TARGET);
PrepareForBailoutForId(expr->ReturnId(), TOS_REG); PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
// Restore context register. // Restore context register.
__ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
......
...@@ -2428,6 +2428,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -2428,6 +2428,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
// r5 : feedback vector // r5 : feedback vector
// r6 : slot in feedback vector (Smi) // r6 : slot in feedback vector (Smi)
Label initialize, done, miss, megamorphic, not_array_function; Label initialize, done, miss, megamorphic, not_array_function;
Label done_increment_count;
DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
masm->isolate()->heap()->megamorphic_symbol()); masm->isolate()->heap()->megamorphic_symbol());
...@@ -2448,7 +2449,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -2448,7 +2449,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
Register weak_value = r10; Register weak_value = r10;
__ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset)); __ LoadP(weak_value, FieldMemOperand(r8, WeakCell::kValueOffset));
__ cmp(r4, weak_value); __ cmp(r4, weak_value);
__ beq(&done); __ beq(&done_increment_count);
__ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex); __ CompareRoot(r8, Heap::kmegamorphic_symbolRootIndex);
__ beq(&done); __ beq(&done);
__ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset)); __ LoadP(feedback_map, FieldMemOperand(r8, HeapObject::kMapOffset));
...@@ -2471,7 +2472,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -2471,7 +2472,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
__ cmp(r4, r8); __ cmp(r4, r8);
__ bne(&megamorphic); __ bne(&megamorphic);
__ b(&done); __ b(&done_increment_count);
__ bind(&miss); __ bind(&miss);
...@@ -2491,6 +2492,13 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -2491,6 +2492,13 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
// An uninitialized cache is patched with the function // An uninitialized cache is patched with the function
__ bind(&initialize); __ bind(&initialize);
// Initialize the call counter.
__ LoadSmiLiteral(r8, Smi::FromInt(CallICNexus::kCallCountIncrement));
__ SmiToPtrArrayOffset(r7, r6);
__ add(r7, r5, r7);
__ StoreP(r8, FieldMemOperand(r7, FixedArray::kHeaderSize + kPointerSize),
r0);
// Make sure the function is the Array() function. // Make sure the function is the Array() function.
__ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
__ cmp(r4, r8); __ cmp(r4, r8);
...@@ -2504,14 +2512,23 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) { ...@@ -2504,14 +2512,23 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
__ b(&done); __ b(&done);
__ bind(&not_array_function); __ bind(&not_array_function);
CreateWeakCellStub weak_cell_stub(masm->isolate()); CreateWeakCellStub weak_cell_stub(masm->isolate());
CallStubInRecordCallTarget(masm, &weak_cell_stub); CallStubInRecordCallTarget(masm, &weak_cell_stub);
__ b(&done);
__ bind(&done_increment_count);
__ SmiToPtrArrayOffset(r7, r6);
__ add(r7, r5, r7);
__ LoadP(r8, FieldMemOperand(r7, FixedArray::kHeaderSize + kPointerSize));
__ AddSmiLiteral(r8, r8, Smi::FromInt(CallICNexus::kCallCountIncrement), r0);
__ StoreP(r8, FieldMemOperand(r7, FixedArray::kHeaderSize + kPointerSize),
r0);
__ bind(&done); __ bind(&done);
} }
void CallConstructStub::Generate(MacroAssembler* masm) { void ConstructICStub::Generate(MacroAssembler* masm) {
// r3 : number of arguments // r3 : number of arguments
// r4 : the function to call // r4 : the function to call
// r5 : feedback vector // r5 : feedback vector
......
...@@ -188,16 +188,15 @@ void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific( ...@@ -188,16 +188,15 @@ void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
} }
void CallConstructDescriptor::InitializePlatformSpecific( void ConstructDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
// r3 : number of arguments // r3 : number of arguments
// r4 : the function to call // r4 : the function to call
// r5 : feedback vector // r5 : feedback vector
// r6 : slot in feedback vector (Smi, for RecordCallTarget) // r6 : slot in feedback vector (Smi, for RecordCallTarget)
// r7 : new target (for IsSuperConstructorCall)
// TODO(turbofan): So far we don't gather type feedback and hence skip the // TODO(turbofan): So far we don't gather type feedback and hence skip the
// slot parameter, but ArrayConstructStub needs the vector to be undefined. // slot parameter, but ArrayConstructStub needs the vector to be undefined.
Register registers[] = {r3, r4, r7, r5}; Register registers[] = {r3, r4, r5, r6};
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment