Commit 338f3902 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Make {JSPromise::Resolve} and friend MUST_USE_RESULT.

R=adamk@chromium.org

Change-Id: Ib6b66003aaf8694c1e5eed6db7d2537322eddad8
Reviewed-on: https://chromium-review.googlesource.com/897498Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51051}
parent b8059eb5
......@@ -4033,10 +4033,10 @@ class JSPromise : public JSObject {
v8::Promise::PromiseState status() const;
// Resolve/reject the promise with a given value.
static MaybeHandle<Object> Resolve(Handle<JSPromise> promise,
Handle<Object> value);
static MaybeHandle<Object> Reject(Handle<JSPromise> promise,
Handle<Object> value);
MUST_USE_RESULT static MaybeHandle<Object> Resolve(Handle<JSPromise> promise,
Handle<Object> value);
MUST_USE_RESULT static MaybeHandle<Object> Reject(Handle<JSPromise> promise,
Handle<Object> value);
DECL_CAST(JSPromise)
......
......@@ -3459,14 +3459,18 @@ void AsyncCompileJob::AsyncCompileFailed(ErrorThrower& thrower) {
// {job} keeps the {this} pointer alive.
std::shared_ptr<AsyncCompileJob> job =
isolate_->wasm_engine()->compilation_manager()->RemoveJob(this);
JSPromise::Reject(module_promise_, thrower.Reify());
MaybeHandle<Object> promise_result =
JSPromise::Reject(module_promise_, thrower.Reify());
CHECK_EQ(promise_result.is_null(), isolate_->has_pending_exception());
}
void AsyncCompileJob::AsyncCompileSucceeded(Handle<Object> result) {
// {job} keeps the {this} pointer alive.
std::shared_ptr<AsyncCompileJob> job =
isolate_->wasm_engine()->compilation_manager()->RemoveJob(this);
JSPromise::Resolve(module_promise_, result);
MaybeHandle<Object> promise_result =
JSPromise::Resolve(module_promise_, result);
CHECK_EQ(promise_result.is_null(), isolate_->has_pending_exception());
}
// A closure to run a compilation step (either as foreground or background
......
......@@ -63,10 +63,13 @@ void WasmEngine::AsyncInstantiate(Isolate* isolate, Handle<JSPromise> promise,
MaybeHandle<WasmInstanceObject> instance_object = SyncInstantiate(
isolate, &thrower, module_object, imports, Handle<JSArrayBuffer>::null());
if (thrower.error()) {
JSPromise::Reject(promise, thrower.Reify());
MaybeHandle<Object> result = JSPromise::Reject(promise, thrower.Reify());
CHECK_EQ(result.is_null(), isolate->has_pending_exception());
return;
}
JSPromise::Resolve(promise, instance_object.ToHandleChecked());
Handle<WasmInstanceObject> instance = instance_object.ToHandleChecked();
MaybeHandle<Object> result = JSPromise::Resolve(promise, instance);
CHECK_EQ(result.is_null(), isolate->has_pending_exception());
}
void WasmEngine::AsyncCompile(Isolate* isolate, Handle<JSPromise> promise,
......@@ -87,11 +90,13 @@ void WasmEngine::AsyncCompile(Isolate* isolate, Handle<JSPromise> promise,
module_object = SyncCompile(isolate, &thrower, bytes);
}
if (thrower.error()) {
JSPromise::Reject(promise, thrower.Reify());
MaybeHandle<Object> result = JSPromise::Reject(promise, thrower.Reify());
CHECK_EQ(result.is_null(), isolate->has_pending_exception());
return;
}
Handle<WasmModuleObject> module = module_object.ToHandleChecked();
JSPromise::Resolve(promise, module);
MaybeHandle<Object> result = JSPromise::Resolve(promise, module);
CHECK_EQ(result.is_null(), isolate->has_pending_exception());
return;
}
......
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