-
Couldn't load subscription status.
- Fork 0
Open
Description
From the overview:
Number (wasm:js-number):
Type test: test, testI32, testU32
Create from primitive: fromF64, fromI32, fromU32
Extract to primitive: toF64, toI32, toU32
How would you feel about reducing this to:
js-number:test: (x: externref) -> i32
return (typeof x == "number") ? 1 : 0
js-number:cast: (x: externref) -> f64
if (typeof x !== "number") trap();
return x;
js-value:from: (x: T) -> externref
generic over any value type `T`
equivalent to ToWebAssemblyValue(ToJSValue(x, T), 'externref')
testI32/testU32 could be replicated using test + cast + wasm arithmetic instructions. I think this sequence would be easily optimizable in a compiler for engines using a Smi representation to avoid unnecessary conversions.
fromF64/fromI32/fromU32 are basically just wrappers around ToJSValue, and so I wonder if just exposing that as js-value:from would make sense.
toF64 becomes cast and toI32/ toU32 must cast and then do a further check. Again as with testI32/testU32, I think optimizing compilers for engines using Smi's can make it optimally fast.
Metadata
Metadata
Assignees
Labels
No labels