Index: test/unittests/interpreter/bytecode-array-builder-unittest.cc |
diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc |
index 68995a714af9d52dc21803c6a1c9338b55972abd..87115990c5fe9432114f09e80be2a7a72ad2e3c9 100644 |
--- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc |
+++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc |
@@ -6,6 +6,7 @@ |
#include "src/interpreter/bytecode-array-builder.h" |
#include "src/interpreter/bytecode-array-iterator.h" |
+#include "src/interpreter/bytecode-label.h" |
#include "src/interpreter/bytecode-register-allocator.h" |
#include "test/unittests/test-utils.h" |
@@ -358,6 +359,14 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { |
scorecard[Bytecodes::ToByte(Bytecode::kLdrGlobal)] = 1; |
scorecard[Bytecodes::ToByte(Bytecode::kLdrContextSlot)] = 1; |
scorecard[Bytecodes::ToByte(Bytecode::kLdrUndefined)] = 1; |
+ if (!FLAG_ignition_peephole) { |
oth
2016/06/03 09:50:21
Comment here explaining why the delta.
rmcilroy
2016/06/03 14:27:15
Added writes for the preceding Ldr instructions an
|
+ scorecard[Bytecodes::ToByte(Bytecode::kLogicalNot)] = 1; |
+ scorecard[Bytecodes::ToByte(Bytecode::kJump)] = 1; |
+ scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrue)] = 1; |
+ scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalse)] = 1; |
+ scorecard[Bytecodes::ToByte(Bytecode::kJumpIfTrueConstant)] = 1; |
+ scorecard[Bytecodes::ToByte(Bytecode::kJumpIfFalseConstant)] = 1; |
+ } |
// Check return occurs at the end and only once in the BytecodeArray. |
CHECK_EQ(final_bytecode, Bytecode::kReturn); |
@@ -470,6 +479,11 @@ TEST_F(BytecodeArrayBuilderTest, Constants) { |
CHECK_EQ(array->constant_pool()->length(), 3); |
} |
+static Bytecode PeepholeToBoolean(Bytecode jump_bytecode) { |
+ return FLAG_ignition_peephole |
+ ? Bytecodes::GetJumpWithoutToBoolean(jump_bytecode) |
+ : jump_bytecode; |
+} |
TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { |
static const int kFarJumpDistance = 256; |
@@ -520,14 +534,16 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrue); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrue)); |
CHECK_EQ(iterator.GetImmediateOperand(0), 14); |
iterator.Advance(); |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalse); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalse)); |
CHECK_EQ(iterator.GetImmediateOperand(0), 10); |
iterator.Advance(); |
@@ -553,7 +569,8 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrueConstant); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrueConstant)); |
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), |
Smi::FromInt(kFarJumpDistance - 4)); |
iterator.Advance(); |
@@ -561,7 +578,8 @@ TEST_F(BytecodeArrayBuilderTest, ForwardJumps) { |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalseConstant); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalseConstant)); |
CHECK_EQ(*iterator.GetConstantForIndexOperand(0), |
Smi::FromInt(kFarJumpDistance - 8)); |
iterator.Advance(); |
@@ -628,13 +646,15 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) { |
iterator.Advance(); |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrue); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrue)); |
CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
CHECK_EQ(iterator.GetImmediateOperand(0), -2); |
iterator.Advance(); |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalse); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalse)); |
CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); |
CHECK_EQ(iterator.GetImmediateOperand(0), -2); |
iterator.Advance(); |
@@ -675,13 +695,15 @@ TEST_F(BytecodeArrayBuilderTest, BackwardJumps) { |
iterator.Advance(); |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfFalse); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanFalse)); |
CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble); |
CHECK_EQ(iterator.GetImmediateOperand(0), -409); |
iterator.Advance(); |
// Ignore compare operation. |
iterator.Advance(); |
- CHECK_EQ(iterator.current_bytecode(), Bytecode::kJumpIfTrue); |
+ CHECK_EQ(iterator.current_bytecode(), |
+ PeepholeToBoolean(Bytecode::kJumpIfToBooleanTrue)); |
CHECK_EQ(iterator.current_operand_scale(), OperandScale::kDouble); |
CHECK_EQ(iterator.GetImmediateOperand(0), -419); |
iterator.Advance(); |