mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 13:58:27 +00:00
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
This commit is contained in:
parent
27c084065a
commit
c7e4c711fc
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user