Chromium Code Reviews| Index: src/interpreter/setup-interpreter-full.cc |
| diff --git a/src/interpreter/setup-interpreter-full.cc b/src/interpreter/setup-interpreter-full.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dd6298a80e9c5738f8de912b5fe9058189ff8133 |
| --- /dev/null |
| +++ b/src/interpreter/setup-interpreter-full.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2017 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "src/interpreter/interpreter.h" |
| + |
| +#include "src/handles-inl.h" |
| +#include "src/interpreter/bytecodes.h" |
| +#include "src/interpreter/interpreter-generator.h" |
| +#include "src/objects-inl.h" |
| + |
| +namespace v8 { |
| +namespace internal { |
| +namespace interpreter { |
| + |
| +void Interpreter::Initialize() { |
| + DCHECK(!IsDispatchTableInitialized()); |
| + HandleScope scope(isolate_); |
| + |
| + if (FLAG_trace_ignition_dispatches) { |
| + static const int kBytecodeCount = static_cast<int>(Bytecode::kLast) + 1; |
| + bytecode_dispatch_counters_table_.reset( |
| + new uintptr_t[kBytecodeCount * kBytecodeCount]); |
| + memset(bytecode_dispatch_counters_table_.get(), 0, |
| + sizeof(uintptr_t) * kBytecodeCount * kBytecodeCount); |
| + } |
|
rmcilroy
2017/03/21 16:55:56
This code needs to be done for snapshot builds as
Jakob Kummerow
2017/03/28 10:35:16
Done.
As it turns out, cctests/test-serialize requ
|
| + |
| + // Generate bytecode handlers for all bytecodes and scales. |
| + const OperandScale kOperandScales[] = { |
| +#define VALUE(Name, _) OperandScale::k##Name, |
| + OPERAND_SCALE_LIST(VALUE) |
| +#undef VALUE |
| + }; |
| + |
| + for (OperandScale operand_scale : kOperandScales) { |
| +#define GENERATE_CODE(Name, ...) \ |
| + InstallBytecodeHandler(isolate_, Bytecode::k##Name, operand_scale); |
| + BYTECODE_LIST(GENERATE_CODE) |
| +#undef GENERATE_CODE |
| + } |
| + |
| + // Fill unused entries will the illegal bytecode handler. |
| + size_t illegal_index = |
| + GetDispatchTableIndex(Bytecode::kIllegal, OperandScale::kSingle); |
| + for (size_t index = 0; index < arraysize(dispatch_table_); ++index) { |
| + if (dispatch_table_[index] == nullptr) { |
| + dispatch_table_[index] = dispatch_table_[illegal_index]; |
| + } |
| + } |
| + |
| + // Initialization should have been successful. |
| + DCHECK(IsDispatchTableInitialized()); |
| +} |
| + |
| +void Interpreter::InstallBytecodeHandler(Isolate* isolate, Bytecode bytecode, |
| + OperandScale operand_scale) { |
| + if (!Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) return; |
| + if (ReuseExistingHandler(bytecode, operand_scale)) return; |
| + |
| + size_t index = GetDispatchTableIndex(bytecode, operand_scale); |
| + Handle<Code> code = GenerateBytecodeHandler(isolate, bytecode, operand_scale); |
| + dispatch_table_[index] = code->entry(); |
| +} |
| + |
| +} // namespace interpreter |
| +} // namespace internal |
| +} // namespace v8 |