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::IsStarLookahead(bytecode, | |
381 OperandScale::kSingle)) { | |
382 return; | |
383 } | |
384 | |
klaasb
2016/07/20 11:22:55
Jump was the only caller of DispatchTo, to which I
rmcilroy
2016/07/20 11:36:25
Agreed - could you instead make the check:
if (!in
| |
354 InterpreterAssemblerForTest m(this, bytecode); | 385 InterpreterAssemblerForTest m(this, bytecode); |
355 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); | 386 Node* tail_call_node = m.Jump(m.IntPtrConstant(jump_offset)); |
356 | 387 |
357 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( | 388 Matcher<Node*> next_bytecode_offset_matcher = IsIntPtrAdd( |
358 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), | 389 IsParameter(InterpreterDispatchDescriptor::kBytecodeOffsetParameter), |
359 IsIntPtrConstant(jump_offset)); | 390 IsIntPtrConstant(jump_offset)); |
360 Matcher<Node*> target_bytecode_matcher = | 391 Matcher<Node*> target_bytecode_matcher = |
361 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); | 392 m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher); |
362 if (kPointerSize == 8) { | 393 if (kPointerSize == 8) { |
363 target_bytecode_matcher = | 394 target_bytecode_matcher = |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 EXPECT_THAT(feedback_vector, | 734 EXPECT_THAT(feedback_vector, |
704 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, | 735 m.IsLoad(MachineType::AnyTagged(), load_literals_matcher, |
705 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | 736 IsIntPtrConstant(LiteralsArray::kFeedbackVectorOffset - |
706 kHeapObjectTag))); | 737 kHeapObjectTag))); |
707 } | 738 } |
708 } | 739 } |
709 | 740 |
710 } // namespace interpreter | 741 } // namespace interpreter |
711 } // namespace internal | 742 } // namespace internal |
712 } // namespace v8 | 743 } // namespace v8 |
OLD | NEW |