Index: src/compiler/arm/code-generator-arm.cc |
diff --git a/src/compiler/arm/code-generator-arm.cc b/src/compiler/arm/code-generator-arm.cc |
index 6ea5e1bde2c22347b16eeeededd3d657f163cc46..059dadd5e021c37ed805c54d4b625543bb47ca73 100644 |
--- a/src/compiler/arm/code-generator-arm.cc |
+++ b/src/compiler/arm/code-generator-arm.cc |
@@ -1015,9 +1015,24 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, |
case Constant::kExternalReference: |
__ mov(dst, Operand(src.ToExternalReference())); |
break; |
- case Constant::kHeapObject: |
- __ Move(dst, src.ToHeapObject()); |
+ case Constant::kHeapObject: { |
+ Handle<HeapObject> src_object = src.ToHeapObject(); |
+ if (info()->IsOptimizing() && |
+ src_object.is_identical_to(info()->context())) { |
+ // Loading the context from the frame is way cheaper than |
+ // materializing the actual context heap object address. |
+ __ ldr(dst, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
+ } else if (info()->IsOptimizing() && |
+ src_object.is_identical_to(info()->closure())) { |
+ // Loading the JSFunction from the frame is way cheaper than |
+ // materializing the actual JSFunction heap object address. |
+ __ ldr(dst, |
+ MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
+ } else { |
+ __ Move(dst, src_object); |
+ } |
break; |
+ } |
case Constant::kRpoNumber: |
UNREACHABLE(); // TODO(dcarney): loading RPO constants on arm. |
break; |