| 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 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { | 25 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { |
| 26 memset(&dispatch_table_, 0, sizeof(dispatch_table_)); | 26 memset(&dispatch_table_, 0, sizeof(dispatch_table_)); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void Interpreter::Initialize() { | 29 void Interpreter::Initialize() { |
| 30 DCHECK(FLAG_ignition); | 30 DCHECK(FLAG_ignition); |
| 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 #define GENERATE_CODE(Name, ...) \ | 39 #define GENERATE_CODE(Name, ...) \ |
| 36 { \ | 40 { \ |
| 37 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name); \ | 41 InterpreterAssembler assembler(isolate_, &zone, Bytecode::k##Name); \ |
| 38 Do##Name(&assembler); \ | 42 Do##Name(&assembler); \ |
| 39 Handle<Code> code = assembler.GenerateCode(); \ | 43 Handle<Code> code = assembler.GenerateCode(); \ |
| 40 dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \ | 44 dispatch_table_[Bytecodes::ToByte(Bytecode::k##Name)] = *code; \ |
| 41 TraceCodegen(code); \ | 45 TraceCodegen(code); \ |
| 42 LOG_CODE_EVENT(isolate_, \ | 46 LOG_CODE_EVENT(isolate_, \ |
| 43 CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, \ | 47 CodeCreateEvent(Logger::BYTECODE_HANDLER_TAG, \ |
| 44 AbstractCode::cast(*code), #Name)); \ | 48 AbstractCode::cast(*code), #Name)); \ |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bytecodes->Print(os); | 108 bytecodes->Print(os); |
| 105 os << std::flush; | 109 os << std::flush; |
| 106 } | 110 } |
| 107 | 111 |
| 108 info->SetBytecodeArray(bytecodes); | 112 info->SetBytecodeArray(bytecodes); |
| 109 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); | 113 info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 110 return true; | 114 return true; |
| 111 } | 115 } |
| 112 | 116 |
| 113 bool Interpreter::IsDispatchTableInitialized() { | 117 bool Interpreter::IsDispatchTableInitialized() { |
| 114 if (FLAG_trace_ignition) { | 118 if (FLAG_trace_ignition || FLAG_ignition_count_handler_dispatches) { |
| 115 // Regenerate table to add bytecode tracing operations. | 119 // Regenerate table to add bytecode tracing operations. |
| 116 return false; | 120 return false; |
| 117 } | 121 } |
| 118 return dispatch_table_[0] != nullptr; | 122 return dispatch_table_[0] != nullptr; |
| 119 } | 123 } |
| 120 | 124 |
| 121 void Interpreter::TraceCodegen(Handle<Code> code) { | 125 void Interpreter::TraceCodegen(Handle<Code> code) { |
| 122 #ifdef ENABLE_DISASSEMBLER | 126 #ifdef ENABLE_DISASSEMBLER |
| 123 if (FLAG_trace_ignition_codegen) { | 127 if (FLAG_trace_ignition_codegen) { |
| 124 OFStream os(stdout); | 128 OFStream os(stdout); |
| (...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 Node* index = __ LoadRegister(index_reg); | 1926 Node* index = __ LoadRegister(index_reg); |
| 1923 Node* one = __ SmiConstant(Smi::FromInt(1)); | 1927 Node* one = __ SmiConstant(Smi::FromInt(1)); |
| 1924 Node* result = __ SmiAdd(index, one); | 1928 Node* result = __ SmiAdd(index, one); |
| 1925 __ SetAccumulator(result); | 1929 __ SetAccumulator(result); |
| 1926 __ Dispatch(); | 1930 __ Dispatch(); |
| 1927 } | 1931 } |
| 1928 | 1932 |
| 1929 } // namespace interpreter | 1933 } // namespace interpreter |
| 1930 } // namespace internal | 1934 } // namespace internal |
| 1931 } // namespace v8 | 1935 } // namespace v8 |
| OLD | NEW |