diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-06-29 20:35:31 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-07-10 09:38:05 +0200 |
commit | e2148d742549b7c88891bb50b4b4a562bf4bd46a (patch) | |
tree | 4df9f919264e7d44f0a40177ffca8e0cf080325f /deps/v8/src/wasm/wasm-js.cc | |
parent | 6463adf183449b83d125a0e975c54f8bdf54d847 (diff) | |
download | node-new-e2148d742549b7c88891bb50b4b4a562bf4bd46a.tar.gz |
deps: patch V8 to 9.1.269.38
Refs: https://github.com/v8/v8/compare/9.1.269.36...9.1.269.38
Fixes: https://github.com/nodejs/node/issues/37553
PR-URL: https://github.com/nodejs/node/pull/39196
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/src/wasm/wasm-js.cc')
-rw-r--r-- | deps/v8/src/wasm/wasm-js.cc | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/deps/v8/src/wasm/wasm-js.cc b/deps/v8/src/wasm/wasm-js.cc index bc9c5557eb..7f1d8e261f 100644 --- a/deps/v8/src/wasm/wasm-js.cc +++ b/deps/v8/src/wasm/wasm-js.cc @@ -2318,28 +2318,49 @@ void WasmJs::InstallConditionalFeatures(Isolate* isolate, Handle<JSGlobalObject> global = handle(context->global_object(), isolate); MaybeHandle<Object> maybe_webassembly = JSObject::GetProperty(isolate, global, "WebAssembly"); - Handle<JSObject> webassembly = - Handle<JSObject>::cast(maybe_webassembly.ToHandleChecked()); + Handle<Object> webassembly_obj; + if (!maybe_webassembly.ToHandle(&webassembly_obj)) { + // There is not {WebAssembly} object. We just return without adding the + // {Exception} constructor. + return; + } + if (!webassembly_obj->IsJSObject()) { + // The {WebAssembly} object is invalid. As we cannot add the {Exception} + // constructor, we just return. + return; + } + Handle<JSObject> webassembly = Handle<JSObject>::cast(webassembly_obj); // 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); - // Install the constructor on the context. - 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(isolate, exception_constructor, exception_map, - exception_proto); + + if (JSObject::HasOwnProperty(webassembly, exception_name).FromMaybe(true)) { + // The {Exception} constructor already exists, there is nothing more to + // do. + return; + } + + bool has_prototype = true; + Handle<JSFunction> exception_constructor = + CreateFunc(isolate, exception_name, WebAssemblyException, has_prototype, + SideEffectType::kHasNoSideEffect); + exception_constructor->shared().set_length(1); + auto result = Object::SetProperty( + isolate, webassembly, exception_name, exception_constructor, + StoreOrigin::kNamed, Just(ShouldThrow::kDontThrow)); + if (result.is_null()) { + // Setting the {Exception} constructor failed. We just bail out. + return; } + // Install the constructor on the context. + 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(isolate, exception_constructor, exception_map, + exception_proto); } } #undef ASSIGN |