Skip to content

Commit bc08a86

Browse files
Michael StarzingerCommit Bot
authored andcommitted
[wasm] Remove {AsyncCompileJob::module} field.
[email protected] Change-Id: I904de575c8c049de64111c12b940c48a50090668 Reviewed-on: https://chromium-review.googlesource.com/1186338 Commit-Queue: Michael Starzinger <[email protected]> Reviewed-by: Andreas Haas <[email protected]> Cr-Commit-Position: refs/heads/master@{#55424}
1 parent 86d3005 commit bc08a86

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

src/wasm/module-compiler.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,8 +2368,7 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep {
23682368
job_->DoSync<DecodeFail>(std::move(result));
23692369
} else {
23702370
// Decode passed.
2371-
job_->module_ = std::move(result.val);
2372-
job_->DoSync<PrepareAndStartCompile>(true);
2371+
job_->DoSync<PrepareAndStartCompile>(std::move(result.val), true);
23732372
}
23742373
}
23752374
};
@@ -2397,10 +2396,12 @@ class AsyncCompileJob::DecodeFail : public CompileStep {
23972396
//==========================================================================
23982397
class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
23992398
public:
2400-
explicit PrepareAndStartCompile(bool start_compilation)
2401-
: start_compilation_(start_compilation) {}
2399+
PrepareAndStartCompile(std::shared_ptr<const WasmModule> module,
2400+
bool start_compilation)
2401+
: module_(module), start_compilation_(start_compilation) {}
24022402

24032403
private:
2404+
std::shared_ptr<const WasmModule> module_;
24042405
bool start_compilation_;
24052406

24062407
void RunInForeground() override {
@@ -2411,7 +2412,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
24112412
job_->background_task_manager_.CancelAndWait();
24122413

24132414
// Embedder usage count for declared shared memories.
2414-
if (job_->module_->has_shared_memory) {
2415+
if (module_->has_shared_memory) {
24152416
job_->isolate_->CountUsage(
24162417
v8::Isolate::UseCounterFeature::kWasmSharedMemory);
24172418
}
@@ -2421,7 +2422,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
24212422
Handle<Script> script = CreateWasmScript(job_->isolate_, job_->wire_bytes_);
24222423
Handle<ByteArray> asm_js_offset_table;
24232424

2424-
const WasmModule* module = job_->module_.get();
2425+
const WasmModule* module = module_.get();
24252426
ModuleEnv env = CreateDefaultModuleEnv(module);
24262427
// TODO(wasm): Improve efficiency of storing module wire bytes. Only store
24272428
// relevant sections, not function bodies
@@ -2433,7 +2434,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
24332434
// breakpoints on a (potentially empty) subset of the instances.
24342435
// Create the module object.
24352436
job_->module_object_ = WasmModuleObject::New(
2436-
job_->isolate_, job_->enabled_features_, job_->module_, env,
2437+
job_->isolate_, job_->enabled_features_, module_, env,
24372438
{std::move(job_->bytes_copy_), job_->wire_bytes_.length()}, script,
24382439
asm_js_offset_table);
24392440
job_->native_module_ = job_->module_object_->native_module();
@@ -2559,8 +2560,8 @@ class AsyncCompileJob::FinishModule : public CompileStep {
25592560
TRACE_COMPILE("(6) Finish module...\n");
25602561
job_->AsyncCompileSucceeded(job_->module_object_);
25612562

2562-
size_t num_functions =
2563-
job_->module_->functions.size() - job_->module_->num_imported_functions;
2563+
size_t num_functions = job_->native_module_->num_functions() -
2564+
job_->native_module_->num_imported_functions();
25642565
if (job_->native_module_->compilation_state()->compile_mode() ==
25652566
CompileMode::kRegular ||
25662567
num_functions == 0) {
@@ -2621,7 +2622,6 @@ bool AsyncStreamingProcessor::ProcessModuleHeader(Vector<const uint8_t> bytes,
26212622
TRACE_STREAMING("Process module header...\n");
26222623
decoder_.StartDecoding(job_->async_counters().get(),
26232624
job_->isolate()->wasm_engine()->allocator());
2624-
job_->module_ = decoder_.shared_module();
26252625
decoder_.DecodeModuleHeader(bytes, offset);
26262626
if (!decoder_.ok()) {
26272627
FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false));
@@ -2672,7 +2672,8 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(size_t functions_count,
26722672
FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false));
26732673
return false;
26742674
}
2675-
job_->NextStep<AsyncCompileJob::PrepareAndStartCompile>(false);
2675+
job_->NextStep<AsyncCompileJob::PrepareAndStartCompile>(
2676+
decoder_.shared_module(), false);
26762677
// Execute the PrepareAndStartCompile step immediately and not in a separate
26772678
// task.
26782679
job_->ExecuteForegroundTaskImmediately();
@@ -2725,14 +2726,13 @@ void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) {
27252726
}
27262727
ModuleResult result = decoder_.FinishDecoding(false);
27272728
DCHECK(result.ok());
2728-
DCHECK_EQ(job_->module_, result.val);
27292729
if (job_->DecrementAndCheckFinisherCount()) {
27302730
if (job_->native_module_ == nullptr) {
27312731
// We are processing a WebAssembly module without code section. We need to
27322732
// prepare compilation first before we can finish it.
27332733
// {PrepareAndStartCompile} will call {FinishCompile} by itself if there
27342734
// is no code section.
2735-
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(true);
2735+
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(result.val, true);
27362736
} else {
27372737
HandleScope scope(job_->isolate_);
27382738
SaveContext saved_context(job_->isolate_);

src/wasm/module-compiler.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,12 @@ class AsyncCompileJob {
9898
class CompileStep;
9999

100100
// States of the AsyncCompileJob.
101-
class DecodeModule;
102-
class DecodeFail;
103-
class PrepareAndStartCompile;
104-
class CompileFailed;
105-
class CompileWrappers;
106-
class FinishModule;
107-
class UpdateToTopTierCompiledCode;
101+
class DecodeModule; // Step 1 (async)
102+
class DecodeFail; // Step 1b (sync)
103+
class PrepareAndStartCompile; // Step 2 (sync)
104+
class CompileFailed; // Step 4b (sync)
105+
class CompileWrappers; // Step 5 (sync)
106+
class FinishModule; // Step 6 (sync)
108107

109108
const std::shared_ptr<Counters>& async_counters() const {
110109
return async_counters_;
@@ -150,7 +149,6 @@ class AsyncCompileJob {
150149
ModuleWireBytes wire_bytes_;
151150
Handle<Context> native_context_;
152151
std::shared_ptr<CompilationResultResolver> resolver_;
153-
std::shared_ptr<const WasmModule> module_;
154152

155153
std::vector<DeferredHandles*> deferred_handles_;
156154
Handle<WasmModuleObject> module_object_;

0 commit comments

Comments
 (0)