| ... | @@ -10,6 +10,8 @@ shards: []Shard = &.{}, | ... | @@ -10,6 +10,8 @@ shards: []Shard = &.{}, |
| 10 | global_error_set: GlobalErrorSet = GlobalErrorSet.empty, | 10 | global_error_set: GlobalErrorSet = GlobalErrorSet.empty, |
| 11 | /// Cached number of active bits in a `tid`. | 11 | /// Cached number of active bits in a `tid`. |
| 12 | tid_width: if (single_threaded) u0 else std.math.Log2Int(u32) = 0, | 12 | tid_width: if (single_threaded) u0 else std.math.Log2Int(u32) = 0, |
| | 13 | /// Cached shift amount to put a `tid` in the top bits of a 30-bit value. |
| | 14 | tid_shift_30: if (single_threaded) u0 else std.math.Log2Int(u32) = if (single_threaded) 0 else 31, |
| 13 | /// Cached shift amount to put a `tid` in the top bits of a 31-bit value. | 15 | /// Cached shift amount to put a `tid` in the top bits of a 31-bit value. |
| 14 | tid_shift_31: if (single_threaded) u0 else std.math.Log2Int(u32) = if (single_threaded) 0 else 31, | 16 | tid_shift_31: if (single_threaded) u0 else std.math.Log2Int(u32) = if (single_threaded) 0 else 31, |
| 15 | /// Cached shift amount to put a `tid` in the top bits of a 32-bit value. | 17 | /// Cached shift amount to put a `tid` in the top bits of a 32-bit value. |
| ... | @@ -4091,8 +4093,8 @@ pub const Index = enum(u32) { | ... | @@ -4091,8 +4093,8 @@ pub const Index = enum(u32) { |
| 4091 | | 4093 | |
| 4092 | fn wrap(unwrapped: Unwrapped, ip: *const InternPool) Index { | 4094 | fn wrap(unwrapped: Unwrapped, ip: *const InternPool) Index { |
| 4093 | assert(@intFromEnum(unwrapped.tid) <= ip.getTidMask()); | 4095 | assert(@intFromEnum(unwrapped.tid) <= ip.getTidMask()); |
| 4094 | assert(unwrapped.index <= ip.getIndexMask(u31)); | 4096 | assert(unwrapped.index <= ip.getIndexMask(u30)); |
| 4095 | return @enumFromInt(@as(u32, @intFromEnum(unwrapped.tid)) << ip.tid_shift_31 | unwrapped.index); | 4097 | return @enumFromInt(@as(u32, @intFromEnum(unwrapped.tid)) << ip.tid_shift_30 | unwrapped.index); |
| 4096 | } | 4098 | } |
| 4097 | | 4099 | |
| 4098 | pub fn getExtra(unwrapped: Unwrapped, ip: *const InternPool) Local.Extra { | 4100 | pub fn getExtra(unwrapped: Unwrapped, ip: *const InternPool) Local.Extra { |
| ... | @@ -4131,8 +4133,8 @@ pub const Index = enum(u32) { | ... | @@ -4131,8 +4133,8 @@ pub const Index = enum(u32) { |
| 4131 | .tid = .main, | 4133 | .tid = .main, |
| 4132 | .index = @intFromEnum(index), | 4134 | .index = @intFromEnum(index), |
| 4133 | } else .{ | 4135 | } else .{ |
| 4134 | .tid = @enumFromInt(@intFromEnum(index) >> ip.tid_shift_31 & ip.getTidMask()), | 4136 | .tid = @enumFromInt(@intFromEnum(index) >> ip.tid_shift_30 & ip.getTidMask()), |
| 4135 | .index = @intFromEnum(index) & ip.getIndexMask(u31), | 4137 | .index = @intFromEnum(index) & ip.getIndexMask(u30), |
| 4136 | }; | 4138 | }; |
| 4137 | } | 4139 | } |
| 4138 | | 4140 | |
| ... | @@ -5822,6 +5824,7 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void { | ... | @@ -5822,6 +5824,7 @@ pub fn init(ip: *InternPool, gpa: Allocator, available_threads: usize) !void { |
| 5822 | }); | 5824 | }); |
| 5823 | | 5825 | |
| 5824 | ip.tid_width = @intCast(std.math.log2_int_ceil(usize, used_threads)); | 5826 | ip.tid_width = @intCast(std.math.log2_int_ceil(usize, used_threads)); |
| | 5827 | ip.tid_shift_30 = if (single_threaded) 0 else 30 - ip.tid_width; |
| 5825 | ip.tid_shift_31 = if (single_threaded) 0 else 31 - ip.tid_width; | 5828 | ip.tid_shift_31 = if (single_threaded) 0 else 31 - ip.tid_width; |
| 5826 | ip.tid_shift_32 = if (single_threaded) 0 else ip.tid_shift_31 +| 1; | 5829 | ip.tid_shift_32 = if (single_threaded) 0 else ip.tid_shift_31 +| 1; |
| 5827 | ip.shards = try gpa.alloc(Shard, @as(usize, 1) << ip.tid_width); | 5830 | ip.shards = try gpa.alloc(Shard, @as(usize, 1) << ip.tid_width); |