| Index: src/x64/full-codegen-x64.cc
|
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
|
| index 36361a84eac53cb4dfc3fd4a60760edec59431d0..1e3b87e67ee637d6d7b30e2697bcef7c4311d189 100644
|
| --- a/src/x64/full-codegen-x64.cc
|
| +++ b/src/x64/full-codegen-x64.cc
|
| @@ -2554,14 +2554,14 @@ void FullCodeGenerator::CallIC(Handle<Code> code,
|
|
|
|
|
| // Code common for calls using the IC.
|
| -void FullCodeGenerator::EmitCallWithIC(Call* expr) {
|
| +void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
|
| Expression* callee = expr->expression();
|
| - ZoneList<Expression*>* args = expr->arguments();
|
| - int arg_count = args->length();
|
|
|
| - CallFunctionFlags flags;
|
| - // Get the target function;
|
| - if (callee->IsVariableProxy()) {
|
| + CallIC::CallType call_type = callee->IsVariableProxy()
|
| + ? CallIC::FUNCTION
|
| + : CallIC::METHOD;
|
| + // Get the target function.
|
| + if (call_type == CallIC::FUNCTION) {
|
| { StackValueContext context(this);
|
| EmitVariableLoad(callee->AsVariableProxy());
|
| PrepareForBailout(callee, NO_REGISTERS);
|
| @@ -2569,7 +2569,6 @@ void FullCodeGenerator::EmitCallWithIC(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());
|
| @@ -2579,40 +2578,19 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr) {
|
| // Push the target function under the receiver.
|
| __ Push(Operand(rsp, 0));
|
| __ movp(Operand(rsp, kPointerSize), rax);
|
| - flags = CALL_AS_METHOD;
|
| - }
|
| -
|
| - // Load the arguments.
|
| - { 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(isolate(), arg_count, flags);
|
| - __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
|
| - __ CallStub(&stub);
|
| -
|
| - RecordJSReturnSite(expr);
|
| -
|
| - // Restore context register.
|
| - __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| -
|
| - context()->DropAndPlug(1, rax);
|
| + EmitCall(expr, call_type);
|
| }
|
|
|
|
|
| // Common code for calls using the IC.
|
| -void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
|
| - Expression* key) {
|
| +void FullCodeGenerator::EmitKeyedCallWithLoadIC(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());
|
| @@ -2624,29 +2602,12 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
|
| __ Push(Operand(rsp, 0));
|
| __ movp(Operand(rsp, kPointerSize), rax);
|
|
|
| - // Load the arguments.
|
| - { 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(isolate(), arg_count, CALL_AS_METHOD);
|
| - __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
|
| - __ CallStub(&stub);
|
| -
|
| - RecordJSReturnSite(expr);
|
| - // Restore context register.
|
| - __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| -
|
| - context()->DropAndPlug(1, rax);
|
| + EmitCall(expr, CallIC::METHOD);
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitCallWithStub(Call* expr) {
|
| - // Code common for calls using the call stub.
|
| +void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) {
|
| + // Load the arguments.
|
| ZoneList<Expression*>* args = expr->arguments();
|
| int arg_count = args->length();
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| @@ -2654,17 +2615,19 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr) {
|
| VisitForStackValue(args->at(i));
|
| }
|
| }
|
| - // Record source position for debugger.
|
| - SetSourcePosition(expr->position());
|
|
|
| - __ Move(rbx, FeedbackVector());
|
| + // Record source position of the IC call.
|
| + SetSourcePosition(expr->position());
|
| + Handle<Code> ic = CallIC::initialize_stub(
|
| + isolate(), arg_count, call_type);
|
| __ Move(rdx, Smi::FromInt(expr->CallFeedbackSlot()));
|
| -
|
| - // Record call targets in unoptimized code.
|
| - CallFunctionStub stub(isolate(), arg_count, RECORD_CALL_TARGET);
|
| __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
|
| - __ CallStub(&stub);
|
| + // Don't assign a type feedback id to the IC, since type feedback is provided
|
| + // by the vector above.
|
| + CallIC(ic);
|
| +
|
| RecordJSReturnSite(expr);
|
| +
|
| // Restore context register.
|
| __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| // Discard the function left on TOS.
|
| @@ -2741,7 +2704,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| context()->DropAndPlug(1, rax);
|
| } else if (call_type == Call::GLOBAL_CALL) {
|
| - EmitCallWithIC(expr);
|
| + EmitCallWithLoadIC(expr);
|
|
|
| } else if (call_type == Call::LOOKUP_SLOT_CALL) {
|
| // Call to a lookup slot (dynamically introduced variable).
|
| @@ -2778,16 +2741,16 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
|
|
| // The receiver is either the global receiver or an object found by
|
| // LoadContextSlot.
|
| - EmitCallWithStub(expr);
|
| + EmitCall(expr);
|
| } else if (call_type == Call::PROPERTY_CALL) {
|
| Property* property = callee->AsProperty();
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| VisitForStackValue(property->obj());
|
| }
|
| if (property->key()->IsPropertyName()) {
|
| - EmitCallWithIC(expr);
|
| + EmitCallWithLoadIC(expr);
|
| } else {
|
| - EmitKeyedCallWithIC(expr, property->key());
|
| + EmitKeyedCallWithLoadIC(expr, property->key());
|
| }
|
| } else {
|
| ASSERT(call_type == Call::OTHER_CALL);
|
| @@ -2797,7 +2760,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| }
|
| __ PushRoot(Heap::kUndefinedValueRootIndex);
|
| // Emit function call.
|
| - EmitCallWithStub(expr);
|
| + EmitCall(expr);
|
| }
|
|
|
| #ifdef DEBUG
|
| @@ -2843,7 +2806,7 @@ void FullCodeGenerator::VisitCallNew(CallNew* expr) {
|
| __ Move(rbx, FeedbackVector());
|
| __ Move(rdx, Smi::FromInt(expr->CallNewFeedbackSlot()));
|
|
|
| - CallConstructStub stub(isolate(), RECORD_CALL_TARGET);
|
| + CallConstructStub stub(isolate(), RECORD_CONSTRUCTOR_TARGET);
|
| __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL);
|
| PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
|
| context()->Plug(rax);
|
|
|