4 ms·
Announcement post in March 2025 summarizes the changes from WASM 1.0. Wasm 2.0 Completed - https://webassembly.org/news/2025-03-20-wasm-2.0/ https://webassembl
by lioeters 1y ago
Announcement post in March 2025 summarizes the changes from WASM 1.0.
Wasm 2.0 Completed - https://webassembly.org/news/2025-03-20-wasm-2.0/ https://webassembly.org/news/2025-03-20-wasm-2.0/
> ..here is the summary of the additions in version 2.0 of the language:
Vector instructions: With a massive 236 new instructions — more than the total number Wasm had before — it now supports 128-bit wide SIMD (single instruction, multiple data) functionality of contemporary CPUs, like Intel’s SSE or ARM’s SVE. This helps speeding up certain classes of compute-intense applications like audio/video codecs, machine learning, and some cryptography.
Bulk memory instructions: A set of new instructions allows faster copying and initialization of regions of memory or ranges of tables.
Multi-value results: Instructions, blocks, and functions can now return more than one result value, sometimes supporting faster calling conventions and avoiding indirections. In addition, block instructions now also can have inputs, enabling new program transformations.
Reference types: References to functions or pointers to external objects (e.g., JavaScript values) become available as opaque first-class values. Tables are repurposed as a general storage for such reference values, and new instructions allow accessing and mutating tables in Wasm code. In addition, modules now may define multiple tables of different types.
Non-trapping conversions: Additional instructions allow the conversion from float to integer types without the risk of trapping unexpectedly.
Sign extension instructions: A new group of instructions allows directly extending the width of signed integer value. Previously that was only possible when reading from memory.
- immibis 1y agoYou can have an ISA sufficiently generic to run on any CPU, or one sufficiently specific to efficiently exploit SIMD on a particular CPU. Never both. That's why some platforms provider higher-level operations, like element-wise multiplication of packed arrays. I can't see whether the actual WASM2 SIMD instructions are sufficiently generic because apparently I'm rate-limited on GitHub (???) and therefore can't see the spec.
- flohofwoe 1y agohttps://web.archive.org/web/20250429065033/https://webassembly.github.io/spec/core/syntax/types.html https://web.archive.org/web/20250429065033/https://webassemb... Values are hardwired to 128 bits which can be i8x16/i16x8/i32x4/i64x2 or f32x4/f64x2, so that already limits the 'feature surface' drastically. IMHO as long as it covers the most common use cases (e.g. vec4 / mat4x4 floating point math used in games and a couple of common ALU and bit-twiddling operations on integers) that's already quite a bit better than having to fall back to scalar math.
- mdaniel 1y ago> apparently I'm rate-limited on GitHub (???) and therefore can't see the spec. Are you also on Firefox? I've been getting those 429s a lot over the past week or so. I haven't changed my configuration other than I'm religious about the "check for updates" button, but I cannot imagine a world in which my release-branch browser is a novelty. No proxies, yes I run UBO but it is disabled for GH
- eppsilon 1y agoI got some using Orion on iOS yesterday. Same engine as every other iOS browser, so I guess it's sending a user agent GH doesn't like?
- ncruces 1y agoThey were sufficient for me to implement most of `string.h` and get speedups between 4 and 16x vs “portable musl C code,” including sophisticated algorithms such as this one: http://0x80.pl/notesen/2016-11-28-simd-strfind.html http://0x80.pl/notesen/2016-11-28-simd-strfind.html I posted about my efforts here: https://news.ycombinator.com/item?id=43935284 https://news.ycombinator.com/item?id=43935284 Or, if you wanna jump to the code: https://github.com/ncruces/go-sqlite3/blob/main/sqlite3/libc/string.h https://github.com/ncruces/go-sqlite3/blob/main/sqlite3/libc...
- adrian17 1y ago> Instructions, blocks, and functions can now return more than one result value, sometimes supporting faster calling conventions and avoiding indirections. Unfortunately, despite being "enabled", Rust+LLVM don't take advantage of this because of ABI compatibility mess. I don't know whether the story on Clang's side is similar.
- sapiogram 1y agoInteresting, got any links to more information?
- adrian17 1y agohttps://blog.rust-lang.org/2024/09/24/webassembly-targets-change-in-default-target-features/ https://blog.rust-lang.org/2024/09/24/webassembly-targets-ch... "As a result there is no longer any possible method of writing a function in Rust that returns multiple values at the WebAssembly function type level." And similar queries in Rust's zulip: https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/how.20to.20write.20multivalue.20functions.20for.20webassembly/near/507127327 https://rust-lang.zulipchat.com/#narrow/channel/122651-gener...
- burakemir 1y agohttps://blog.rust-lang.org/2025/04/04/c-abi-changes-for-wasm32-unknown-unknown/ https://blog.rust-lang.org/2025/04/04/c-abi-changes-for-wasm...
- Dwedit 1y agoI figured out the way to get multi-value results on GCC for 32-bit ARM. Use a union to pack two 32-bit values into a 64-bit value. Return the 64-bit value. Then use a union to split the 64-bit value into two 32-bit values. I haven't tested it on other 32-bit architectures though.
- _lvbh 1y agoI'm using the same trick in Zig via packed structs
- varjag 1y agoMulti-value results are great for prospective Common Lisp runtimes.
- cryptonector 1y agoOne can always compile CL to CPS, then "returning" is just calling the current continuation, and then passing multiple values to the current continuation is trivial (since that's always possible). Since WASM is single-threaded there is not concurrency risk with using closures so extensively, though one pays the full price of call/cc when implementing this way, which means that the stack becomes a heap, which is not great for performance.
- varjag 1y agoI mean yes you can compile CL into Turing machine tape too just that it's not terribly practical.
- singularity2001 1y agopremature optimization is the root of all evil and this SIMD mess could have been implemented so much more elegantly if they just followed the general variable size flexible vector proposal https://github.com/WebAssembly/flexible-vectors https://github.com/WebAssembly/flexible-vectors
- mycall 1y agoCould they in a follow up revision or would that throw out lots of past work?
- romperstomper 1y agoThey also say at the end "In a future post we will take a look at Wasm 3.0, which is already around the corner at this point!" so I suppose the Wasm 3.0 is coming very soon?
- lioeters 1y agoFound a draft here: WebAssembly Specification - Release 3.0 (Draft 2024-11-07) https://webassembly.github.io/spec/versions/core/WebAssembly-3.0-draft.pdf https://webassembly.github.io/spec/versions/core/WebAssembly... (PDF) Source: https://github.com/WebAssembly/spec https://github.com/WebAssembly/spec
- singularity2001 1y ago"the browsers vendors have weaponized web standards complexity against any newcomers" https://joeyh.name/blog/entry/WASM_Wayland_Web_WWW/ https://joeyh.name/blog/entry/WASM_Wayland_Web_WWW/