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 14 matching lines...) Expand all Loading... | |
25 | 25 |
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 if (IsDispatchTableInitialized()) return; | 31 if (IsDispatchTableInitialized()) return; |
32 Zone zone; | 32 Zone zone; |
33 HandleScope scope(isolate_); | 33 HandleScope scope(isolate_); |
34 | 34 |
35 if (FLAG_ignition_count_handler_dispatches) { | |
36 memset(handlers_dispatch_counters_, 0, sizeof(handlers_dispatch_counters_)); | |
37 } | |
38 | |
35 // Generate bytecode handlers for all bytecodes and scales. | 39 // Generate bytecode handlers for all bytecodes and scales. |
36 for (OperandScale operand_scale = OperandScale::kSingle; | 40 for (OperandScale operand_scale = OperandScale::kSingle; |
37 operand_scale <= OperandScale::kMaxValid; | 41 operand_scale <= OperandScale::kMaxValid; |
38 operand_scale = Bytecodes::NextOperandScale(operand_scale)) { | 42 operand_scale = Bytecodes::NextOperandScale(operand_scale)) { |
39 #define GENERATE_CODE(Name, ...) \ | 43 #define GENERATE_CODE(Name, ...) \ |
40 { \ | 44 { \ |
41 if (BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \ | 45 if (BytecodeHasHandler(Bytecode::k##Name, operand_scale)) { \ |
42 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \ | 46 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name, \ |
43 operand_scale); \ | 47 operand_scale); \ |
44 Do##Name(&assembler); \ | 48 Do##Name(&assembler); \ |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 bytecodes->Print(os); | 151 bytecodes->Print(os); |
148 os << std::flush; | 152 os << std::flush; |
149 } | 153 } |
150 | 154 |
151 info->SetBytecodeArray(bytecodes); | 155 info->SetBytecodeArray(bytecodes); |
152 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); | 156 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); |
153 return true; | 157 return true; |
154 } | 158 } |
155 | 159 |
156 bool Interpreter::IsDispatchTableInitialized() { | 160 bool Interpreter::IsDispatchTableInitialized() { |
157 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen) { | 161 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen || |
162 FLAG_ignition_count_handler_dispatches) { | |
158 // Regenerate table to add bytecode tracing operations | 163 // Regenerate table to add bytecode tracing operations |
159 // or to print the assembly code generated by TurboFan. | 164 // or to print the assembly code generated by TurboFan. |
rmcilroy
2016/04/05 10:00:46
Please update this comment
Stefano Sanfilippo
2016/04/05 14:01:46
Done.
| |
160 return false; | 165 return false; |
161 } | 166 } |
162 return dispatch_table_[0] != nullptr; | 167 return dispatch_table_[0] != nullptr; |
163 } | 168 } |
164 | 169 |
165 void Interpreter::TraceCodegen(Handle<Code> code) { | 170 void Interpreter::TraceCodegen(Handle<Code> code) { |
166 #ifdef ENABLE_DISASSEMBLER | 171 #ifdef ENABLE_DISASSEMBLER |
167 if (FLAG_trace_ignition_codegen) { | 172 if (FLAG_trace_ignition_codegen) { |
168 OFStream os(stdout); | 173 OFStream os(stdout); |
169 code->Disassemble(nullptr, os); | 174 code->Disassemble(nullptr, os); |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1618 // Illegal | 1623 // Illegal |
1619 // | 1624 // |
1620 // An invalid bytecode aborting execution if dispatched. | 1625 // An invalid bytecode aborting execution if dispatched. |
1621 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { | 1626 void Interpreter::DoIllegal(InterpreterAssembler* assembler) { |
1622 __ Abort(kInvalidBytecode); | 1627 __ Abort(kInvalidBytecode); |
1623 } | 1628 } |
1624 | 1629 |
1625 } // namespace interpreter | 1630 } // namespace interpreter |
1626 } // namespace internal | 1631 } // namespace internal |
1627 } // namespace v8 | 1632 } // namespace v8 |
OLD | NEW |