Index: src/arm64/full-codegen-arm64.cc |
diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc |
index 5bae367d90ab8b1f7264d63eae4621fe95074f22..819868b5d855af8c15eb13f87a35e067d47625ec 100644 |
--- a/src/arm64/full-codegen-arm64.cc |
+++ b/src/arm64/full-codegen-arm64.cc |
@@ -2337,15 +2337,16 @@ void FullCodeGenerator::CallIC(Handle<Code> code, |
// Code common for calls using the IC. |
-void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
- Expression* callee = expr->expression(); |
+void FullCodeGenerator::EmitCallWithIC(Call* expr) { |
+ ASM_LOCATION("EmitCallWithIC"); |
- CallIC::CallType call_type = callee->IsVariableProxy() |
- ? CallIC::FUNCTION |
- : CallIC::METHOD; |
+ Expression* callee = expr->expression(); |
+ ZoneList<Expression*>* args = expr->arguments(); |
+ int arg_count = args->length(); |
+ CallFunctionFlags flags; |
// Get the target function. |
- if (call_type == CallIC::FUNCTION) { |
+ if (callee->IsVariableProxy()) { |
{ StackValueContext context(this); |
EmitVariableLoad(callee->AsVariableProxy()); |
PrepareForBailout(callee, NO_REGISTERS); |
@@ -2353,6 +2354,7 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
// Push undefined as receiver. This is patched in the method prologue if it |
// is a sloppy mode method. |
__ Push(isolate()->factory()->undefined_value()); |
+ flags = NO_CALL_FUNCTION_FLAGS; |
} else { |
// Load the function from the receiver. |
ASSERT(callee->IsProperty()); |
@@ -2362,19 +2364,40 @@ void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) { |
// Push the target function under the receiver. |
__ Pop(x10); |
__ Push(x0, x10); |
+ flags = CALL_AS_METHOD; |
+ } |
+ |
+ // Load the arguments. |
+ { PreservePositionScope scope(masm()->positions_recorder()); |
+ for (int i = 0; i < arg_count; i++) { |
+ VisitForStackValue(args->at(i)); |
+ } |
} |
- EmitCall(expr, call_type); |
+ // Record source position for debugger. |
+ SetSourcePosition(expr->position()); |
+ CallFunctionStub stub(arg_count, flags); |
+ __ Peek(x1, (arg_count + 1) * kPointerSize); |
+ __ CallStub(&stub); |
+ |
+ RecordJSReturnSite(expr); |
+ |
+ // Restore context register. |
+ __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
+ |
+ context()->DropAndPlug(1, x0); |
} |
// Code common for calls using the IC. |
-void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
- Expression* key) { |
+void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
+ Expression* key) { |
// Load the key. |
VisitForAccumulatorValue(key); |
Expression* callee = expr->expression(); |
+ ZoneList<Expression*>* args = expr->arguments(); |
+ int arg_count = args->length(); |
// Load the function from the receiver. |
ASSERT(callee->IsProperty()); |
@@ -2386,12 +2409,28 @@ void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr, |
__ Pop(x10); |
__ Push(x0, x10); |
- EmitCall(expr, CallIC::METHOD); |
+ { PreservePositionScope scope(masm()->positions_recorder()); |
+ for (int i = 0; i < arg_count; i++) { |
+ VisitForStackValue(args->at(i)); |
+ } |
+ } |
+ |
+ // Record source position for debugger. |
+ SetSourcePosition(expr->position()); |
+ CallFunctionStub stub(arg_count, CALL_AS_METHOD); |
+ __ Peek(x1, (arg_count + 1) * kPointerSize); |
+ __ CallStub(&stub); |
+ |
+ RecordJSReturnSite(expr); |
+ // Restore context register. |
+ __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
+ |
+ context()->DropAndPlug(1, x0); |
} |
-void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { |
- // Load the arguments. |
+void FullCodeGenerator::EmitCallWithStub(Call* expr) { |
+ // Code common for calls using the call stub. |
ZoneList<Expression*>* args = expr->arguments(); |
int arg_count = args->length(); |
{ PreservePositionScope scope(masm()->positions_recorder()); |
@@ -2399,21 +2438,19 @@ void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) { |
VisitForStackValue(args->at(i)); |
} |
} |
- // Record source position of the IC call. |
+ // Record source position for debugger. |
SetSourcePosition(expr->position()); |
- Handle<Code> ic = CallIC::initialize_stub( |
- isolate(), arg_count, call_type); |
Handle<Object> uninitialized = |
TypeFeedbackInfo::UninitializedSentinel(isolate()); |
StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); |
__ LoadObject(x2, FeedbackVector()); |
__ Mov(x3, Smi::FromInt(expr->CallFeedbackSlot())); |
- __ Peek(x1, (arg_count + 1) * kXRegSize); |
- // Don't assign a type feedback id to the IC, since type feedback is provided |
- // by the vector above. |
- CallIC(ic); |
+ // Record call targets in unoptimized code. |
+ CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); |
+ __ Peek(x1, (arg_count + 1) * kXRegSize); |
+ __ CallStub(&stub); |
RecordJSReturnSite(expr); |
// Restore context register. |
__ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
@@ -2505,7 +2542,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
context()->DropAndPlug(1, x0); |
} else if (call_type == Call::GLOBAL_CALL) { |
- EmitCallWithLoadIC(expr); |
+ EmitCallWithIC(expr); |
} else if (call_type == Call::LOOKUP_SLOT_CALL) { |
// Call to a lookup slot (dynamically introduced variable). |
@@ -2545,16 +2582,16 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
// The receiver is either the global receiver or an object found |
// by LoadContextSlot. |
- EmitCall(expr); |
+ EmitCallWithStub(expr); |
} else if (call_type == Call::PROPERTY_CALL) { |
Property* property = callee->AsProperty(); |
{ PreservePositionScope scope(masm()->positions_recorder()); |
VisitForStackValue(property->obj()); |
} |
if (property->key()->IsPropertyName()) { |
- EmitCallWithLoadIC(expr); |
+ EmitCallWithIC(expr); |
} else { |
- EmitKeyedCallWithLoadIC(expr, property->key()); |
+ EmitKeyedCallWithIC(expr, property->key()); |
} |
} else { |
@@ -2566,7 +2603,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
__ LoadRoot(x1, Heap::kUndefinedValueRootIndex); |
__ Push(x1); |
// Emit function call. |
- EmitCall(expr); |
+ EmitCallWithStub(expr); |
} |
#ifdef DEBUG |
@@ -2616,7 +2653,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
__ LoadObject(x2, FeedbackVector()); |
__ Mov(x3, Smi::FromInt(expr->CallNewFeedbackSlot())); |
- CallConstructStub stub(RECORD_CONSTRUCTOR_TARGET); |
+ CallConstructStub stub(RECORD_CALL_TARGET); |
__ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
context()->Plug(x0); |