[wasm] Move wasm objects from Isolate to new WasmEngine object
This is a small refactoring that moves the WasmCodeManager and CompilationManager from being a part of the Isolate directly to living in a new WasmEngine object. This makes it easier to change Wasm components without rebuilding so much of V8, and also enables future changes to Wasm without affecting unrelated parts of V8. Bug: v8:7109 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Ic89bfc3974483aa909d12556d1386e18785a1d71 Reviewed-on: https://chromium-review.googlesource.com/804824 Commit-Queue: Eric Holk <eholk@chromium.org> Reviewed-by: Ben Titzer <titzer@chromium.org> Cr-Commit-Position: refs/heads/master@{#49848}
This commit is contained in:
parent
cb9e7af4e5
commit
5fb4b176fa
1
BUILD.gn
1
BUILD.gn
@ -2118,6 +2118,7 @@ v8_source_set("v8_base") {
|
||||
"src/wasm/wasm-code-wrapper.cc",
|
||||
"src/wasm/wasm-code-wrapper.h",
|
||||
"src/wasm/wasm-debug.cc",
|
||||
"src/wasm/wasm-engine.h",
|
||||
"src/wasm/wasm-external-refs.cc",
|
||||
"src/wasm/wasm-external-refs.h",
|
||||
"src/wasm/wasm-heap.cc",
|
||||
|
@ -84,6 +84,7 @@
|
||||
#include "src/vm-state-inl.h"
|
||||
#include "src/wasm/compilation-manager.h"
|
||||
#include "src/wasm/streaming-decoder.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "src/wasm/wasm-result.h"
|
||||
#include "src/wasm/wasm-serialization.h"
|
||||
@ -7887,8 +7888,10 @@ WasmModuleObjectBuilderStreaming::WasmModuleObjectBuilderStreaming(
|
||||
i::Handle<i::JSPromise> promise = Utils::OpenHandle(*GetPromise());
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
streaming_decoder_ =
|
||||
i_isolate->wasm_compilation_manager()->StartStreamingCompilation(
|
||||
i_isolate, handle(i_isolate->context()), promise);
|
||||
i_isolate->wasm_engine()
|
||||
->compilation_manager()
|
||||
->StartStreamingCompilation(i_isolate, handle(i_isolate->context()),
|
||||
promise);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/snapshot/serializer-common.h"
|
||||
#include "src/string-stream.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -54,7 +55,8 @@ const char* V8NameConverter::NameOfAddress(byte* pc) const {
|
||||
return v8_buffer_.start();
|
||||
}
|
||||
|
||||
wasm::WasmCode* wasm_code = isolate->wasm_code_manager()->LookupCode(pc);
|
||||
wasm::WasmCode* wasm_code =
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(pc);
|
||||
if (wasm_code != nullptr) {
|
||||
SNPrintF(v8_buffer_, "%p (%s)", static_cast<void*>(pc),
|
||||
GetWasmCodeKindAsString(wasm_code->kind()));
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/string-stream.h"
|
||||
#include "src/visitors.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "src/zone/zone-containers.h"
|
||||
@ -439,7 +440,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
|
||||
// than checking the flag, then getting the code, and then, if both are true
|
||||
// (non-null, respectivelly), going down the wasm_code path.
|
||||
wasm::WasmCode* wasm_code =
|
||||
iterator->isolate()->wasm_code_manager()->LookupCode(pc);
|
||||
iterator->isolate()->wasm_engine()->code_manager()->LookupCode(pc);
|
||||
if (wasm_code != nullptr) {
|
||||
switch (wasm_code->kind()) {
|
||||
case wasm::WasmCode::kInterpreterStub:
|
||||
@ -777,7 +778,7 @@ void StandardFrame::IterateCompiledFrame(RootVisitor* v) const {
|
||||
Address inner_pointer = pc();
|
||||
const wasm::WasmCode* wasm_code =
|
||||
FLAG_wasm_jit_to_native
|
||||
? isolate()->wasm_code_manager()->LookupCode(inner_pointer)
|
||||
? isolate()->wasm_engine()->code_manager()->LookupCode(inner_pointer)
|
||||
: nullptr;
|
||||
SafepointEntry safepoint_entry;
|
||||
uint32_t stack_slots;
|
||||
@ -1713,7 +1714,7 @@ WasmInstanceObject* WasmCompiledFrame::wasm_instance() const {
|
||||
WasmInstanceObject* obj =
|
||||
FLAG_wasm_jit_to_native
|
||||
? WasmInstanceObject::GetOwningInstance(
|
||||
isolate()->wasm_code_manager()->LookupCode(pc()))
|
||||
isolate()->wasm_engine()->code_manager()->LookupCode(pc()))
|
||||
: WasmInstanceObject::GetOwningInstanceGC(LookupCode());
|
||||
// This is a live stack frame; it must have a live instance.
|
||||
DCHECK_NOT_NULL(obj);
|
||||
@ -1738,7 +1739,8 @@ void WasmCompiledFrame::Summarize(std::vector<FrameSummary>* functions) const {
|
||||
Handle<WasmInstanceObject> instance;
|
||||
int offset = -1;
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
code = WasmCodeWrapper(isolate()->wasm_code_manager()->LookupCode(pc()));
|
||||
code = WasmCodeWrapper(
|
||||
isolate()->wasm_engine()->code_manager()->LookupCode(pc()));
|
||||
offset =
|
||||
static_cast<int>(pc() - code.GetWasmCode()->instructions().start());
|
||||
instance = Handle<WasmInstanceObject>(
|
||||
@ -1765,8 +1767,9 @@ bool WasmCompiledFrame::at_to_number_conversion() const {
|
||||
int pos = -1;
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
wasm::WasmCode* code =
|
||||
callee_pc ? isolate()->wasm_code_manager()->LookupCode(callee_pc)
|
||||
: nullptr;
|
||||
callee_pc
|
||||
? isolate()->wasm_engine()->code_manager()->LookupCode(callee_pc)
|
||||
: nullptr;
|
||||
if (!code || code->kind() != wasm::WasmCode::kWasmToJsWrapper) return false;
|
||||
int offset = static_cast<int>(callee_pc - code->instructions().start());
|
||||
pos = FrameSummary::WasmCompiledFrameSummary::GetWasmSourcePosition(code,
|
||||
@ -1791,7 +1794,8 @@ int WasmCompiledFrame::LookupExceptionHandlerInTable(int* stack_slots) {
|
||||
*stack_slots = code->stack_slots();
|
||||
return table->LookupReturn(pc_offset);
|
||||
}
|
||||
wasm::WasmCode* code = isolate()->wasm_code_manager()->LookupCode(pc());
|
||||
wasm::WasmCode* code =
|
||||
isolate()->wasm_engine()->code_manager()->LookupCode(pc());
|
||||
if (!code->IsAnonymous()) {
|
||||
Object* table_entry =
|
||||
code->owner()->compiled_module()->ptr_to_handler_table()->get(
|
||||
@ -1845,7 +1849,7 @@ WasmInstanceObject* WasmInterpreterEntryFrame::wasm_instance() const {
|
||||
WasmInstanceObject* ret =
|
||||
FLAG_wasm_jit_to_native
|
||||
? WasmInstanceObject::GetOwningInstance(
|
||||
isolate()->wasm_code_manager()->LookupCode(pc()))
|
||||
isolate()->wasm_engine()->code_manager()->LookupCode(pc()))
|
||||
: WasmInstanceObject::GetOwningInstanceGC(LookupCode());
|
||||
// This is a live stack frame, there must be a live wasm instance available.
|
||||
DCHECK_NOT_NULL(ret);
|
||||
@ -2072,8 +2076,9 @@ void JavaScriptFrame::Iterate(RootVisitor* v) const {
|
||||
|
||||
void InternalFrame::Iterate(RootVisitor* v) const {
|
||||
wasm::WasmCode* wasm_code =
|
||||
FLAG_wasm_jit_to_native ? isolate()->wasm_code_manager()->LookupCode(pc())
|
||||
: nullptr;
|
||||
FLAG_wasm_jit_to_native
|
||||
? isolate()->wasm_engine()->code_manager()->LookupCode(pc())
|
||||
: nullptr;
|
||||
if (wasm_code != nullptr) {
|
||||
DCHECK(wasm_code->kind() == wasm::WasmCode::kLazyStub);
|
||||
} else {
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "src/visitors.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
#include "src/wasm/compilation-manager.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "src/zone/accounting-allocator.h"
|
||||
@ -1303,7 +1304,7 @@ Object* Isolate::UnwindAndFindHandler() {
|
||||
set_wasm_caught_exception(exception);
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
wasm::WasmCode* wasm_code =
|
||||
wasm_code_manager()->LookupCode(frame->pc());
|
||||
wasm_engine()->code_manager()->LookupCode(frame->pc());
|
||||
return FoundHandler(nullptr, wasm_code->instructions().start(),
|
||||
offset, wasm_code->constant_pool(), return_sp,
|
||||
frame->fp());
|
||||
@ -2516,7 +2517,6 @@ Isolate::Isolate(bool enable_serializer)
|
||||
use_counter_callback_(nullptr),
|
||||
basic_block_profiler_(nullptr),
|
||||
cancelable_task_manager_(new CancelableTaskManager()),
|
||||
wasm_compilation_manager_(new wasm::CompilationManager()),
|
||||
abort_on_uncaught_exception_callback_(nullptr),
|
||||
total_regexp_code_generated_(0) {
|
||||
{
|
||||
@ -2619,7 +2619,7 @@ void Isolate::Deinit() {
|
||||
optimizing_compile_dispatcher_ = nullptr;
|
||||
}
|
||||
|
||||
wasm_compilation_manager_->TearDown();
|
||||
wasm_engine()->compilation_manager()->TearDown();
|
||||
|
||||
heap_.mark_compact_collector()->EnsureSweepingCompleted();
|
||||
heap_.memory_allocator()->unmapper()->WaitUntilCompleted();
|
||||
@ -2921,16 +2921,15 @@ bool Isolate::Init(StartupDeserializer* des) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup the wasm code manager. Currently, there's one per Isolate.
|
||||
if (!wasm_code_manager_) {
|
||||
size_t max_code_size = kMaxWasmCodeMemory;
|
||||
if (kRequiresCodeRange) {
|
||||
max_code_size = std::min(max_code_size,
|
||||
heap_.memory_allocator()->code_range()->size());
|
||||
}
|
||||
wasm_code_manager_.reset(new wasm::WasmCodeManager(
|
||||
reinterpret_cast<v8::Isolate*>(this), max_code_size));
|
||||
}
|
||||
// Setup the wasm engine. Currently, there's one per Isolate.
|
||||
const size_t max_code_size =
|
||||
kRequiresCodeRange
|
||||
? std::min(kMaxWasmCodeMemory,
|
||||
heap_.memory_allocator()->code_range()->size())
|
||||
: kMaxWasmCodeMemory;
|
||||
wasm_engine_.reset(new wasm::WasmEngine(
|
||||
std::unique_ptr<wasm::WasmCodeManager>(new wasm::WasmCodeManager(
|
||||
reinterpret_cast<v8::Isolate*>(this), max_code_size))));
|
||||
|
||||
// Initialize the interface descriptors ahead of time.
|
||||
#define INTERFACE_DESCRIPTOR(Name, ...) \
|
||||
@ -3988,10 +3987,6 @@ void Isolate::PrintWithTimestamp(const char* format, ...) {
|
||||
va_end(arguments);
|
||||
}
|
||||
|
||||
wasm::WasmCodeManager* Isolate::wasm_code_manager() {
|
||||
return wasm_code_manager_.get();
|
||||
}
|
||||
|
||||
bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
|
||||
StackGuard* stack_guard = isolate_->stack_guard();
|
||||
#ifdef USE_SIMULATOR
|
||||
|
@ -109,8 +109,7 @@ class Interpreter;
|
||||
}
|
||||
|
||||
namespace wasm {
|
||||
class CompilationManager;
|
||||
class WasmCodeManager;
|
||||
class WasmEngine;
|
||||
}
|
||||
|
||||
#define RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate) \
|
||||
@ -331,7 +330,7 @@ class ThreadLocalTop BASE_EMBEDDED {
|
||||
Object* pending_exception_;
|
||||
// TODO(kschimpf): Change this to a stack of caught exceptions (rather than
|
||||
// just innermost catching try block).
|
||||
Object* wasm_caught_exception_;
|
||||
Object* wasm_caught_exception_ = nullptr;
|
||||
|
||||
// Communication channel between Isolate::FindHandler and the CEntryStub.
|
||||
Context* pending_handler_context_;
|
||||
@ -926,7 +925,7 @@ class Isolate {
|
||||
}
|
||||
StackGuard* stack_guard() { return &stack_guard_; }
|
||||
Heap* heap() { return &heap_; }
|
||||
V8_EXPORT_PRIVATE wasm::WasmCodeManager* wasm_code_manager();
|
||||
wasm::WasmEngine* wasm_engine() const { return wasm_engine_.get(); }
|
||||
StubCache* load_stub_cache() { return load_stub_cache_; }
|
||||
StubCache* store_stub_cache() { return store_stub_cache_; }
|
||||
DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; }
|
||||
@ -1288,10 +1287,6 @@ class Isolate {
|
||||
return cancelable_task_manager_;
|
||||
}
|
||||
|
||||
wasm::CompilationManager* wasm_compilation_manager() {
|
||||
return wasm_compilation_manager_.get();
|
||||
}
|
||||
|
||||
const AstStringConstants* ast_string_constants() const {
|
||||
return ast_string_constants_;
|
||||
}
|
||||
@ -1663,8 +1658,6 @@ class Isolate {
|
||||
|
||||
CancelableTaskManager* cancelable_task_manager_;
|
||||
|
||||
std::unique_ptr<wasm::CompilationManager> wasm_compilation_manager_;
|
||||
|
||||
debug::ConsoleDelegate* console_delegate_ = nullptr;
|
||||
|
||||
v8::Isolate::AbortOnUncaughtExceptionCallback
|
||||
@ -1683,7 +1676,7 @@ class Isolate {
|
||||
|
||||
size_t elements_deletion_counter_ = 0;
|
||||
|
||||
std::unique_ptr<wasm::WasmCodeManager> wasm_code_manager_;
|
||||
std::unique_ptr<wasm::WasmEngine> wasm_engine_;
|
||||
|
||||
// The top entry of the v8::Context::BackupIncumbentScope stack.
|
||||
const v8::Context::BackupIncumbentScope* top_backup_incumbent_scope_ =
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/ostreams.h"
|
||||
#include "src/regexp/jsregexp.h"
|
||||
#include "src/transitions-inl.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
|
||||
@ -1897,8 +1898,9 @@ extern void _v8_internal_Print_Object(void* object) {
|
||||
|
||||
extern void _v8_internal_Print_Code(void* object) {
|
||||
i::Isolate* isolate = i::Isolate::Current();
|
||||
i::wasm::WasmCode* wasm_code = isolate->wasm_code_manager()->LookupCode(
|
||||
reinterpret_cast<i::Address>(object));
|
||||
i::wasm::WasmCode* wasm_code =
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(
|
||||
reinterpret_cast<i::Address>(object));
|
||||
if (wasm_code) {
|
||||
wasm_code->Print(isolate);
|
||||
return;
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "src/trap-handler/trap-handler.h"
|
||||
#include "src/wasm/memory-tracing.h"
|
||||
#include "src/wasm/module-compiler.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
#include "src/wasm/wasm-serialization.h"
|
||||
@ -500,7 +501,7 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
|
||||
: rinfo->target_address();
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
wasm::WasmCode* target =
|
||||
isolate->wasm_code_manager()->LookupCode(target_address);
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(target_address);
|
||||
if (target->kind() == wasm::WasmCode::kFunction) {
|
||||
++count;
|
||||
export_fct = target;
|
||||
@ -524,7 +525,7 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
|
||||
RelocInfo* rinfo = it.rinfo();
|
||||
Address target_address = rinfo->target_address();
|
||||
wasm::WasmCode* target =
|
||||
isolate->wasm_code_manager()->LookupCode(target_address);
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(target_address);
|
||||
if (target->kind() == wasm::WasmCode::kFunction) {
|
||||
++count;
|
||||
intermediate_fct = target;
|
||||
@ -560,7 +561,7 @@ RUNTIME_FUNCTION(Runtime_CheckWasmWrapperElision) {
|
||||
RelocInfo* rinfo = it.rinfo();
|
||||
Address target_address = rinfo->target_address();
|
||||
wasm::WasmCode* target =
|
||||
isolate->wasm_code_manager()->LookupCode(target_address);
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(target_address);
|
||||
if (target->kind() == target_kind) {
|
||||
++count;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "src/trap-handler/trap-handler.h"
|
||||
#include "src/v8memory.h"
|
||||
#include "src/wasm/module-compiler.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
#include "src/wasm/wasm-objects.h"
|
||||
#include "src/wasm/wasm-opcodes.h"
|
||||
@ -33,7 +34,7 @@ WasmInstanceObject* GetWasmInstanceOnStackTop(Isolate* isolate) {
|
||||
WasmInstanceObject* owning_instance = nullptr;
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
owning_instance = WasmInstanceObject::GetOwningInstance(
|
||||
isolate->wasm_code_manager()->LookupCode(pc));
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(pc));
|
||||
} else {
|
||||
owning_instance = WasmInstanceObject::GetOwningInstanceGC(
|
||||
isolate->inner_pointer_to_code_cache()->GetCacheEntry(pc)->code);
|
||||
|
@ -1472,6 +1472,7 @@
|
||||
'wasm/wasm-code-wrapper.cc',
|
||||
'wasm/wasm-code-wrapper.h',
|
||||
'wasm/wasm-debug.cc',
|
||||
'wasm/wasm-engine.h',
|
||||
'wasm/wasm-external-refs.cc',
|
||||
'wasm/wasm-external-refs.h',
|
||||
'wasm/wasm-heap.cc',
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "src/wasm/compilation-manager.h"
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/wasm-code-specialization.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
#include "src/wasm/wasm-js.h"
|
||||
#include "src/wasm/wasm-memory.h"
|
||||
@ -638,8 +639,10 @@ void AsyncCompile(Isolate* isolate, Handle<JSPromise> promise,
|
||||
|
||||
if (FLAG_wasm_test_streaming) {
|
||||
std::shared_ptr<StreamingDecoder> streaming_decoder =
|
||||
isolate->wasm_compilation_manager()->StartStreamingCompilation(
|
||||
isolate, handle(isolate->context()), promise);
|
||||
isolate->wasm_engine()
|
||||
->compilation_manager()
|
||||
->StartStreamingCompilation(isolate, handle(isolate->context()),
|
||||
promise);
|
||||
streaming_decoder->OnBytesReceived(bytes.module_bytes());
|
||||
streaming_decoder->Finish();
|
||||
return;
|
||||
@ -648,7 +651,7 @@ void AsyncCompile(Isolate* isolate, Handle<JSPromise> promise,
|
||||
// during asynchronous compilation.
|
||||
std::unique_ptr<byte[]> copy(new byte[bytes.length()]);
|
||||
memcpy(copy.get(), bytes.start(), bytes.length());
|
||||
isolate->wasm_compilation_manager()->StartAsyncCompileJob(
|
||||
isolate->wasm_engine()->compilation_manager()->StartAsyncCompileJob(
|
||||
isolate, std::move(copy), bytes.length(), handle(isolate->context()),
|
||||
promise);
|
||||
}
|
||||
@ -758,7 +761,7 @@ Address CompileLazy(Isolate* isolate) {
|
||||
Maybe<uint32_t> func_index_to_compile = Nothing<uint32_t>();
|
||||
Handle<Object> exp_deopt_data_entry;
|
||||
const wasm::WasmCode* lazy_stub_or_copy =
|
||||
isolate->wasm_code_manager()->LookupCode(it.frame()->pc());
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(it.frame()->pc());
|
||||
DCHECK_EQ(wasm::WasmCode::kLazyStub, lazy_stub_or_copy->kind());
|
||||
if (!lazy_stub_or_copy->IsAnonymous()) {
|
||||
// Then it's an indirect call or via JS->wasm wrapper.
|
||||
@ -782,7 +785,7 @@ Address CompileLazy(Isolate* isolate) {
|
||||
js_to_wasm_caller_code = handle(it.frame()->LookupCode(), isolate);
|
||||
} else {
|
||||
wasm_caller_code =
|
||||
isolate->wasm_code_manager()->LookupCode(it.frame()->pc());
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(it.frame()->pc());
|
||||
offset = Just(static_cast<uint32_t>(
|
||||
it.frame()->pc() - wasm_caller_code->instructions().start()));
|
||||
if (instance.is_null()) {
|
||||
@ -1267,8 +1270,9 @@ const wasm::WasmCode* LazyCompilationOrchestrator::CompileDirectCall(
|
||||
wasm_caller->constant_pool(),
|
||||
RelocInfo::ModeMask(RelocInfo::WASM_CALL));
|
||||
!it.done(); it.next()) {
|
||||
const WasmCode* callee = isolate->wasm_code_manager()->LookupCode(
|
||||
it.rinfo()->target_address());
|
||||
const WasmCode* callee =
|
||||
isolate->wasm_engine()->code_manager()->LookupCode(
|
||||
it.rinfo()->target_address());
|
||||
if (callee->kind() != WasmCode::kLazyStub) {
|
||||
non_compiled_functions.push_back(Nothing<WasmDirectCallData>());
|
||||
continue;
|
||||
@ -3555,7 +3559,7 @@ void AsyncCompileJob::Abort() {
|
||||
background_task_manager_.CancelAndWait();
|
||||
if (num_pending_foreground_tasks_ == 0) {
|
||||
// No task is pending, we can just remove the AsyncCompileJob.
|
||||
isolate_->wasm_compilation_manager()->RemoveJob(this);
|
||||
isolate_->wasm_engine()->compilation_manager()->RemoveJob(this);
|
||||
} else {
|
||||
// There is still a compilation task in the task queue. We enter the
|
||||
// AbortCompilation state and wait for this compilation task to abort the
|
||||
@ -3616,14 +3620,14 @@ void AsyncCompileJob::AsyncCompileFailed(ErrorThrower& thrower) {
|
||||
if (stream_) stream_->NotifyError();
|
||||
// {job} keeps the {this} pointer alive.
|
||||
std::shared_ptr<AsyncCompileJob> job =
|
||||
isolate_->wasm_compilation_manager()->RemoveJob(this);
|
||||
isolate_->wasm_engine()->compilation_manager()->RemoveJob(this);
|
||||
RejectPromise(isolate_, context_, thrower, module_promise_);
|
||||
}
|
||||
|
||||
void AsyncCompileJob::AsyncCompileSucceeded(Handle<Object> result) {
|
||||
// {job} keeps the {this} pointer alive.
|
||||
std::shared_ptr<AsyncCompileJob> job =
|
||||
isolate_->wasm_compilation_manager()->RemoveJob(this);
|
||||
isolate_->wasm_engine()->compilation_manager()->RemoveJob(this);
|
||||
ResolvePromise(isolate_, context_, module_promise_, result);
|
||||
}
|
||||
|
||||
@ -4077,7 +4081,7 @@ class AsyncCompileJob::FinishModule : public CompileStep {
|
||||
class AsyncCompileJob::AbortCompilation : public CompileStep {
|
||||
void RunInForeground() override {
|
||||
TRACE_COMPILE("Abort asynchronous compilation ...\n");
|
||||
job_->isolate_->wasm_compilation_manager()->RemoveJob(job_);
|
||||
job_->isolate_->wasm_engine()->compilation_manager()->RemoveJob(job_);
|
||||
}
|
||||
};
|
||||
|
||||
|
40
src/wasm/wasm-engine.h
Normal file
40
src/wasm/wasm-engine.h
Normal file
@ -0,0 +1,40 @@
|
||||
// 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.
|
||||
|
||||
#ifndef WASM_ENGINE_H_
|
||||
#define WASM_ENGINE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/wasm/compilation-manager.h"
|
||||
#include "src/wasm/wasm-heap.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
namespace wasm {
|
||||
|
||||
class CompilationManager;
|
||||
|
||||
// The central data structure that represents an engine instance capable of
|
||||
// loading, instantiating, and executing WASM code.
|
||||
class WasmEngine {
|
||||
public:
|
||||
explicit WasmEngine(std::unique_ptr<WasmCodeManager> code_manager)
|
||||
: code_manager_(std::move(code_manager)) {}
|
||||
|
||||
CompilationManager* compilation_manager() { return &compilation_manager_; }
|
||||
|
||||
WasmCodeManager* code_manager() const { return code_manager_.get(); }
|
||||
|
||||
private:
|
||||
CompilationManager compilation_manager_;
|
||||
std::unique_ptr<WasmCodeManager> code_manager_;
|
||||
};
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif
|
@ -19,6 +19,7 @@
|
||||
#include "src/wasm/function-body-decoder-impl.h"
|
||||
#include "src/wasm/function-body-decoder.h"
|
||||
#include "src/wasm/memory-tracing.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-external-refs.h"
|
||||
#include "src/wasm/wasm-limits.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
@ -2605,7 +2606,8 @@ class ThreadImpl {
|
||||
Foreign::cast(fun_table->get(static_cast<int>(entry_index)))
|
||||
->foreign_address();
|
||||
target =
|
||||
isolate->wasm_code_manager()->GetCodeFromStartAddress(first_instr);
|
||||
isolate->wasm_engine()->code_manager()->GetCodeFromStartAddress(
|
||||
first_instr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "src/wasm/module-compiler.h"
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/wasm-code-specialization.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-memory.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
#include "src/wasm/wasm-objects-inl.h"
|
||||
@ -762,8 +763,9 @@ WasmCodeWrapper WasmExportedFunction::GetWasmCode() {
|
||||
DCHECK(!it.done());
|
||||
WasmCodeWrapper target;
|
||||
if (FLAG_wasm_jit_to_native) {
|
||||
target = WasmCodeWrapper(GetIsolate()->wasm_code_manager()->LookupCode(
|
||||
it.rinfo()->js_to_wasm_address()));
|
||||
target = WasmCodeWrapper(
|
||||
GetIsolate()->wasm_engine()->code_manager()->LookupCode(
|
||||
it.rinfo()->js_to_wasm_address()));
|
||||
} else {
|
||||
Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
|
||||
if (!IsWasmFunctionCode(code)) continue;
|
||||
@ -1069,7 +1071,7 @@ Handle<WasmCompiledModule> WasmCompiledModule::New(
|
||||
wasm::NativeModule* native_module = nullptr;
|
||||
{
|
||||
std::unique_ptr<wasm::NativeModule> native_module_ptr =
|
||||
isolate->wasm_code_manager()->NewNativeModule(*module);
|
||||
isolate->wasm_engine()->code_manager()->NewNativeModule(*module);
|
||||
native_module = native_module_ptr.release();
|
||||
Handle<Foreign> native_module_wrapper =
|
||||
Managed<wasm::NativeModule>::From(isolate, native_module);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/wasm/compilation-manager.h"
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/streaming-decoder.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-module-builder.h"
|
||||
#include "src/wasm/wasm-module.h"
|
||||
|
||||
@ -103,8 +104,10 @@ class StreamTester {
|
||||
|
||||
i::Handle<i::JSPromise> i_promise = v8::Utils::OpenHandle(*promise_);
|
||||
|
||||
stream_ = i_isolate->wasm_compilation_manager()->StartStreamingCompilation(
|
||||
i_isolate, v8::Utils::OpenHandle(*context), i_promise);
|
||||
stream_ = i_isolate->wasm_engine()
|
||||
->compilation_manager()
|
||||
->StartStreamingCompilation(
|
||||
i_isolate, v8::Utils::OpenHandle(*context), i_promise);
|
||||
}
|
||||
|
||||
std::shared_ptr<StreamingDecoder> stream() { return stream_; }
|
||||
|
Loading…
Reference in New Issue
Block a user