| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 325 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 326 next_bytecode_offset_matcher); | 326 next_bytecode_offset_matcher); |
| 327 if (kPointerSize == 8) { | 327 if (kPointerSize == 8) { |
| 328 target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher); | 328 target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher); |
| 329 } | 329 } |
| 330 Matcher<Node*> code_target_matcher = m.IsLoad( | 330 Matcher<Node*> code_target_matcher = m.IsLoad( |
| 331 MachineType::Pointer(), | 331 MachineType::Pointer(), |
| 332 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), | 332 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 333 IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); | 333 IsWordShl(target_bytecode_matcher, IsIntPtrConstant(kPointerSizeLog2))); |
| 334 | 334 |
| 335 if (interpreter::Bytecodes::IsStarLookahead(bytecode, operand_scale)) { |
| 336 Matcher<Node*> after_lookahead_offset = |
| 337 IsIntPtrAdd(next_bytecode_offset_matcher, |
| 338 IsIntPtrConstant(interpreter::Bytecodes::Size( |
| 339 Bytecode::kStar, operand_scale))); |
| 340 next_bytecode_offset_matcher = |
| 341 IsPhi(MachineType::PointerRepresentation(), |
| 342 next_bytecode_offset_matcher, after_lookahead_offset, _); |
| 343 Matcher<Node*> after_lookahead_bytecode = m.IsLoad( |
| 344 MachineType::Uint8(), |
| 345 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 346 after_lookahead_offset); |
| 347 if (kPointerSize == 8) { |
| 348 after_lookahead_bytecode = |
| 349 IsChangeUint32ToUint64(after_lookahead_bytecode); |
| 350 } |
| 351 target_bytecode_matcher = |
| 352 IsPhi(MachineRepresentation::kWord8, target_bytecode_matcher, |
| 353 after_lookahead_bytecode, _); |
| 354 code_target_matcher = m.IsLoad( |
| 355 MachineType::Pointer(), |
| 356 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 357 IsWordShl(target_bytecode_matcher, |
| 358 IsIntPtrConstant(kPointerSizeLog2))); |
| 359 } |
| 360 |
| 335 EXPECT_THAT( | 361 EXPECT_THAT( |
| 336 tail_call_node, | 362 tail_call_node, |
| 337 IsTailCall( | 363 IsTailCall( |
| 338 _, code_target_matcher, | 364 _, code_target_matcher, |
| 339 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), | 365 IsParameter(InterpreterDispatchDescriptor::kAccumulatorParameter), |
| 340 next_bytecode_offset_matcher, | 366 next_bytecode_offset_matcher, |
| 341 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), | 367 IsParameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter), |
| 342 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), | 368 IsParameter(InterpreterDispatchDescriptor::kDispatchTableParameter), |
| 343 _, _)); | 369 _, _)); |
| 344 } | 370 } |
| 345 } | 371 } |
| 346 | 372 |
| 347 TARGET_TEST_F(InterpreterAssemblerTest, Jump) { | 373 TARGET_TEST_F(InterpreterAssemblerTest, Jump) { |
| 348 // If debug code is enabled we emit extra code in Jump. | 374 // If debug code is enabled we emit extra code in Jump. |
| 349 if (FLAG_debug_code) return; | 375 if (FLAG_debug_code) return; |
| 350 | 376 |
| 351 int jump_offsets[] = {-9710, -77, 0, +3, +97109}; | 377 int jump_offsets[] = {-9710, -77, 0, +3, +97109}; |
| 352 TRACED_FOREACH(int, jump_offset, jump_offsets) { | 378 TRACED_FOREACH(int, jump_offset, jump_offsets) { |
| 353 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { | 379 TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) { |
| 380 if (!interpreter::Bytecodes::IsJump(bytecode)) return; |
| 381 |
| 354 InterpreterAssemblerForTest m(this, bytecode); | 382 InterpreterAssemblerForTest m(this, bytecode); |
| 355 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); | 383 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); |
| 356 | 384 |
| 357 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( | 385 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( |
| 358 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 386 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
| 359 IsIntPtrConstant(jump_offset)); | 387 IsIntPtrConstant(jump_offset)); |
| 360 Matcher<Node*> target_bytecode_matcher = | 388 Matcher<Node*> target_bytecode_matcher = |
| 361 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); | 389 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); |
| 362 if (kPointerSize == 8) { | 390 if (kPointerSize == 8) { |
| 363 target_bytecode_matcher = | 391 target_bytecode_matcher = |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 EXPECT_THAT(feedback_vector, | 731 EXPECT_THAT(feedback_vector, |
| 704 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, | 732 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, |
| 705 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 733 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
| 706 kHeapObjectTag))); | 734 kHeapObjectTag))); |
| 707 } | 735 } |
| 708 } | 736 } |
| 709 | 737 |
| 710 } // namespace interpreter | 738 } // namespace interpreter |
| 711 } // namespace internal | 739 } // namespace internal |
| 712 } // namespace v8 | 740 } // namespace v8 |
| OLD | NEW |