Commit c68644bb authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[embed handlers] Make bytecode handlers isolate independent

Use BuiltinAssemblerOptions to generate AssemblerOptions when generating
the bytecode handlers (assuming v8_enable_embedded_bytecode_handlers is
on).

Mark all but InvokeIntrinsic, InvokeIntrinsicWide,
InvokeIntrinsicExtraWide, TestIn, TestInWide, TestInExtraWide and
TestTypeOf as isolate-independent. The excluded handlers create jump
tables which have absolute addresses.

Bug: v8:8068
Change-Id: Ia29e9c737ec345193e24fc2aa3684daefb113a9a
Reviewed-on: https://chromium-review.googlesource.com/1195508Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55514}
parent cb09d7b7
......@@ -316,15 +316,16 @@ bool Builtins::IsIsolateIndependent(int index) {
DCHECK(IsBuiltinId(index));
#ifndef V8_TARGET_ARCH_IA32
switch (index) {
// Bytecode handlers do not yet support being embedded.
// The following bytecode handlers do not yet support being embedded as they
// use internal references.
#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
case kInvokeIntrinsicHandler:
case kInvokeIntrinsicWideHandler:
case kInvokeIntrinsicExtraWideHandler:
case kTestInHandler:
case kTestInWideHandler:
case kTestInExtraWideHandler:
case kTestTypeOfHandler:
#endif // V8_EMBEDDED_BYTECODE_HANDLERS
// TODO(jgruber): There's currently two blockers for moving
......
......@@ -258,7 +258,8 @@ Code* GenerateBytecodeHandler(Isolate* isolate, int builtin_index,
}
Handle<Code> code = interpreter::GenerateBytecodeHandler(
isolate, bytecode, operand_scale, builtin_index);
isolate, bytecode, operand_scale, builtin_index,
BuiltinAssemblerOptions(isolate, builtin_index));
PostBuildProfileAndTracing(isolate, *code, name);
......
......@@ -3128,7 +3128,8 @@ IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
OperandScale operand_scale,
int builtin_index) {
int builtin_index,
const AssemblerOptions& options) {
Zone zone(isolate->allocator(), ZONE_NAME);
compiler::CodeAssemblerState state(
isolate, &zone, InterpreterDispatchDescriptor{}, Code::BYTECODE_HANDLER,
......@@ -3147,8 +3148,7 @@ Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
#undef CALL_GENERATOR
}
Handle<Code> code = compiler::CodeAssembler::GenerateCode(
&state, AssemblerOptions::Default(isolate));
Handle<Code> code = compiler::CodeAssembler::GenerateCode(&state, options);
PROFILE(isolate, CodeCreateEvent(
CodeEventListener::BYTECODE_HANDLER_TAG,
AbstractCode::cast(*code),
......
......@@ -10,11 +10,15 @@
namespace v8 {
namespace internal {
struct AssemblerOptions;
namespace interpreter {
extern Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
OperandScale operand_scale,
int builtin_index);
int builtin_index,
const AssemblerOptions& options);
extern Handle<Code> GenerateDeserializeLazyHandler(Isolate* isolate,
OperandScale operand_scale);
......
......@@ -4,6 +4,7 @@
#include "src/interpreter/setup-interpreter.h"
#include "src/assembler.h"
#include "src/handles-inl.h"
#include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter-generator.h"
......@@ -83,8 +84,9 @@ void SetupInterpreter::InstallBytecodeHandler(Isolate* isolate,
// 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);
Handle<Code> code = GenerateBytecodeHandler(
isolate, bytecode, operand_scale, Builtins::kNoBuiltinId,
AssemblerOptions::Default(isolate));
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