[interpreter] Don't keep postfix result if only visited for effect
Remove TODO to perform same optimization as AstGraphBuilder. When visiting for effect in a postfix count operation, don't keep the intermediate result of ToNumber. BUG=v4:4280 LOG=n Review-Url: https://codereview.chromium.org/2187823002 Cr-Commit-Position: refs/heads/master@{#38101}
This commit is contained in:
parent
31eefa438a
commit
27a9b032ab
@ -2782,8 +2782,7 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
|
||||
Property* property = expr->expression()->AsProperty();
|
||||
LhsKind assign_type = Property::GetAssignType(property);
|
||||
|
||||
// TODO(rmcilroy): Set is_postfix to false if visiting for effect.
|
||||
bool is_postfix = expr->is_postfix();
|
||||
bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect();
|
||||
|
||||
// Evaluate LHS expression and get old value.
|
||||
Register object, home_object, key, old_value, value;
|
||||
|
@ -99,7 +99,7 @@ snippet: "
|
||||
"
|
||||
frame size: 3
|
||||
parameter count: 1
|
||||
bytecode array length: 28
|
||||
bytecode array length: 26
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaSmi), U8(55),
|
||||
@ -112,8 +112,7 @@ bytecodes: [
|
||||
B(Star), R(0),
|
||||
/* 68 E> */ B(Add), R(2),
|
||||
B(Star), R(0),
|
||||
/* 75 S> */ B(ToNumber), R(1),
|
||||
B(Inc),
|
||||
/* 75 S> */ B(Inc),
|
||||
B(Star), R(0),
|
||||
/* 80 S> */ B(Nop),
|
||||
/* 90 S> */ B(Return),
|
||||
|
@ -679,15 +679,15 @@ snippet: "
|
||||
}
|
||||
}
|
||||
"
|
||||
frame size: 7
|
||||
frame size: 6
|
||||
parameter count: 1
|
||||
bytecode array length: 118
|
||||
bytecode array length: 116
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaZero),
|
||||
B(Star), R(1),
|
||||
/* 52 S> */ B(Ldar), R(1),
|
||||
B(JumpIfToBooleanFalse), U8(110),
|
||||
B(JumpIfToBooleanFalse), U8(108),
|
||||
/* 45 E> */ B(StackCheck),
|
||||
B(LdaConstant), U8(0),
|
||||
B(Star), R(4),
|
||||
@ -714,24 +714,23 @@ bytecodes: [
|
||||
B(JumpIfToBooleanFalse), U8(8),
|
||||
/* 113 S> */ B(PopContext), R(3),
|
||||
B(PopContext), R(3),
|
||||
B(Jump), U8(42),
|
||||
B(Jump), U8(40),
|
||||
/* 126 S> */ B(LdaContextSlot), R(context), U8(4),
|
||||
B(JumpIfNotHole), U8(11),
|
||||
B(LdaConstant), U8(3),
|
||||
B(Star), R(4),
|
||||
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1),
|
||||
B(ToNumber), R(4),
|
||||
B(Inc),
|
||||
B(Star), R(5),
|
||||
B(Star), R(4),
|
||||
/* 127 E> */ B(LdaContextSlot), R(context), U8(4),
|
||||
B(JumpIfNotHole), U8(11),
|
||||
B(LdaConstant), U8(3),
|
||||
B(Star), R(6),
|
||||
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(6), U8(1),
|
||||
B(Ldar), R(5),
|
||||
B(Star), R(5),
|
||||
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(5), U8(1),
|
||||
B(Ldar), R(4),
|
||||
B(StaContextSlot), R(context), U8(4),
|
||||
B(PopContext), R(3),
|
||||
B(Jump), U8(-110),
|
||||
B(Jump), U8(-108),
|
||||
B(LdaUndefined),
|
||||
/* 137 S> */ B(Return),
|
||||
]
|
||||
|
@ -327,9 +327,9 @@ snippet: "
|
||||
}
|
||||
return 3;
|
||||
"
|
||||
frame size: 3
|
||||
frame size: 2
|
||||
parameter count: 1
|
||||
bytecode array length: 1409
|
||||
bytecode array length: 1407
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 42 S> */ B(LdaConstant), U8(0),
|
||||
@ -960,7 +960,7 @@ bytecodes: [
|
||||
B(Star), R(1),
|
||||
/* 4108 S> */ B(LdaSmi), U8(3),
|
||||
/* 4108 E> */ B(TestLessThan), R(1),
|
||||
B(Wide), B(JumpIfFalse), U16(37),
|
||||
B(Wide), B(JumpIfFalse), U16(35),
|
||||
/* 4090 E> */ B(StackCheck),
|
||||
/* 4122 S> */ B(LdaSmi), U8(1),
|
||||
/* 4128 E> */ B(TestEqual), R(1),
|
||||
@ -969,12 +969,11 @@ bytecodes: [
|
||||
/* 4146 S> */ B(LdaSmi), U8(2),
|
||||
/* 4152 E> */ B(TestEqual), R(1),
|
||||
B(Wide), B(JumpIfFalse), U16(7),
|
||||
/* 4158 S> */ B(Wide), B(Jump), U16(12),
|
||||
/* 4158 S> */ B(Wide), B(Jump), U16(10),
|
||||
/* 4114 S> */ B(Ldar), R(1),
|
||||
B(ToNumber), R(2),
|
||||
B(Inc),
|
||||
B(Star), R(1),
|
||||
B(Jump), U8(-40),
|
||||
B(Jump), U8(-38),
|
||||
/* 4167 S> */ B(LdaSmi), U8(3),
|
||||
/* 4177 S> */ B(Return),
|
||||
]
|
||||
|
@ -893,7 +893,7 @@ snippet: "
|
||||
"
|
||||
frame size: 158
|
||||
parameter count: 1
|
||||
bytecode array length: 55
|
||||
bytecode array length: 51
|
||||
bytecodes: [
|
||||
/* 30 E> */ B(StackCheck),
|
||||
/* 1503 S> */ B(LdaZero),
|
||||
@ -904,17 +904,16 @@ bytecodes: [
|
||||
B(Wide), B(Star), R16(128),
|
||||
/* 1538 S> */ B(LdaSmi), U8(64),
|
||||
/* 1538 E> */ B(Wide), B(TestLessThan), R16(128),
|
||||
B(JumpIfFalse), U8(32),
|
||||
B(JumpIfFalse), U8(28),
|
||||
/* 1518 E> */ B(StackCheck),
|
||||
/* 1555 S> */ B(Wide), B(Ldar), R16(128),
|
||||
/* 1561 E> */ B(Add), R(1),
|
||||
B(Wide), B(Mov), R16(1), R16(157),
|
||||
B(Star), R(1),
|
||||
/* 1548 S> */ B(Wide), B(Ldar), R16(128),
|
||||
B(Wide), B(ToNumber), R16(157),
|
||||
B(Inc),
|
||||
B(Wide), B(Star), R16(128),
|
||||
B(Jump), U8(-36),
|
||||
B(Jump), U8(-32),
|
||||
/* 1567 S> */ B(Wide), B(Ldar), R16(128),
|
||||
/* 1580 S> */ B(Return),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user