| ... | ... | @@ -702,24 +702,15 @@ pub const Block = struct { |
| 702 | 702 | pub fn startAnonDecl(block: *Block) !WipAnonDecl { |
| 703 | 703 | return WipAnonDecl{ |
| 704 | 704 | .block = block, |
| 705 | | .new_decl_arena = std.heap.ArenaAllocator.init(block.sema.gpa), |
| 706 | 705 | .finished = false, |
| 707 | 706 | }; |
| 708 | 707 | } |
| 709 | 708 | |
| 710 | 709 | pub const WipAnonDecl = struct { |
| 711 | 710 | block: *Block, |
| 712 | | new_decl_arena: std.heap.ArenaAllocator, |
| 713 | 711 | finished: bool, |
| 714 | 712 | |
| 715 | | pub fn arena(wad: *WipAnonDecl) Allocator { |
| 716 | | return wad.new_decl_arena.allocator(); |
| 717 | | } |
| 718 | | |
| 719 | 713 | pub fn deinit(wad: *WipAnonDecl) void { |
| 720 | | if (!wad.finished) { |
| 721 | | wad.new_decl_arena.deinit(); |
| 722 | | } |
| 723 | 714 | wad.* = undefined; |
| 724 | 715 | } |
| 725 | 716 | |
| ... | ... | @@ -2774,9 +2765,6 @@ fn zirStructDecl( |
| 2774 | 2765 | break :blk LazySrcLoc.nodeOffset(node_offset); |
| 2775 | 2766 | } else sema.src; |
| 2776 | 2767 | |
| 2777 | | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 2778 | | errdefer new_decl_arena.deinit(); |
| 2779 | | |
| 2780 | 2768 | // Because these three things each reference each other, `undefined` |
| 2781 | 2769 | // placeholders are used before being set after the struct type gains an |
| 2782 | 2770 | // InternPool index. |
| ... | ... | @@ -3230,9 +3218,6 @@ fn zirUnionDecl( |
| 3230 | 3218 | break :blk decls_len; |
| 3231 | 3219 | } else 0; |
| 3232 | 3220 | |
| 3233 | | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 3234 | | errdefer new_decl_arena.deinit(); |
| 3235 | | |
| 3236 | 3221 | // Because these three things each reference each other, `undefined` |
| 3237 | 3222 | // placeholders are used before being set after the union type gains an |
| 3238 | 3223 | // InternPool index. |
| ... | ... | @@ -3297,7 +3282,6 @@ fn zirOpaqueDecl( |
| 3297 | 3282 | defer tracy.end(); |
| 3298 | 3283 | |
| 3299 | 3284 | const mod = sema.mod; |
| 3300 | | const gpa = sema.gpa; |
| 3301 | 3285 | const small = @bitCast(Zir.Inst.OpaqueDecl.Small, extended.small); |
| 3302 | 3286 | var extra_index: usize = extended.operand; |
| 3303 | 3287 | |
| ... | ... | @@ -3313,9 +3297,6 @@ fn zirOpaqueDecl( |
| 3313 | 3297 | break :blk decls_len; |
| 3314 | 3298 | } else 0; |
| 3315 | 3299 | |
| 3316 | | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 3317 | | errdefer new_decl_arena.deinit(); |
| 3318 | | |
| 3319 | 3300 | // Because these three things each reference each other, `undefined` |
| 3320 | 3301 | // placeholders are used in two places before being set after the opaque |
| 3321 | 3302 | // type gains an InternPool index. |
| ... | ... | @@ -3691,7 +3672,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3691 | 3672 | defer anon_decl.deinit(); |
| 3692 | 3673 | return sema.analyzeDeclRef(try anon_decl.finish( |
| 3693 | 3674 | elem_ty, |
| 3694 | | try store_val.copy(anon_decl.arena()), |
| 3675 | store_val, |
| 3695 | 3676 | ptr_info.@"align", |
| 3696 | 3677 | )); |
| 3697 | 3678 | } |
| ... | ... | @@ -3937,7 +3918,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3937 | 3918 | defer anon_decl.deinit(); |
| 3938 | 3919 | const new_decl_index = try anon_decl.finish( |
| 3939 | 3920 | final_elem_ty, |
| 3940 | | try store_val.copy(anon_decl.arena()), |
| 3921 | store_val, |
| 3941 | 3922 | ia1.alignment.toByteUnits(0), |
| 3942 | 3923 | ); |
| 3943 | 3924 | break :d new_decl_index; |
| ... | ... | @@ -5168,7 +5149,7 @@ fn storeToInferredAllocComptime( |
| 5168 | 5149 | defer anon_decl.deinit(); |
| 5169 | 5150 | iac.decl_index = try anon_decl.finish( |
| 5170 | 5151 | operand_ty, |
| 5171 | | try operand_val.copy(anon_decl.arena()), |
| 5152 | operand_val, |
| 5172 | 5153 | iac.alignment.toByteUnits(0), |
| 5173 | 5154 | ); |
| 5174 | 5155 | return; |
| ... | ... | @@ -5860,7 +5841,7 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 5860 | 5841 | defer anon_decl.deinit(); |
| 5861 | 5842 | break :blk try anon_decl.finish( |
| 5862 | 5843 | operand.ty, |
| 5863 | | try operand.val.copy(anon_decl.arena()), |
| 5844 | operand.val, |
| 5864 | 5845 | 0, |
| 5865 | 5846 | ); |
| 5866 | 5847 | }; |
| ... | ... | @@ -15895,7 +15876,7 @@ fn zirBuiltinSrc( |
| 15895 | 15876 | var anon_decl = try block.startAnonDecl(); |
| 15896 | 15877 | defer anon_decl.deinit(); |
| 15897 | 15878 | // The compiler must not call realpath anywhere. |
| 15898 | | const name = try fn_owner_decl.getFileScope(mod).fullPathZ(anon_decl.arena()); |
| 15879 | const name = try fn_owner_decl.getFileScope(mod).fullPathZ(sema.arena); |
| 15899 | 15880 | const new_decl_ty = try mod.arrayType(.{ |
| 15900 | 15881 | .len = name.len, |
| 15901 | 15882 | .child = .u8_type, |
| ... | ... | @@ -18792,7 +18773,7 @@ fn addConstantMaybeRef( |
| 18792 | 18773 | defer anon_decl.deinit(); |
| 18793 | 18774 | const decl = try anon_decl.finish( |
| 18794 | 18775 | ty, |
| 18795 | | try val.copy(anon_decl.arena()), |
| 18776 | val, |
| 18796 | 18777 | 0, // default alignment |
| 18797 | 18778 | ); |
| 18798 | 18779 | return sema.analyzeDeclRef(decl); |
| ... | ... | @@ -19515,9 +19496,6 @@ fn zirReify( |
| 19515 | 19496 | return sema.fail(block, src, "reified opaque must have no decls", .{}); |
| 19516 | 19497 | } |
| 19517 | 19498 | |
| 19518 | | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 19519 | | errdefer new_decl_arena.deinit(); |
| 19520 | | |
| 19521 | 19499 | // Because these three things each reference each other, |
| 19522 | 19500 | // `undefined` placeholders are used in two places before being set |
| 19523 | 19501 | // after the opaque type gains an InternPool index. |
| ... | ... | @@ -19572,10 +19550,6 @@ fn zirReify( |
| 19572 | 19550 | } |
| 19573 | 19551 | const layout = mod.toEnum(std.builtin.Type.ContainerLayout, layout_val); |
| 19574 | 19552 | |
| 19575 | | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 19576 | | errdefer new_decl_arena.deinit(); |
| 19577 | | const new_decl_arena_allocator = new_decl_arena.allocator(); |
| 19578 | | |
| 19579 | 19553 | // Because these three things each reference each other, `undefined` |
| 19580 | 19554 | // placeholders are used before being set after the union type gains an |
| 19581 | 19555 | // InternPool index. |
| ... | ... | @@ -19645,7 +19619,7 @@ fn zirReify( |
| 19645 | 19619 | } |
| 19646 | 19620 | |
| 19647 | 19621 | // Fields |
| 19648 | | try union_obj.fields.ensureTotalCapacity(new_decl_arena_allocator, fields_len); |
| 19622 | try union_obj.fields.ensureTotalCapacity(mod.tmp_hack_arena.allocator(), fields_len); |
| 19649 | 19623 | |
| 19650 | 19624 | for (0..fields_len) |i| { |
| 19651 | 19625 | const elem_val = try fields_val.elemValue(mod, i); |
| ... | ... | @@ -19873,10 +19847,6 @@ fn reifyStruct( |
| 19873 | 19847 | const gpa = sema.gpa; |
| 19874 | 19848 | const ip = &mod.intern_pool; |
| 19875 | 19849 | |
| 19876 | | var new_decl_arena = std.heap.ArenaAllocator.init(gpa); |
| 19877 | | errdefer new_decl_arena.deinit(); |
| 19878 | | const new_decl_arena_allocator = new_decl_arena.allocator(); |
| 19879 | | |
| 19880 | 19850 | // Because these three things each reference each other, `undefined` |
| 19881 | 19851 | // placeholders are used before being set after the struct type gains an |
| 19882 | 19852 | // InternPool index. |
| ... | ... | @@ -19921,7 +19891,7 @@ fn reifyStruct( |
| 19921 | 19891 | |
| 19922 | 19892 | // Fields |
| 19923 | 19893 | const fields_len = try sema.usizeCast(block, src, fields_val.sliceLen(mod)); |
| 19924 | | try struct_obj.fields.ensureTotalCapacity(new_decl_arena_allocator, fields_len); |
| 19894 | try struct_obj.fields.ensureTotalCapacity(mod.tmp_hack_arena.allocator(), fields_len); |
| 19925 | 19895 | var i: usize = 0; |
| 19926 | 19896 | while (i < fields_len) : (i += 1) { |
| 19927 | 19897 | const elem_val = try fields_val.elemValue(mod, i); |
| ... | ... | @@ -20209,7 +20179,7 @@ fn zirTypeName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 20209 | 20179 | var anon_decl = try block.startAnonDecl(); |
| 20210 | 20180 | defer anon_decl.deinit(); |
| 20211 | 20181 | |
| 20212 | | const bytes = try ty.nameAllocArena(anon_decl.arena(), mod); |
| 20182 | const bytes = try ty.nameAllocArena(sema.arena, mod); |
| 20213 | 20183 | |
| 20214 | 20184 | const decl_ty = try mod.arrayType(.{ |
| 20215 | 20185 | .len = bytes.len, |
| ... | ... | @@ -29740,7 +29710,7 @@ fn refValue(sema: *Sema, block: *Block, ty: Type, val: Value) !Value { |
| 29740 | 29710 | defer anon_decl.deinit(); |
| 29741 | 29711 | const decl = try anon_decl.finish( |
| 29742 | 29712 | ty, |
| 29743 | | try val.copy(anon_decl.arena()), |
| 29713 | val, |
| 29744 | 29714 | 0, // default alignment |
| 29745 | 29715 | ); |
| 29746 | 29716 | try sema.maybeQueueFuncBodyAnalysis(decl); |
| ... | ... | @@ -29824,7 +29794,7 @@ fn analyzeRef( |
| 29824 | 29794 | defer anon_decl.deinit(); |
| 29825 | 29795 | return sema.analyzeDeclRef(try anon_decl.finish( |
| 29826 | 29796 | operand_ty, |
| 29827 | | try val.copy(anon_decl.arena()), |
| 29797 | val, |
| 29828 | 29798 | 0, // default alignment |
| 29829 | 29799 | )); |
| 29830 | 29800 | } |