plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
cf29fca
— Peter John
2026-11-11T00:30:34+05:30
codegen comments: Array's intrinsic read is at, not get
compiler/wasm-codegen/src/gctypes.rs
CHANGED
|
@@ -177,7 +177,7 @@ impl GcTypeRegistry {
|
|
|
177
177
|
|
|
178
178
|
/// Whether `name` is the `Array` intrinsic — it is backed by one
|
|
179
179
|
/// physical wasm-gc array type (`GcTypeRegistry::array_type_idx`) instead of
|
|
180
|
-
/// a struct type, and its `init`/`
|
|
180
|
+
/// a struct type, and its `init`/`at`/`set`/`length` methods are
|
|
181
181
|
/// compiler intrinsics (`@native` bodies) (see
|
|
182
182
|
/// `compileIntrinsicFnBody`).
|
|
183
183
|
pub(crate) fn isArraySpecialization(name: &str) -> bool {
|
compiler/wasm-codegen/src/intrinsics.rs
CHANGED
|
@@ -188,13 +188,13 @@ pub(crate) fn wrapBytesAsStr(body: &mut Vec<u8>) {
|
|
|
188
188
|
Instruction::Call(mk).encode(body);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
/// `Array<T>`'s `init`/`
|
|
191
|
+
/// `Array<T>`'s `init`/`at`/`set`/`length` — the intrinsic is backed by ONE wasm-gc `array<anyref>` type
|
|
192
192
|
/// (`GcTypeRegistry::array_type_idx`, see `isArraySpecialization`), so these
|
|
193
193
|
/// compile identically regardless of the concrete `T`.
|
|
194
194
|
/// Every `type_param`-bearing `Fn` — methods AND non-`self` nested
|
|
195
195
|
/// "static" constructors like `init` (see `fnWasmParamTypes`) — gets an
|
|
196
196
|
/// implicit receiver as wasm param 0, so a declared plum param at position `k`
|
|
197
|
-
/// is always wasm local `k + 1`. `
|
|
197
|
+
/// is always wasm local `k + 1`. `at` is the one case that also needs a
|
|
198
198
|
/// `ref.cast` back from the raw stored `anyref` down to `T`'s own concrete
|
|
199
199
|
/// type; `set`/`init` need no such cast the other way, since any concrete ref
|
|
200
200
|
/// is already a valid subtype wherever `anyref` is expected.
|
|
@@ -433,7 +433,7 @@ pub(crate) fn compileArrayIntrinsicFnBody(f: &ast::Fn, subst: &Subst) -> Option<
|
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/// `Array<S>` (S a `struct`) intrinsics for the struct-of-arrays layout: the array
|
|
436
|
-
/// is one GC struct whose field `k` is the native array of leaf `k`. `
|
|
436
|
+
/// is one GC struct whose field `k` is the native array of leaf `k`. `at`/`set`
|
|
437
437
|
/// read/write each leaf array directly (no allocation, no box).
|
|
438
438
|
pub(crate) fn compileSoaArrayIntrinsic(name: &str, elem: &PlumType, soa_idx: u32) -> Option<Vec<u8>> {
|
|
439
439
|
let leaves = flatValtypes(elem, &gcTypes());
|