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

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

Issue 1828633003: [Interpreter] Enable tracing of bytecode handler dispatches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@count-bc
Patch Set: 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
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.h" 5 #include "src/interpreter/interpreter.h"
6 6
7 #include "src/ast/prettyprinter.h" 7 #include "src/ast/prettyprinter.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 15 matching lines...) Expand all
26 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { 26 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
27 memset(dispatch_table_, 0, sizeof(dispatch_table_)); 27 memset(dispatch_table_, 0, sizeof(dispatch_table_));
28 } 28 }
29 29
30 void Interpreter::Initialize() { 30 void Interpreter::Initialize() {
31 DCHECK(FLAG_ignition); 31 DCHECK(FLAG_ignition);
32 if (IsDispatchTableInitialized()) return; 32 if (IsDispatchTableInitialized()) return;
33 Zone zone(isolate_->allocator()); 33 Zone zone(isolate_->allocator());
34 HandleScope scope(isolate_); 34 HandleScope scope(isolate_);
35 35
36 if (FLAG_trace_ignition_dispatches) {
37 static const int kBytecodeCount = static_cast<int>(Bytecode::kLast) + 1;
38 bytecode_dispatch_count_table_.Reset(
39 new uintptr_t[kBytecodeCount * kBytecodeCount]);
40 memset(bytecode_dispatch_count_table_.get(), 0,
41 sizeof(uintptr_t) * kBytecodeCount * kBytecodeCount);
42 }
43
36 // Generate bytecode handlers for all bytecodes and scales. 44 // Generate bytecode handlers for all bytecodes and scales.
37 for (OperandScale operand_scale = OperandScale::kSingle; 45 for (OperandScale operand_scale = OperandScale::kSingle;
38 operand_scale <= OperandScale::kMaxValid; 46 operand_scale <= OperandScale::kMaxValid;
39 operand_scale = Bytecodes::NextOperandScale(operand_scale)) { 47 operand_scale = Bytecodes::NextOperandScale(operand_scale)) {
40 #define GENERATE_CODE(Name, ...) \ 48 #define GENERATE_CODE(Name, ...) \
41 { \ 49 { \
42 if (Bytecodes::BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \ 50 if (Bytecodes::BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \
43 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \ 51 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \
44 operand_scale); \ 52 operand_scale); \
45 Do##Name(&assembler); \ 53 Do##Name(&assembler); \
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 bytecodes->Print(os); 149 bytecodes->Print(os);
142 os << std::flush; 150 os << std::flush;
143 } 151 }
144 152
145 info->SetBytecodeArray(bytecodes); 153 info->SetBytecodeArray(bytecodes);
146 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); 154 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline());
147 return true; 155 return true;
148 } 156 }
149 157
150 bool Interpreter::IsDispatchTableInitialized() { 158 bool Interpreter::IsDispatchTableInitialized() {
151 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen) { 159 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
152 // Regenerate table to add bytecode tracing operations 160 FLAG_trace_ignition_dispatches) {
153 // or to print the assembly code generated by TurboFan. 161 // Regenerate table to add bytecode tracing operations,
162 // print the assembly code generated by TurboFan,
163 // or instrument handlers with dispatch counters.
154 return false; 164 return false;
155 } 165 }
156 return dispatch_table_[0] != nullptr; 166 return dispatch_table_[0] != nullptr;
157 } 167 }
158 168
159 void Interpreter::TraceCodegen(Handle<Code> code) { 169 void Interpreter::TraceCodegen(Handle<Code> code) {
160 #ifdef ENABLE_DISASSEMBLER 170 #ifdef ENABLE_DISASSEMBLER
161 if (FLAG_trace_ignition_codegen) { 171 if (FLAG_trace_ignition_codegen) {
162 OFStream os(stdout); 172 OFStream os(stdout);
163 code->Disassemble(nullptr, os); 173 code->Disassemble(nullptr, os);
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 // Illegal 1624 // Illegal
1615 // 1625 //
1616 // An invalid bytecode aborting execution if dispatched. 1626 // An invalid bytecode aborting execution if dispatched.
1617 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { 1627 void Interpreter::DoIllegal(InterpreterAssembler* assembler) {
1618 __ Abort(kInvalidBytecode); 1628 __ Abort(kInvalidBytecode);
1619 } 1629 }
1620 1630
1621 } // namespace interpreter 1631 } // namespace interpreter
1622 } // namespace internal 1632 } // namespace internal
1623 } // namespace v8 1633 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698