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

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

Issue 2360193003: Revert of [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)
Patch Set: 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 d7beb47a01b23f8baae15eaa69488df16c9055ba..86a2407c3d8ba11a31238f6f182f1b635ad01c18 100644
--- a/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc
+++ b/test/unittests/interpreter/bytecode-peephole-optimizer-unittest.cc
@@ -18,8 +18,7 @@
class BytecodePeepholeOptimizerTest : public BytecodePipelineStage,
public TestWithIsolateAndZone {
public:
- BytecodePeepholeOptimizerTest()
- : peephole_optimizer_(this), last_written_(Bytecode::kIllegal) {}
+ BytecodePeepholeOptimizerTest() : peephole_optimizer_(this) {}
~BytecodePeepholeOptimizerTest() override {}
void Reset() {
@@ -72,7 +71,7 @@
CHECK_EQ(write_count(), 0);
BytecodeLabel target;
- BytecodeNode jump(Bytecode::kJump, 0, nullptr);
+ BytecodeNode jump(Bytecode::kJump, 0);
optimizer()->WriteJump(&jump, &target);
CHECK_EQ(write_count(), 2);
CHECK_EQ(jump, last_written());
@@ -104,8 +103,8 @@
}
TEST_F(BytecodePeepholeOptimizerTest, ElideExpressionNop) {
- BytecodeSourceInfo source_info(3, false);
- BytecodeNode nop(Bytecode::kNop, &source_info);
+ BytecodeNode nop(Bytecode::kNop);
+ nop.source_info().MakeExpressionPosition(3);
optimizer()->Write(&nop);
BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
optimizer()->Write(&add);
@@ -115,11 +114,11 @@
}
TEST_F(BytecodePeepholeOptimizerTest, KeepStatementNop) {
- BytecodeSourceInfo source_info(3, true);
- BytecodeNode nop(Bytecode::kNop, &source_info);
+ BytecodeNode nop(Bytecode::kNop);
+ nop.source_info().MakeStatementPosition(3);
optimizer()->Write(&nop);
- source_info.MakeExpressionPosition(3);
- BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1, &source_info);
+ BytecodeNode add(Bytecode::kAdd, Register(0).ToOperand(), 1);
+ add.source_info().MakeExpressionPosition(3);
optimizer()->Write(&add);
Flush();
CHECK_EQ(write_count(), 2);
@@ -205,8 +204,8 @@
TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatement) {
BytecodeNode first(Bytecode::kStar, Register(0).ToOperand());
- BytecodeSourceInfo source_info(3, true);
- BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand(), &source_info);
+ BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand());
+ second.source_info().MakeStatementPosition(0);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
@@ -221,9 +220,9 @@
TEST_F(BytecodePeepholeOptimizerTest, StarRxLdarRxStatementStarRy) {
BytecodeLabel label;
BytecodeNode first(Bytecode::kStar, Register(0).ToOperand());
- BytecodeSourceInfo source_info(0, true);
- BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand(), &source_info);
+ BytecodeNode second(Bytecode::kLdar, Register(0).ToOperand());
BytecodeNode third(Bytecode::kStar, Register(3).ToOperand());
+ second.source_info().MakeStatementPosition(0);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
@@ -278,8 +277,8 @@
}
TEST_F(BytecodePeepholeOptimizerTest, LdaTrueStatementLdaFalse) {
- BytecodeSourceInfo source_info(3, true);
- BytecodeNode first(Bytecode::kLdaTrue, &source_info);
+ BytecodeNode first(Bytecode::kLdaTrue);
+ first.source_info().MakeExpressionPosition(3);
BytecodeNode second(Bytecode::kLdaFalse);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
@@ -288,13 +287,13 @@
Flush();
CHECK_EQ(write_count(), 1);
CHECK_EQ(last_written(), second);
- CHECK(second.source_info().is_statement());
+ CHECK(second.source_info().is_expression());
CHECK_EQ(second.source_info().source_position(), 3);
}
TEST_F(BytecodePeepholeOptimizerTest, NopStackCheck) {
BytecodeNode first(Bytecode::kNop);
- BytecodeNode second(Bytecode::kStackCheck, nullptr);
+ BytecodeNode second(Bytecode::kStackCheck);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
optimizer()->Write(&second);
@@ -305,8 +304,8 @@
}
TEST_F(BytecodePeepholeOptimizerTest, NopStatementStackCheck) {
- BytecodeSourceInfo source_info(3, true);
- BytecodeNode first(Bytecode::kNop, &source_info);
+ BytecodeNode first(Bytecode::kNop);
+ first.source_info().MakeExpressionPosition(3);
BytecodeNode second(Bytecode::kStackCheck);
optimizer()->Write(&first);
CHECK_EQ(write_count(), 0);
@@ -314,9 +313,9 @@
CHECK_EQ(write_count(), 0);
Flush();
CHECK_EQ(write_count(), 1);
- BytecodeSourceInfo expected_source_info(3, true);
- BytecodeNode expected(Bytecode::kStackCheck, &expected_source_info);
- CHECK_EQ(last_written(), expected);
+ second.source_info().MakeExpressionPosition(
+ first.source_info().source_position());
+ CHECK_EQ(last_written(), second);
}
// Tests covering BytecodePeepholeOptimizer::UpdateLastAndCurrentBytecodes().
@@ -353,8 +352,7 @@
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],
- nullptr);
+ BytecodeNode first(Bytecode::kLdaKeyedProperty, operands[0], operands[1]);
BytecodeNode second(Bytecode::kStar, operands[2]);
BytecodeNode third(Bytecode::kReturn);
optimizer()->Write(&first);
@@ -459,8 +457,8 @@
for (auto operator_replacement : operator_replacement_pairs) {
uint32_t imm_operand = 17;
- BytecodeSourceInfo source_info(3, true);
- BytecodeNode first(Bytecode::kLdaSmi, imm_operand, &source_info);
+ BytecodeNode first(Bytecode::kLdaSmi, imm_operand);
+ first.source_info().Clone({3, true});
uint32_t reg_operand = Register(0).ToOperand();
uint32_t idx_operand = 1;
BytecodeNode second(operator_replacement[0], reg_operand, idx_operand);
@@ -489,11 +487,11 @@
for (auto operator_replacement : operator_replacement_pairs) {
uint32_t imm_operand = 17;
- BytecodeSourceInfo source_info(3, true);
- BytecodeNode first(Bytecode::kLdaSmi, imm_operand, &source_info);
+ BytecodeNode first(Bytecode::kLdaSmi, imm_operand);
+ first.source_info().Clone({3, true});
uint32_t reg_operand = Register(0).ToOperand();
- source_info.MakeStatementPosition(4);
- BytecodeNode second(operator_replacement[0], reg_operand, 1, &source_info);
+ BytecodeNode second(operator_replacement[0], reg_operand, 1);
+ second.source_info().Clone({4, true});
optimizer()->Write(&first);
optimizer()->Write(&second);
CHECK_EQ(last_written(), first);

Powered by Google App Engine
This is Rietveld 408576698