Reviewers: jarin,
Description:
[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).
[email protected]
Please review this at https://codereview.chromium.org/970803002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+21, -3 lines):
M src/compiler/ia32/code-generator-ia32.cc
M src/compiler/x64/code-generator-x64.cc
Index: src/compiler/ia32/code-generator-ia32.cc
diff --git a/src/compiler/ia32/code-generator-ia32.cc
b/src/compiler/ia32/code-generator-ia32.cc
index
7864d90a82672afc5c866125db897eb6b0b3f12c..7adc7131c16b2fe939922cc1000aad7f93d0f073
100644
--- a/src/compiler/ia32/code-generator-ia32.cc
+++ b/src/compiler/ia32/code-generator-ia32.cc
@@ -1119,7 +1119,16 @@ 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()) {
+ __ mov(dst, Operand(ebp,
StandardFrameConstants::kContextOffset));
+ } else {
+ __ push(Operand(ebp, StandardFrameConstants::kContextOffset));
+ __ pop(dst);
+ }
+ } else if (destination->IsRegister()) {
Register dst = g.ToRegister(destination);
__ LoadHeapObject(dst, src);
} else {
Index: src/compiler/x64/code-generator-x64.cc
diff --git a/src/compiler/x64/code-generator-x64.cc
b/src/compiler/x64/code-generator-x64.cc
index
db5a448adc9a0ee689421edeedbd843c58ad2dba..be28bf74d589b5ef08359d6349af79a277c88ef6
100644
--- a/src/compiler/x64/code-generator-x64.cc
+++ b/src/compiler/x64/code-generator-x64.cc
@@ -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;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.