Index: test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc |
diff --git a/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc b/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc |
index c3548252a7ff25c7832612787254161d4f162f05..168e0a732294f72182cffc104807a5268447de5e 100644 |
--- a/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc |
+++ b/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc |
@@ -134,10 +134,12 @@ |
TEST_F(BytecodePeepholeOptimizerTest, KeepJumpIfToBooleanTrue) { |
BytecodeNode first(Bytecode::kLdaNull); |
BytecodeNode second(Bytecode::kJumpIfToBooleanTrue, 3); |
- BytecodeLabel label; |
- optimizer()->Write(&first); |
- CHECK_EQ(write_count(), 0); |
- optimizer()->WriteJump(&second, &label); |
+ optimizer()->Write(&first); |
+ CHECK_EQ(write_count(), 0); |
+ optimizer()->Write(&second); |
+ CHECK_EQ(write_count(), 1); |
+ CHECK_EQ(last_written(), first); |
+ Flush(); |
CHECK_EQ(write_count(), 2); |
CHECK_EQ(last_written(), second); |
} |
@@ -145,12 +147,15 @@ |
TEST_F(BytecodePeepholeOptimizerTest, ElideJumpIfToBooleanTrue) { |
BytecodeNode first(Bytecode::kLdaTrue); |
BytecodeNode second(Bytecode::kJumpIfToBooleanTrue, 3); |
- BytecodeLabel label; |
- optimizer()->Write(&first); |
- CHECK_EQ(write_count(), 0); |
- optimizer()->WriteJump(&second, &label); |
- CHECK_EQ(write_count(), 2); |
- CHECK_EQ(last_written(), second); |
+ optimizer()->Write(&first); |
+ CHECK_EQ(write_count(), 0); |
+ optimizer()->Write(&second); |
+ CHECK_EQ(write_count(), 1); |
+ CHECK_EQ(last_written(), first); |
+ Flush(); |
+ CHECK_EQ(write_count(), 2); |
+ CHECK_EQ(last_written().bytecode(), Bytecode::kJumpIfTrue); |
+ CHECK_EQ(last_written().operand(0), second.operand(0)); |
} |
TEST_F(BytecodePeepholeOptimizerTest, KeepToBooleanLogicalNot) { |
@@ -199,11 +204,12 @@ |
BytecodeNode first(Bytecode::kStar, Register(0).ToOperand()); |
BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand()); |
optimizer()->Write(&first); |
- optimizer()->Write(&second); |
- CHECK_EQ(write_count(), 0); |
- Flush(); |
- CHECK_EQ(write_count(), 1); |
- CHECK_EQ(last_written(), first); |
+ CHECK_EQ(write_count(), 0); |
+ optimizer()->Write(&second); |
+ CHECK_EQ(write_count(), 1); |
+ CHECK_EQ(last_written(), first); |
+ Flush(); |
+ CHECK_EQ(write_count(), 1); |
} |
TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatement) { |
@@ -256,10 +262,11 @@ |
BytecodeNode first(Bytecode::kToName); |
BytecodeNode second(Bytecode::kToName); |
optimizer()->Write(&first); |
- optimizer()->Write(&second); |
- CHECK_EQ(write_count(), 0); |
- Flush(); |
- CHECK_EQ(last_written(), first); |
+ CHECK_EQ(write_count(), 0); |
+ optimizer()->Write(&second); |
+ CHECK_EQ(write_count(), 1); |
+ CHECK_EQ(last_written(), first); |
+ Flush(); |
CHECK_EQ(write_count(), 1); |
} |
@@ -267,11 +274,12 @@ |
BytecodeNode first(Bytecode::kTypeOf); |
BytecodeNode second(Bytecode::kToName); |
optimizer()->Write(&first); |
- optimizer()->Write(&second); |
- CHECK_EQ(write_count(), 0); |
- Flush(); |
- CHECK_EQ(write_count(), 1); |
- CHECK_EQ(last_written(), first); |
+ CHECK_EQ(write_count(), 0); |
+ optimizer()->Write(&second); |
+ CHECK_EQ(write_count(), 1); |
+ CHECK_EQ(last_written(), first); |
+ Flush(); |
+ CHECK_EQ(write_count(), 1); |
} |
TEST_F(BytecodePeepholeOptimizerTest, LdaConstantStringToName) { |
@@ -281,11 +289,12 @@ |
BytecodeNode first(Bytecode::kLdaConstant, static_cast<uint32_t>(index)); |
BytecodeNode second(Bytecode::kToName); |
optimizer()->Write(&first); |
- optimizer()->Write(&second); |
- CHECK_EQ(write_count(), 0); |
- Flush(); |
- CHECK_EQ(write_count(), 1); |
- CHECK_EQ(last_written(), first); |
+ CHECK_EQ(write_count(), 0); |
+ optimizer()->Write(&second); |
+ CHECK_EQ(write_count(), 1); |
+ CHECK_EQ(last_written(), first); |
+ Flush(); |
+ CHECK_EQ(write_count(), 1); |
} |
TEST_F(BytecodePeepholeOptimizerTest, LdaConstantNumberToName) { |