diff options
| author | Luuk de Gram <luuk@degram.dev> | 2022-03-06 22:38:10 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-03-06 23:33:50 +0100 |
| commit | c7e4c711fc5795e66f974316611922a0b962eb99 (patch) | |
| tree | 71ea7a30dc840d640b55d632294603c0bc920df1 /src | |
| parent | 27c084065abcc404b7f58562f802999ae3ebce10 (diff) | |
| download | zig-c7e4c711fc5795e66f974316611922a0b962eb99.tar.gz zig-c7e4c711fc5795e66f974316611922a0b962eb99.zip | |
wasm: Fix incremental compilation
- atoms may have relocations, so freeing them when we update the parent
atom will cause segfaults.
- Not all declarations will live in symbol_atom
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Wasm.zig | 6 | ||||
| -rw-r--r-- | src/link/Wasm/Atom.zig | 7 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index ca9d06e0ec..1288b27a81 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -504,7 +504,7 @@ pub fn updateFunc(self: *Wasm, module: *Module, func: *Module.Fn, air: Air, live const decl = func.owner_decl; assert(decl.link.wasm.sym_index != 0); // Must call allocateDeclIndexes() - decl.link.wasm.clear(self.base.allocator); + decl.link.wasm.clear(); var code_writer = std.ArrayList(u8).init(self.base.allocator); defer code_writer.deinit(); @@ -542,7 +542,7 @@ pub fn updateDecl(self: *Wasm, module: *Module, decl: *Module.Decl) !void { assert(decl.link.wasm.sym_index != 0); // Must call allocateDeclIndexes() - decl.link.wasm.clear(self.base.allocator); + decl.link.wasm.clear(); if (decl.isExtern()) { return self.addOrUpdateImport(decl); @@ -827,7 +827,7 @@ pub fn freeDecl(self: *Wasm, decl: *Module.Decl) void { assert(self.imports.remove(atom.symbolLoc())); } assert(self.resolved_symbols.swapRemove(atom.symbolLoc())); - assert(self.symbol_atom.remove(atom.symbolLoc())); + _ = self.symbol_atom.remove(atom.symbolLoc()); // not all decl's exist in symbol_atom atom.deinit(self.base.allocator); } diff --git a/src/link/Wasm/Atom.zig b/src/link/Wasm/Atom.zig index e89ed37123..a3e1c25190 100644 --- a/src/link/Wasm/Atom.zig +++ b/src/link/Wasm/Atom.zig @@ -62,14 +62,9 @@ pub fn deinit(self: *Atom, gpa: Allocator) void { /// Sets the length of relocations and code to '0', /// effectively resetting them and allowing them to be re-populated. -pub fn clear(self: *Atom, gpa: Allocator) void { +pub fn clear(self: *Atom) void { self.relocs.clearRetainingCapacity(); self.code.clearRetainingCapacity(); - - // locals will be re-generated - for (self.locals.items) |*local| { - local.deinit(gpa); - } } pub fn format(self: Atom, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { |
