Commit 91cfbda6 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by V8 LUCI CQ

[wasm][eh] Clean up exception constructor

Re-use InstallConstructorFunc and remove an obsolete comment.

R=ahaas@chromium.org

Change-Id: I1143d3e58e968b9210cef5045d8221d20ed18419
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2886859Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74499}
parent 7ff863b3
......@@ -2241,15 +2241,8 @@ void WasmJs::Install(Isolate* isolate, bool exposed_on_global_object) {
// Setup Exception
if (enabled_features.has_eh()) {
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);
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.
Handle<JSFunction> exception_constructor = InstallConstructorFunc(
isolate, webassembly, "Exception", WebAssemblyException);
context->set_wasm_exception_constructor(*exception_constructor);
SetDummyInstanceTemplate(isolate, exception_constructor);
JSFunction::EnsureHasInitialMap(exception_constructor);
......@@ -2321,12 +2314,8 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate,
// Setup Exception
Handle<String> exception_name = v8_str(isolate, "Exception");
if (!JSObject::HasProperty(webassembly, exception_name).FromMaybe(true)) {
Handle<JSFunction> exception_constructor =
CreateFunc(isolate, exception_name, WebAssemblyException, true,
SideEffectType::kHasSideEffect);
exception_constructor->shared().set_length(1);
JSObject::AddProperty(isolate, webassembly, exception_name,
exception_constructor, DONT_ENUM);
Handle<JSFunction> exception_constructor = InstallConstructorFunc(
isolate, webassembly, "Exception", WebAssemblyException);
// Install the constructor on the context.
context->set_wasm_exception_constructor(*exception_constructor);
SetDummyInstanceTemplate(isolate, exception_constructor);
......
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