From d9302a8892886857f9f012656522bfacf4f8ec1c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 14 Feb 2024 17:45:49 -0800 Subject: [PATCH 1/3] [spec] Throw consistent exns in "read the imports" Instead of allowing ToWebAssemblyValue to throw a TypeError, explicitly catch any exceptions and throw a WebAssembly.LinkError. --- document/js-api/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index d7657d9fe..41df72d75 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -370,7 +370,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje 1. Throw a {{LinkError}} exception. 1. If |valtype| is [=v128=], 1. Throw a {{LinkError}} exception. - 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). + 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). If this operation throws an exception, catch it, and throw a {{LinkError}} exception. 1. Let |store| be the [=surrounding agent=]'s [=associated store=]. 1. Let (|store|, |globaladdr|) be [=global_alloc=](|store|, [=const=] |valtype|, |value|). 1. Set the [=surrounding agent=]'s [=associated store=] to |store|. From e1b39d5b9c077dbf97539c98d8b0882141184add Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 14 Feb 2024 17:45:49 -0800 Subject: [PATCH 2/3] [js-api] Throw consistent exns in "read the imports" Instead of allowing ToWebAssemblyValue to throw a TypeError, explicitly catch any exceptions and throw a WebAssembly.LinkError. --- document/js-api/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index d7657d9fe..41df72d75 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -370,7 +370,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje 1. Throw a {{LinkError}} exception. 1. If |valtype| is [=v128=], 1. Throw a {{LinkError}} exception. - 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). + 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). If this operation throws an exception, catch it, and throw a {{LinkError}} exception. 1. Let |store| be the [=surrounding agent=]'s [=associated store=]. 1. Let (|store|, |globaladdr|) be [=global_alloc=](|store|, [=const=] |valtype|, |value|). 1. Set the [=surrounding agent=]'s [=associated store=] to |store|. From cae2341e8fdbfc11016dfc860fcc95bbb8012d60 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 15 Feb 2024 11:05:09 -0800 Subject: [PATCH 3/3] Catch only TypeError in case TWAV throws other exns in the future --- document/js-api/index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index 41df72d75..36d688c13 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -370,7 +370,7 @@ A {{Module}} object represents a single WebAssembly module. Each {{Module}} obje 1. Throw a {{LinkError}} exception. 1. If |valtype| is [=v128=], 1. Throw a {{LinkError}} exception. - 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). If this operation throws an exception, catch it, and throw a {{LinkError}} exception. + 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valtype|). If this operation throws a {{TypeError}}, catch it, and throw a {{LinkError}} exception. 1. Let |store| be the [=surrounding agent=]'s [=associated store=]. 1. Let (|store|, |globaladdr|) be [=global_alloc=](|store|, [=const=] |valtype|, |value|). 1. Set the [=surrounding agent=]'s [=associated store=] to |store|.