Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index d2c9a2515fae8e038aa4d3b662bffb9f635c030e..47376d113c1a98f02f8c6287a1f8e5e709d11db0 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -147,15 +147,27 @@ bool LCodeGen::GeneratePrologue() { |
// fp: Caller's frame pointer. |
// lr: Caller's pc. |
- // Strict mode functions and builtins need to replace the receiver |
- // with undefined when called as functions (without an explicit |
- // receiver object). r5 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_->this_has_uses() && |
+ info_->is_classic_mode() && |
+ !info_->is_native()) { |
+ Label ok; |
__ cmp(r5, Operand::Zero()); |
- int receiver_offset = scope()->num_parameters() * kPointerSize; |
- __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
- __ str(r2, MemOperand(sp, receiver_offset), ne); |
+ __ b(eq, &ok); |
+ |
+ int receiver_offset = info_->scope()->num_parameters() * kPointerSize; |
+ __ ldr(r2, MemOperand(sp, receiver_offset)); |
+ __ CompareRoot(r2, Heap::kUndefinedValueRootIndex); |
+ __ b(ne, &ok); |
+ |
+ __ ldr(r2, GlobalObjectOperand()); |
+ __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); |
+ |
+ __ str(r2, MemOperand(sp, receiver_offset)); |
+ |
+ __ bind(&ok); |
} |
} |
@@ -3494,7 +3506,12 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
__ b(&result_in_receiver); |
__ bind(&global_object); |
- CallStubCompiler::FetchGlobalProxy(masm(), receiver, function); |
+ __ ldr(receiver, FieldMemOperand(function, JSFunction::kContextOffset)); |
+ __ ldr(receiver, |
+ ContextOperand(receiver, |
+ Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
+ __ ldr(receiver, |
+ FieldMemOperand(receiver, GlobalObject::kGlobalReceiverOffset)); |
if (result.is(receiver)) { |
__ bind(&result_in_receiver); |
@@ -3552,7 +3569,7 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
// by InvokeFunction. |
ParameterCount actual(receiver); |
__ InvokeFunction(function, actual, CALL_FUNCTION, |
- safepoint_generator, CALL_AS_METHOD); |
+ safepoint_generator, CALL_AS_FUNCTION); |
} |
@@ -3673,7 +3690,7 @@ void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { |
instr->hydrogen()->formal_parameter_count(), |
instr->arity(), |
instr, |
- CALL_AS_METHOD, |
+ CALL_AS_FUNCTION, |
R1_UNINITIALIZED); |
} |
@@ -3951,13 +3968,13 @@ void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) { |
LPointerMap* pointers = instr->pointer_map(); |
SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
ParameterCount count(instr->arity()); |
- __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_METHOD); |
+ __ InvokeFunction(r1, count, CALL_FUNCTION, generator, CALL_AS_FUNCTION); |
} else { |
CallKnownFunction(known_function, |
instr->hydrogen()->formal_parameter_count(), |
instr->arity(), |
instr, |
- CALL_AS_METHOD, |
+ CALL_AS_FUNCTION, |
R1_CONTAINS_TARGET); |
} |
} |
@@ -3992,10 +4009,7 @@ void LCodeGen::DoCallFunction(LCallFunction* instr) { |
ASSERT(ToRegister(instr->result()).is(r0)); |
int arity = instr->arity(); |
- CallFunctionFlags flags = |
- instr->hydrogen()->IsContextualCall() ? |
- RECEIVER_IS_IMPLICIT : NO_CALL_FUNCTION_FLAGS; |
- CallFunctionStub stub(arity, flags); |
+ CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); |
if (instr->hydrogen()->IsTailCall()) { |
if (NeedsEagerFrame()) __ mov(sp, fp); |
__ Jump(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); |