authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-19 11:56:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-19 11:56:01-07:00
log7c6981e0c0f2412c49457a900e5a6a4db96be2e8
tree94ff2a8ee79d8eebf5bad8209b6bd2cdee6e0a15
parent4e8fedffd12e1f995f38369421391f5a12035a99

stage2: fix ABI size of slice types to be 2 * ptr size

Previously it was returning 1 * ptr size.

1 files changed, 13 insertions(+), 11 deletions(-)

src/type.zig+13-11
...@@ -2094,8 +2094,7 @@ pub const Type = extern union {...@@ -2094,8 +2094,7 @@ pub const Type = extern union {
2094 .const_slice,2094 .const_slice,
2095 .mut_slice,2095 .mut_slice,
2096 => {2096 => {
2097 if (self.elemType().hasCodeGenBits()) return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2;2097 return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2;
2098 return @divExact(target.cpu.arch.ptrBitWidth(), 8);
2099 },2098 },
2100 .const_slice_u8,2099 .const_slice_u8,
2101 .const_slice_u8_sentinel_0,2100 .const_slice_u8_sentinel_0,
...@@ -2114,12 +2113,16 @@ pub const Type = extern union {...@@ -2114,12 +2113,16 @@ pub const Type = extern union {
2114 .many_mut_pointer,2113 .many_mut_pointer,
2115 .c_const_pointer,2114 .c_const_pointer,
2116 .c_mut_pointer,2115 .c_mut_pointer,
2117 .pointer,
2118 .manyptr_u8,2116 .manyptr_u8,
2119 .manyptr_const_u8,2117 .manyptr_const_u8,
2120 .manyptr_const_u8_sentinel_0,2118 .manyptr_const_u8_sentinel_0,
2121 => return @divExact(target.cpu.arch.ptrBitWidth(), 8),2119 => return @divExact(target.cpu.arch.ptrBitWidth(), 8),
21222120
2121 .pointer => switch (self.castTag(.pointer).?.data.size) {
2122 .Slice => @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2,
2123 else => @divExact(target.cpu.arch.ptrBitWidth(), 8),
2124 },
2125
2123 .c_short => return @divExact(CType.short.sizeInBits(target), 8),2126 .c_short => return @divExact(CType.short.sizeInBits(target), 8),
2124 .c_ushort => return @divExact(CType.ushort.sizeInBits(target), 8),2127 .c_ushort => return @divExact(CType.ushort.sizeInBits(target), 8),
2125 .c_int => return @divExact(CType.int.sizeInBits(target), 8),2128 .c_int => return @divExact(CType.int.sizeInBits(target), 8),
...@@ -2276,13 +2279,8 @@ pub const Type = extern union {...@@ -2276,13 +2279,8 @@ pub const Type = extern union {
22762279
2277 .const_slice,2280 .const_slice,
2278 .mut_slice,2281 .mut_slice,
2279 => {2282 => return target.cpu.arch.ptrBitWidth() * 2,
2280 if (ty.elemType().hasCodeGenBits()) {2283
2281 return target.cpu.arch.ptrBitWidth() * 2;
2282 } else {
2283 return target.cpu.arch.ptrBitWidth();
2284 }
2285 },
2286 .const_slice_u8,2284 .const_slice_u8,
2287 .const_slice_u8_sentinel_0,2285 .const_slice_u8_sentinel_0,
2288 => target.cpu.arch.ptrBitWidth() * 2,2286 => target.cpu.arch.ptrBitWidth() * 2,
...@@ -2303,7 +2301,6 @@ pub const Type = extern union {...@@ -2303,7 +2301,6 @@ pub const Type = extern union {
2303 .many_mut_pointer,2301 .many_mut_pointer,
2304 .c_const_pointer,2302 .c_const_pointer,
2305 .c_mut_pointer,2303 .c_mut_pointer,
2306 .pointer,
2307 => {2304 => {
2308 if (ty.elemType().hasCodeGenBits()) {2305 if (ty.elemType().hasCodeGenBits()) {
2309 return target.cpu.arch.ptrBitWidth();2306 return target.cpu.arch.ptrBitWidth();
...@@ -2312,6 +2309,11 @@ pub const Type = extern union {...@@ -2312,6 +2309,11 @@ pub const Type = extern union {
2312 }2309 }
2313 },2310 },
23142311
2312 .pointer => switch (ty.castTag(.pointer).?.data.size) {
2313 .Slice => target.cpu.arch.ptrBitWidth() * 2,
2314 else => target.cpu.arch.ptrBitWidth(),
2315 },
2316
2315 .manyptr_u8,2317 .manyptr_u8,
2316 .manyptr_const_u8,2318 .manyptr_const_u8,
2317 .manyptr_const_u8_sentinel_0,2319 .manyptr_const_u8_sentinel_0,