Commit 98919e51 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[wasm][eh] Install exception constructor unconditionally

WasmJs::Install uses command line flags for feature detection, because
the context is not yet available to detect origin trial flags.

Exception handling is available via an origin trial, so make sure that
the exception constructor is installed regardless of the command line
flag.

R=ahaas@chromium.org

Bug: chromium:1183026
Change-Id: Ie0950ce19adeafea6e46892098c9485d6f9da792
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2732022Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73223}
parent c370624a
......@@ -2238,19 +2238,26 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
v8_str(isolate, "WebAssembly.Global"), ro_attributes);
// Setup Exception
Handle<String> exception_name = v8_str(isolate, "Exception");
Handle<JSFunction> exception_constructor =
CreateFunc(isolate, exception_name, WebAssemblyException, true,
SideEffectType::kHasSideEffect);
exception_constructor->shared().set_length(1);
if (enabled_features.has_eh()) {
Handle<JSFunction> exception_constructor = InstallConstructorFunc(
isolate, webassembly, "Exception", WebAssemblyException);
context->set_wasm_exception_constructor(*exception_constructor);
SetDummyInstanceTemplate(isolate, exception_constructor);
JSFunction::EnsureHasInitialMap(exception_constructor);
Handle<JSObject> exception_proto(
JSObject::cast(exception_constructor->instance_prototype()), isolate);
Handle<Map> exception_map = isolate->factory()->NewMap(
i::WASM_EXCEPTION_OBJECT_TYPE, WasmExceptionObject::kHeaderSize);
JSFunction::SetInitialMap(exception_constructor, exception_map,
exception_proto);
}
JSObject::AddProperty(isolate, webassembly, exception_name,
exception_constructor, DONT_ENUM);
}
// Install the constructor on the context unconditionally so that it is also
// available when the feature is enabled via the origin trial.
context->set_wasm_exception_constructor(*exception_constructor);
SetDummyInstanceTemplate(isolate, exception_constructor);
JSFunction::EnsureHasInitialMap(exception_constructor);
Handle<JSObject> exception_proto(
JSObject::cast(exception_constructor->instance_prototype()), isolate);
Handle<Map> exception_map = isolate->factory()->NewMap(
i::WASM_EXCEPTION_OBJECT_TYPE, WasmExceptionObject::kHeaderSize);
JSFunction::SetInitialMap(exception_constructor, exception_map,
exception_proto);
// Setup Function
if (enabled_features.has_type_reflection()) {
......
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