Skip to content

[js-api] Editorial improvements#2126

Open
eqrion wants to merge 21 commits intoWebAssembly:mainfrom
eqrion:editorial
Open

[js-api] Editorial improvements#2126
eqrion wants to merge 21 commits intoWebAssembly:mainfrom
eqrion:editorial

Conversation

@eqrion
Copy link
Copy Markdown
Collaborator

@eqrion eqrion commented Mar 27, 2026

I spent some time auditing the js-api and web-api specs. There should be no functional changes, just editorial improvements and fixes.

eqrion added 21 commits March 27, 2026 11:42
|module| was overwritten with its [[Module]] slot before reading
[[BuiltinSets]] and [[ImportedStringModule]], which are slots on the
JS Module wrapper, not the internal module.
The condition used i31 on both sides of signed_31(), making it a
circular tautology. Every other similar conversion in the algorithm
uses the unsigned variable (e.g. signed_64(u64)). Change to u31.
…ble name

|store| was used without being retrieved first, and |functype| didn't
match the parameter name |funcType|.
…builtins

find a builtin returns (builtinSetName, builtin) where builtin is
(name, funcType, steps). The funcType is at maybeBuiltin[1][1], not
maybeBuiltin[0][1] which indexes into the string name.
Remove the js-api's local tag_alloc(store, parameters) and replace all
callers with the embedding spec's tag_alloc(store, tagtype), passing an
inline functype as the tag type.
When re-throwing a JS exception that was caught by WebAssembly,
the payload is a list of WebAssembly values from exn_read. For
the JSTag, payload[0] is ref.extern (ref.host hostaddr), not a
raw host address. Passing it directly to 'retrieving a host
value' is wrong since that algorithm expects a host address
integer. Use ToJSValue to correctly unwrap the value.
…odeArray

ToWebAssemblyValue takes two arguments (value, type). The call was
missing the element type. The array type is (array (mut i16)) whose
elements are stored as i32.
table_size returns a raw u64. Table.grow's IDL signature returns
AddressValue. The length getter and Memory.grow both use U64ToAddressValue
for this conversion; Table.grow was missing it.
The hook previously hardcoded memaddrs[0], which is wrong for
multi-memory modules where memory.grow x can target any memory index.
Use the instruction's immediate x to index memaddrs.
For 64-bit memories, memory.grow pushes i64.const (-1) on
failure, not i32.const (-1). The previous check only matched
the i32 case, so for a failed i64 grow the hook incorrectly
called Refresh the memory buffer, detaching the ArrayBuffer
even though the memory size did not change.
func_invoke returns (store, val* | exception | error) where exception
is defined in the core embedding spec as EXCEPTION exnaddr. The check
was using [=THROW=] [=ref.exn=] which is undefined notation. Use
[=exception=] to match the core embedder spec's type.
The outer algorithm used |store| in the func_alloc call without
ever binding it. The |store| inside the hostfunc closure is a
separate binding read at invocation time, not at definition time.
ToJSValue is infallible. Add ! to all call sites that are missing it
for consistency with the existing pattern in run a host function and
create a builtin function.
Per ECMA-262, all internal slots must be declared in the
MakeBasicObject call. [[ObjectKind]] was set immediately after
but was missing from the initial slot list.
The map is keyed by qualified names ("wasm:" prefix) but the assert
checked for the unqualified name, which was never present and made the
assert vacuously true. Compute the qualified name first and assert
against that.
The builtin/string exports object is a plain JS object, not an Infra
ordered map. Use HasProperty to check for component name presence.
- Fix elementType case inconsistency in Table constructor
- Fix "Let return" typo in ToJSValue
- Fix missing "be" in ToWebAssemblyValue
- Fix "fo" typo in instantiate a builtin set
- Fix indentation of 'Return handled' in HostResizeArrayBuffer
- Fix spurious space in get the JavaScript exception tag links
- Fix 'a import' typo in validate builtins display text
- Fix 'is' typo in Set [[ArrayBufferMaxByteLength]] step
- Update WebIDL URL to webidl.spec.whatwg.org
- Use [=/new=] consistently for Tag and Exception object creation
- Use 'surrounding agent' consistently instead of 'current agent'
- Update TC39 URL to tc39.es/ecma262
- Remove dead and duplicate ECMASCRIPT anchor entries
- Fix 'appending' typo in embedding interface URL
- Fix tag address pluralization in Tag object cache description
- Use [=/new=] for Module object creation in construct a WebAssembly module object
- Fix list item numbering in ToJSValue i32 branch
- Remove unused 'instantiate a WebAssembly module' anchor
- Rename Instance constructor parameter to moduleObject
- Fix missing period in Exception constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant