diff options
Diffstat (limited to '')
-rw-r--r-- | js/src/wasm/WasmValue.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/wasm/WasmValue.cpp b/js/src/wasm/WasmValue.cpp index 6039b00517..824cc0e2cc 100644 --- a/js/src/wasm/WasmValue.cpp +++ b/js/src/wasm/WasmValue.cpp @@ -135,6 +135,8 @@ bool wasm::CheckRefType(JSContext* cx, RefType targetType, HandleValue v, return CheckAnyRefValue(cx, v, refval); case RefType::NoFunc: return CheckNullFuncRefValue(cx, v, fnval); + case RefType::NoExn: + return CheckNullExnRefValue(cx, v, refval); case RefType::NoExtern: return CheckNullExternRefValue(cx, v, refval); case RefType::None: @@ -200,6 +202,18 @@ bool wasm::CheckNullFuncRefValue(JSContext* cx, HandleValue v, return true; } +bool wasm::CheckNullExnRefValue(JSContext* cx, HandleValue v, + MutableHandleAnyRef vp) { + if (!v.isNull()) { + JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, + JSMSG_WASM_BAD_NULL_EXNREF_VALUE); + return false; + } + + vp.set(AnyRef::null()); + return true; +} + bool wasm::CheckNullExternRefValue(JSContext* cx, HandleValue v, MutableHandleAnyRef vp) { if (!v.isNull()) { @@ -436,6 +450,23 @@ bool ToWebAssemblyValue_externref(JSContext* cx, HandleValue val, void** loc, } template <typename Debug = NoDebug> +bool ToWebAssemblyValue_nullexnref(JSContext* cx, HandleValue val, void** loc, + bool mustWrite64) { + RootedAnyRef result(cx, AnyRef::null()); + if (!CheckNullExnRefValue(cx, val, &result)) { + return false; + } + loc[0] = result.get().forCompiledCode(); +#ifndef JS_64BIT + if (mustWrite64) { + loc[1] = nullptr; + } +#endif + Debug::print(*loc); + return true; +} + +template <typename Debug = NoDebug> bool ToWebAssemblyValue_nullexternref(JSContext* cx, HandleValue val, void** loc, bool mustWrite64) { RootedAnyRef result(cx, AnyRef::null()); @@ -667,6 +698,9 @@ bool wasm::ToWebAssemblyValue(JSContext* cx, HandleValue val, ValType type, case RefType::NoFunc: return ToWebAssemblyValue_nullfuncref<Debug>(cx, val, (void**)loc, mustWrite64); + case RefType::NoExn: + return ToWebAssemblyValue_nullexnref<Debug>(cx, val, (void**)loc, + mustWrite64); case RefType::NoExtern: return ToWebAssemblyValue_nullexternref<Debug>(cx, val, (void**)loc, mustWrite64); @@ -775,6 +809,9 @@ bool ToJSValue_lossless(JSContext* cx, const void* src, MutableHandleValue dst, cx, GlobalObject::getOrCreatePrototype(cx, JSProto_WasmGlobal)); Rooted<WasmGlobalObject*> srcGlobal( cx, WasmGlobalObject::create(cx, srcVal, false, prototype)); + if (!srcGlobal) { + return false; + } dst.set(ObjectValue(*srcGlobal.get())); return true; } |