| author | |
| committer | |
| log | 6b56f4ff0bf9ac9c5e0b4a11cf0536472447bc4a |
| tree | 033edcdf8ec8f2570d874f15040d4fc9258df71e |
| parent | d69e324eae6d245a4b0c75c0a8ce91275dfcc938 |
2 files changed, 27 insertions(+), 27 deletions(-)
src/InternPool.zig+24| ... | ... | @@ -5706,6 +5706,30 @@ pub fn isRuntimeValue(ip: *const InternPool, val: Index) bool { |
| 5706 | 5706 | return ip.items.items(.tag)[@intFromEnum(val)] == .runtime_value; |
| 5707 | 5707 | } |
| 5708 | 5708 | |
| 5709 | pub fn getBackingDecl(ip: *const InternPool, val: Index) Module.Decl.OptionalIndex { | |
| 5710 | var base = @intFromEnum(val); | |
| 5711 | while (true) { | |
| 5712 | switch (ip.items.items(.tag)[base]) { | |
| 5713 | inline .ptr_decl, | |
| 5714 | .ptr_mut_decl, | |
| 5715 | => |tag| return @enumFromInt(Module.Decl.OptionalIndex, ip.extra.items[ | |
| 5716 | ip.items.items(.data)[base] + std.meta.fieldIndex(tag.Payload(), "decl").? | |
| 5717 | ]), | |
| 5718 | inline .ptr_eu_payload, | |
| 5719 | .ptr_opt_payload, | |
| 5720 | .ptr_elem, | |
| 5721 | .ptr_field, | |
| 5722 | => |tag| base = ip.extra.items[ | |
| 5723 | ip.items.items(.data)[base] + std.meta.fieldIndex(tag.Payload(), "base").? | |
| 5724 | ], | |
| 5725 | inline .ptr_slice => |tag| base = ip.extra.items[ | |
| 5726 | ip.items.items(.data)[base] + std.meta.fieldIndex(tag.Payload(), "ptr").? | |
| 5727 | ], | |
| 5728 | else => return .none, | |
| 5729 | } | |
| 5730 | } | |
| 5731 | } | |
| 5732 | ||
| 5709 | 5733 | /// This is a particularly hot function, so we operate directly on encodings |
| 5710 | 5734 | /// rather than the more straightforward implementation of calling `indexToKey`. |
| 5711 | 5735 | pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPoison}!std.builtin.TypeId { |
src/value.zig+3-27| ... | ... | @@ -1851,33 +1851,9 @@ pub const Value = struct { |
| 1851 | 1851 | } |
| 1852 | 1852 | |
| 1853 | 1853 | pub fn isPtrToThreadLocal(val: Value, mod: *Module) bool { |
| 1854 | return val.ip_index != .none and switch (mod.intern_pool.indexToKey(val.toIntern())) { | |
| 1855 | .variable => false, | |
| 1856 | else => val.isPtrToThreadLocalInner(mod), | |
| 1857 | }; | |
| 1858 | } | |
| 1859 | ||
| 1860 | pub fn isPtrToThreadLocalInner(val: Value, mod: *Module) bool { | |
| 1861 | return val.ip_index != .none and switch (mod.intern_pool.indexToKey(val.toIntern())) { | |
| 1862 | .variable => |variable| variable.is_threadlocal, | |
| 1863 | .ptr => |ptr| switch (ptr.addr) { | |
| 1864 | .decl => |decl_index| { | |
| 1865 | const decl = mod.declPtr(decl_index); | |
| 1866 | assert(decl.has_tv); | |
| 1867 | return decl.val.isPtrToThreadLocalInner(mod); | |
| 1868 | }, | |
| 1869 | .mut_decl => |mut_decl| { | |
| 1870 | const decl = mod.declPtr(mut_decl.decl); | |
| 1871 | assert(decl.has_tv); | |
| 1872 | return decl.val.isPtrToThreadLocalInner(mod); | |
| 1873 | }, | |
| 1874 | .int => false, | |
| 1875 | .eu_payload, .opt_payload => |base_ptr| base_ptr.toValue().isPtrToThreadLocalInner(mod), | |
| 1876 | .comptime_field => |comptime_field| comptime_field.toValue().isPtrToThreadLocalInner(mod), | |
| 1877 | .elem, .field => |base_index| base_index.base.toValue().isPtrToThreadLocalInner(mod), | |
| 1878 | }, | |
| 1879 | else => false, | |
| 1880 | }; | |
| 1854 | const backing_decl = mod.intern_pool.getBackingDecl(val.toIntern()).unwrap() orelse return false; | |
| 1855 | const variable = mod.declPtr(backing_decl).getOwnedVariable(mod) orelse return false; | |
| 1856 | return variable.is_threadlocal; | |
| 1881 | 1857 | } |
| 1882 | 1858 | |
| 1883 | 1859 | // Asserts that the provided start/end are in-bounds. |