Index: test/unittests/interpreter/bytecode-pipeline-unittest.cc |
diff --git a/test/unittests/interpreter/bytecode-pipeline-unittest.cc b/test/unittests/interpreter/bytecode-pipeline-unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..be5348fc3a9bd8153c3214b03fee588d67e48089 |
--- /dev/null |
+++ b/test/unittests/interpreter/bytecode-pipeline-unittest.cc |
@@ -0,0 +1,93 @@ |
+// Copyright 2016 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "src/v8.h" |
+ |
+#include "src/interpreter/bytecode-pipeline.h" |
+#include "src/interpreter/bytecode-register-allocator.h" |
+#include "src/isolate.h" |
+#include "test/unittests/test-utils.h" |
+ |
+namespace v8 { |
+namespace internal { |
+namespace interpreter { |
+ |
+using BytecodeNodeTest = TestWithIsolateAndZone; |
+ |
+TEST(BytecodeSourceInfo, Operations) { |
+ BytecodeSourceInfo x(0, true); |
+ CHECK_EQ(x.source_position(), 0); |
+ CHECK_EQ(x.is_statement(), true); |
+ CHECK_EQ(x.is_valid(), true); |
+ x.set_invalid(); |
+ CHECK_EQ(x.is_statement(), false); |
+ CHECK_EQ(x.is_valid(), false); |
+ |
+ x.Update({1, true}); |
+ BytecodeSourceInfo y(1, true); |
+ CHECK(x == y); |
+ CHECK(!(x != y)); |
+ |
+ x.set_invalid(); |
+ CHECK(!(x == y)); |
+ CHECK(x != y); |
+ |
+ y.Update({2, false}); |
+ CHECK_EQ(y.source_position(), 1); |
+ CHECK_EQ(y.is_statement(), true); |
+ |
+ y.Update({2, true}); |
+ CHECK_EQ(y.source_position(), 2); |
+ CHECK_EQ(y.is_statement(), true); |
+ |
+ y.set_invalid(); |
+ y.Update({3, false}); |
+ CHECK_EQ(y.source_position(), 3); |
+ CHECK_EQ(y.is_statement(), false); |
+ |
+ y.Update({3, true}); |
+ CHECK_EQ(y.source_position(), 3); |
+ CHECK_EQ(y.is_statement(), true); |
+} |
+ |
+TEST_F(BytecodeNodeTest, BytecodeNodeProperties) { |
+ /* |
+ BytecodeNode node; |
+ Register first(0), second(1); |
+ node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
+ second.ToOperand(), OperandScale::kSingle); |
+ CHECK_EQ(node.Size(), 3); |
+ node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
+ second.ToOperand(), OperandScale::kDouble); |
+ CHECK_EQ(node.Size(), 6); |
+ node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
+ second.ToOperand(), OperandScale::kQuadruple); |
+ CHECK_EQ(node.Size(), 10); |
+ node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
+ second.ToOperand(), OperandScale::kQuadruple); |
+ CHECK_EQ(node.Size(), 10); |
+ node.set_bytecode(Bytecode::kCall, first.ToOperand(), second.ToOperand(), 2, |
+ 3, OperandScale::kDouble); |
+ CHECK_EQ(node.Size(), 10); |
+ CHECK_EQ(node.operands()[0], first.ToOperand()); |
+ CHECK_EQ(node.operands()[1], second.ToOperand()); |
+ CHECK_EQ(node.operands()[2], 2); |
+ CHECK_EQ(node.operands()[3], 3); |
+ CHECK(!node.source_info().is_valid()); |
+ node.source_info().Update({77, true}); |
+ CHECK(node.source_info().is_valid()); |
+ CHECK_EQ(node.source_info().source_position(), 77); |
+ CHECK_EQ(node.source_info().is_statement(), true); |
+ */ |
+} |
+ |
+// TODO(oth): FinalStageBytecodeWriterTest. |
+// |
+// - Measured frame size is correct. |
+// - BytecodeArraySize. |
+// - SourcePositionTable iterates as expected. |
+ |
+} // namespace interpreter |
+} // namespace internal |
+} // namespace v8 |