Module: move memoized data to the intern pool

This avoids memory management bugs with the previous implementation.
This commit is contained in:
Jacob Young
2023-05-28 02:41:22 -04:00
committed by Andrew Kelley
parent d40b83de45
commit 3b6ca1d35b
11 changed files with 264 additions and 140 deletions

View File

@@ -1090,6 +1090,7 @@ pub const DeclGen = struct {
};
switch (mod.intern_pool.indexToKey(val.ip_index)) {
// types, not values
.int_type,
.ptr_type,
.array_type,
@@ -1106,7 +1107,10 @@ pub const DeclGen = struct {
.func_type,
.error_set_type,
.inferred_error_set_type,
=> unreachable, // types, not values
// memoization, not values
.memoized_decl,
.memoized_call,
=> unreachable,
.undef, .runtime_value => unreachable, // handled above
.simple_value => |simple_value| switch (simple_value) {

View File

@@ -3793,6 +3793,9 @@ pub const DeclGen = struct {
return llvm_union_ty.constNamedStruct(&fields, fields_len);
}
},
.memoized_decl,
.memoized_call,
=> unreachable,
}
}

View File

@@ -830,6 +830,9 @@ pub const DeclGen = struct {
try self.addUndef(layout.padding);
},
.memoized_decl,
.memoized_call,
=> unreachable,
}
}
};