Commit 0f7356e6 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Interpreter] Only materialize output register if in a different equivalence set.

We only need to materialize the existing output register for a given
register transfer if it is in a different equivalence set, otherwise we
already have the value we want in the output register.

BUG=v8:4280

Change-Id: Ic4966590ac10445180aff353940d2c93e6a818aa
Reviewed-on: https://chromium-review.googlesource.com/493168Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45051}
parent 7991d960
......@@ -318,6 +318,15 @@ void BytecodeRegisterOptimizer::AddToEquivalenceSet(
void BytecodeRegisterOptimizer::RegisterTransfer(RegisterInfo* input_info,
RegisterInfo* output_info) {
bool output_is_observable =
RegisterIsObservable(output_info->register_value());
bool in_same_equivalence_set =
output_info->IsInSameEquivalenceSet(input_info);
if (in_same_equivalence_set &&
(!output_is_observable || output_info->materialized())) {
return; // Nothing more to do.
}
// Materialize an alternate in the equivalence set that
// |output_info| is leaving.
if (output_info->materialized()) {
......@@ -325,12 +334,10 @@ void BytecodeRegisterOptimizer::RegisterTransfer(RegisterInfo* input_info,
}
// Add |output_info| to new equivalence set.
if (!output_info->IsInSameEquivalenceSet(input_info)) {
if (!in_same_equivalence_set) {
AddToEquivalenceSet(input_info, output_info);
}
bool output_is_observable =
RegisterIsObservable(output_info->register_value());
if (output_is_observable) {
// Force store to be emitted when register is observable.
output_info->set_materialized(false);
......
......@@ -118,7 +118,7 @@ snippet: "
"
frame size: 10
parameter count: 1
bytecode array length: 116
bytecode array length: 114
bytecodes: [
B(CreateFunctionContext), U8(2),
B(PushContext), R(3),
......@@ -158,7 +158,6 @@ bytecodes: [
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowStaticPrototypeError), R(0), U8(0),
B(CreateClosure), U8(5), U8(4), U8(2),
B(Star), R(8),
B(StaDataPropertyInLiteral), R(6), R(7), U8(3), U8(7),
B(CallRuntime), U16(Runtime::kInstallClassNameAccessorWithCheck), R(4), U8(1),
B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1),
......
......@@ -58,9 +58,9 @@ bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1),
B(Mov), R(1), R(0),
/* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(3),
/* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(3),
B(MulSmi), I8(2), U8(5),
/* 61 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(6),
/* 61 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(6),
B(LdaUndefined),
/* 67 S> */ B(Return),
]
......@@ -84,9 +84,9 @@ bytecodes: [
B(Mov), R(1), R(0),
/* 52 S> */ B(LdaSmi), I8(1),
B(Star), R(2),
B(LdaKeyedProperty), R(0), U8(3),
B(LdaKeyedProperty), R(1), U8(3),
B(BitwiseXorSmi), I8(2), U8(5),
/* 57 E> */ B(StaKeyedPropertySloppy), R(0), R(2), U8(6),
/* 57 E> */ B(StaKeyedPropertySloppy), R(1), R(2), U8(6),
B(LdaUndefined),
/* 63 S> */ B(Return),
]
......
......@@ -102,11 +102,11 @@ bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1),
B(Mov), R(1), R(0),
/* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(3),
/* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(3),
B(ToNumber), R(2), U8(7),
B(Ldar), R(2),
B(Inc), U8(7),
/* 66 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(5),
/* 66 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(5),
B(Ldar), R(2),
/* 70 S> */ B(Return),
]
......@@ -128,9 +128,9 @@ bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1),
B(Mov), R(1), R(0),
/* 54 S> */ B(LdaNamedProperty), R(0), U8(1), U8(3),
/* 54 S> */ B(LdaNamedProperty), R(1), U8(1), U8(3),
B(Dec), U8(7),
/* 65 E> */ B(StaNamedPropertySloppy), R(0), U8(1), U8(5),
/* 65 E> */ B(StaNamedPropertySloppy), R(1), U8(1), U8(5),
/* 70 S> */ B(Return),
]
constant pool: [
......@@ -154,11 +154,11 @@ bytecodes: [
/* 60 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(1), R(2),
B(Mov), R(2), R(1),
/* 72 S> */ B(Ldar), R(0),
/* 81 E> */ B(LdaKeyedProperty), R(1), U8(3),
/* 81 E> */ B(LdaKeyedProperty), R(2), U8(3),
B(ToNumber), R(4), U8(7),
B(Ldar), R(4),
B(Dec), U8(7),
/* 86 E> */ B(StaKeyedPropertySloppy), R(1), R(0), U8(5),
/* 86 E> */ B(StaKeyedPropertySloppy), R(2), R(0), U8(5),
B(Ldar), R(4),
/* 90 S> */ B(Return),
]
......@@ -183,9 +183,9 @@ bytecodes: [
/* 60 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(1), R(2),
B(Mov), R(2), R(1),
/* 72 S> */ B(Ldar), R(0),
/* 83 E> */ B(LdaKeyedProperty), R(1), U8(3),
/* 83 E> */ B(LdaKeyedProperty), R(2), U8(3),
B(Inc), U8(7),
/* 87 E> */ B(StaKeyedPropertySloppy), R(1), R(0), U8(5),
/* 87 E> */ B(StaKeyedPropertySloppy), R(2), R(0), U8(5),
/* 90 S> */ B(Return),
]
constant pool: [
......
......@@ -17,7 +17,7 @@ bytecodes: [
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1),
B(Mov), R(1), R(0),
/* 56 S> */ B(LdaConstant), U8(1),
B(DeletePropertySloppy), R(0),
B(DeletePropertySloppy), R(1),
/* 75 S> */ B(Return),
]
constant pool: [
......@@ -39,7 +39,7 @@ bytecodes: [
/* 56 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1),
B(Mov), R(1), R(0),
/* 70 S> */ B(LdaConstant), U8(1),
B(DeletePropertyStrict), R(0),
B(DeletePropertyStrict), R(1),
/* 89 S> */ B(Return),
]
constant pool: [
......@@ -61,7 +61,7 @@ bytecodes: [
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(2), U8(1), R(1),
B(Mov), R(1), R(0),
/* 56 S> */ B(LdaSmi), I8(2),
B(DeletePropertySloppy), R(0),
B(DeletePropertySloppy), R(1),
/* 76 S> */ B(Return),
]
constant pool: [
......
......@@ -50,8 +50,8 @@ bytecodes: [
B(Star), R(13),
B(Ldar), R(closure),
B(CreateCatchContext), R(13), U8(5), U8(6),
B(Star), R(12),
B(PushContext), R(8),
B(Star), R(12),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(4), U8(15),
B(JumpIfFalse), U8(6),
......@@ -191,8 +191,8 @@ bytecodes: [
B(Star), R(14),
B(Ldar), R(closure),
B(CreateCatchContext), R(14), U8(5), U8(6),
B(Star), R(13),
B(PushContext), R(9),
B(Star), R(13),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(5), U8(14),
B(JumpIfFalse), U8(6),
......@@ -345,8 +345,8 @@ bytecodes: [
B(Star), R(13),
B(Ldar), R(closure),
B(CreateCatchContext), R(13), U8(5), U8(6),
B(Star), R(12),
B(PushContext), R(8),
B(Star), R(12),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(4), U8(17),
B(JumpIfFalse), U8(6),
......@@ -489,8 +489,8 @@ bytecodes: [
B(Star), R(12),
B(Ldar), R(closure),
B(CreateCatchContext), R(12), U8(7), U8(8),
B(Star), R(11),
B(PushContext), R(7),
B(Star), R(11),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(3), U8(20),
B(JumpIfFalse), U8(6),
......
......@@ -60,8 +60,8 @@ bytecodes: [
B(Star), R(15),
B(Ldar), R(closure),
/* 49 E> */ B(CreateCatchContext), R(15), U8(4), U8(5),
B(Star), R(14),
B(PushContext), R(10),
B(Star), R(14),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(6), U8(14),
B(JumpIfFalse), U8(6),
......@@ -238,8 +238,8 @@ bytecodes: [
B(Star), R(14),
B(Ldar), R(closure),
B(CreateCatchContext), R(14), U8(8), U8(9),
B(Star), R(13),
B(PushContext), R(9),
B(Star), R(13),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(3), U8(18),
B(JumpIfFalse), U8(6),
......@@ -395,8 +395,8 @@ bytecodes: [
B(Star), R(13),
B(Ldar), R(closure),
B(CreateCatchContext), R(13), U8(6), U8(7),
B(Star), R(12),
B(PushContext), R(8),
B(Star), R(12),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(4), U8(17),
B(JumpIfFalse), U8(6),
......@@ -563,8 +563,8 @@ bytecodes: [
B(Star), R(18),
B(Ldar), R(closure),
/* 58 E> */ B(CreateCatchContext), R(18), U8(7), U8(8),
B(Star), R(17),
B(PushContext), R(13),
B(Star), R(17),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(9), U8(21),
B(JumpIfFalse), U8(6),
......@@ -791,8 +791,8 @@ bytecodes: [
B(Star), R(13),
B(Ldar), R(closure),
B(CreateCatchContext), R(13), U8(7), U8(8),
B(Star), R(12),
B(PushContext), R(2),
B(Star), R(12),
B(LdaContextSlot), R(1), U8(10), U8(0),
B(Star), R(13),
B(LdaSmi), I8(2),
......@@ -1133,8 +1133,8 @@ bytecodes: [
B(Star), R(12),
B(Ldar), R(closure),
B(CreateCatchContext), R(12), U8(6), U8(7),
B(Star), R(11),
B(PushContext), R(2),
B(Star), R(11),
B(LdaContextSlot), R(1), U8(10), U8(0),
B(Star), R(12),
B(LdaSmi), I8(2),
......
......@@ -448,8 +448,8 @@ bytecodes: [
B(Star), R(12),
B(Ldar), R(closure),
B(CreateCatchContext), R(12), U8(7), U8(8),
B(Star), R(11),
B(PushContext), R(2),
B(Star), R(11),
B(LdaContextSlot), R(1), U8(9), U8(0),
B(Star), R(12),
B(LdaSmi), I8(2),
......
......@@ -53,7 +53,7 @@ snippet: "
"
frame size: 3
parameter count: 1
bytecode array length: 29
bytecode array length: 26
bytecodes: [
B(LdaTheHole),
B(Star), R(0),
......@@ -65,7 +65,6 @@ bytecodes: [
B(LdaConstant), U8(0),
B(Star), R(2),
/* 45 E> */ B(CallRuntime), U16(Runtime::kThrowReferenceError), R(2), U8(1),
B(Mov), R(1), R(0),
B(Mov), R(1), R(0),
B(LdaUndefined),
/* 52 S> */ B(Return),
......
......@@ -281,9 +281,9 @@ handlers: [
snippet: "
var a = 'test'; return { [a]: 1 };
"
frame size: 4
frame size: 3
parameter count: 1
bytecode array length: 24
bytecode array length: 22
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaConstant), U8(0),
......@@ -291,7 +291,6 @@ bytecodes: [
/* 50 S> */ B(CreateObjectLiteral), U8(1), U8(2), U8(67), R(1),
/* 60 E> */ B(ToName), R(2),
B(LdaSmi), I8(1),
B(Star), R(3),
B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(3),
B(Ldar), R(1),
/* 69 S> */ B(Return),
......@@ -307,9 +306,9 @@ handlers: [
snippet: "
var a = 'test'; return { val: a, [a]: 1 };
"
frame size: 4
frame size: 3
parameter count: 1
bytecode array length: 28
bytecode array length: 26
bytecodes: [
/* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaConstant), U8(0),
......@@ -318,7 +317,6 @@ bytecodes: [
/* 64 E> */ B(StaNamedOwnProperty), R(1), U8(2), U8(3),
/* 68 E> */ B(ToName), R(2),
B(LdaSmi), I8(1),
B(Star), R(3),
B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(5),
B(Ldar), R(1),
/* 77 S> */ B(Return),
......@@ -345,9 +343,9 @@ bytecodes: [
/* 50 S> */ B(CreateObjectLiteral), U8(1), U8(3), U8(67), R(1),
/* 60 E> */ B(ToName), R(2),
B(LdaSmi), I8(1),
B(Star), R(3),
B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(4),
B(CreateObjectLiteral), U8(1), U8(2), U8(67), R(4),
B(Star), R(3),
B(Mov), R(1), R(2),
B(Mov), R(4), R(3),
B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(2), U8(2),
......@@ -375,8 +373,8 @@ bytecodes: [
/* 50 S> */ B(CreateObjectLiteral), U8(1), U8(4), U8(67), R(1),
/* 60 E> */ B(ToName), R(2),
B(LdaConstant), U8(2),
B(Star), R(3),
B(StaDataPropertyInLiteral), R(1), R(2), U8(0), U8(5),
B(Star), R(3),
B(LdaConstant), U8(3),
B(Star), R(3),
B(CreateClosure), U8(4), U8(2), U8(2),
......
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