]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/string.go
runtime: implement experiment to replace heap bitmap with alloc headers
[gostls13.git] / src / runtime / string.go
index eaade640c411dd42a94a5becc027a394fc05173f..e01b7fc74448e5c41ed9c146f70e1d86e42cef26 100644 (file)
@@ -270,7 +270,7 @@ func rawstring(size int) (s string, b []byte) {
 
 // rawbyteslice allocates a new byte slice. The byte slice is not zeroed.
 func rawbyteslice(size int) (b []byte) {
-       cap := roundupsize(uintptr(size))
+       cap := roundupsize(uintptr(size), true)
        p := mallocgc(cap, nil, false)
        if cap != uintptr(size) {
                memclrNoHeapPointers(add(p, uintptr(size)), cap-uintptr(size))
@@ -285,7 +285,7 @@ func rawruneslice(size int) (b []rune) {
        if uintptr(size) > maxAlloc/4 {
                throw("out of memory")
        }
-       mem := roundupsize(uintptr(size) * 4)
+       mem := roundupsize(uintptr(size)*4, true)
        p := mallocgc(mem, nil, false)
        if mem != uintptr(size)*4 {
                memclrNoHeapPointers(add(p, uintptr(size)*4), mem-uintptr(size)*4)
@@ -325,6 +325,13 @@ func gostring(p *byte) string {
        return s
 }
 
+// internal_syscall_gostring is a version of gostring for internal/syscall/unix.
+//
+//go:linkname internal_syscall_gostring internal/syscall/unix.gostring
+func internal_syscall_gostring(p *byte) string {
+       return gostring(p)
+}
+
 func gostringn(p *byte, l int) string {
        if l == 0 {
                return ""
@@ -338,6 +345,10 @@ func hasPrefix(s, prefix string) bool {
        return len(s) >= len(prefix) && s[:len(prefix)] == prefix
 }
 
+func hasSuffix(s, suffix string) bool {
+       return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix
+}
+
 const (
        maxUint64 = ^uint64(0)
        maxInt64  = int64(maxUint64 >> 1)