Skip to content

Commit be4e0e1

Browse files
committed
CHAIN LIES
note: this requires a version of wabt which doesn't exist yet, see WebAssembly/wabt#2622
1 parent d8069e1 commit be4e0e1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

wasm_anon/build.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub fn build(b: *std.Build) void {
125125
.{ "store", 0, null },
126126
.{ "call", 2, null },
127127
.{ "global", 0, null },
128+
.{ "gc/array", 0, null },
128129
};
129130
for (upstream_specs) |item| {
130131
const name, const fail, const heavy = item;

wasm_anon/src/Module.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,18 @@ pub fn element_section(self: *Module, in: *Instance) !void {
447447
dbg("Elements: {}\n", .{len});
448448
for (0..len) |_| {
449449
const kinda = try r.readu();
450-
if (kinda == 0) {
450+
if (kinda == 0 or kinda == 4) {
451451
const offset: usize = @intCast((try Interpreter.eval_constant_expr(&r, .i32, in.preglobals(), self.allocator)).i32);
452452
const elen = try r.readu();
453453
if (offset + len > in.funcref_table.len) {
454454
return error.InvalidFormat;
455455
}
456456
for (0..elen) |i| {
457+
if (kinda == 4) {
458+
const wat = try r.readByte();
459+
if (wat != 0xd2) @panic("TODO :D");
460+
}
461+
457462
const item = try r.readu();
458463
if (item >= self.funcs_internal.len + self.n_funcs_import) return error.InvalidFormat;
459464
in.funcref_table[offset + i] = item;

wasm_anon/src/wast_runner.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ const Tokenizer = struct {
558558
};
559559

560560
fn wat2wasm(source: []const u8, allocator: std.mem.Allocator) ![]u8 {
561-
const argv = &[_][]const u8{ "wat2wasm", "--enable-all", "-", "--output=-" };
561+
const argv = &[_][]const u8{ "wat2wasm", "--enable-extended-const", "--enable-gc", "-", "--output=-" };
562562

563563
const Child = std.process.Child;
564564
var child: Child = .init(argv, allocator);

0 commit comments

Comments
 (0)