runtime: add gc layout info for some basic types

This commit is contained in:
Damian Gryski
2024-10-03 12:03:32 -07:00
committed by Ayke
parent b8fe75a9dd
commit 6e6507bf77
6 changed files with 73 additions and 7 deletions
+5 -2
View File
@@ -1479,7 +1479,8 @@ func MakeSlice(typ Type, len, cap int) Value {
ulen := uint(len)
ucap := uint(cap)
maxSize := (^uintptr(0)) / 2
elementSize := rtype.elem().Size()
elem := rtype.elem()
elementSize := elem.Size()
if elementSize > 1 {
maxSize /= uintptr(elementSize)
}
@@ -1493,7 +1494,9 @@ func MakeSlice(typ Type, len, cap int) Value {
var slice sliceHeader
slice.cap = uintptr(ucap)
slice.len = uintptr(ulen)
slice.data = alloc(size, nil)
layout := elem.gcLayout()
slice.data = alloc(size, layout)
return Value{
typecode: rtype,