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

Unified Diff: src/interpreter/setup-interpreter-internal.cc

Issue 2760233005: [snapshot] Move builtins generation into mksnapshot (Closed)
Patch Set: fix GYP builds Created 3 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/setup-interpreter.h ('k') | src/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/setup-interpreter-internal.cc
diff --git a/src/interpreter/setup-interpreter-internal.cc b/src/interpreter/setup-interpreter-internal.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1477ee8c7b145250c99e6ac3c1a66abf73cf0888
--- /dev/null
+++ b/src/interpreter/setup-interpreter-internal.cc
@@ -0,0 +1,94 @@
+// 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/setup-interpreter.h"
+
+#include "src/handles-inl.h"
+#include "src/interpreter/bytecodes.h"
+#include "src/interpreter/interpreter-generator.h"
+#include "src/interpreter/interpreter.h"
+#include "src/objects-inl.h"
+
+namespace v8 {
+namespace internal {
+namespace interpreter {
+
+// static
+void SetupInterpreter::InstallBytecodeHandlers(Interpreter* interpreter) {
+ DCHECK(!interpreter->IsDispatchTableInitialized());
+ HandleScope scope(interpreter->isolate_);
+ Address* dispatch_table = interpreter->dispatch_table_;
+
+ // 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(interpreter->isolate_, dispatch_table, \
+ Bytecode::k##Name, operand_scale);
+ BYTECODE_LIST(GENERATE_CODE)
+#undef GENERATE_CODE
+ }
+
+ // Fill unused entries will the illegal bytecode handler.
+ size_t illegal_index = Interpreter::GetDispatchTableIndex(
+ Bytecode::kIllegal, OperandScale::kSingle);
+ for (size_t index = 0; index < Interpreter::kDispatchTableSize; ++index) {
+ if (dispatch_table[index] == nullptr) {
+ dispatch_table[index] = dispatch_table[illegal_index];
+ }
+ }
+
+ // Initialization should have been successful.
+ DCHECK(interpreter->IsDispatchTableInitialized());
+}
+
+// static
+bool SetupInterpreter::ReuseExistingHandler(Address* dispatch_table,
+ Bytecode bytecode,
+ OperandScale operand_scale) {
+ size_t index = Interpreter::GetDispatchTableIndex(bytecode, operand_scale);
+ switch (bytecode) {
+ case Bytecode::kCallProperty:
+ case Bytecode::kCallProperty0:
+ case Bytecode::kCallProperty1:
+ case Bytecode::kCallProperty2: {
+ const int offset = static_cast<int>(Bytecode::kCallProperty) -
+ static_cast<int>(Bytecode::kCall);
+ STATIC_ASSERT(offset == static_cast<int>(Bytecode::kCallProperty0) -
+ static_cast<int>(Bytecode::kCall0));
+ STATIC_ASSERT(offset == static_cast<int>(Bytecode::kCallProperty1) -
+ static_cast<int>(Bytecode::kCall1));
+ STATIC_ASSERT(offset == static_cast<int>(Bytecode::kCallProperty2) -
+ static_cast<int>(Bytecode::kCall2));
+ CHECK_LT(offset, index);
+ dispatch_table[index] = dispatch_table[index - offset];
+ return true;
+ break;
+ }
+ default:
+ return false;
+ }
+}
+
+// static
+void SetupInterpreter::InstallBytecodeHandler(Isolate* isolate,
+ Address* dispatch_table,
+ Bytecode bytecode,
+ OperandScale operand_scale) {
+ if (!Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) return;
+ if (ReuseExistingHandler(dispatch_table, bytecode, operand_scale)) return;
+
+ size_t index = Interpreter::GetDispatchTableIndex(bytecode, operand_scale);
+ Handle<Code> code = GenerateBytecodeHandler(isolate, bytecode, operand_scale);
+ dispatch_table[index] = code->entry();
+}
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/interpreter/setup-interpreter.h ('k') | src/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698