Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: src/interpreter/interpreter-assembler.cc

Issue 1828633003: [Interpreter] Enable tracing of bytecode handler dispatches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@count-bc
Patch Set: Second review. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 TraceBytecodeDispatch(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
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 TraceBytecodeDispatch(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
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::TraceBytecodeDispatch(Node* target_bytecode) {
671 Node* counters_table = ExternalConstant(
672 ExternalReference::interpreter_dispatch_counters(isolate()));
673 Node* source_bytecode_table_index = IntPtrConstant(
674 static_cast<int>(bytecode_) * (static_cast<int>(Bytecode::kLast) + 1));
675
676 Node* counter_offset =
677 WordShl(IntPtrAdd(source_bytecode_table_index, target_bytecode),
678 IntPtrConstant(kPointerSizeLog2));
679 Node* old_counter =
680 Load(MachineType::IntPtr(), counters_table, counter_offset);
681
682 CodeStubAssembler::Label counter_ok(this);
683 CodeStubAssembler::Label counter_saturated(this);
684 CodeStubAssembler::Label end(this);
685
686 Node* counter_reached_max = WordEqual(
687 old_counter, IntPtrConstant(std::numeric_limits<uintptr_t>::max()));
688 Branch(counter_reached_max, &counter_saturated, &counter_ok);
689 Bind(&counter_ok);
690 Node* new_counter = IntPtrAdd(old_counter, IntPtrConstant(1));
691 StoreNoWriteBarrier(MachineType::PointerRepresentation(), counters_table,
692 counter_offset, new_counter);
693 Goto(&end);
694 Bind(&counter_saturated);
695 Goto(&end);
696 Bind(&end);
697 }
698
660 // static 699 // static
661 bool InterpreterAssembler::TargetSupportsUnalignedAccess() { 700 bool InterpreterAssembler::TargetSupportsUnalignedAccess() {
662 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 701 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
663 return false; 702 return false;
664 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC 703 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC
665 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); 704 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES);
666 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ 705 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \
667 V8_TARGET_ARCH_S390 706 V8_TARGET_ARCH_S390
668 return true; 707 return true;
669 #else 708 #else
670 #error "Unknown Architecture" 709 #error "Unknown Architecture"
671 #endif 710 #endif
672 } 711 }
673 712
674 } // namespace interpreter 713 } // namespace interpreter
675 } // namespace internal 714 } // namespace internal
676 } // namespace v8 715 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698