[interpreter] Ensure --debug-code works with snapshots.

This makes sure that bytecode handlers are regenerated when debugging
code within handlers is being requested. We cannot use the handlers
baked into the snapshot in this case.

R=rmcilroy@chromium.org

Review-Url: https://codereview.chromium.org/2443923002
Cr-Commit-Position: refs/heads/master@{#40555}
This commit is contained in:
mstarzinger 2016-10-25 03:30:16 -07:00 committed by Commit bot
parent ad9cf53473
commit 438c5eb28b
2 changed files with 16 additions and 7 deletions

View File

@ -53,7 +53,7 @@ Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
}
void Interpreter::Initialize() {
if (IsDispatchTableInitialized()) return;
if (!ShouldInitializeDispatchTable()) return;
Zone zone(isolate_->allocator(), ZONE_NAME);
HandleScope scope(isolate_);
@ -103,6 +103,9 @@ void Interpreter::Initialize() {
dispatch_table_[index] = dispatch_table_[illegal_index];
}
}
// Initialization should have been successful.
DCHECK(IsDispatchTableInitialized());
}
Code* Interpreter::GetBytecodeHandler(Bytecode bytecode,
@ -215,15 +218,20 @@ CompilationJob* Interpreter::NewCompilationJob(CompilationInfo* info) {
}
bool Interpreter::IsDispatchTableInitialized() {
if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
FLAG_trace_ignition_dispatches) {
// Regenerate table to add bytecode tracing operations, print the assembly
// code generated by TurboFan or instrument handlers with dispatch counters.
return false;
}
return dispatch_table_[0] != nullptr;
}
bool Interpreter::ShouldInitializeDispatchTable() {
if (FLAG_trace_ignition || FLAG_trace_ignition_codegen ||
FLAG_trace_ignition_dispatches || FLAG_debug_code) {
// Regenerate table to add bytecode tracing operations, print the assembly
// code generated by TurboFan, instrument handlers with dispatch counters,
// or insert debugging code into the bytecode handlers.
return true;
}
return !IsDispatchTableInitialized();
}
void Interpreter::TraceCodegen(Handle<Code> code) {
#ifdef ENABLE_DISASSEMBLER
if (FLAG_trace_ignition_codegen) {

View File

@ -175,6 +175,7 @@ class Interpreter {
OperandScale operand_scale);
bool IsDispatchTableInitialized();
bool ShouldInitializeDispatchTable();
static const int kNumberOfWideVariants = 3;
static const int kDispatchTableSize = kNumberOfWideVariants * (kMaxUInt8 + 1);