Index: src/x87/full-codegen-x87.cc |
diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc |
index 450953aba7973a137e6b997e3b8e62bd8cf84bc3..794b2cc19e954e9b259d11eee58cfd5ad8d095d1 100644 |
--- a/src/x87/full-codegen-x87.cc |
+++ b/src/x87/full-codegen-x87.cc |
@@ -3017,6 +3017,49 @@ void FullCodeGenerator::EmitInitializeThisAfterSuper( |
} |
+// See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
+void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
+ VariableProxy* callee = expr->expression()->AsVariableProxy(); |
+ if (callee->var()->IsLookupSlot()) { |
+ Label slow, done; |
+ SetSourcePosition(callee->position()); |
+ { |
+ PreservePositionScope scope(masm()->positions_recorder()); |
+ // Generate code for loading from variables potentially shadowed by |
+ // eval-introduced variables. |
+ EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); |
+ } |
+ __ bind(&slow); |
+ // Call the runtime to find the function to call (returned in eax) and |
+ // the object holding it (returned in edx). |
+ __ push(context_register()); |
+ __ push(Immediate(callee->name())); |
+ __ CallRuntime(Runtime::kLoadLookupSlot, 2); |
+ __ push(eax); // Function. |
+ __ push(edx); // Receiver. |
+ PrepareForBailoutForId(expr->LookupId(), NO_REGISTERS); |
+ |
+ // If fast case code has been generated, emit code to push the function |
+ // and receiver and have the slow path jump around this code. |
+ if (done.is_linked()) { |
+ Label call; |
+ __ jmp(&call, Label::kNear); |
+ __ bind(&done); |
+ // Push function. |
+ __ push(eax); |
+ // The receiver is implicitly the global receiver. Indicate this by |
+ // passing the hole to the call function stub. |
+ __ push(Immediate(isolate()->factory()->undefined_value())); |
+ __ bind(&call); |
+ } |
+ } else { |
+ VisitForStackValue(callee); |
+ // refEnv.WithBaseObject() |
+ __ push(Immediate(isolate()->factory()->undefined_value())); |
+ } |
+} |
+ |
+ |
void FullCodeGenerator::VisitCall(Call* expr) { |
#ifdef DEBUG |
// We want to verify that RecordJSReturnSite gets called on all paths |
@@ -3035,9 +3078,8 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
ZoneList<Expression*>* args = expr->arguments(); |
int arg_count = args->length(); |
{ PreservePositionScope pos_scope(masm()->positions_recorder()); |
- VisitForStackValue(callee); |
- // Reserved receiver slot. |
- __ push(Immediate(isolate()->factory()->undefined_value())); |
+ PushCalleeAndWithBaseObject(expr); |
+ |
// Push the arguments. |
for (int i = 0; i < arg_count; i++) { |
VisitForStackValue(args->at(i)); |
@@ -3051,7 +3093,7 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
// Touch up the stack with the resolved function. |
__ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax); |
- PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); |
+ PrepareForBailoutForId(expr->EvalId(), NO_REGISTERS); |
} |
// Record source position for debugger. |
SetSourcePosition(expr->position()); |
@@ -3067,41 +3109,8 @@ void FullCodeGenerator::VisitCall(Call* expr) { |
EmitCallWithLoadIC(expr); |
} else if (call_type == Call::LOOKUP_SLOT_CALL) { |
// Call to a lookup slot (dynamically introduced variable). |
- VariableProxy* proxy = callee->AsVariableProxy(); |
- Label slow, done; |
- { PreservePositionScope scope(masm()->positions_recorder()); |
- // Generate code for loading from variables potentially shadowed by |
- // eval-introduced variables. |
- EmitDynamicLookupFastCase(proxy, NOT_INSIDE_TYPEOF, &slow, &done); |
- } |
- __ bind(&slow); |
- // Call the runtime to find the function to call (returned in eax) and |
- // the object holding it (returned in edx). |
- __ push(context_register()); |
- __ push(Immediate(proxy->name())); |
- __ CallRuntime(Runtime::kLoadLookupSlot, 2); |
- __ push(eax); // Function. |
- __ push(edx); // Receiver. |
- PrepareForBailoutForId(expr->EvalOrLookupId(), NO_REGISTERS); |
- |
- // If fast case code has been generated, emit code to push the function |
- // and receiver and have the slow path jump around this code. |
- if (done.is_linked()) { |
- Label call; |
- __ jmp(&call, Label::kNear); |
- __ bind(&done); |
- // Push function. |
- __ push(eax); |
- // The receiver is implicitly the global receiver. Indicate this by |
- // passing the hole to the call function stub. |
- __ push(Immediate(isolate()->factory()->undefined_value())); |
- __ bind(&call); |
- } |
- |
- // The receiver is either the global receiver or an object found by |
- // LoadContextSlot. |
+ PushCalleeAndWithBaseObject(expr); |
EmitCall(expr); |
- |
} else if (call_type == Call::PROPERTY_CALL) { |
Property* property = callee->AsProperty(); |
bool is_named_call = property->key()->IsPropertyName(); |