From d73f306df7423b0b9273964f4874088c21d59616 Mon Sep 17 00:00:00 2001 From: Ryan Hunt Date: Fri, 12 Apr 2024 08:44:49 -0500 Subject: [PATCH] Fix nullability for string constants --- proposals/js-string-builtins/Overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proposals/js-string-builtins/Overview.md b/proposals/js-string-builtins/Overview.md index 0b248e02..007bf83f 100644 --- a/proposals/js-string-builtins/Overview.md +++ b/proposals/js-string-builtins/Overview.md @@ -171,11 +171,11 @@ The simplest way is to have a module import each string as an immutable global. This proposal adds an extension to JS-API compile routine to support optimized 'imported string constants' to address this use-case. -The `WebAssemblyCompileOptions` is extended with a `boolean importedStringConstants` flag. When this is set, the module may define imports of the form `(import "'" "%stringConstant%"" (global externref))`, and the JS-API will use the provided `%stringConstant%` import field name to be the value of the global. This allows for any UTF-8 string to be imported with minimal overhead. +The `WebAssemblyCompileOptions` is extended with a `boolean importedStringConstants` flag. When this is set, the module may import globals of the form `(import "'" "%stringConstant%"" (global ...))`, and the JS-API will use the provided `%stringConstant%` import field name to be the value of the global. This allows for any UTF-8 string to be imported with minimal overhead. -The string namespace is chosen to be the single quote ASCII character `'`. We may revise this to be a longer name before this proposal is finalized. +This works by having the JS-API create a `(global (ref extern))` for each string constant, and provide that as the import value to the module. The [normal import checking for globals](https://webassembly.github.io/gc/core/valid/matching.html#match-globaltype) is performed, which allows for a user to specify either nullable or non-nullable externref, as long as the import global type is immutable. This check is eager, resulting in a compile error if it fails. -All imports that reference this namespace must be globals of type immutable externref. If they are not, an eager compile error is emitted. +The string namespace is chosen to be the single quote ASCII character `'`. This is to reduce binary size impact. We may revise this to be a longer name before this proposal is finalized, if we can mitigate the binary size increase. ## JS String Builtin API