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