11---
22name : wasm
33description : |
4- Modern WebAssembly (WASM ) development expertise covering WASM 3.0 features
4+ Modern WebAssembly (Wasm ) development expertise covering modern Wasm features
55 and optimization techniques. Use this skill when working with WebAssembly
6- modules, optimizing WASM performance, or integrating WASM with JavaScript/TypeScript .
6+ modules or optimizing Wasm performance .
77compatibility : WebAssembly v3.0 and later
88---
99
@@ -23,7 +23,7 @@ local.get $y
2323i32.add
2424```
2525
26- ## WebAssembly 3.0 Features
26+ ## WebAssembly Features
2727
2828### Memory64 (64-bit Address Space)
2929- Memories and tables use ` i64 ` as address type
@@ -62,6 +62,21 @@ i32.add
6262- Hardware-dependent SIMD optimizations beyond fixed-width 128-bit
6363- ` i8x16.relaxed_swizzle ` , ` f32x4.relaxed_madd ` , etc.
6464
65+ ### WasmGC
66+ - Native garbage-collected types: ` struct ` , ` array `
67+ - Instructions: ` array.new ` , ` array.get ` , ` array.set ` , ` struct.new ` , ` struct.get `
68+ - Reference types: ` (ref $type) ` , ` (ref null $type) `
69+
70+ ### externref
71+ - Opaque reference to host (JS) objects
72+ - Cannot be inspected or modified in Wasm, only passed around
73+ - Used with js-string-builtins for efficient string handling
74+
75+ ### js-string-builtins
76+ - Import ` "wasm:js-string" ` for direct JS string operations
77+ - Functions: ` length ` , ` charCodeAt ` , ` fromCharCodeArray ` , ` intoCharCodeArray `
78+ - Avoids costly JS↔Wasm boundary crossings for string processing
79+
6580### SIMD Example
6681``` wat
6782;; Process 16 bytes at a time
@@ -75,26 +90,11 @@ i32.add
7590
7691| Task | Command |
7792| ------| ---------|
78- | Assemble WAT to WASM | ` wasm-as module.wat -o module.wasm ` |
79- | Disassemble WASM to WAT | ` wasm-dis module.wasm -o module.wat ` |
93+ | Assemble WAT to Wasm | ` wasm-as module.wat -o module.wasm ` |
94+ | Disassemble Wasm to WAT | ` wasm-dis module.wasm -o module.wat ` |
8095| Optimize for size | ` wasm-opt -Oz in.wasm -o out.wasm ` |
8196| Optimize for speed | ` wasm-opt -O3 in.wasm -o out.wasm ` |
8297
83- ## JavaScript/TypeScript Integration
84-
85- ### Instantiation
86- ``` typescript
87- const module = await WebAssembly .compileStreaming (fetch (' module.wasm' ));
88- const instance = await WebAssembly .instantiate (module , imports );
89- ```
90-
91- ### Memory Access
92- ``` typescript
93- const memory = new WebAssembly .Memory ({ initial: 1 , maximum: 100 });
94- const buffer = new Uint8Array (instance .exports .memory .buffer );
95- buffer .set (data , offset );
96- ```
97-
9898## Resources
9999
100100- [ WebAssembly Specification] ( https://webassembly.github.io/spec/ )
0 commit comments