Index: src/arm/lithium-codegen-arm.cc |
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc |
index 4e1cc2f7a58bce915542263d8f182b8058f34463..c81d3e963900f4f4da120a8c9c6b24f6e0818ad1 100644 |
--- a/src/arm/lithium-codegen-arm.cc |
+++ b/src/arm/lithium-codegen-arm.cc |
@@ -3496,12 +3496,13 @@ void LCodeGen::DoArgumentsLength(LArgumentsLength* instr) { |
void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
Register receiver = ToRegister(instr->receiver()); |
Register function = ToRegister(instr->function()); |
+ Register result = ToRegister(instr->result()); |
Register scratch = scratch0(); |
// If the receiver is null or undefined, we have to pass the global |
// object as a receiver to normal functions. Values have to be |
// passed unchanged to builtins and strict-mode functions. |
- Label global_object, receiver_ok; |
+ Label global_object, result_in_receiver; |
// Do not transform the receiver to object for strict mode |
// functions. |
@@ -3511,11 +3512,11 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
FieldMemOperand(scratch, SharedFunctionInfo::kCompilerHintsOffset)); |
__ tst(scratch, |
Operand(1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize))); |
- __ b(ne, &receiver_ok); |
+ __ b(ne, &result_in_receiver); |
// Do not transform the receiver to object for builtins. |
__ tst(scratch, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); |
- __ b(ne, &receiver_ok); |
+ __ b(ne, &result_in_receiver); |
// Normal function. Replace undefined or null with global receiver. |
__ LoadRoot(scratch, Heap::kNullValueRootIndex); |
@@ -3530,13 +3531,21 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { |
DeoptimizeIf(eq, instr->environment()); |
__ CompareObjectType(receiver, scratch, scratch, FIRST_SPEC_OBJECT_TYPE); |
DeoptimizeIf(lt, instr->environment()); |
- __ jmp(&receiver_ok); |
+ __ b(&result_in_receiver); |
__ bind(&global_object); |
- __ ldr(receiver, GlobalObjectOperand()); |
- __ ldr(receiver, |
- FieldMemOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); |
- __ bind(&receiver_ok); |
+ __ ldr(result, GlobalObjectOperand()); |
+ __ ldr(result, |
+ FieldMemOperand(result, JSGlobalObject::kGlobalReceiverOffset)); |
+ if (result.is(receiver)) { |
+ __ bind(&result_in_receiver); |
+ } else { |
+ Label result_ok; |
+ __ b(&result_ok); |
+ __ bind(&result_in_receiver); |
+ __ mov(result, receiver); |
+ __ bind(&result_ok); |
+ } |
} |