OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/interpreter/bytecode-pipeline.h" | 7 #include "src/interpreter/bytecode-pipeline.h" |
8 #include "src/interpreter/bytecode-register-allocator.h" | 8 #include "src/interpreter/bytecode-register-allocator.h" |
9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
10 #include "test/unittests/test-utils.h" | 10 #include "test/unittests/test-utils.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 y.set_invalid(); | 44 y.set_invalid(); |
45 y.MakeExpressionPosition(3); | 45 y.MakeExpressionPosition(3); |
46 CHECK_EQ(y.source_position(), 3); | 46 CHECK_EQ(y.source_position(), 3); |
47 CHECK_EQ(y.is_statement(), false); | 47 CHECK_EQ(y.is_statement(), false); |
48 | 48 |
49 y.MakeStatementPosition(3); | 49 y.MakeStatementPosition(3); |
50 CHECK_EQ(y.source_position(), 3); | 50 CHECK_EQ(y.source_position(), 3); |
51 CHECK_EQ(y.is_statement(), true); | 51 CHECK_EQ(y.is_statement(), true); |
52 } | 52 } |
53 | 53 |
| 54 TEST_F(BytecodeNodeTest, Constructor0) { |
| 55 BytecodeNode node; |
| 56 CHECK_EQ(node.bytecode(), Bytecode::kIllegal); |
| 57 CHECK(!node.source_info().is_valid()); |
| 58 } |
| 59 |
54 TEST_F(BytecodeNodeTest, Constructor1) { | 60 TEST_F(BytecodeNodeTest, Constructor1) { |
55 BytecodeNode node(Bytecode::kLdaZero); | 61 BytecodeNode node(Bytecode::kLdaZero); |
56 CHECK_EQ(node.bytecode(), Bytecode::kLdaZero); | 62 CHECK_EQ(node.bytecode(), Bytecode::kLdaZero); |
57 CHECK_EQ(node.operand_count(), 0); | 63 CHECK_EQ(node.operand_count(), 0); |
58 CHECK(!node.source_info().is_valid()); | 64 CHECK(!node.source_info().is_valid()); |
59 } | 65 } |
60 | 66 |
61 TEST_F(BytecodeNodeTest, Constructor2) { | 67 TEST_F(BytecodeNodeTest, Constructor2) { |
62 uint32_t operands[] = {0x11}; | 68 uint32_t operands[] = {0x11}; |
63 BytecodeNode node(Bytecode::kJumpIfTrue, operands[0]); | 69 BytecodeNode node(Bytecode::kJumpIfTrue, operands[0]); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], | 112 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], |
107 operands[3]); | 113 operands[3]); |
108 CHECK_EQ(node, node); | 114 CHECK_EQ(node, node); |
109 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], | 115 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], |
110 operands[2], operands[3]); | 116 operands[2], operands[3]); |
111 CHECK_EQ(node, other); | 117 CHECK_EQ(node, other); |
112 } | 118 } |
113 | 119 |
114 TEST_F(BytecodeNodeTest, EqualityWithSourceInfo) { | 120 TEST_F(BytecodeNodeTest, EqualityWithSourceInfo) { |
115 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; | 121 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; |
116 BytecodeSourceInfo first_source_info(3, true); | |
117 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], | 122 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], |
118 operands[3], &first_source_info); | 123 operands[3]); |
| 124 node.source_info().MakeStatementPosition(3); |
119 CHECK_EQ(node, node); | 125 CHECK_EQ(node, node); |
120 BytecodeSourceInfo second_source_info(3, true); | |
121 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], | 126 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], |
122 operands[2], operands[3], &second_source_info); | 127 operands[2], operands[3]); |
| 128 other.source_info().MakeStatementPosition(3); |
123 CHECK_EQ(node, other); | 129 CHECK_EQ(node, other); |
124 } | 130 } |
125 | 131 |
126 TEST_F(BytecodeNodeTest, NoEqualityWithDifferentSourceInfo) { | 132 TEST_F(BytecodeNodeTest, NoEqualityWithDifferentSourceInfo) { |
127 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; | 133 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; |
128 BytecodeSourceInfo source_info(77, true); | |
129 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], | 134 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], |
130 operands[3], &source_info); | 135 operands[3]); |
| 136 node.source_info().MakeStatementPosition(3); |
131 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], | 137 BytecodeNode other(Bytecode::kForInNext, operands[0], operands[1], |
132 operands[2], operands[3]); | 138 operands[2], operands[3]); |
133 CHECK_NE(node, other); | 139 CHECK_NE(node, other); |
134 } | 140 } |
135 | 141 |
136 TEST_F(BytecodeNodeTest, Clone) { | 142 TEST_F(BytecodeNodeTest, Clone) { |
137 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; | 143 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; |
138 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], | 144 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], |
139 operands[3]); | 145 operands[3]); |
140 BytecodeNode clone(Bytecode::kIllegal); | 146 BytecodeNode clone; |
141 clone.Clone(&node); | 147 clone.Clone(&node); |
142 CHECK_EQ(clone, node); | 148 CHECK_EQ(clone, node); |
143 } | 149 } |
144 | 150 |
145 TEST_F(BytecodeNodeTest, SetBytecode0) { | 151 TEST_F(BytecodeNodeTest, SetBytecode0) { |
146 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; | 152 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; |
| 153 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], |
| 154 operands[3]); |
147 BytecodeSourceInfo source_info(77, false); | 155 BytecodeSourceInfo source_info(77, false); |
148 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], | 156 node.source_info().Clone(source_info); |
149 operands[3], &source_info); | 157 CHECK_EQ(node.source_info(), source_info); |
150 CHECK_EQ(node.source_info(), BytecodeSourceInfo(77, false)); | |
151 | 158 |
152 BytecodeNode clone(Bytecode::kIllegal); | 159 BytecodeNode clone; |
153 clone.Clone(&node); | 160 clone.Clone(&node); |
154 clone.set_bytecode(Bytecode::kNop); | 161 clone.set_bytecode(Bytecode::kNop); |
155 CHECK_EQ(clone.bytecode(), Bytecode::kNop); | 162 CHECK_EQ(clone.bytecode(), Bytecode::kNop); |
156 CHECK_EQ(clone.operand_count(), 0); | 163 CHECK_EQ(clone.operand_count(), 0); |
157 CHECK_EQ(clone.source_info(), BytecodeSourceInfo(77, false)); | 164 CHECK_EQ(clone.source_info(), source_info); |
158 } | 165 } |
159 | 166 |
160 TEST_F(BytecodeNodeTest, SetBytecode1) { | 167 TEST_F(BytecodeNodeTest, SetBytecode1) { |
161 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; | 168 uint32_t operands[] = {0x71, 0xa5, 0x5a, 0xfc}; |
| 169 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], |
| 170 operands[3]); |
162 BytecodeSourceInfo source_info(77, false); | 171 BytecodeSourceInfo source_info(77, false); |
163 BytecodeNode node(Bytecode::kForInNext, operands[0], operands[1], operands[2], | 172 node.source_info().Clone(source_info); |
164 operands[3], &source_info); | |
165 | 173 |
166 BytecodeNode clone(Bytecode::kIllegal); | 174 BytecodeNode clone; |
167 clone.Clone(&node); | 175 clone.Clone(&node); |
168 clone.set_bytecode(Bytecode::kJump, 0x01aabbcc); | 176 clone.set_bytecode(Bytecode::kJump, 0x01aabbcc); |
169 CHECK_EQ(clone.bytecode(), Bytecode::kJump); | 177 CHECK_EQ(clone.bytecode(), Bytecode::kJump); |
170 CHECK_EQ(clone.operand_count(), 1); | 178 CHECK_EQ(clone.operand_count(), 1); |
171 CHECK_EQ(clone.operand(0), 0x01aabbcc); | 179 CHECK_EQ(clone.operand(0), 0x01aabbcc); |
172 CHECK_EQ(clone.source_info(), BytecodeSourceInfo(77, false)); | 180 CHECK_EQ(clone.source_info(), source_info); |
173 } | 181 } |
174 | 182 |
175 } // namespace interpreter | 183 } // namespace interpreter |
176 } // namespace internal | 184 } // namespace internal |
177 } // namespace v8 | 185 } // namespace v8 |
OLD | NEW |