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 {
20942094 .const_slice,
20952095 .mut_slice,
20962096 => {
2097 if (self.elemType().hasCodeGenBits()) return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2;
2098 return @divExact(target.cpu.arch.ptrBitWidth(), 8);
2097 return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2;
20992098 },
21002099 .const_slice_u8,
21012100 .const_slice_u8_sentinel_0,
......@@ -2114,12 +2113,16 @@ pub const Type = extern union {
21142113 .many_mut_pointer,
21152114 .c_const_pointer,
21162115 .c_mut_pointer,
2117 .pointer,
21182116 .manyptr_u8,
21192117 .manyptr_const_u8,
21202118 .manyptr_const_u8_sentinel_0,
21212119 => 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
21232126 .c_short => return @divExact(CType.short.sizeInBits(target), 8),
21242127 .c_ushort => return @divExact(CType.ushort.sizeInBits(target), 8),
21252128 .c_int => return @divExact(CType.int.sizeInBits(target), 8),
......@@ -2276,13 +2279,8 @@ pub const Type = extern union {
22762279
22772280 .const_slice,
22782281 .mut_slice,
2279 => {
2280 if (ty.elemType().hasCodeGenBits()) {
2281 return target.cpu.arch.ptrBitWidth() * 2;
2282 } else {
2283 return target.cpu.arch.ptrBitWidth();
2284 }
2285 },
2282 => return target.cpu.arch.ptrBitWidth() * 2,
2283
22862284 .const_slice_u8,
22872285 .const_slice_u8_sentinel_0,
22882286 => target.cpu.arch.ptrBitWidth() * 2,
......@@ -2303,7 +2301,6 @@ pub const Type = extern union {
23032301 .many_mut_pointer,
23042302 .c_const_pointer,
23052303 .c_mut_pointer,
2306 .pointer,
23072304 => {
23082305 if (ty.elemType().hasCodeGenBits()) {
23092306 return target.cpu.arch.ptrBitWidth();
......@@ -2312,6 +2309,11 @@ pub const Type = extern union {
23122309 }
23132310 },
23142311
2312 .pointer => switch (ty.castTag(.pointer).?.data.size) {
2313 .Slice => target.cpu.arch.ptrBitWidth() * 2,
2314 else => target.cpu.arch.ptrBitWidth(),
2315 },
2316
23152317 .manyptr_u8,
23162318 .manyptr_const_u8,
23172319 .manyptr_const_u8_sentinel_0,