case Constant::kExternalReference:
__ li(dst, Operand(src.ToExternalReference()));
break;
- case Constant::kHeapObject:
- __ li(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.
+ __ lw(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.
+ __ lw(dst,
+ MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
+ } else {
+ __ li(dst, src_object);
+ }
break;
+ }
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(titzer): loading RPO numbers on mips.
break;
case Constant::kExternalReference:
__ li(dst, Operand(src.ToExternalReference()));
break;
- case Constant::kHeapObject:
- __ li(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.
+ __ ld(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.
+ __ ld(dst,
+ MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
+ } else {
+ __ li(dst, src_object);
+ }
break;
+ }
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(titzer): loading RPO numbers on mips64.
break;