compiler, runtime: add layout parameter to runtime.alloc

This layout parameter is currently always nil and ignored, but will
eventually contain a pointer to a memory layout.

This commit also adds module verification to the transform tests, as I
found out that it didn't (and therefore didn't initially catch all
bugs).
This commit is contained in:
Ayke van Laethem
2021-07-09 14:01:37 +02:00
committed by Ron Evans
parent c454568688
commit f24a93c51d
38 changed files with 99 additions and 89 deletions
+4 -4
View File
@@ -57,7 +57,7 @@ func stringConcat(x, y _string) _string {
return x
} else {
length := x.length + y.length
buf := alloc(length)
buf := alloc(length, nil)
memcpy(buf, unsafe.Pointer(x.ptr), x.length)
memcpy(unsafe.Pointer(uintptr(buf)+x.length), unsafe.Pointer(y.ptr), y.length)
return _string{ptr: (*byte)(buf), length: length}
@@ -70,7 +70,7 @@ func stringFromBytes(x struct {
len uintptr
cap uintptr
}) _string {
buf := alloc(x.len)
buf := alloc(x.len, nil)
memcpy(buf, unsafe.Pointer(x.ptr), x.len)
return _string{ptr: (*byte)(buf), length: x.len}
}
@@ -81,7 +81,7 @@ func stringToBytes(x _string) (slice struct {
len uintptr
cap uintptr
}) {
buf := alloc(x.length)
buf := alloc(x.length, nil)
memcpy(buf, unsafe.Pointer(x.ptr), x.length)
slice.ptr = (*byte)(buf)
slice.len = x.length
@@ -98,7 +98,7 @@ func stringFromRunes(runeSlice []rune) (s _string) {
}
// Allocate memory for the string.
s.ptr = (*byte)(alloc(s.length))
s.ptr = (*byte)(alloc(s.length, nil))
// Encode runes to UTF-8 and store the resulting bytes in the string.
index := uintptr(0)