Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Unified Diff: test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc

Issue 2351763002: [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)
Patch Set: Fix Chromium Windows bots. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 86a2407c3d8ba11a31238f6f182f1b635ad01c18..d7beb47a01b23f8baae15eaa69488df16c9055ba 100644
--- a/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc
+++ b/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc
@@ -18,7 +18,8 @@ namespace interpreter {
class BytecodePeepholeOptimizerTest : public BytecodePipelineStage,
public TestWithIsolateAndZone {
public:
- BytecodePeepholeOptimizerTest() : peephole_optimizer_(this) {}
+ BytecodePeepholeOptimizerTest()
+ : peephole_optimizer_(this), last_written_(Bytecode::kIllegal) {}
~BytecodePeepholeOptimizerTest() override {}
void Reset() {
@@ -71,7 +72,7 @@ TEST_F(BytecodePeepholeOptimizerTest, FlushOnJump) {
CHECK_EQ(write_count(), 0);
BytecodeLabel target;
- BytecodeNode jump(Bytecode::kJump, 0);
+ BytecodeNode jump(Bytecode::kJump, 0, nullptr);
optimizer()->WriteJump(&jump, &target);
CHECK_EQ(write_count(), 2);
CHECK_EQ(jump, last_written());
@@ -103,8 +104,8 @@ TEST_F(BytecodePeepholeOptimizerTest, ElideEmptyNop) {
}
TEST_F(BytecodePeepholeOptimizerTest, ElideExpressionNop) {
- BytecodeNode nop(Bytecode::kNop);
- nop.source_info().MakeExpressionPosition(3);
+ BytecodeSourceInfo source_info(3, false);
+ BytecodeNode nop(Bytecode::kNop, &source_info);
optimizer()->Write(&nop);
BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
optimizer()->Write(&add);
@@ -114,11 +115,11 @@ TEST_F(BytecodePeepholeOptimizerTest, ElideExpressionNop) {
}
TEST_F(BytecodePeepholeOptimizerTest, KeepStatementNop) {
- BytecodeNode nop(Bytecode::kNop);
- nop.source_info().MakeStatementPosition(3);
+ BytecodeSourceInfo source_info(3, true);
+ BytecodeNode nop(Bytecode::kNop, &source_info);
optimizer()->Write(&nop);
- BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
- add.source_info().MakeExpressionPosition(3);
+ source_info.MakeExpressionPosition(3);
+ BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1, &source_info);
optimizer()->Write(&add);
Flush();
CHECK_EQ(write_count(), 2);
@@ -204,8 +205,8 @@ TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRx) {
TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatement) {
BytecodeNode first(Bytecode::kStar, Register(0).ToOperand());
- BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand());
- second.source_info().MakeStatementPosition(0);
+ BytecodeSourceInfo source_info(3, true);
+ BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand(), &source_info);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
@@ -220,9 +221,9 @@ TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatement) {
TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatementStarRy) {
BytecodeLabel label;
BytecodeNode first(Bytecode::kStar, Register(0).ToOperand());
- BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand());
+ BytecodeSourceInfo source_info(0, true);
+ BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand(), &source_info);
BytecodeNode third(Bytecode::kStar, Register(3).ToOperand());
- second.source_info().MakeStatementPosition(0);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
@@ -277,8 +278,8 @@ TEST_F(BytecodePeepholeOptimizerTest, LdaTrueLdaFalse) {
}
TEST_F(BytecodePeepholeOptimizerTest, LdaTrueStatementLdaFalse) {
- BytecodeNode first(Bytecode::kLdaTrue);
- first.source_info().MakeExpressionPosition(3);
+ BytecodeSourceInfo source_info(3, true);
+ BytecodeNode first(Bytecode::kLdaTrue, &source_info);
BytecodeNode second(Bytecode::kLdaFalse);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
@@ -287,13 +288,13 @@ TEST_F(BytecodePeepholeOptimizerTest, LdaTrueStatementLdaFalse) {
Flush();
CHECK_EQ(write_count(), 1);
CHECK_EQ(last_written(), second);
- CHECK(second.source_info().is_expression());
+ CHECK(second.source_info().is_statement());
CHECK_EQ(second.source_info().source_position(), 3);
}
TEST_F(BytecodePeepholeOptimizerTest, NopStackCheck) {
BytecodeNode first(Bytecode::kNop);
- BytecodeNode second(Bytecode::kStackCheck);
+ BytecodeNode second(Bytecode::kStackCheck, nullptr);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
@@ -304,8 +305,8 @@ TEST_F(BytecodePeepholeOptimizerTest, NopStackCheck) {
}
TEST_F(BytecodePeepholeOptimizerTest, NopStatementStackCheck) {
- BytecodeNode first(Bytecode::kNop);
- first.source_info().MakeExpressionPosition(3);
+ BytecodeSourceInfo source_info(3, true);
+ BytecodeNode first(Bytecode::kNop, &source_info);
BytecodeNode second(Bytecode::kStackCheck);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
@@ -313,9 +314,9 @@ TEST_F(BytecodePeepholeOptimizerTest, NopStatementStackCheck) {
CHECK_EQ(write_count(), 0);
Flush();
CHECK_EQ(write_count(), 1);
- second.source_info().MakeExpressionPosition(
- first.source_info().source_position());
- CHECK_EQ(last_written(), second);
+ BytecodeSourceInfo expected_source_info(3, true);
+ BytecodeNode expected(Bytecode::kStackCheck, &expected_source_info);
+ CHECK_EQ(last_written(), expected);
}
// Tests covering BytecodePeepholeOptimizer::UpdateLastAndCurrentBytecodes().
@@ -352,7 +353,8 @@ TEST_F(BytecodePeepholeOptimizerTest, MergeLdaKeyedPropertyStar) {
static_cast<uint32_t>(Register(1).ToOperand())};
const int expected_operand_count = static_cast<int>(arraysize(operands));
- BytecodeNode first(Bytecode::kLdaKeyedProperty, operands[0], operands[1]);
+ BytecodeNode first(Bytecode::kLdaKeyedProperty, operands[0], operands[1],
+ nullptr);
BytecodeNode second(Bytecode::kStar, operands[2]);
BytecodeNode third(Bytecode::kReturn);
optimizer()->Write(&first);
@@ -457,8 +459,8 @@ TEST_F(BytecodePeepholeOptimizerTest, MergeLdaSmiWithBinaryOp) {
for (auto operator_replacement : operator_replacement_pairs) {
uint32_t imm_operand = 17;
- BytecodeNode first(Bytecode::kLdaSmi, imm_operand);
- first.source_info().Clone({3, true});
+ BytecodeSourceInfo source_info(3, true);
+ BytecodeNode first(Bytecode::kLdaSmi, imm_operand, &source_info);
uint32_t reg_operand = Register(0).ToOperand();
uint32_t idx_operand = 1;
BytecodeNode second(operator_replacement[0], reg_operand, idx_operand);
@@ -487,11 +489,11 @@ TEST_F(BytecodePeepholeOptimizerTest, NotMergingLdaSmiWithBinaryOp) {
for (auto operator_replacement : operator_replacement_pairs) {
uint32_t imm_operand = 17;
- BytecodeNode first(Bytecode::kLdaSmi, imm_operand);
- first.source_info().Clone({3, true});
+ BytecodeSourceInfo source_info(3, true);
+ BytecodeNode first(Bytecode::kLdaSmi, imm_operand, &source_info);
uint32_t reg_operand = Register(0).ToOperand();
- BytecodeNode second(operator_replacement[0], reg_operand, 1);
- second.source_info().Clone({4, true});
+ source_info.MakeStatementPosition(4);
+ BytecodeNode second(operator_replacement[0], reg_operand, 1, &source_info);
optimizer()->Write(&first);
optimizer()->Write(&second);
CHECK_EQ(last_written(), first);

Powered by Google App Engine
This is Rietveld 408576698