OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/v8.h" |
| 6 |
| 7 #include "src/interpreter/bytecode-pipeline.h" |
| 8 #include "src/interpreter/bytecode-register-allocator.h" |
| 9 #include "src/isolate.h" |
| 10 #include "test/unittests/test-utils.h" |
| 11 |
| 12 namespace v8 { |
| 13 namespace internal { |
| 14 namespace interpreter { |
| 15 |
| 16 using BytecodeNodeTest = TestWithIsolateAndZone; |
| 17 |
| 18 TEST(BytecodeSourceInfo, Operations) { |
| 19 BytecodeSourceInfo x(0, true); |
| 20 CHECK_EQ(x.source_position(), 0); |
| 21 CHECK_EQ(x.is_statement(), true); |
| 22 CHECK_EQ(x.is_valid(), true); |
| 23 x.set_invalid(); |
| 24 CHECK_EQ(x.is_statement(), false); |
| 25 CHECK_EQ(x.is_valid(), false); |
| 26 |
| 27 x.Update({1, true}); |
| 28 BytecodeSourceInfo y(1, true); |
| 29 CHECK(x == y); |
| 30 CHECK(!(x != y)); |
| 31 |
| 32 x.set_invalid(); |
| 33 CHECK(!(x == y)); |
| 34 CHECK(x != y); |
| 35 |
| 36 y.Update({2, false}); |
| 37 CHECK_EQ(y.source_position(), 1); |
| 38 CHECK_EQ(y.is_statement(), true); |
| 39 |
| 40 y.Update({2, true}); |
| 41 CHECK_EQ(y.source_position(), 2); |
| 42 CHECK_EQ(y.is_statement(), true); |
| 43 |
| 44 y.set_invalid(); |
| 45 y.Update({3, false}); |
| 46 CHECK_EQ(y.source_position(), 3); |
| 47 CHECK_EQ(y.is_statement(), false); |
| 48 |
| 49 y.Update({3, true}); |
| 50 CHECK_EQ(y.source_position(), 3); |
| 51 CHECK_EQ(y.is_statement(), true); |
| 52 } |
| 53 |
| 54 TEST_F(BytecodeNodeTest, BytecodeNodeProperties) { |
| 55 /* |
| 56 BytecodeNode node; |
| 57 Register first(0), second(1); |
| 58 node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
| 59 second.ToOperand(), OperandScale::kSingle); |
| 60 CHECK_EQ(node.Size(), 3); |
| 61 node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
| 62 second.ToOperand(), OperandScale::kDouble); |
| 63 CHECK_EQ(node.Size(), 6); |
| 64 node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
| 65 second.ToOperand(), OperandScale::kQuadruple); |
| 66 CHECK_EQ(node.Size(), 10); |
| 67 node.set_bytecode(Bytecode::kForInDone, first.ToOperand(), |
| 68 second.ToOperand(), OperandScale::kQuadruple); |
| 69 CHECK_EQ(node.Size(), 10); |
| 70 node.set_bytecode(Bytecode::kCall, first.ToOperand(), second.ToOperand(), 2, |
| 71 3, OperandScale::kDouble); |
| 72 CHECK_EQ(node.Size(), 10); |
| 73 CHECK_EQ(node.operands()[0], first.ToOperand()); |
| 74 CHECK_EQ(node.operands()[1], second.ToOperand()); |
| 75 CHECK_EQ(node.operands()[2], 2); |
| 76 CHECK_EQ(node.operands()[3], 3); |
| 77 CHECK(!node.source_info().is_valid()); |
| 78 node.source_info().Update({77, true}); |
| 79 CHECK(node.source_info().is_valid()); |
| 80 CHECK_EQ(node.source_info().source_position(), 77); |
| 81 CHECK_EQ(node.source_info().is_statement(), true); |
| 82 */ |
| 83 } |
| 84 |
| 85 // TODO(oth): FinalStageBytecodeWriterTest. |
| 86 // |
| 87 // - Measured frame size is correct. |
| 88 // - BytecodeArraySize. |
| 89 // - SourcePositionTable iterates as expected. |
| 90 |
| 91 } // namespace interpreter |
| 92 } // namespace internal |
| 93 } // namespace v8 |
OLD | NEW |