Commit 27a9b032 authored by klaasb's avatar klaasb Committed by Commit bot

[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}
parent 31eefa43
...@@ -2782,8 +2782,7 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { ...@@ -2782,8 +2782,7 @@ void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
Property* property = expr->expression()->AsProperty(); Property* property = expr->expression()->AsProperty();
LhsKind assign_type = Property::GetAssignType(property); LhsKind assign_type = Property::GetAssignType(property);
// TODO(rmcilroy): Set is_postfix to false if visiting for effect. bool is_postfix = expr->is_postfix() && !execution_result()->IsEffect();
bool is_postfix = expr->is_postfix();
// Evaluate LHS expression and get old value. // Evaluate LHS expression and get old value.
Register object, home_object, key, old_value, value; Register object, home_object, key, old_value, value;
......
...@@ -99,7 +99,7 @@ snippet: " ...@@ -99,7 +99,7 @@ snippet: "
" "
frame size: 3 frame size: 3
parameter count: 1 parameter count: 1
bytecode array length: 28 bytecode array length: 26
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaSmi), U8(55), /* 42 S> */ B(LdaSmi), U8(55),
...@@ -112,8 +112,7 @@ bytecodes: [ ...@@ -112,8 +112,7 @@ bytecodes: [
B(Star), R(0), B(Star), R(0),
/* 68 E> */ B(Add), R(2), /* 68 E> */ B(Add), R(2),
B(Star), R(0), B(Star), R(0),
/* 75 S> */ B(ToNumber), R(1), /* 75 S> */ B(Inc),
B(Inc),
B(Star), R(0), B(Star), R(0),
/* 80 S> */ B(Nop), /* 80 S> */ B(Nop),
/* 90 S> */ B(Return), /* 90 S> */ B(Return),
......
...@@ -679,15 +679,15 @@ snippet: " ...@@ -679,15 +679,15 @@ snippet: "
} }
} }
" "
frame size: 7 frame size: 6
parameter count: 1 parameter count: 1
bytecode array length: 118 bytecode array length: 116
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaZero), /* 42 S> */ B(LdaZero),
B(Star), R(1), B(Star), R(1),
/* 52 S> */ B(Ldar), R(1), /* 52 S> */ B(Ldar), R(1),
B(JumpIfToBooleanFalse), U8(110), B(JumpIfToBooleanFalse), U8(108),
/* 45 E> */ B(StackCheck), /* 45 E> */ B(StackCheck),
B(LdaConstant), U8(0), B(LdaConstant), U8(0),
B(Star), R(4), B(Star), R(4),
...@@ -714,24 +714,23 @@ bytecodes: [ ...@@ -714,24 +714,23 @@ bytecodes: [
B(JumpIfToBooleanFalse), U8(8), B(JumpIfToBooleanFalse), U8(8),
/* 113 S> */ B(PopContext), R(3), /* 113 S> */ B(PopContext), R(3),
B(PopContext), R(3), B(PopContext), R(3),
B(Jump), U8(42), B(Jump), U8(40),
/* 126 S> */ B(LdaContextSlot), R(context), U8(4), /* 126 S> */ B(LdaContextSlot), R(context), U8(4),
B(JumpIfNotHole), U8(11), B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(3), B(LdaConstant), U8(3),
B(Star), R(4), B(Star), R(4),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1), B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1),
B(ToNumber), R(4),
B(Inc), B(Inc),
B(Star), R(5), B(Star), R(4),
/* 127 E> */ B(LdaContextSlot), R(context), U8(4), /* 127 E> */ B(LdaContextSlot), R(context), U8(4),
B(JumpIfNotHole), U8(11), B(JumpIfNotHole), U8(11),
B(LdaConstant), U8(3), B(LdaConstant), U8(3),
B(Star), R(6), B(Star), R(5),
B(CallRuntime), U16(Runtime::kThrowReferenceError), R(6), U8(1), B(CallRuntime), U16(Runtime::kThrowReferenceError), R(5), U8(1),
B(Ldar), R(5), B(Ldar), R(4),
B(StaContextSlot), R(context), U8(4), B(StaContextSlot), R(context), U8(4),
B(PopContext), R(3), B(PopContext), R(3),
B(Jump), U8(-110), B(Jump), U8(-108),
B(LdaUndefined), B(LdaUndefined),
/* 137 S> */ B(Return), /* 137 S> */ B(Return),
] ]
......
...@@ -327,9 +327,9 @@ snippet: " ...@@ -327,9 +327,9 @@ snippet: "
} }
return 3; return 3;
" "
frame size: 3 frame size: 2
parameter count: 1 parameter count: 1
bytecode array length: 1409 bytecode array length: 1407
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaConstant), U8(0), /* 42 S> */ B(LdaConstant), U8(0),
...@@ -960,7 +960,7 @@ bytecodes: [ ...@@ -960,7 +960,7 @@ bytecodes: [
B(Star), R(1), B(Star), R(1),
/* 4108 S> */ B(LdaSmi), U8(3), /* 4108 S> */ B(LdaSmi), U8(3),
/* 4108 E> */ B(TestLessThan), R(1), /* 4108 E> */ B(TestLessThan), R(1),
B(Wide), B(JumpIfFalse), U16(37), B(Wide), B(JumpIfFalse), U16(35),
/* 4090 E> */ B(StackCheck), /* 4090 E> */ B(StackCheck),
/* 4122 S> */ B(LdaSmi), U8(1), /* 4122 S> */ B(LdaSmi), U8(1),
/* 4128 E> */ B(TestEqual), R(1), /* 4128 E> */ B(TestEqual), R(1),
...@@ -969,12 +969,11 @@ bytecodes: [ ...@@ -969,12 +969,11 @@ bytecodes: [
/* 4146 S> */ B(LdaSmi), U8(2), /* 4146 S> */ B(LdaSmi), U8(2),
/* 4152 E> */ B(TestEqual), R(1), /* 4152 E> */ B(TestEqual), R(1),
B(Wide), B(JumpIfFalse), U16(7), 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), /* 4114 S> */ B(Ldar), R(1),
B(ToNumber), R(2),
B(Inc), B(Inc),
B(Star), R(1), B(Star), R(1),
B(Jump), U8(-40), B(Jump), U8(-38),
/* 4167 S> */ B(LdaSmi), U8(3), /* 4167 S> */ B(LdaSmi), U8(3),
/* 4177 S> */ B(Return), /* 4177 S> */ B(Return),
] ]
......
...@@ -893,7 +893,7 @@ snippet: " ...@@ -893,7 +893,7 @@ snippet: "
" "
frame size: 158 frame size: 158
parameter count: 1 parameter count: 1
bytecode array length: 55 bytecode array length: 51
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 1503 S> */ B(LdaZero), /* 1503 S> */ B(LdaZero),
...@@ -904,17 +904,16 @@ bytecodes: [ ...@@ -904,17 +904,16 @@ bytecodes: [
B(Wide), B(Star), R16(128), B(Wide), B(Star), R16(128),
/* 1538 S> */ B(LdaSmi), U8(64), /* 1538 S> */ B(LdaSmi), U8(64),
/* 1538 E> */ B(Wide), B(TestLessThan), R16(128), /* 1538 E> */ B(Wide), B(TestLessThan), R16(128),
B(JumpIfFalse), U8(32), B(JumpIfFalse), U8(28),
/* 1518 E> */ B(StackCheck), /* 1518 E> */ B(StackCheck),
/* 1555 S> */ B(Wide), B(Ldar), R16(128), /* 1555 S> */ B(Wide), B(Ldar), R16(128),
/* 1561 E> */ B(Add), R(1), /* 1561 E> */ B(Add), R(1),
B(Wide), B(Mov), R16(1), R16(157), B(Wide), B(Mov), R16(1), R16(157),
B(Star), R(1), B(Star), R(1),
/* 1548 S> */ B(Wide), B(Ldar), R16(128), /* 1548 S> */ B(Wide), B(Ldar), R16(128),
B(Wide), B(ToNumber), R16(157),
B(Inc), B(Inc),
B(Wide), B(Star), R16(128), B(Wide), B(Star), R16(128),
B(Jump), U8(-36), B(Jump), U8(-32),
/* 1567 S> */ B(Wide), B(Ldar), R16(128), /* 1567 S> */ B(Wide), B(Ldar), R16(128),
/* 1580 S> */ B(Return), /* 1580 S> */ B(Return),
] ]
......
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