Commit 3b46a984 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Don't store the ModuleResult in the AsyncCompileJob

It's only needed to pass error information from step 1 to step 1b, thus
pass it explicitly to step 1b.

R=ahaas@chromium.org, mtrofin@chromium.org

Change-Id: Icca5ef8f94dedad65e797a4fb5a4d83145b7dfbd
Reviewed-on: https://chromium-review.googlesource.com/489521
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44972}
parent b88c2e47
......@@ -2640,7 +2640,6 @@ class AsyncCompileJob {
Handle<Context> context_;
Handle<JSPromise> module_promise_;
WasmModule* module_ = nullptr;
ModuleResult result_;
std::unique_ptr<CompilationHelper> helper_ = nullptr;
std::unique_ptr<ModuleBytesEnv> module_bytes_env_ = nullptr;
......@@ -2697,7 +2696,7 @@ class AsyncCompileJob {
template <typename Task, typename... Args>
void DoSync(Args... args) {
static_assert(Task::type == SYNC, "Scheduled type must be sync");
Task* task = new Task(args...);
Task* task = new Task(std::forward<Args>(args)...);
task->job_ = this;
V8::GetCurrentPlatform()->CallOnForegroundThread(
reinterpret_cast<v8::Isolate*>(isolate_), task);
......@@ -2706,7 +2705,7 @@ class AsyncCompileJob {
template <typename Task, typename... Args>
void DoAsync(Args... args) {
static_assert(Task::type == ASYNC, "Scheduled type must be async");
Task* task = new Task(args...);
Task* task = new Task(std::forward<Args>(args)...);
task->job_ = this;
V8::GetCurrentPlatform()->CallOnBackgroundThread(
task, v8::Platform::kShortRunningTask);
......@@ -2717,22 +2716,22 @@ class AsyncCompileJob {
//==========================================================================
class DecodeModule : public CompileTask<ASYNC> {
void Run() override {
ModuleResult result;
{
DisallowHandleAllocation no_handle;
DisallowHeapAllocation no_allocation;
// Decode the module bytes.
TRACE_COMPILE("(1) Decoding module...\n");
job_->result_ =
DecodeWasmModule(job_->isolate_, job_->wire_bytes_.start(),
job_->wire_bytes_.end(), true, kWasmOrigin);
result = DecodeWasmModule(job_->isolate_, job_->wire_bytes_.start(),
job_->wire_bytes_.end(), true, kWasmOrigin);
}
if (job_->result_.failed()) {
if (result.failed()) {
// Decoding failure; reject the promise and clean up.
if (job_->result_.val) delete job_->result_.val;
job_->DoSync<DecodeFail>();
if (result.val) delete result.val;
job_->DoSync<DecodeFail>(std::move(result));
} else {
// Decode passed.
job_->module_ = const_cast<WasmModule*>(job_->result_.val);
job_->module_ = const_cast<WasmModule*>(result.val);
job_->DoSync<PrepareAndStartCompile>();
}
}
......@@ -2743,9 +2742,13 @@ class AsyncCompileJob {
//==========================================================================
class DecodeFail : public CompileTask<SYNC> {
public:
explicit DecodeFail(ModuleResult result) : result_(std::move(result)) {}
private:
ModuleResult result_;
void Run() override {
HandleScope scope(job_->isolate_);
job_->thrower_.CompileFailed("Wasm decoding failed", job_->result_);
job_->thrower_.CompileFailed("Wasm decoding failed", result_);
// {job_} is deleted in AsyncCompileFailed, therefore the {return}.
return job_->AsyncCompileFailed();
}
......
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