Commit 556ef4c3 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Inline CompileFailed step

The {CompileFailed} just calls {AsyncCompileFailed}, which also does
not do much. Thus just inline directly call a function instead of
spawning a foreground task. This saves one instance of DeferredHandles.

R=ahaas@chromium.org

Bug: v8:7921, v8:8423
Change-Id: Ia8fb72a3ce2efd1f9a069c1a3b0b670b15fd8bce
Reviewed-on: https://chromium-review.googlesource.com/c/1402714Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58662}
parent 23f087cc
......@@ -2557,7 +2557,7 @@ void AsyncCompileJob::FinishCompile() {
}
}
void AsyncCompileJob::AsyncCompileFailed(Handle<Object> error_reason) {
void AsyncCompileJob::CompileFailed(Handle<Object> error_reason) {
// {job} keeps the {this} pointer alive.
std::shared_ptr<AsyncCompileJob> job =
isolate_->wasm_engine()->RemoveCompileJob(this);
......@@ -2606,12 +2606,7 @@ class AsyncCompileJob::CompilationStateCallback {
ErrorThrower thrower(job_->isolate(), "AsyncCompilation");
thrower.CompileFailed(*error_result);
Handle<Object> error = thrower.Reify();
DeferredHandleScope deferred(job_->isolate());
error = handle(*error, job_->isolate());
job_->deferred_handles_.push_back(deferred.Detach());
job_->DoSync<CompileFailed, kUseExistingForegroundTask>(error);
job_->CompileFailed(error);
}
break;
......@@ -2800,7 +2795,7 @@ class AsyncCompileJob::DecodeFail : public CompileStep {
ErrorThrower thrower(job->isolate_, "AsyncCompile");
thrower.CompileFailed("Wasm decoding failed", result_);
// {job_} is deleted in AsyncCompileFailed, therefore the {return}.
return job->AsyncCompileFailed(thrower.Reify());
return job->CompileFailed(thrower.Reify());
}
};
......@@ -2853,23 +2848,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
}
};
//==========================================================================
// Step 4b (sync): Compilation failed. Reject Promise.
//==========================================================================
class AsyncCompileJob::CompileFailed : public CompileStep {
public:
explicit CompileFailed(Handle<Object> error_reason)
: error_reason_(error_reason) {}
void RunInForeground(AsyncCompileJob* job) override {
TRACE_COMPILE("(4b) Compilation Failed...\n");
return job->AsyncCompileFailed(error_reason_);
}
private:
Handle<Object> error_reason_;
};
//==========================================================================
// Step 5 (sync): Compile JS->wasm wrappers.
//==========================================================================
......
......@@ -92,7 +92,6 @@ class AsyncCompileJob {
class DecodeModule; // Step 1 (async)
class DecodeFail; // Step 1b (sync)
class PrepareAndStartCompile; // Step 2 (sync)
class CompileFailed; // Step 4b (sync)
class CompileWrappers; // Step 5 (sync)
class FinishModule; // Step 6 (sync)
......@@ -110,7 +109,7 @@ class AsyncCompileJob {
void FinishCompile();
void AsyncCompileFailed(Handle<Object> error_reason);
void CompileFailed(Handle<Object> error_reason);
void AsyncCompileSucceeded(Handle<WasmModuleObject> result);
......
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