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 "src/interpreter/interpreter-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
6 | 6 |
7 #include <limits> | |
7 #include <ostream> | 8 #include <ostream> |
8 | 9 |
9 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
10 #include "src/frames.h" | 11 #include "src/frames.h" |
11 #include "src/interface-descriptors.h" | 12 #include "src/interface-descriptors.h" |
12 #include "src/interpreter/bytecodes.h" | 13 #include "src/interpreter/bytecodes.h" |
13 #include "src/interpreter/interpreter.h" | 14 #include "src/interpreter/interpreter.h" |
14 #include "src/machine-type.h" | 15 #include "src/machine-type.h" |
15 #include "src/macro-assembler.h" | 16 #include "src/macro-assembler.h" |
16 #include "src/zone.h" | 17 #include "src/zone.h" |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 DispatchTo(Advance(Bytecodes::Size(bytecode_, operand_scale_))); | 532 DispatchTo(Advance(Bytecodes::Size(bytecode_, operand_scale_))); |
532 } | 533 } |
533 | 534 |
534 void InterpreterAssembler::DispatchTo(Node* new_bytecode_offset) { | 535 void InterpreterAssembler::DispatchTo(Node* new_bytecode_offset) { |
535 Node* target_bytecode = Load( | 536 Node* target_bytecode = Load( |
536 MachineType::Uint8(), BytecodeArrayTaggedPointer(), new_bytecode_offset); | 537 MachineType::Uint8(), BytecodeArrayTaggedPointer(), new_bytecode_offset); |
537 if (kPointerSize == 8) { | 538 if (kPointerSize == 8) { |
538 target_bytecode = ChangeUint32ToUint64(target_bytecode); | 539 target_bytecode = ChangeUint32ToUint64(target_bytecode); |
539 } | 540 } |
540 | 541 |
542 if (FLAG_trace_ignition_dispatches) { | |
543 TraceHandlerToHandlerBytecodeDispatch(target_bytecode); | |
544 } | |
545 | |
541 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion | 546 // TODO(rmcilroy): Create a code target dispatch table to avoid conversion |
542 // from code object on every dispatch. | 547 // from code object on every dispatch. |
543 Node* target_code_object = | 548 Node* target_code_object = |
544 Load(MachineType::Pointer(), DispatchTableRawPointer(), | 549 Load(MachineType::Pointer(), DispatchTableRawPointer(), |
545 WordShl(target_bytecode, IntPtrConstant(kPointerSizeLog2))); | 550 WordShl(target_bytecode, IntPtrConstant(kPointerSizeLog2))); |
546 | 551 |
547 DispatchToBytecodeHandler(target_code_object, new_bytecode_offset); | 552 DispatchToBytecodeHandler(target_code_object, new_bytecode_offset); |
548 } | 553 } |
549 | 554 |
550 void InterpreterAssembler::DispatchToBytecodeHandler(Node* handler, | 555 void InterpreterAssembler::DispatchToBytecodeHandler(Node* handler, |
(...skipping 16 matching lines...) Expand all Loading... | |
567 // | 572 // |
568 // Indices 0-255 correspond to bytecodes with operand_scale == 0 | 573 // Indices 0-255 correspond to bytecodes with operand_scale == 0 |
569 // Indices 256-511 correspond to bytecodes with operand_scale == 1 | 574 // Indices 256-511 correspond to bytecodes with operand_scale == 1 |
570 // Indices 512-767 correspond to bytecodes with operand_scale == 2 | 575 // Indices 512-767 correspond to bytecodes with operand_scale == 2 |
571 Node* next_bytecode_offset = Advance(1); | 576 Node* next_bytecode_offset = Advance(1); |
572 Node* next_bytecode = Load(MachineType::Uint8(), BytecodeArrayTaggedPointer(), | 577 Node* next_bytecode = Load(MachineType::Uint8(), BytecodeArrayTaggedPointer(), |
573 next_bytecode_offset); | 578 next_bytecode_offset); |
574 if (kPointerSize == 8) { | 579 if (kPointerSize == 8) { |
575 next_bytecode = ChangeUint32ToUint64(next_bytecode); | 580 next_bytecode = ChangeUint32ToUint64(next_bytecode); |
576 } | 581 } |
582 | |
583 if (FLAG_trace_ignition_dispatches) { | |
584 TraceHandlerToHandlerBytecodeDispatch(next_bytecode); | |
585 } | |
586 | |
577 Node* base_index; | 587 Node* base_index; |
578 switch (operand_scale) { | 588 switch (operand_scale) { |
579 case OperandScale::kDouble: | 589 case OperandScale::kDouble: |
580 base_index = IntPtrConstant(1 << kBitsPerByte); | 590 base_index = IntPtrConstant(1 << kBitsPerByte); |
581 break; | 591 break; |
582 case OperandScale::kQuadruple: | 592 case OperandScale::kQuadruple: |
583 base_index = IntPtrConstant(2 << kBitsPerByte); | 593 base_index = IntPtrConstant(2 << kBitsPerByte); |
584 break; | 594 break; |
585 default: | 595 default: |
586 UNREACHABLE(); | 596 UNREACHABLE(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
650 Bind(&match); | 660 Bind(&match); |
651 Goto(&end); | 661 Goto(&end); |
652 Bind(&end); | 662 Bind(&end); |
653 } | 663 } |
654 | 664 |
655 void InterpreterAssembler::TraceBytecode(Runtime::FunctionId function_id) { | 665 void InterpreterAssembler::TraceBytecode(Runtime::FunctionId function_id) { |
656 CallRuntime(function_id, GetContext(), BytecodeArrayTaggedPointer(), | 666 CallRuntime(function_id, GetContext(), BytecodeArrayTaggedPointer(), |
657 SmiTag(BytecodeOffset()), GetAccumulator()); | 667 SmiTag(BytecodeOffset()), GetAccumulator()); |
658 } | 668 } |
659 | 669 |
670 void InterpreterAssembler::TraceHandlerToHandlerBytecodeDispatch( | |
rmcilroy
2016/04/08 11:24:44
Just TraceBytecodeDispatch
Stefano Sanfilippo
2016/04/08 14:42:44
Done.
| |
671 Node* target_index) { | |
rmcilroy
2016/04/08 11:24:44
/s/target_index/target_bytecode
Stefano Sanfilippo
2016/04/08 14:42:44
Done.
| |
672 Node* counters_table = ExternalConstant( | |
673 ExternalReference::interpreter_handler_to_handler_dispatch_counters( | |
674 isolate())); | |
675 Node* handler_row_base = IntPtrConstant( | |
rmcilroy
2016/04/08 11:24:44
source_bytecode_table_index
Stefano Sanfilippo
2016/04/08 14:42:44
Done.
| |
676 static_cast<int>(bytecode_) * (static_cast<int>(Bytecode::kLast) + 1)); | |
677 | |
678 Node* counter_offset = WordShl(IntPtrAdd(handler_row_base, target_index), | |
679 IntPtrConstant(kPointerSizeLog2)); | |
680 | |
681 SaturatedCounterIncrement(counters_table, counter_offset); | |
682 } | |
683 | |
684 void InterpreterAssembler::SaturatedCounterIncrement(Node* counters_table, | |
rmcilroy
2016/04/08 11:24:44
Just do this inline above
Stefano Sanfilippo
2016/04/08 14:42:44
Done.
| |
685 Node* counter_offset) { | |
686 Node* old_counter = | |
687 Load(MachineType::IntPtr(), counters_table, counter_offset); | |
688 | |
689 CodeStubAssembler::Label counter_ok(this); | |
690 CodeStubAssembler::Label counter_saturated(this); | |
691 CodeStubAssembler::Label end(this); | |
692 | |
693 Node* counter_reached_max = WordEqual( | |
694 old_counter, IntPtrConstant(std::numeric_limits<uintptr_t>::max())); | |
695 Branch(counter_reached_max, &counter_saturated, &counter_ok); | |
696 Bind(&counter_ok); | |
697 Node* new_counter = IntPtrAdd(old_counter, IntPtrConstant(1)); | |
698 StoreNoWriteBarrier(kPointerSize == 8 ? MachineRepresentation::kWord64 | |
699 : MachineRepresentation::kWord32, | |
rmcilroy
2016/04/08 11:24:43
PointerRepresentation()
Stefano Sanfilippo
2016/04/08 14:42:44
Done.
| |
700 counters_table, counter_offset, new_counter); | |
701 Goto(&end); | |
702 Bind(&counter_saturated); | |
703 Goto(&end); | |
704 Bind(&end); | |
705 } | |
706 | |
660 // static | 707 // static |
661 bool InterpreterAssembler::TargetSupportsUnalignedAccess() { | 708 bool InterpreterAssembler::TargetSupportsUnalignedAccess() { |
662 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 709 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
663 return false; | 710 return false; |
664 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC | 711 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC |
665 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); | 712 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); |
666 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ | 713 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ |
667 V8_TARGET_ARCH_S390 | 714 V8_TARGET_ARCH_S390 |
668 return true; | 715 return true; |
669 #else | 716 #else |
670 #error "Unknown Architecture" | 717 #error "Unknown Architecture" |
671 #endif | 718 #endif |
672 } | 719 } |
673 | 720 |
674 } // namespace interpreter | 721 } // namespace interpreter |
675 } // namespace internal | 722 } // namespace internal |
676 } // namespace v8 | 723 } // namespace v8 |
OLD | NEW |