Skip to content

Commit

Permalink
Fix nullability for string constants
Browse files Browse the repository at this point in the history
  • Loading branch information
eqrion committed Apr 12, 2024
1 parent f13f076 commit 5dfc5d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions proposals/js-string-builtins/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 define imports of the form `(import "'" "%stringConstant%"" (global (ref extern)))`, 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.

All imports that reference this namespace must be globals of type immutable externref. If they are not, an eager compile error is emitted.
All imports that reference this namespace must be immutable globals and have a type that matches non-nullable externref (i.e. `(ref extern)` and `externref` are both allowed). If they are not, an eager compile error is emitted.

## JS String Builtin API

Expand Down

0 comments on commit 5dfc5d8

Please sign in to comment.