github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/bench/growslice/stubs.go (about) 1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import "unsafe" 8 9 // base address for all 0-byte allocations 10 var zerobase uintptr 11 12 type errorString string 13 14 func (e errorString) RuntimeError() {} 15 16 func (e errorString) Error() string { 17 return "runtime error: " + string(e) 18 } 19 20 type slice struct { 21 array unsafe.Pointer 22 len int 23 cap int 24 } 25 26 type Type struct { 27 Size_ uintptr 28 PtrBytes uintptr // number of (prefix) bytes in the type that can contain pointers 29 Hash uint32 // hash of type; avoids computation in hash tables 30 TFlag uint8 // extra type information flags 31 Align_ uint8 // alignment of variable with this type 32 FieldAlign_ uint8 // alignment of struct field with this type 33 Kind_ uint8 // enumeration for C 34 // function for comparing objects of this type 35 // (ptr to object A, ptr to object B) -> ==? 36 Equal func(unsafe.Pointer, unsafe.Pointer) bool 37 // GCData stores the GC type data for the garbage collector. 38 // If the KindGCProg bit is set in kind, GCData is a GC program. 39 // Otherwise it is a ptrmask bitmap. See mbitmap.go for details. 40 GCData *byte 41 Str int32 // string form 42 PtrToThis int32 // type for pointer to this type, may be zero 43 } 44 45 type _type = Type 46 47 //go:noinline 48 func memmove(p, oldptr unsafe.Pointer, lenmem uintptr) {} 49 50 //go:nosplit 51 //go:noinline 52 func bulkBarrierPreWriteSrcOnly(dst, src, size uintptr) {} 53 54 //go:noinline 55 func memclrNoHeapPointersChunked(size uintptr, x unsafe.Pointer) {} 56 57 //go:noinline 58 func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer { return nil } 59 60 var writeBarrier struct { 61 enabled bool // compiler emits a check of this before calling write barrier 62 pad [3]byte // compiler uses 32-bit load for "enabled" field 63 needed bool // identical to enabled, for now (TODO: dedup) 64 alignme uint64 // guarantee alignment so that compiler can use a 32 or 64-bit load 65 } 66 67 //go:noinline 68 func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) {} 69 70 //go:noinline 71 func add(p unsafe.Pointer, newlenmem uintptr) unsafe.Pointer { 72 return nil 73 } 74 75 // this is actually a compiler intrinsic 76 func abi_FuncPCABIInternal(f interface{}) uintptr { return 0 } 77 78 //go:noinline 79 func getcallerpc() uintptr { return 0 } 80 81 //go:noinline 82 func racereadrangepc(addr unsafe.Pointer, sz, callerpc, pc uintptr) {} 83 84 //go:noinline 85 func msanread(addr unsafe.Pointer, sz uintptr) {} 86 87 //go:noinline 88 func asanread(addr unsafe.Pointer, sz uintptr) {}