wasm: get self-hosted compiling, and supporting separate_thread

My original goal here was just to get the self-hosted Wasm backend
compiling again after the pipeline change, but it turned out that from
there it was pretty simple to entirely eliminate the shared state
between `codegen.wasm` and `link.Wasm`. As such, this commit not only
fixes the backend, but makes it the second backend (after CBE) to
support the new 1:N:1 threading model.
This commit is contained in:
mlugg
2025-06-03 16:25:16 +01:00
parent 5ab307cf47
commit c0df707066
10 changed files with 402 additions and 309 deletions

View File

@@ -135,6 +135,22 @@ pub fn MultiArrayList(comptime T: type) type {
self.* = undefined;
}
/// Returns a `Slice` representing a range of elements in `s`, analagous to `arr[off..len]`.
/// It is illegal to call `deinit` or `toMultiArrayList` on the returned `Slice`.
/// Asserts that `off + len <= s.len`.
pub fn subslice(s: Slice, off: usize, len: usize) Slice {
assert(off + len <= s.len);
var ptrs: [fields.len][*]u8 = undefined;
inline for (s.ptrs, &ptrs, fields) |in, *out, field| {
out.* = in + (off * @sizeOf(field.type));
}
return .{
.ptrs = ptrs,
.len = len,
.capacity = len,
};
}
/// This function is used in the debugger pretty formatters in tools/ to fetch the
/// child field order and entry type to facilitate fancy debug printing for this type.
fn dbHelper(self: *Slice, child: *Elem, field: *Field, entry: *Entry) void {