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.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 Loading... |
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 handlers_dispatch_counters_.Reset(new uintptr_t[kCountersTableRowSize]); |
| 38 memset(handlers_dispatch_counters_.get(), 0, |
| 39 sizeof(uintptr_t) * kCountersTableRowSize); |
| 40 } |
| 41 |
36 // Generate bytecode handlers for all bytecodes and scales. | 42 // Generate bytecode handlers for all bytecodes and scales. |
37 for (OperandScale operand_scale = OperandScale::kSingle; | 43 for (OperandScale operand_scale = OperandScale::kSingle; |
38 operand_scale <= OperandScale::kMaxValid; | 44 operand_scale <= OperandScale::kMaxValid; |
39 operand_scale = Bytecodes::NextOperandScale(operand_scale)) { | 45 operand_scale = Bytecodes::NextOperandScale(operand_scale)) { |
40 #define GENERATE_CODE(Name, ...) \ | 46 #define GENERATE_CODE(Name, ...) \ |
41 { \ | 47 { \ |
42 if (Bytecodes::BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \ | 48 if (Bytecodes::BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \ |
43 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \ | 49 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \ |
44 operand_scale); \ | 50 operand_scale); \ |
45 Do##Name(&assembler); \ | 51 Do##Name(&assembler); \ |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 bytecodes->Print(os); | 147 bytecodes->Print(os); |
142 os << std::flush; | 148 os << std::flush; |
143 } | 149 } |
144 | 150 |
145 info->SetBytecodeArray(bytecodes); | 151 info->SetBytecodeArray(bytecodes); |
146 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); | 152 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); |
147 return true; | 153 return true; |
148 } | 154 } |
149 | 155 |
150 bool Interpreter::IsDispatchTableInitialized() { | 156 bool Interpreter::IsDispatchTableInitialized() { |
151 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen) { | 157 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen || |
152 // Regenerate table to add bytecode tracing operations | 158 FLAG_trace_ignition_dispatches) { |
153 // or to print the assembly code generated by TurboFan. | 159 // Regenerate table to add bytecode tracing operations, |
| 160 // print the assembly code generated by TurboFan, |
| 161 // or instrument handlers with dispatch counters. |
154 return false; | 162 return false; |
155 } | 163 } |
156 return dispatch_table_[0] != nullptr; | 164 return dispatch_table_[0] != nullptr; |
157 } | 165 } |
158 | 166 |
159 void Interpreter::TraceCodegen(Handle<Code> code) { | 167 void Interpreter::TraceCodegen(Handle<Code> code) { |
160 #ifdef ENABLE_DISASSEMBLER | 168 #ifdef ENABLE_DISASSEMBLER |
161 if (FLAG_trace_ignition_codegen) { | 169 if (FLAG_trace_ignition_codegen) { |
162 OFStream os(stdout); | 170 OFStream os(stdout); |
163 code->Disassemble(nullptr, os); | 171 code->Disassemble(nullptr, os); |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 // Illegal | 1622 // Illegal |
1615 // | 1623 // |
1616 // An invalid bytecode aborting execution if dispatched. | 1624 // An invalid bytecode aborting execution if dispatched. |
1617 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { | 1625 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { |
1618 __ Abort(kInvalidBytecode); | 1626 __ Abort(kInvalidBytecode); |
1619 } | 1627 } |
1620 | 1628 |
1621 } // namespace interpreter | 1629 } // namespace interpreter |
1622 } // namespace internal | 1630 } // namespace internal |
1623 } // namespace v8 | 1631 } // namespace v8 |
OLD | NEW |