Commit 502898ef authored by Benedikt Meurer's avatar Benedikt Meurer

[x86] Improve code generation for context materialization.

On Intel targets, it is cheaper to load the context from the frame
instead of loading the context as a constant (which usually involves a
PropertyCell because the context is in new space when we compile the
function).

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/970803002

Cr-Commit-Position: refs/heads/master@{#26935}
parent 155278d6
......@@ -1119,7 +1119,19 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
Constant src_constant = g.ToConstant(source);
if (src_constant.type() == Constant::kHeapObject) {
Handle<HeapObject> src = src_constant.ToHeapObject();
if (destination->IsRegister()) {
if (info()->IsOptimizing() && src.is_identical_to(info()->context())) {
// Loading the context from the frame is way cheaper than materializing
// the actual context heap object address.
if (destination->IsRegister()) {
Register dst = g.ToRegister(destination);
__ mov(dst, Operand(ebp, StandardFrameConstants::kContextOffset));
} else {
DCHECK(destination->IsStackSlot());
Operand dst = g.ToOperand(destination);
__ push(Operand(ebp, StandardFrameConstants::kContextOffset));
__ pop(dst);
}
} else if (destination->IsRegister()) {
Register dst = g.ToRegister(destination);
__ LoadHeapObject(dst, src);
} else {
......
......@@ -1309,9 +1309,18 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
case Constant::kExternalReference:
__ Move(dst, 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.
__ movp(dst, Operand(rbp, StandardFrameConstants::kContextOffset));
} else {
__ Move(dst, src_object);
}
break;
}
case Constant::kRpoNumber:
UNREACHABLE(); // TODO(dcarney): load of labels on x64.
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment