diff --git a/src/compiler/ppc/code-generator-ppc.cc b/src/compiler/ppc/code-generator-ppc.cc index 8644c36941..2ebb840a9d 100644 --- a/src/compiler/ppc/code-generator-ppc.cc +++ b/src/compiler/ppc/code-generator-ppc.cc @@ -1348,9 +1348,25 @@ 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 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. + __ LoadP(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. + __ LoadP(dst, + MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); + } else { + __ Move(dst, src_object); + } break; + } case Constant::kRpoNumber: UNREACHABLE(); // TODO(dcarney): loading RPO constants on PPC. break;