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

[wasm] Remove {AsyncCompileJob::module} field.

R=ahaas@chromium.org

Change-Id: I904de575c8c049de64111c12b940c48a50090668
Reviewed-on: https://chromium-review.googlesource.com/1186338
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55424}
parent 86d30050
...@@ -2368,8 +2368,7 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep { ...@@ -2368,8 +2368,7 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep {
job_->DoSync<DecodeFail>(std::move(result)); job_->DoSync<DecodeFail>(std::move(result));
} else { } else {
// Decode passed. // Decode passed.
job_->module_ = std::move(result.val); job_->DoSync<PrepareAndStartCompile>(std::move(result.val), true);
job_->DoSync<PrepareAndStartCompile>(true);
} }
} }
}; };
...@@ -2397,10 +2396,12 @@ class AsyncCompileJob::DecodeFail : public CompileStep { ...@@ -2397,10 +2396,12 @@ class AsyncCompileJob::DecodeFail : public CompileStep {
//========================================================================== //==========================================================================
class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
public: public:
explicit PrepareAndStartCompile(bool start_compilation) PrepareAndStartCompile(std::shared_ptr<const WasmModule> module,
: start_compilation_(start_compilation) {} bool start_compilation)
: module_(module), start_compilation_(start_compilation) {}
private: private:
std::shared_ptr<const WasmModule> module_;
bool start_compilation_; bool start_compilation_;
void RunInForeground() override { void RunInForeground() override {
...@@ -2411,7 +2412,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -2411,7 +2412,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
job_->background_task_manager_.CancelAndWait(); job_->background_task_manager_.CancelAndWait();
// Embedder usage count for declared shared memories. // Embedder usage count for declared shared memories.
if (job_->module_->has_shared_memory) { if (module_->has_shared_memory) {
job_->isolate_->CountUsage( job_->isolate_->CountUsage(
v8::Isolate::UseCounterFeature::kWasmSharedMemory); v8::Isolate::UseCounterFeature::kWasmSharedMemory);
} }
...@@ -2421,7 +2422,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -2421,7 +2422,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
Handle<Script> script = CreateWasmScript(job_->isolate_, job_->wire_bytes_); Handle<Script> script = CreateWasmScript(job_->isolate_, job_->wire_bytes_);
Handle<ByteArray> asm_js_offset_table; Handle<ByteArray> asm_js_offset_table;
const WasmModule* module = job_->module_.get(); const WasmModule* module = module_.get();
ModuleEnv env = CreateDefaultModuleEnv(module); ModuleEnv env = CreateDefaultModuleEnv(module);
// TODO(wasm): Improve efficiency of storing module wire bytes. Only store // TODO(wasm): Improve efficiency of storing module wire bytes. Only store
// relevant sections, not function bodies // relevant sections, not function bodies
...@@ -2433,7 +2434,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -2433,7 +2434,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
// breakpoints on a (potentially empty) subset of the instances. // breakpoints on a (potentially empty) subset of the instances.
// Create the module object. // Create the module object.
job_->module_object_ = WasmModuleObject::New( job_->module_object_ = WasmModuleObject::New(
job_->isolate_, job_->enabled_features_, job_->module_, env, job_->isolate_, job_->enabled_features_, module_, env,
{std::move(job_->bytes_copy_), job_->wire_bytes_.length()}, script, {std::move(job_->bytes_copy_), job_->wire_bytes_.length()}, script,
asm_js_offset_table); asm_js_offset_table);
job_->native_module_ = job_->module_object_->native_module(); job_->native_module_ = job_->module_object_->native_module();
...@@ -2559,8 +2560,8 @@ class AsyncCompileJob::FinishModule : public CompileStep { ...@@ -2559,8 +2560,8 @@ class AsyncCompileJob::FinishModule : public CompileStep {
TRACE_COMPILE("(6) Finish module...\n"); TRACE_COMPILE("(6) Finish module...\n");
job_->AsyncCompileSucceeded(job_->module_object_); job_->AsyncCompileSucceeded(job_->module_object_);
size_t num_functions = size_t num_functions = job_->native_module_->num_functions() -
job_->module_->functions.size() - job_->module_->num_imported_functions; job_->native_module_->num_imported_functions();
if (job_->native_module_->compilation_state()->compile_mode() == if (job_->native_module_->compilation_state()->compile_mode() ==
CompileMode::kRegular || CompileMode::kRegular ||
num_functions == 0) { num_functions == 0) {
...@@ -2621,7 +2622,6 @@ bool AsyncStreamingProcessor::ProcessModuleHeader(Vector<const uint8_t> bytes, ...@@ -2621,7 +2622,6 @@ bool AsyncStreamingProcessor::ProcessModuleHeader(Vector<const uint8_t> bytes,
TRACE_STREAMING("Process module header...\n"); TRACE_STREAMING("Process module header...\n");
decoder_.StartDecoding(job_->async_counters().get(), decoder_.StartDecoding(job_->async_counters().get(),
job_->isolate()->wasm_engine()->allocator()); job_->isolate()->wasm_engine()->allocator());
job_->module_ = decoder_.shared_module();
decoder_.DecodeModuleHeader(bytes, offset); decoder_.DecodeModuleHeader(bytes, offset);
if (!decoder_.ok()) { if (!decoder_.ok()) {
FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false)); FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false));
...@@ -2672,7 +2672,8 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(size_t functions_count, ...@@ -2672,7 +2672,8 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(size_t functions_count,
FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false)); FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false));
return false; return false;
} }
job_->NextStep<AsyncCompileJob::PrepareAndStartCompile>(false); job_->NextStep<AsyncCompileJob::PrepareAndStartCompile>(
decoder_.shared_module(), false);
// Execute the PrepareAndStartCompile step immediately and not in a separate // Execute the PrepareAndStartCompile step immediately and not in a separate
// task. // task.
job_->ExecuteForegroundTaskImmediately(); job_->ExecuteForegroundTaskImmediately();
...@@ -2725,14 +2726,13 @@ void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) { ...@@ -2725,14 +2726,13 @@ void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) {
} }
ModuleResult result = decoder_.FinishDecoding(false); ModuleResult result = decoder_.FinishDecoding(false);
DCHECK(result.ok()); DCHECK(result.ok());
DCHECK_EQ(job_->module_, result.val);
if (job_->DecrementAndCheckFinisherCount()) { if (job_->DecrementAndCheckFinisherCount()) {
if (job_->native_module_ == nullptr) { if (job_->native_module_ == nullptr) {
// We are processing a WebAssembly module without code section. We need to // We are processing a WebAssembly module without code section. We need to
// prepare compilation first before we can finish it. // prepare compilation first before we can finish it.
// {PrepareAndStartCompile} will call {FinishCompile} by itself if there // {PrepareAndStartCompile} will call {FinishCompile} by itself if there
// is no code section. // is no code section.
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(true); job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(result.val, true);
} else { } else {
HandleScope scope(job_->isolate_); HandleScope scope(job_->isolate_);
SaveContext saved_context(job_->isolate_); SaveContext saved_context(job_->isolate_);
......
...@@ -98,13 +98,12 @@ class AsyncCompileJob { ...@@ -98,13 +98,12 @@ class AsyncCompileJob {
class CompileStep; class CompileStep;
// States of the AsyncCompileJob. // States of the AsyncCompileJob.
class DecodeModule; class DecodeModule; // Step 1 (async)
class DecodeFail; class DecodeFail; // Step 1b (sync)
class PrepareAndStartCompile; class PrepareAndStartCompile; // Step 2 (sync)
class CompileFailed; class CompileFailed; // Step 4b (sync)
class CompileWrappers; class CompileWrappers; // Step 5 (sync)
class FinishModule; class FinishModule; // Step 6 (sync)
class UpdateToTopTierCompiledCode;
const std::shared_ptr<Counters>& async_counters() const { const std::shared_ptr<Counters>& async_counters() const {
return async_counters_; return async_counters_;
...@@ -150,7 +149,6 @@ class AsyncCompileJob { ...@@ -150,7 +149,6 @@ class AsyncCompileJob {
ModuleWireBytes wire_bytes_; ModuleWireBytes wire_bytes_;
Handle<Context> native_context_; Handle<Context> native_context_;
std::shared_ptr<CompilationResultResolver> resolver_; std::shared_ptr<CompilationResultResolver> resolver_;
std::shared_ptr<const WasmModule> module_;
std::vector<DeferredHandles*> deferred_handles_; std::vector<DeferredHandles*> deferred_handles_;
Handle<WasmModuleObject> module_object_; Handle<WasmModuleObject> module_object_;
......
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