Commit b9dde931 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] No longer require Isolate for runtime stubs.

R=jgruber@chromium.org

Change-Id: I03c1aec177c389bf4d6550a26ad30d870e10135a
Reviewed-on: https://chromium-review.googlesource.com/c/1477738
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59699}
parent d992246d
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "src/macro-assembler.h" #include "src/macro-assembler.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/snapshot/embedded-data.h"
#include "src/wasm/compilation-environment.h" #include "src/wasm/compilation-environment.h"
#include "src/wasm/function-compiler.h" #include "src/wasm/function-compiler.h"
#include "src/wasm/jump-table-assembler.h" #include "src/wasm/jump-table-assembler.h"
...@@ -503,16 +504,16 @@ void NativeModule::SetLazyBuiltin(Handle<Code> code) { ...@@ -503,16 +504,16 @@ void NativeModule::SetLazyBuiltin(Handle<Code> code) {
jump_table_->instructions().size()); jump_table_->instructions().size());
} }
// TODO(mstarzinger): Remove {Isolate} parameter once {V8_EMBEDDED_BUILTINS}
// was removed and embedded builtins are no longer optional.
void NativeModule::SetRuntimeStubs(Isolate* isolate) { void NativeModule::SetRuntimeStubs(Isolate* isolate) {
// TODO(mstarzinger): Switch this from accessing the {Isolate} to using the
// embedded blob directly. This will allow us to do this from the background.
HandleScope scope(isolate);
DCHECK_EQ(kNullAddress, runtime_stub_entries_[0]); // Only called once. DCHECK_EQ(kNullAddress, runtime_stub_entries_[0]); // Only called once.
#ifdef V8_EMBEDDED_BUILTINS #ifdef V8_EMBEDDED_BUILTINS
WasmCode* jump_table = WasmCode* jump_table =
CreateEmptyJumpTable(JumpTableAssembler::SizeForNumberOfStubSlots( CreateEmptyJumpTable(JumpTableAssembler::SizeForNumberOfStubSlots(
WasmCode::kRuntimeStubCount)); WasmCode::kRuntimeStubCount));
Address base = jump_table->instruction_start(); Address base = jump_table->instruction_start();
EmbeddedData embedded_data = EmbeddedData::FromBlob();
#define RUNTIME_STUB(Name) {Builtins::k##Name, WasmCode::k##Name}, #define RUNTIME_STUB(Name) {Builtins::k##Name, WasmCode::k##Name},
#define RUNTIME_STUB_TRAP(Name) RUNTIME_STUB(ThrowWasm##Name) #define RUNTIME_STUB_TRAP(Name) RUNTIME_STUB(ThrowWasm##Name)
std::pair<Builtins::Name, WasmCode::RuntimeStubId> wasm_runtime_stubs[] = { std::pair<Builtins::Name, WasmCode::RuntimeStubId> wasm_runtime_stubs[] = {
...@@ -520,11 +521,10 @@ void NativeModule::SetRuntimeStubs(Isolate* isolate) { ...@@ -520,11 +521,10 @@ void NativeModule::SetRuntimeStubs(Isolate* isolate) {
#undef RUNTIME_STUB #undef RUNTIME_STUB
#undef RUNTIME_STUB_TRAP #undef RUNTIME_STUB_TRAP
for (auto pair : wasm_runtime_stubs) { for (auto pair : wasm_runtime_stubs) {
Handle<Code> builtin_code = isolate->builtins()->builtin_handle(pair.first); CHECK(embedded_data.ContainsBuiltin(pair.first));
CHECK(builtin_code->is_off_heap_trampoline()); Address builtin = embedded_data.InstructionStartOfBuiltin(pair.first);
JumpTableAssembler::EmitRuntimeStubSlot( JumpTableAssembler::EmitRuntimeStubSlot(base, pair.second, builtin,
base, pair.second, builtin_code->OffHeapInstructionStart(), WasmCode::kNoFlushICache);
WasmCode::kNoFlushICache);
uint32_t slot_offset = uint32_t slot_offset =
JumpTableAssembler::StubSlotIndexToOffset(pair.second); JumpTableAssembler::StubSlotIndexToOffset(pair.second);
runtime_stub_entries_[pair.second] = base + slot_offset; runtime_stub_entries_[pair.second] = base + slot_offset;
...@@ -534,6 +534,7 @@ void NativeModule::SetRuntimeStubs(Isolate* isolate) { ...@@ -534,6 +534,7 @@ void NativeModule::SetRuntimeStubs(Isolate* isolate) {
DCHECK_NULL(runtime_stub_table_); DCHECK_NULL(runtime_stub_table_);
runtime_stub_table_ = jump_table; runtime_stub_table_ = jump_table;
#else // V8_EMBEDDED_BUILTINS #else // V8_EMBEDDED_BUILTINS
HandleScope scope(isolate);
USE(runtime_stub_table_); // Actually unused, but avoids ifdef's in header. USE(runtime_stub_table_); // Actually unused, but avoids ifdef's in header.
#define COPY_BUILTIN(Name) \ #define COPY_BUILTIN(Name) \
runtime_stub_entries_[WasmCode::k##Name] = \ runtime_stub_entries_[WasmCode::k##Name] = \
......
...@@ -256,10 +256,9 @@ class V8_EXPORT_PRIVATE NativeModule final { ...@@ -256,10 +256,9 @@ class V8_EXPORT_PRIVATE NativeModule final {
// jump table will be populated with that copy. // jump table will be populated with that copy.
void SetLazyBuiltin(Handle<Code> code); void SetLazyBuiltin(Handle<Code> code);
// Initializes all runtime stubs by copying them over from the JS-allocated // Initializes all runtime stubs by setting up entry addresses in the runtime
// heap into this native module. It must be called exactly once per native // stub table. It must be called exactly once per native module before adding
// module before adding other WasmCode so that runtime stub ids can be // other WasmCode so that runtime stub ids can be resolved during relocation.
// resolved during relocation.
void SetRuntimeStubs(Isolate* isolate); void SetRuntimeStubs(Isolate* isolate);
// Makes the code available to the system (by entering it into the code table // Makes the code available to the system (by entering it into the code table
......
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