| 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/interpreter/interpreter-assembler-unittest.h" | 5 #include "test/unittests/interpreter/interpreter-assembler-unittest.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/graph.h" | 8 #include "src/compiler/graph.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/interface-descriptors.h" | 10 #include "src/interface-descriptors.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 EXPECT_THAT( | 340 EXPECT_THAT( |
| 341 tail_call_node, | 341 tail_call_node, |
| 342 IsTailCall( | 342 IsTailCall( |
| 343 _, code_target_matcher, | 343 _, code_target_matcher, |
| 344 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), | 344 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), |
| 345 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), | 345 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), |
| 346 next_bytecode_offset_matcher, | 346 next_bytecode_offset_matcher, |
| 347 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 347 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 348 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), | 348 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 349 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, | 349 _, _)); |
| 350 _)); | |
| 351 } | 350 } |
| 352 } | 351 } |
| 353 | 352 |
| 354 TARGET_TEST_F(InterpreterAssemblerTest, Jump) { | 353 TARGET_TEST_F(InterpreterAssemblerTest, Jump) { |
| 355 // If debug code is enabled we emit extra code in Jump. | 354 // If debug code is enabled we emit extra code in Jump. |
| 356 if (FLAG_debug_code) return; | 355 if (FLAG_debug_code) return; |
| 357 | 356 |
| 358 int jump_offsets[] = {-9710, -77, 0, +3, +97109}; | 357 int jump_offsets[] = {-9710, -77, 0, +3, +97109}; |
| 359 TRACED_FOREACH(int, jump_offset, jump_offsets) { | 358 TRACED_FOREACH(int, jump_offset, jump_offsets) { |
| 360 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 359 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 383 EXPECT_THAT( | 382 EXPECT_THAT( |
| 384 tail_call_node, | 383 tail_call_node, |
| 385 IsTailCall( | 384 IsTailCall( |
| 386 _, code_target_matcher, | 385 _, code_target_matcher, |
| 387 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), | 386 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), |
| 388 IsParameter( | 387 IsParameter( |
| 389 InterpreterDispatchDescriptor::kRegisterFileParameter), | 388 InterpreterDispatchDescriptor::kRegisterFileParameter), |
| 390 next_bytecode_offset_matcher, _, | 389 next_bytecode_offset_matcher, _, |
| 391 IsParameter( | 390 IsParameter( |
| 392 InterpreterDispatchDescriptor::kDispatchTableParameter), | 391 InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 393 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, | 392 _, _)); |
| 394 _)); | |
| 395 } | 393 } |
| 396 } | 394 } |
| 397 } | 395 } |
| 398 | 396 |
| 399 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) { | 397 TARGET_TEST_F(InterpreterAssemblerTest, JumpIfWordEqual) { |
| 400 static const int kJumpIfTrueOffset = 73; | 398 static const int kJumpIfTrueOffset = 73; |
| 401 | 399 |
| 402 // If debug code is enabled we emit extra code in Jump. | 400 // If debug code is enabled we emit extra code in Jump. |
| 403 if (FLAG_debug_code) return; | 401 if (FLAG_debug_code) return; |
| 404 | 402 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 434 EXPECT_THAT( | 432 EXPECT_THAT( |
| 435 end->InputAt(i), | 433 end->InputAt(i), |
| 436 IsTailCall( | 434 IsTailCall( |
| 437 _, code_target_matcher, | 435 _, code_target_matcher, |
| 438 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), | 436 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), |
| 439 IsParameter( | 437 IsParameter( |
| 440 InterpreterDispatchDescriptor::kRegisterFileParameter), | 438 InterpreterDispatchDescriptor::kRegisterFileParameter), |
| 441 next_bytecode_offset_matcher, _, | 439 next_bytecode_offset_matcher, _, |
| 442 IsParameter( | 440 IsParameter( |
| 443 InterpreterDispatchDescriptor::kDispatchTableParameter), | 441 InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 444 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, | 442 _, _)); |
| 445 _)); | |
| 446 } | 443 } |
| 447 | 444 |
| 448 // TODO(oth): test control flow paths. | 445 // TODO(oth): test control flow paths. |
| 449 } | 446 } |
| 450 } | 447 } |
| 451 | 448 |
| 452 TARGET_TEST_F(InterpreterAssemblerTest, InterpreterReturn) { | 449 TARGET_TEST_F(InterpreterAssemblerTest, InterpreterReturn) { |
| 453 // If debug code is enabled we emit extra code in InterpreterReturn. | 450 // If debug code is enabled we emit extra code in InterpreterReturn. |
| 454 if (FLAG_debug_code) return; | 451 if (FLAG_debug_code) return; |
| 455 | 452 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 470 EXPECT_THAT( | 467 EXPECT_THAT( |
| 471 tail_call_node, | 468 tail_call_node, |
| 472 IsTailCall( | 469 IsTailCall( |
| 473 _, exit_trampoline_entry_matcher, | 470 _, exit_trampoline_entry_matcher, |
| 474 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), | 471 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), |
| 475 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), | 472 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), |
| 476 IsParameter( | 473 IsParameter( |
| 477 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 474 InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
| 478 _, | 475 _, |
| 479 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), | 476 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 480 IsParameter(InterpreterDispatchDescriptor::kContextParameter), _, | 477 _, _)); |
| 481 _)); | |
| 482 } | 478 } |
| 483 } | 479 } |
| 484 | 480 |
| 485 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { | 481 TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { |
| 486 static const OperandScale kOperandScales[] = { | 482 static const OperandScale kOperandScales[] = { |
| 487 OperandScale::kSingle, OperandScale::kDouble, OperandScale::kQuadruple}; | 483 OperandScale::kSingle, OperandScale::kDouble, OperandScale::kQuadruple}; |
| 488 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 484 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 489 TRACED_FOREACH(interpreter::OperandScale, operand_scale, kOperandScales) { | 485 TRACED_FOREACH(interpreter::OperandScale, operand_scale, kOperandScales) { |
| 490 InterpreterAssemblerForTest m(this, bytecode, operand_scale); | 486 InterpreterAssemblerForTest m(this, bytecode, operand_scale); |
| 491 int number_of_operands = | 487 int number_of_operands = |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 559 |
| 564 Node* end = graph->end(); | 560 Node* end = graph->end(); |
| 565 EXPECT_EQ(1, end->InputCount()); | 561 EXPECT_EQ(1, end->InputCount()); |
| 566 Node* tail_call_node = end->InputAt(0); | 562 Node* tail_call_node = end->InputAt(0); |
| 567 | 563 |
| 568 EXPECT_THAT(tail_call_node, | 564 EXPECT_THAT(tail_call_node, |
| 569 IsTailCall(_, _, accumulator_value_2, _, _, _, _, _, _)); | 565 IsTailCall(_, _, accumulator_value_2, _, _, _, _, _, _)); |
| 570 } | 566 } |
| 571 } | 567 } |
| 572 | 568 |
| 573 TARGET_TEST_F(InterpreterAssemblerTest, GetSetContext) { | 569 TARGET_TEST_F(InterpreterAssemblerTest, GetContext) { |
| 574 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 570 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 575 InterpreterAssemblerForTest m(this, bytecode); | 571 InterpreterAssemblerForTest m(this, bytecode); |
| 576 Node* context_node = m.Int32Constant(100); | 572 EXPECT_THAT( |
| 577 m.SetContext(context_node); | 573 m.GetContext(), |
| 578 EXPECT_THAT(m.GetContext(), context_node); | 574 m.IsLoad( |
| 575 MachineType::AnyTagged(), |
| 576 IsParameter(InterpreterDispatchDescriptor::kRegisterFileParameter), |
| 577 IsIntPtrConstant(-Register::current_context().index() |
| 578 << kPointerSizeLog2))); |
| 579 } | 579 } |
| 580 } | 580 } |
| 581 | 581 |
| 582 TARGET_TEST_F(InterpreterAssemblerTest, RegisterLocation) { | 582 TARGET_TEST_F(InterpreterAssemblerTest, RegisterLocation) { |
| 583 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 583 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 584 InterpreterAssemblerForTest m(this, bytecode); | 584 InterpreterAssemblerForTest m(this, bytecode); |
| 585 Node* reg_index_node = m.IntPtrConstant(44); | 585 Node* reg_index_node = m.IntPtrConstant(44); |
| 586 Node* reg_location_node = m.RegisterLocation(reg_index_node); | 586 Node* reg_location_node = m.RegisterLocation(reg_index_node); |
| 587 EXPECT_THAT( | 587 EXPECT_THAT( |
| 588 reg_location_node, | 588 reg_location_node, |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 feedback_vector, | 822 feedback_vector, |
| 823 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, | 823 m.IsLoad(MachineType::AnyTagged(), load_shared_function_info_matcher, |
| 824 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - | 824 IsIntPtrConstant(SharedFunctionInfo::kFeedbackVectorOffset - |
| 825 kHeapObjectTag))); | 825 kHeapObjectTag))); |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 | 828 |
| 829 } // namespace interpreter | 829 } // namespace interpreter |
| 830 } // namespace internal | 830 } // namespace internal |
| 831 } // namespace v8 | 831 } // namespace v8 |
| OLD | NEW |