aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
Diffstat (limited to 'src/link')
-rw-r--r--src/link/Wasm.zig15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 367f3376f0..12afc7164c 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -162,9 +162,8 @@ pub fn deinit(self: *Wasm) void {
decl.link.wasm.deinit(self.base.allocator);
}
- for (self.func_types.items) |func_type| {
- self.base.allocator.free(func_type.params);
- self.base.allocator.free(func_type.returns);
+ for (self.func_types.items) |*func_type| {
+ func_type.deinit(self.base.allocator);
}
for (self.segment_info.items) |segment_info| {
self.base.allocator.free(segment_info.name);
@@ -278,7 +277,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void {
defer codegen.deinit();
// generate the 'code' section for the function declaration
- const result = codegen.genDecl(decl.ty, decl.val) catch |err| switch (err) {
+ const result = codegen.genDecl() catch |err| switch (err) {
error.CodegenFail => {
decl.analysis = .codegen_failure;
try module.failed_decls.put(module.gpa, decl, codegen.err_msg);
@@ -298,6 +297,7 @@ fn finishUpdateDecl(self: *Wasm, decl: *Module.Decl, result: CodeGen.Result, cod
if (decl.isExtern()) {
try self.addOrUpdateImport(decl);
+ return;
}
if (code.len == 0) return;
@@ -574,7 +574,6 @@ fn resetState(self: *Wasm) void {
self.segments.clearRetainingCapacity();
self.segment_info.clearRetainingCapacity();
self.data_segments.clearRetainingCapacity();
- self.function_table.clearRetainingCapacity();
self.atoms.clearRetainingCapacity();
self.code_section_index = null;
}
@@ -684,12 +683,16 @@ pub fn flushModule(self: *Wasm, comp: *Compilation) !void {
);
}
+ // Table section
if (self.function_table.count() > 0) {
const header_offset = try reserveVecSectionHeader(file);
const writer = file.writer();
try leb.writeULEB128(writer, wasm.reftype(.funcref));
- try emitLimits(writer, .{ .min = 1, .max = null });
+ try emitLimits(writer, .{
+ .min = @intCast(u32, self.function_table.count()),
+ .max = null,
+ });
try writeVecSectionHeader(
file,