| Index: src/ia32/full-codegen-ia32.cc
|
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
|
| index 04a0f7fe75790bb931a649d15ff95f6083c6fde9..eac3f5a5069bc88dacbc8600a6286a67886198bf 100644
|
| --- a/src/ia32/full-codegen-ia32.cc
|
| +++ b/src/ia32/full-codegen-ia32.cc
|
| @@ -133,22 +133,26 @@ void FullCodeGenerator::Generate() {
|
| }
|
| #endif
|
|
|
| - // Strict mode functions and builtins need to replace the receiver
|
| - // with undefined when called as functions (without an explicit
|
| - // receiver object). ecx is zero for method calls and non-zero for
|
| - // function calls.
|
| - if (!info->is_classic_mode() || info->is_native()) {
|
| + // Classic mode functions and builtins need to replace the receiver with the
|
| + // global proxy when called as functions (without an explicit receiver
|
| + // object).
|
| + if (info->is_classic_mode() && !info->is_native()) {
|
| Label ok;
|
| __ test(ecx, ecx);
|
| __ j(zero, &ok, Label::kNear);
|
| +
|
| // +1 for return address.
|
| int receiver_offset = (info->scope()->num_parameters() + 1) * kPointerSize;
|
| __ mov(ecx, Operand(esp, receiver_offset));
|
| - __ JumpIfSmi(ecx, &ok);
|
| - __ CmpObjectType(ecx, JS_GLOBAL_PROXY_TYPE, ecx);
|
| +
|
| + __ cmp(ecx, isolate()->factory()->undefined_value());
|
| __ j(not_equal, &ok, Label::kNear);
|
| - __ mov(Operand(esp, receiver_offset),
|
| - Immediate(isolate()->factory()->undefined_value()));
|
| +
|
| + __ mov(ecx, GlobalObjectOperand());
|
| + __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
|
| +
|
| + __ mov(Operand(esp, receiver_offset), ecx);
|
| +
|
| __ bind(&ok);
|
| }
|
|
|
| @@ -2688,7 +2692,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| }
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| - CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT);
|
| + CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
|
| __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize));
|
| __ CallStub(&stub);
|
| RecordJSReturnSite(expr);
|
| @@ -2727,14 +2731,13 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| __ push(eax);
|
| // The receiver is implicitly the global receiver. Indicate this by
|
| // passing the hole to the call function stub.
|
| - __ push(Immediate(isolate()->factory()->the_hole_value()));
|
| + __ push(Immediate(isolate()->factory()->undefined_value()));
|
| __ bind(&call);
|
| }
|
|
|
| // The receiver is either the global receiver or an object found by
|
| - // LoadContextSlot. That object could be the hole if the receiver is
|
| - // implicitly the global object.
|
| - EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT);
|
| + // LoadContextSlot.
|
| + EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
|
|
| } else if (property != NULL) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| @@ -2753,11 +2756,9 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| VisitForStackValue(callee);
|
| }
|
| - // Push the hole as receiver.
|
| - // It will be correctly replaced in the call stub.
|
| - __ push(Immediate(isolate()->factory()->the_hole_value()));
|
| + __ push(Immediate(isolate()->factory()->undefined_value()));
|
| // Emit function call.
|
| - EmitCallWithStub(expr, RECEIVER_IS_IMPLICIT);
|
| + EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
| }
|
|
|
| #ifdef DEBUG
|
| @@ -3693,7 +3694,7 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
|
| __ mov(edi, result_register());
|
| ParameterCount count(arg_count);
|
| __ InvokeFunction(edi, count, CALL_FUNCTION,
|
| - NullCallWrapper(), CALL_AS_METHOD);
|
| + NullCallWrapper(), CALL_AS_FUNCTION);
|
| __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
|
| __ jmp(&done);
|
|
|
|
|