Commit 855d4b48 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

Create bytecode handlers and add them to the builtins table

This doubles the size of the snapshot since it creates all of the
handlers twice (and it doesn't use any of these new ones). However it's
all behind a flag.

For now all bytecode handlers are marked as being not Isolate
independent to prevent snapshot creation failures.

Bug: v8:8068
Change-Id: Id49f521445643d9fc6b141353f0a29b585160e10
Reviewed-on: https://chromium-review.googlesource.com/1185100
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55411}
parent dc5cb1f0
......@@ -23,6 +23,7 @@ include_rules = [
"+src/interpreter/bytecode-register.h",
"+src/interpreter/bytecodes.h",
"+src/interpreter/interpreter.h",
"+src/interpreter/interpreter-generator.h",
"+src/interpreter/setup-interpreter.h",
"-src/trap-handler",
"+src/trap-handler/trap-handler.h",
......
......@@ -316,6 +316,17 @@ bool Builtins::IsIsolateIndependent(int index) {
DCHECK(IsBuiltinId(index));
#ifndef V8_TARGET_ARCH_IA32
switch (index) {
// Bytecode handlers do not yet support being embedded.
#ifdef V8_EMBEDDED_BYTECODE_HANDLERS
#define BYTECODE_BUILTIN(Name, ...) \
case k##Name##Handler: \
case k##Name##WideHandler: \
case k##Name##ExtraWideHandler: \
return false;
BUILTIN_LIST_BYTECODE_HANDLERS(BYTECODE_BUILTIN)
#undef BYTECODE_BUILTIN
#endif // V8_EMBEDDED_BYTECODE_HANDLERS
// TODO(jgruber): There's currently two blockers for moving
// InterpreterEntryTrampoline into the binary:
// 1. InterpreterEnterBytecode calculates a pointer into the middle of
......
......@@ -11,6 +11,7 @@
#include "src/handles-inl.h"
#include "src/interface-descriptors.h"
#include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter-generator.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/objects/shared-function-info.h"
......@@ -248,10 +249,20 @@ void SetupIsolateDelegate::ReplacePlaceholders(Isolate* isolate) {
#ifdef V8_EMBEDDED_BYTECODE_HANDLERS
namespace {
Code* GenerateBytecodeHandler(Isolate* isolate, int builtin_index,
interpreter::Bytecode code,
interpreter::OperandScale scale) {
// TODO(v8:8068): Actually generate the handler.
return nullptr;
const char* name, interpreter::Bytecode bytecode,
interpreter::OperandScale operand_scale) {
if (!interpreter::Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) {
// TODO(v8:8068): Consider returning something else to avoid placeholders
// being serialized with the snapshot.
return nullptr;
}
Handle<Code> code = interpreter::GenerateBytecodeHandler(
isolate, bytecode, operand_scale, builtin_index);
PostBuildProfileAndTracing(isolate, *code, name);
return *code;
}
} // namespace
#endif
......@@ -298,13 +309,13 @@ void SetupIsolateDelegate::SetupBuiltinsInternal(Isolate* isolate) {
CallDescriptors::InterfaceDescriptor, #Name, 1); \
AddBuiltin(builtins, index++, code);
#define BUILD_BCH_WITH_SCALE(Code, Scale) \
code = \
GenerateBytecodeHandler(isolate, index, interpreter::Bytecode::k##Code, \
interpreter::OperandScale::k##Scale); \
if (code) { \
AddBuiltin(builtins, index, code); \
} \
#define BUILD_BCH_WITH_SCALE(Code, Scale) \
code = GenerateBytecodeHandler(isolate, index, Builtins::name(index), \
interpreter::Bytecode::k##Code, \
interpreter::OperandScale::k##Scale); \
if (code) { \
AddBuiltin(builtins, index, code); \
} \
++index;
#define BUILD_BCH(Code, ...) \
......
......@@ -3127,14 +3127,16 @@ IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
} // namespace
Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
OperandScale operand_scale) {
OperandScale operand_scale,
int builtin_index) {
Zone zone(isolate->allocator(), ZONE_NAME);
compiler::CodeAssemblerState state(
isolate, &zone, InterpreterDispatchDescriptor{}, Code::BYTECODE_HANDLER,
Bytecodes::ToString(bytecode),
FLAG_untrusted_code_mitigations
? PoisoningMitigationLevel::kPoisonCriticalOnly
: PoisoningMitigationLevel::kDontPoison);
: PoisoningMitigationLevel::kDontPoison,
0, builtin_index);
switch (bytecode) {
#define CALL_GENERATOR(Name, ...) \
......
......@@ -13,7 +13,8 @@ namespace internal {
namespace interpreter {
extern Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
OperandScale operand_scale);
OperandScale operand_scale,
int builtin_index);
extern Handle<Code> GenerateDeserializeLazyHandler(Isolate* isolate,
OperandScale operand_scale);
......
......@@ -80,7 +80,11 @@ void SetupInterpreter::InstallBytecodeHandler(Isolate* isolate,
if (!Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) return;
size_t index = Interpreter::GetDispatchTableIndex(bytecode, operand_scale);
Handle<Code> code = GenerateBytecodeHandler(isolate, bytecode, operand_scale);
// Here we explicitly set the bytecode handler to not be a builtin with an
// index of kNoBuiltinId.
// TODO(delphick): Use builtins version instead.
Handle<Code> code = GenerateBytecodeHandler(isolate, bytecode, operand_scale,
Builtins::kNoBuiltinId);
dispatch_table[index] = code->entry();
if (FLAG_print_builtin_size) PrintBuiltinSize(bytecode, operand_scale, code);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment