aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-01-19 11:56:01 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-01-19 11:56:01 -0700
commit7c6981e0c0f2412c49457a900e5a6a4db96be2e8 (patch)
tree94ff2a8ee79d8eebf5bad8209b6bd2cdee6e0a15 /src/type.zig
parent4e8fedffd12e1f995f38369421391f5a12035a99 (diff)
downloadzig-7c6981e0c0f2412c49457a900e5a6a4db96be2e8.tar.gz
zig-7c6981e0c0f2412c49457a900e5a6a4db96be2e8.zip
stage2: fix ABI size of slice types to be 2 * ptr size
Previously it was returning 1 * ptr size.
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/type.zig b/src/type.zig
index e14c81f707..f62c94c469 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2094,8 +2094,7 @@ pub const Type = extern union {
.const_slice,
.mut_slice,
=> {
- if (self.elemType().hasCodeGenBits()) return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2;
- return @divExact(target.cpu.arch.ptrBitWidth(), 8);
+ return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2;
},
.const_slice_u8,
.const_slice_u8_sentinel_0,
@@ -2114,12 +2113,16 @@ pub const Type = extern union {
.many_mut_pointer,
.c_const_pointer,
.c_mut_pointer,
- .pointer,
.manyptr_u8,
.manyptr_const_u8,
.manyptr_const_u8_sentinel_0,
=> return @divExact(target.cpu.arch.ptrBitWidth(), 8),
+ .pointer => switch (self.castTag(.pointer).?.data.size) {
+ .Slice => @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2,
+ else => @divExact(target.cpu.arch.ptrBitWidth(), 8),
+ },
+
.c_short => return @divExact(CType.short.sizeInBits(target), 8),
.c_ushort => return @divExact(CType.ushort.sizeInBits(target), 8),
.c_int => return @divExact(CType.int.sizeInBits(target), 8),
@@ -2276,13 +2279,8 @@ pub const Type = extern union {
.const_slice,
.mut_slice,
- => {
- if (ty.elemType().hasCodeGenBits()) {
- return target.cpu.arch.ptrBitWidth() * 2;
- } else {
- return target.cpu.arch.ptrBitWidth();
- }
- },
+ => return target.cpu.arch.ptrBitWidth() * 2,
+
.const_slice_u8,
.const_slice_u8_sentinel_0,
=> target.cpu.arch.ptrBitWidth() * 2,
@@ -2303,7 +2301,6 @@ pub const Type = extern union {
.many_mut_pointer,
.c_const_pointer,
.c_mut_pointer,
- .pointer,
=> {
if (ty.elemType().hasCodeGenBits()) {
return target.cpu.arch.ptrBitWidth();
@@ -2312,6 +2309,11 @@ pub const Type = extern union {
}
},
+ .pointer => switch (ty.castTag(.pointer).?.data.size) {
+ .Slice => target.cpu.arch.ptrBitWidth() * 2,
+ else => target.cpu.arch.ptrBitWidth(),
+ },
+
.manyptr_u8,
.manyptr_const_u8,
.manyptr_const_u8_sentinel_0,