Commit fbd8d71e authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Remove Isolate from compilation state

The compilation state is mostly isolate-independent by now. It's only
the counters that are taken from one Isolate and then used throughout
the livetime of the NativeModule. This should be fixed in another CL.
The Isolate itself is never used from the compilation state, thus
remove the pointer.

R=mstarzinger@chromium.org

Bug: v8:8050
Change-Id: Ia605840b81352ede2c84a848081a14e51760e8c8
Reviewed-on: https://chromium-review.googlesource.com/c/1451824
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59367}
parent 5bc1809e
......@@ -126,7 +126,7 @@ class CompilationState {
friend class WasmCompilationUnit;
CompilationState() = delete;
static std::unique_ptr<CompilationState> New(Isolate*, NativeModule*,
static std::unique_ptr<CompilationState> New(NativeModule*,
std::shared_ptr<Counters>);
};
......
......@@ -118,8 +118,7 @@ class BackgroundCompileScope {
// It's public interface {CompilationState} lives in compilation-environment.h.
class CompilationStateImpl {
public:
CompilationStateImpl(internal::Isolate*, NativeModule*,
std::shared_ptr<Counters>);
CompilationStateImpl(NativeModule*, std::shared_ptr<Counters> async_counters);
~CompilationStateImpl();
// Cancel all background compilation and wait for all tasks to finish. Call
......@@ -151,8 +150,6 @@ class CompilationStateImpl {
void SetError(uint32_t func_index, const WasmError& error);
Isolate* isolate() const { return isolate_; }
bool failed() const {
return compile_error_.load(std::memory_order_relaxed) != nullptr;
}
......@@ -210,10 +207,6 @@ class CompilationStateImpl {
void NotifyOnEvent(CompilationEvent event);
// TODO(mstarzinger): Get rid of the Isolate field to make sure the
// {CompilationStateImpl} can be shared across multiple Isolates.
Isolate* const isolate_;
WasmEngine* const engine_;
NativeModule* const native_module_;
const std::shared_ptr<BackgroundCompileToken> background_compile_token_;
const CompileMode compile_mode_;
......@@ -310,11 +303,9 @@ void CompilationState::OnFinishedUnit(ExecutionTier tier, WasmCode* code) {
// static
std::unique_ptr<CompilationState> CompilationState::New(
Isolate* isolate, NativeModule* native_module,
std::shared_ptr<Counters> async_counters) {
return std::unique_ptr<CompilationState>(
reinterpret_cast<CompilationState*>(new CompilationStateImpl(
isolate, native_module, std::move(async_counters))));
NativeModule* native_module, std::shared_ptr<Counters> async_counters) {
return std::unique_ptr<CompilationState>(reinterpret_cast<CompilationState*>(
new CompilationStateImpl(native_module, std::move(async_counters))));
}
// End of PIMPL implementation of {CompilationState}.
......@@ -1458,11 +1449,8 @@ bool AsyncStreamingProcessor::Deserialize(Vector<const uint8_t> module_bytes,
}
CompilationStateImpl::CompilationStateImpl(
internal::Isolate* isolate, NativeModule* native_module,
std::shared_ptr<Counters> async_counters)
: isolate_(isolate),
engine_(isolate->wasm_engine()),
native_module_(native_module),
NativeModule* native_module, std::shared_ptr<Counters> async_counters)
: native_module_(native_module),
background_compile_token_(
std::make_shared<BackgroundCompileToken>(native_module)),
compile_mode_(FLAG_wasm_tier_up &&
......@@ -1581,12 +1569,13 @@ void CompilationStateImpl::OnFinishedUnit(ExecutionTier tier, WasmCode* code) {
}
// TODO(clemensh): Fix and reenable code logging (https://crbug.com/v8/8783).
// if (code != nullptr) engine_->LogCode(code);
// if (code != nullptr) native_module_->engine()->LogCode(code);
}
void CompilationStateImpl::RestartBackgroundCompileTask() {
auto task = engine_->NewBackgroundCompileTask<BackgroundCompileTask>(
background_compile_token_, async_counters_);
auto task =
native_module_->engine()->NewBackgroundCompileTask<BackgroundCompileTask>(
background_compile_token_, async_counters_);
if (baseline_compilation_finished()) {
V8::GetCurrentPlatform()->CallLowPriorityTaskOnWorkerThread(
......
......@@ -380,15 +380,14 @@ WasmCode::~WasmCode() {
}
}
NativeModule::NativeModule(WasmEngine* engine, Isolate* isolate,
const WasmFeatures& enabled, bool can_request_more,
VirtualMemory code_space,
NativeModule::NativeModule(WasmEngine* engine, const WasmFeatures& enabled,
bool can_request_more, VirtualMemory code_space,
std::shared_ptr<const WasmModule> module,
std::shared_ptr<Counters> async_counters)
: enabled_features_(enabled),
module_(std::move(module)),
compilation_state_(
CompilationState::New(isolate, this, std::move(async_counters))),
CompilationState::New(this, std::move(async_counters))),
import_wrapper_cache_(std::unique_ptr<WasmImportWrapperCache>(
new WasmImportWrapperCache(this))),
free_code_space_(code_space.region()),
......@@ -1067,9 +1066,9 @@ std::unique_ptr<NativeModule> WasmCodeManager::NewNativeModule(
Address start = code_space.address();
size_t size = code_space.size();
Address end = code_space.end();
std::unique_ptr<NativeModule> ret(new NativeModule(
engine, isolate, enabled, can_request_more, std::move(code_space),
std::move(module), isolate->async_counters()));
std::unique_ptr<NativeModule> ret(
new NativeModule(engine, enabled, can_request_more, std::move(code_space),
std::move(module), isolate->async_counters()));
TRACE_HEAP("New NativeModule %p: Mem: %" PRIuPTR ",+%zu\n", ret.get(), start,
size);
base::MutexGuard lock(&native_modules_mutex_);
......
......@@ -23,8 +23,9 @@
namespace v8 {
namespace internal {
class CodeDesc;
class Code;
class CodeDesc;
class Isolate;
namespace wasm {
......@@ -349,6 +350,7 @@ class V8_EXPORT_PRIVATE NativeModule final {
const WasmModule* module() const { return module_.get(); }
std::shared_ptr<const WasmModule> shared_module() const { return module_; }
size_t committed_code_space() const { return committed_code_space_.load(); }
WasmEngine* engine() const { return engine_; }
void SetWireBytes(OwnedVector<const uint8_t> wire_bytes);
......@@ -367,9 +369,8 @@ class V8_EXPORT_PRIVATE NativeModule final {
friend class WasmCodeManager;
friend class NativeModuleModificationScope;
NativeModule(WasmEngine* engine, Isolate* isolate,
const WasmFeatures& enabled_features, bool can_request_more,
VirtualMemory code_space,
NativeModule(WasmEngine* engine, const WasmFeatures& enabled_features,
bool can_request_more, VirtualMemory code_space,
std::shared_ptr<const WasmModule> module,
std::shared_ptr<Counters> async_counters);
......
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