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

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

Issue 2443923002: [interpreter] Ensure --debug-code works with snapshots. (Closed)
Patch Set: Addressed comment. Created 4 years, 1 month 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
« no previous file with comments | « src/interpreter/interpreter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <fstream> 7 #include <fstream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 BytecodeGenerator generator_; 46 BytecodeGenerator generator_;
47 47
48 DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob); 48 DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob);
49 }; 49 };
50 50
51 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) { 51 Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
52 memset(dispatch_table_, 0, sizeof(dispatch_table_)); 52 memset(dispatch_table_, 0, sizeof(dispatch_table_));
53 } 53 }
54 54
55 void Interpreter::Initialize() { 55 void Interpreter::Initialize() {
56 if (IsDispatchTableInitialized()) return; 56 if (!ShouldInitializeDispatchTable()) return;
57 Zone zone(isolate_->allocator(), ZONE_NAME); 57 Zone zone(isolate_->allocator(), ZONE_NAME);
58 HandleScope scope(isolate_); 58 HandleScope scope(isolate_);
59 59
60 if (FLAG_trace_ignition_dispatches) { 60 if (FLAG_trace_ignition_dispatches) {
61 static const int kBytecodeCount = static_cast<int>(Bytecode::kLast) + 1; 61 static const int kBytecodeCount = static_cast<int>(Bytecode::kLast) + 1;
62 bytecode_dispatch_counters_table_.reset( 62 bytecode_dispatch_counters_table_.reset(
63 new uintptr_t[kBytecodeCount * kBytecodeCount]); 63 new uintptr_t[kBytecodeCount * kBytecodeCount]);
64 memset(bytecode_dispatch_counters_table_.get(), 0, 64 memset(bytecode_dispatch_counters_table_.get(), 0,
65 sizeof(uintptr_t) * kBytecodeCount * kBytecodeCount); 65 sizeof(uintptr_t) * kBytecodeCount * kBytecodeCount);
66 } 66 }
(...skipping 29 matching lines...) Expand all
96 } 96 }
97 97
98 // Fill unused entries will the illegal bytecode handler. 98 // Fill unused entries will the illegal bytecode handler.
99 size_t illegal_index = 99 size_t illegal_index =
100 GetDispatchTableIndex(Bytecode::kIllegal, OperandScale::kSingle); 100 GetDispatchTableIndex(Bytecode::kIllegal, OperandScale::kSingle);
101 for (size_t index = 0; index < arraysize(dispatch_table_); ++index) { 101 for (size_t index = 0; index < arraysize(dispatch_table_); ++index) {
102 if (dispatch_table_[index] == nullptr) { 102 if (dispatch_table_[index] == nullptr) {
103 dispatch_table_[index] = dispatch_table_[illegal_index]; 103 dispatch_table_[index] = dispatch_table_[illegal_index];
104 } 104 }
105 } 105 }
106
107 // Initialization should have been successful.
108 DCHECK(IsDispatchTableInitialized());
106 } 109 }
107 110
108 Code* Interpreter::GetBytecodeHandler(Bytecode bytecode, 111 Code* Interpreter::GetBytecodeHandler(Bytecode bytecode,
109 OperandScale operand_scale) { 112 OperandScale operand_scale) {
110 DCHECK(IsDispatchTableInitialized()); 113 DCHECK(IsDispatchTableInitialized());
111 DCHECK(Bytecodes::BytecodeHasHandler(bytecode, operand_scale)); 114 DCHECK(Bytecodes::BytecodeHasHandler(bytecode, operand_scale));
112 size_t index = GetDispatchTableIndex(bytecode, operand_scale); 115 size_t index = GetDispatchTableIndex(bytecode, operand_scale);
113 Address code_entry = dispatch_table_[index]; 116 Address code_entry = dispatch_table_[index];
114 return Code::GetCodeFromTargetAddress(code_entry); 117 return Code::GetCodeFromTargetAddress(code_entry);
115 } 118 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 info()->SetBytecodeArray(bytecodes); 209 info()->SetBytecodeArray(bytecodes);
207 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline()); 210 info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline());
208 return SUCCEEDED; 211 return SUCCEEDED;
209 } 212 }
210 213
211 CompilationJob* Interpreter::NewCompilationJob(CompilationInfo* info) { 214 CompilationJob* Interpreter::NewCompilationJob(CompilationInfo* info) {
212 return new InterpreterCompilationJob(info); 215 return new InterpreterCompilationJob(info);
213 } 216 }
214 217
215 bool Interpreter::IsDispatchTableInitialized() { 218 bool Interpreter::IsDispatchTableInitialized() {
216 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
217 FLAG_trace_ignition_dispatches) {
218 // Regenerate table to add bytecode tracing operations, print the assembly
219 // code generated by TurboFan or instrument handlers with dispatch counters.
220 return false;
221 }
222 return dispatch_table_[0] != nullptr; 219 return dispatch_table_[0] != nullptr;
223 } 220 }
224 221
222 bool Interpreter::ShouldInitializeDispatchTable() {
223 if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
224 FLAG_trace_ignition_dispatches || FLAG_debug_code) {
225 // Regenerate table to add bytecode tracing operations, print the assembly
226 // code generated by TurboFan, instrument handlers with dispatch counters,
227 // or insert debugging code into the bytecode handlers.
228 return true;
229 }
230 return !IsDispatchTableInitialized();
231 }
232
225 void Interpreter::TraceCodegen(Handle<Code> code) { 233 void Interpreter::TraceCodegen(Handle<Code> code) {
226 #ifdef ENABLE_DISASSEMBLER 234 #ifdef ENABLE_DISASSEMBLER
227 if (FLAG_trace_ignition_codegen) { 235 if (FLAG_trace_ignition_codegen) {
228 OFStream os(stdout); 236 OFStream os(stdout);
229 code->Disassemble(nullptr, os); 237 code->Disassemble(nullptr, os);
230 os << std::flush; 238 os << std::flush;
231 } 239 }
232 #endif // ENABLE_DISASSEMBLER 240 #endif // ENABLE_DISASSEMBLER
233 } 241 }
234 242
(...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2637 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2645 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2638 __ SmiTag(new_state)); 2646 __ SmiTag(new_state));
2639 __ SetAccumulator(old_state); 2647 __ SetAccumulator(old_state);
2640 2648
2641 __ Dispatch(); 2649 __ Dispatch();
2642 } 2650 }
2643 2651
2644 } // namespace interpreter 2652 } // namespace interpreter
2645 } // namespace internal 2653 } // namespace internal
2646 } // namespace v8 2654 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698