| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 "test/unittests/compiler/interpreter-assembler-unittest.h" | 5 #include "test/unittests/compiler/interpreter-assembler-unittest.h" |
| 6 | 6 |
| 7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
| 8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
| 9 #include "src/unique.h" | 9 #include "src/unique.h" |
| 10 #include "test/unittests/compiler/compiler-test-utils.h" | 10 #include "test/unittests/compiler/compiler-test-utils.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 170 } |
| 171 } | 171 } |
| 172 | 172 |
| 173 | 173 |
| 174 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { | 174 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { |
| 175 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 175 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 176 InterpreterAssemblerForTest m(this, bytecode); | 176 InterpreterAssemblerForTest m(this, bytecode); |
| 177 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); | 177 int number_of_operands = interpreter::Bytecodes::NumberOfOperands(bytecode); |
| 178 for (int i = 0; i < number_of_operands; i++) { | 178 for (int i = 0; i < number_of_operands; i++) { |
| 179 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { | 179 switch (interpreter::Bytecodes::GetOperandType(bytecode, i)) { |
| 180 case interpreter::OperandType::kIdx: |
| 181 EXPECT_THAT(m.BytecodeOperandIdx(i), m.IsBytecodeOperand(i)); |
| 182 break; |
| 180 case interpreter::OperandType::kImm8: | 183 case interpreter::OperandType::kImm8: |
| 181 EXPECT_THAT(m.BytecodeOperandImm8(i), | 184 EXPECT_THAT(m.BytecodeOperandImm8(i), |
| 182 m.IsBytecodeOperandSignExtended(i)); | 185 m.IsBytecodeOperandSignExtended(i)); |
| 183 break; | 186 break; |
| 184 case interpreter::OperandType::kReg: | 187 case interpreter::OperandType::kReg: |
| 185 EXPECT_THAT(m.BytecodeOperandReg(i), | 188 EXPECT_THAT(m.BytecodeOperandReg(i), |
| 186 m.IsBytecodeOperandSignExtended(i)); | 189 m.IsBytecodeOperandSignExtended(i)); |
| 187 break; | 190 break; |
| 188 case interpreter::OperandType::kNone: | 191 case interpreter::OperandType::kNone: |
| 189 UNREACHABLE(); | 192 UNREACHABLE(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 InterpreterAssemblerForTest m(this, bytecode); | 262 InterpreterAssemblerForTest m(this, bytecode); |
| 260 Node* value = m.Int32Constant(44); | 263 Node* value = m.Int32Constant(44); |
| 261 EXPECT_THAT(m.SmiTag(value), | 264 EXPECT_THAT(m.SmiTag(value), |
| 262 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); | 265 IsWordShl(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); |
| 263 EXPECT_THAT(m.SmiUntag(value), | 266 EXPECT_THAT(m.SmiUntag(value), |
| 264 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); | 267 IsWordSar(value, IsInt32Constant(kSmiShiftSize + kSmiTagSize))); |
| 265 } | 268 } |
| 266 } | 269 } |
| 267 | 270 |
| 268 | 271 |
| 272 TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { |
| 273 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 274 InterpreterAssemblerForTest m(this, bytecode); |
| 275 Node* index = m.Int32Constant(2); |
| 276 Node* load_constant = m.LoadConstantPoolEntry(index); |
| 277 Matcher<Node*> constant_pool_matcher = m.IsLoad( |
| 278 kMachAnyTagged, |
| 279 IsParameter(Linkage::kInterpreterBytecodeArrayParameter), |
| 280 IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag)); |
| 281 EXPECT_THAT( |
| 282 load_constant, |
| 283 m.IsLoad(kMachAnyTagged, constant_pool_matcher, |
| 284 IsIntPtrAdd( |
| 285 IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 286 IsWordShl(index, IsInt32Constant(kPointerSizeLog2))))); |
| 287 } |
| 288 } |
| 289 |
| 290 |
| 269 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { | 291 TARGET_TEST_F(InterpreterAssemblerTest, LoadContextSlot) { |
| 270 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 292 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 271 InterpreterAssemblerForTest m(this, bytecode); | 293 InterpreterAssemblerForTest m(this, bytecode); |
| 272 Node* load_from_current_context = m.LoadContextSlot(22); | 294 Node* load_from_current_context = m.LoadContextSlot(22); |
| 273 Matcher<Node*> load_from_current_context_matcher = m.IsLoad( | 295 Matcher<Node*> load_from_current_context_matcher = m.IsLoad( |
| 274 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), | 296 kMachAnyTagged, IsParameter(Linkage::kInterpreterContextParameter), |
| 275 IsIntPtrConstant(Context::SlotOffset(22))); | 297 IsIntPtrConstant(Context::SlotOffset(22))); |
| 276 EXPECT_THAT(load_from_current_context, load_from_current_context_matcher); | 298 EXPECT_THAT(load_from_current_context, load_from_current_context_matcher); |
| 277 | 299 |
| 278 // Let's imagine that the loaded context slot is another context. | 300 // Let's imagine that the loaded context slot is another context. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1); | 348 m.CallJSBuiltin(Context::SUB_BUILTIN_INDEX, receiver, arg1); |
| 327 EXPECT_THAT(call_js_builtin_1, | 349 EXPECT_THAT(call_js_builtin_1, |
| 328 IsCall(_, function_matcher, receiver, arg1, context_matcher, | 350 IsCall(_, function_matcher, receiver, arg1, context_matcher, |
| 329 m.graph()->start(), m.graph()->start())); | 351 m.graph()->start(), m.graph()->start())); |
| 330 } | 352 } |
| 331 } | 353 } |
| 332 | 354 |
| 333 } // namespace compiler | 355 } // namespace compiler |
| 334 } // namespace internal | 356 } // namespace internal |
| 335 } // namespace v8 | 357 } // namespace v8 |
| OLD | NEW |