@@ -2169,90 +2169,92 @@ pub fn init(zcu: *Zcu, thread_count: usize) !void {
2169
2169
}
2170
2170
2171
2171
pub fn deinit (zcu : * Zcu ) void {
2172
- const pt : Zcu.PerThread = .{ .tid = .main , .zcu = zcu };
2173
2172
const gpa = zcu .gpa ;
2173
+ {
2174
+ const pt : Zcu.PerThread = .activate (zcu , .main );
2175
+ defer pt .deactivate ();
2174
2176
2175
- if (zcu .llvm_object ) | llvm_object | llvm_object .deinit ();
2176
-
2177
- for (zcu .import_table .keys ()) | key | {
2178
- gpa .free (key );
2179
- }
2180
- for (zcu .import_table .values ()) | file_index | {
2181
- pt .destroyFile (file_index );
2182
- }
2183
- zcu .import_table .deinit (gpa );
2177
+ if (zcu .llvm_object ) | llvm_object | llvm_object .deinit ();
2184
2178
2185
- for (zcu .embed_table .keys (), zcu .embed_table .values ()) | path , embed_file | {
2186
- gpa .free (path );
2187
- gpa .destroy (embed_file );
2188
- }
2189
- zcu .embed_table .deinit (gpa );
2179
+ for (zcu .import_table .keys ()) | key | {
2180
+ gpa .free (key );
2181
+ }
2182
+ for (zcu .import_table .values ()) | file_index | {
2183
+ pt .destroyFile (file_index );
2184
+ }
2185
+ zcu .import_table .deinit (gpa );
2190
2186
2191
- zcu .compile_log_text .deinit (gpa );
2187
+ for (zcu .embed_table .keys (), zcu .embed_table .values ()) | path , embed_file | {
2188
+ gpa .free (path );
2189
+ gpa .destroy (embed_file );
2190
+ }
2191
+ zcu .embed_table .deinit (gpa );
2192
2192
2193
- zcu .local_zir_cache .handle .close ();
2194
- zcu .global_zir_cache .handle .close ();
2193
+ zcu .compile_log_text .deinit (gpa );
2195
2194
2196
- for (zcu .failed_analysis .values ()) | value | {
2197
- value .destroy (gpa );
2198
- }
2199
- for (zcu .failed_codegen .values ()) | value | {
2200
- value .destroy (gpa );
2201
- }
2202
- zcu .analysis_in_progress .deinit (gpa );
2203
- zcu .failed_analysis .deinit (gpa );
2204
- zcu .transitive_failed_analysis .deinit (gpa );
2205
- zcu .failed_codegen .deinit (gpa );
2195
+ zcu .local_zir_cache .handle .close ();
2196
+ zcu .global_zir_cache .handle .close ();
2206
2197
2207
- for (zcu .failed_files .values ()) | value | {
2208
- if (value ) | msg | msg .destroy (gpa );
2209
- }
2210
- zcu .failed_files .deinit (gpa );
2198
+ for (zcu .failed_analysis .values ()) | value | {
2199
+ value .destroy (gpa );
2200
+ }
2201
+ for (zcu .failed_codegen .values ()) | value | {
2202
+ value .destroy (gpa );
2203
+ }
2204
+ zcu .analysis_in_progress .deinit (gpa );
2205
+ zcu .failed_analysis .deinit (gpa );
2206
+ zcu .transitive_failed_analysis .deinit (gpa );
2207
+ zcu .failed_codegen .deinit (gpa );
2211
2208
2212
- for (zcu .failed_embed_files .values ()) | msg | {
2213
- msg .destroy (gpa );
2214
- }
2215
- zcu .failed_embed_files .deinit (gpa );
2209
+ for (zcu .failed_files .values ()) | value | {
2210
+ if ( value ) | msg | msg .destroy (gpa );
2211
+ }
2212
+ zcu .failed_files .deinit (gpa );
2216
2213
2217
- for (zcu .failed_exports .values ()) | value | {
2218
- value .destroy (gpa );
2219
- }
2220
- zcu .failed_exports .deinit (gpa );
2214
+ for (zcu .failed_embed_files .values ()) | msg | {
2215
+ msg .destroy (gpa );
2216
+ }
2217
+ zcu .failed_embed_files .deinit (gpa );
2221
2218
2222
- for (zcu .cimport_errors .values ()) | * errs | {
2223
- errs . deinit (gpa );
2224
- }
2225
- zcu .cimport_errors .deinit (gpa );
2219
+ for (zcu .failed_exports .values ()) | value | {
2220
+ value . destroy (gpa );
2221
+ }
2222
+ zcu .failed_exports .deinit (gpa );
2226
2223
2227
- zcu .compile_log_sources .deinit (gpa );
2224
+ for (zcu .cimport_errors .values ()) | * errs | {
2225
+ errs .deinit (gpa );
2226
+ }
2227
+ zcu .cimport_errors .deinit (gpa );
2228
2228
2229
- zcu .all_exports .deinit (gpa );
2230
- zcu .free_exports .deinit (gpa );
2231
- zcu .single_exports .deinit (gpa );
2232
- zcu .multi_exports .deinit (gpa );
2229
+ zcu .compile_log_sources .deinit (gpa );
2233
2230
2234
- zcu .potentially_outdated .deinit (gpa );
2235
- zcu .outdated .deinit (gpa );
2236
- zcu .outdated_ready .deinit (gpa );
2237
- zcu .retryable_failures .deinit (gpa );
2231
+ zcu .all_exports .deinit (gpa );
2232
+ zcu .free_exports .deinit (gpa );
2233
+ zcu .single_exports .deinit (gpa );
2234
+ zcu .multi_exports .deinit (gpa );
2238
2235
2239
- zcu .test_functions .deinit (gpa );
2236
+ zcu .potentially_outdated .deinit (gpa );
2237
+ zcu .outdated .deinit (gpa );
2238
+ zcu .outdated_ready .deinit (gpa );
2239
+ zcu .retryable_failures .deinit (gpa );
2240
2240
2241
- for (zcu .global_assembly .values ()) | s | {
2242
- gpa .free (s );
2243
- }
2244
- zcu .global_assembly .deinit (gpa );
2241
+ zcu .test_functions .deinit (gpa );
2245
2242
2246
- zcu .reference_table .deinit (gpa );
2247
- zcu .all_references .deinit (gpa );
2248
- zcu .free_references .deinit (gpa );
2243
+ for (zcu .global_assembly .values ()) | s | {
2244
+ gpa .free (s );
2245
+ }
2246
+ zcu .global_assembly .deinit (gpa );
2249
2247
2250
- zcu .type_reference_table .deinit (gpa );
2251
- zcu .all_type_references .deinit (gpa );
2252
- zcu .free_type_references .deinit (gpa );
2248
+ zcu .reference_table .deinit (gpa );
2249
+ zcu .all_references .deinit (gpa );
2250
+ zcu .free_references .deinit (gpa );
2253
2251
2254
- if (zcu .resolved_references ) | * r | r .deinit (gpa );
2252
+ zcu .type_reference_table .deinit (gpa );
2253
+ zcu .all_type_references .deinit (gpa );
2254
+ zcu .free_type_references .deinit (gpa );
2255
2255
2256
+ if (zcu .resolved_references ) | * r | r .deinit (gpa );
2257
+ }
2256
2258
zcu .intern_pool .deinit (gpa );
2257
2259
}
2258
2260
0 commit comments