Commit 050d30fb authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[wasm] Fix catching of stack overflow in asm.js instantiation

There was a very narrow corner case where we would return from the
runtime function that tries to instantiate a module created by an
asm.js-to-wasm translation in an inconsistent state: returning a
Smi failure sentinel even though there is a pending exception.

Bug: chromium:1061808
Change-Id: I22f5c6cdb8d7f7abfddb2bb81dc9261c8a35bdeb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2106194Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66741}
parent 5cf02f0f
......@@ -408,9 +408,12 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
return single_function;
}
Handle<String> exports_name =
isolate->factory()->InternalizeUtf8String("exports");
return Object::GetProperty(isolate, instance, exports_name);
// Here we rely on the fact that the exports object is eagerly created.
// The following check is a weak indicator for that. If this ever changes,
// then we'll have to call the "exports" getter, and be careful about
// handling possible stack overflow exceptions.
DCHECK(instance->exports_object().IsJSObject());
return handle(instance->exports_object(), isolate);
}
} // namespace internal
......
......@@ -142,6 +142,7 @@ RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) {
DCHECK(function->code() ==
isolate->builtins()->builtin(Builtins::kInstantiateAsmJs));
function->set_code(isolate->builtins()->builtin(Builtins::kCompileLazy));
DCHECK(!isolate->has_pending_exception());
return Smi::zero();
}
......
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