From 783cbd327f624568a14f22cbde42f3aacc10748f Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Thu, 7 Jun 2018 12:25:25 -0700 Subject: [PATCH 1/4] [spec] Use `any` in `Global` constructor See discussion in issue #816. In the future, we'll want to store non-numeric values in a `WebAssembly.Global` object, so using `unrestricted double` is over-constrained. --- document/js-api/index.bs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index 0c82236a18..d5658c2d02 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -720,10 +720,10 @@ dictionary GlobalDescriptor { boolean mutable = false; }; -[LegacyNamespace=WebAssembly, Constructor(GlobalDescriptor descriptor, unrestricted double value = 0), Exposed=(Window,Worker,Worklet)] +[LegacyNamespace=WebAssembly, Constructor(GlobalDescriptor descriptor, optional any value = undefined), Exposed=(Window,Worker,Worklet)] interface Global { - unrestricted double valueOf(); - attribute unrestricted double value; + any valueOf(); + attribute any value; }; @@ -753,11 +753,19 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each 1. Otherwise, throw a {{TypeError}} exception. +
+ The algorithm DefaultGlobalValue(|valuetype|) performs the following steps: + 1. If |valuetype| equals [=𝗂πŸ₯𝟀=], return [=𝗂πŸ₯𝟀.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. If |valuetype| equals [=𝖿πŸ₯𝟀=], return [=𝖿πŸ₯𝟀=.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. If |valuetype| equals [=π–ΏπŸ¨πŸ¦=], return [=π–ΏπŸ¨πŸ¦=.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. Otherwise, throw a {{TypeError}} exception. +
+
The Global(descriptor, v) constructor, when invoked, performs the following steps: 1. Let |mutable| be |descriptor|["mutable"]. 1. Let |valuetype| be [=ToValueType=](|descriptor|["value"]). - 1. Let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|). + 1. If |v| is undefined, let |value| be [=DefaultGlobalValue=](|valuetype|); otherwise, let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|). 1. If |mutable| is true, let |globaltype| be [=var=] |valuetype|; otherwise, let |globaltype| be [=const=] |valuetype|. 1. Let |store| be the current agent's [=associated store=]. 1. Let (|store|, |globaladdr|) be [=alloc_global=](|store|, |globaltype|, |value|). From 6d6a6e41ec9d4d5c47cb5d926f0e92e90ce44f25 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Thu, 7 Jun 2018 14:22:19 -0700 Subject: [PATCH 2/4] s/DefaultGlobalValue/DefaultValue/gc --- document/js-api/index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index d5658c2d02..fd8d810f98 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -754,7 +754,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
- The algorithm DefaultGlobalValue(|valuetype|) performs the following steps: + The algorithm DefaultValue(|valuetype|) performs the following steps: 1. If |valuetype| equals [=𝗂πŸ₯𝟀=], return [=𝗂πŸ₯𝟀.π–Όπ—ˆπ—‡π—Œπ—=] 0. 1. If |valuetype| equals [=𝖿πŸ₯𝟀=], return [=𝖿πŸ₯𝟀=.π–Όπ—ˆπ—‡π—Œπ—=] 0. 1. If |valuetype| equals [=π–ΏπŸ¨πŸ¦=], return [=π–ΏπŸ¨πŸ¦=.π–Όπ—ˆπ—‡π—Œπ—=] 0. @@ -765,7 +765,7 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each The Global(descriptor, v) constructor, when invoked, performs the following steps: 1. Let |mutable| be |descriptor|["mutable"]. 1. Let |valuetype| be [=ToValueType=](|descriptor|["value"]). - 1. If |v| is undefined, let |value| be [=DefaultGlobalValue=](|valuetype|); otherwise, let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|). + 1. If |v| is undefined, let |value| be [=DefaultValue=](|valuetype|); otherwise, let |value| be [=ToWebAssemblyValue=](|v|, |valuetype|). 1. If |mutable| is true, let |globaltype| be [=var=] |valuetype|; otherwise, let |globaltype| be [=const=] |valuetype|. 1. Let |store| be the current agent's [=associated store=]. 1. Let (|store|, |globaladdr|) be [=alloc_global=](|store|, |globaltype|, |value|). From b135aafbdf71c7d376c6163bcd4e3cc02f6496ec Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Thu, 7 Jun 2018 14:49:43 -0700 Subject: [PATCH 3/4] Fix copy/paste mistake --- document/js-api/index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/document/js-api/index.bs b/document/js-api/index.bs index fd8d810f98..22ebfe7850 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -756,8 +756,8 @@ which can be simultaneously referenced by multiple {{Instance}} objects. Each
The algorithm DefaultValue(|valuetype|) performs the following steps: 1. If |valuetype| equals [=𝗂πŸ₯𝟀=], return [=𝗂πŸ₯𝟀.π–Όπ—ˆπ—‡π—Œπ—=] 0. - 1. If |valuetype| equals [=𝖿πŸ₯𝟀=], return [=𝖿πŸ₯𝟀=.π–Όπ—ˆπ—‡π—Œπ—=] 0. - 1. If |valuetype| equals [=π–ΏπŸ¨πŸ¦=], return [=π–ΏπŸ¨πŸ¦=.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. If |valuetype| equals [=𝖿πŸ₯𝟀=], return [=𝖿πŸ₯𝟀.π–Όπ—ˆπ—‡π—Œπ—=] 0. + 1. If |valuetype| equals [=π–ΏπŸ¨πŸ¦=], return [=π–ΏπŸ¨πŸ¦.π–Όπ—ˆπ—‡π—Œπ—=] 0. 1. Otherwise, throw a {{TypeError}} exception.
From c3f2860c5f8dd9accb6c799bdeecd052e06743ed Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Fri, 8 Jun 2018 09:56:19 -0700 Subject: [PATCH 4/4] Remove `= undefined` --- 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 22ebfe7850..644d920e07 100644 --- a/document/js-api/index.bs +++ b/document/js-api/index.bs @@ -720,7 +720,7 @@ dictionary GlobalDescriptor { boolean mutable = false; }; -[LegacyNamespace=WebAssembly, Constructor(GlobalDescriptor descriptor, optional any value = undefined), Exposed=(Window,Worker,Worklet)] +[LegacyNamespace=WebAssembly, Constructor(GlobalDescriptor descriptor, optional any value), Exposed=(Window,Worker,Worklet)] interface Global { any valueOf(); attribute any value;