You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2990083
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: Plugins/BridgeJS/README.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,7 +139,8 @@ The ABI will not be stable, and not meant to be interposed by other tools.
139
139
Parameter passing follows Wasm calling conventions, with custom handling for complex types:
140
140
141
141
-**Primitives**: Passed directly as Wasm arguments (`i32`, `i64`, `f32`, `f64`)
142
-
-**Strings**: UTF-8 bytes stored in `swift.memory`, ID + length passed as Wasm arguments
142
+
-**Strings (JS → Swift)**: UTF-8 bytes stored in `swift.memory`, ID + length passed as Wasm arguments
143
+
-**Strings (Swift → JS)**: the wasm32 12-byte `String` layout passed as three `i32` words. JS fast-decodes small strings, caches large immortals by a 53-bit `ptr + len` pack when `len < 2**21`, and otherwise reads UTF-8 at `word1 + 20` (`nativeBias`). This layout is a Swift stdlib implementation detail and can change with the toolchain.
143
144
-**Swift Classes**: Raw Swift heap pointer passed as `i32`
144
145
-**JSObjects**: Object stored in `swift.memory.heap`, object ID passed as `i32`
145
146
-**Structs/Arrays**: Fields/elements pushed to type-specific stacks, Swift pops in reverse order
@@ -150,7 +151,7 @@ Parameter passing follows Wasm calling conventions, with custom handling for com
150
151
Return values use direct Wasm returns for primitives, and imported intrinsic functions for complex types:
151
152
152
153
-**Primitives**: Returned directly via Wasm return value
153
-
-**Strings**: Swift writes UTF-8 bytes to shared memory, JS decodes
154
+
-**Strings**: Swift passes the 12-byte `String` layout; JS decodes (small / immortal-cached / UTF-8)
154
155
-**Swift Classes**: Pointer returned directly, JS wraps in `SwiftHeapObject` with `FinalizationRegistry`
155
156
-**Structs/Arrays**: Swift pushes fields/elements to type-specific stacks, JS reconstructs
0 commit comments