mirror of
https://github.com/golang/go
synced 2024-11-13 19:20:31 -07:00
runtime: eliminate unnecessary type conversions
Automated refactoring produced using github.com/mdempsky/unconvert. Change-Id: Iacf871a4f221ef17f48999a464ab2858b2bbaa90 Reviewed-on: https://go-review.googlesource.com/20071 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
1ec4f227f4
commit
a03bdc3e6b
@ -264,7 +264,7 @@ func cgocallbackg1() {
|
|||||||
// For cgo, cb.arg points into a C stack frame and therefore doesn't
|
// For cgo, cb.arg points into a C stack frame and therefore doesn't
|
||||||
// hold any pointers that the GC can find anyway - the write barrier
|
// hold any pointers that the GC can find anyway - the write barrier
|
||||||
// would be a no-op.
|
// would be a no-op.
|
||||||
reflectcall(nil, unsafe.Pointer(cb.fn), unsafe.Pointer(cb.arg), uint32(cb.argsize), 0)
|
reflectcall(nil, unsafe.Pointer(cb.fn), cb.arg, uint32(cb.argsize), 0)
|
||||||
|
|
||||||
if raceenabled {
|
if raceenabled {
|
||||||
racereleasemerge(unsafe.Pointer(&racecgosync))
|
racereleasemerge(unsafe.Pointer(&racecgosync))
|
||||||
|
@ -56,7 +56,7 @@ func makechan(t *chantype, size int64) *hchan {
|
|||||||
if hchanSize%maxAlign != 0 || elem.align > maxAlign {
|
if hchanSize%maxAlign != 0 || elem.align > maxAlign {
|
||||||
throw("makechan: bad alignment")
|
throw("makechan: bad alignment")
|
||||||
}
|
}
|
||||||
if size < 0 || int64(uintptr(size)) != size || (elem.size > 0 && uintptr(size) > (_MaxMem-hchanSize)/uintptr(elem.size)) {
|
if size < 0 || int64(uintptr(size)) != size || (elem.size > 0 && uintptr(size) > (_MaxMem-hchanSize)/elem.size) {
|
||||||
panic("makechan: size out of range")
|
panic("makechan: size out of range")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ func makechan(t *chantype, size int64) *hchan {
|
|||||||
// buf points into the same allocation, elemtype is persistent.
|
// buf points into the same allocation, elemtype is persistent.
|
||||||
// SudoG's are referenced from their owning thread so they can't be collected.
|
// SudoG's are referenced from their owning thread so they can't be collected.
|
||||||
// TODO(dvyukov,rlh): Rethink when collector can move allocated objects.
|
// TODO(dvyukov,rlh): Rethink when collector can move allocated objects.
|
||||||
c = (*hchan)(mallocgc(hchanSize+uintptr(size)*uintptr(elem.size), nil, flagNoScan))
|
c = (*hchan)(mallocgc(hchanSize+uintptr(size)*elem.size, nil, flagNoScan))
|
||||||
if size > 0 && elem.size != 0 {
|
if size > 0 && elem.size != 0 {
|
||||||
c.buf = add(unsafe.Pointer(c), hchanSize)
|
c.buf = add(unsafe.Pointer(c), hchanSize)
|
||||||
} else {
|
} else {
|
||||||
@ -227,7 +227,7 @@ func chansend(t *chantype, c *hchan, ep unsafe.Pointer, block bool, callerpc uin
|
|||||||
}
|
}
|
||||||
gp.param = nil
|
gp.param = nil
|
||||||
if mysg.releasetime > 0 {
|
if mysg.releasetime > 0 {
|
||||||
blockevent(int64(mysg.releasetime)-t0, 2)
|
blockevent(mysg.releasetime-t0, 2)
|
||||||
}
|
}
|
||||||
releaseSudog(mysg)
|
releaseSudog(mysg)
|
||||||
return true
|
return true
|
||||||
|
@ -32,7 +32,7 @@ func syscall_setenv_c(k string, v string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
arg := [2]unsafe.Pointer{cstring(k), cstring(v)}
|
arg := [2]unsafe.Pointer{cstring(k), cstring(v)}
|
||||||
asmcgocall(unsafe.Pointer(_cgo_setenv), unsafe.Pointer(&arg))
|
asmcgocall(_cgo_setenv, unsafe.Pointer(&arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the C environment if cgo is loaded.
|
// Update the C environment if cgo is loaded.
|
||||||
@ -43,7 +43,7 @@ func syscall_unsetenv_c(k string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
arg := [1]unsafe.Pointer{cstring(k)}
|
arg := [1]unsafe.Pointer{cstring(k)}
|
||||||
asmcgocall(unsafe.Pointer(_cgo_unsetenv), unsafe.Pointer(&arg))
|
asmcgocall(_cgo_unsetenv, unsafe.Pointer(&arg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func cstring(s string) unsafe.Pointer {
|
func cstring(s string) unsafe.Pointer {
|
||||||
|
@ -188,7 +188,7 @@ func (h *hmap) createOverflow() {
|
|||||||
// If h != nil, the map can be created directly in h.
|
// If h != nil, the map can be created directly in h.
|
||||||
// If bucket != nil, bucket can be used as the first bucket.
|
// If bucket != nil, bucket can be used as the first bucket.
|
||||||
func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
|
func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
|
||||||
if sz := unsafe.Sizeof(hmap{}); sz > 48 || sz != uintptr(t.hmap.size) {
|
if sz := unsafe.Sizeof(hmap{}); sz > 48 || sz != t.hmap.size {
|
||||||
println("runtime: sizeof(hmap) =", sz, ", t.hmap.size =", t.hmap.size)
|
println("runtime: sizeof(hmap) =", sz, ", t.hmap.size =", t.hmap.size)
|
||||||
throw("bad hmap size")
|
throw("bad hmap size")
|
||||||
}
|
}
|
||||||
@ -220,10 +220,10 @@ func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
|
|||||||
if t.elem.align > bucketCnt {
|
if t.elem.align > bucketCnt {
|
||||||
throw("value align too big")
|
throw("value align too big")
|
||||||
}
|
}
|
||||||
if uintptr(t.key.size)%uintptr(t.key.align) != 0 {
|
if t.key.size%uintptr(t.key.align) != 0 {
|
||||||
throw("key size not a multiple of key align")
|
throw("key size not a multiple of key align")
|
||||||
}
|
}
|
||||||
if uintptr(t.elem.size)%uintptr(t.elem.align) != 0 {
|
if t.elem.size%uintptr(t.elem.align) != 0 {
|
||||||
throw("value size not a multiple of value align")
|
throw("value size not a multiple of value align")
|
||||||
}
|
}
|
||||||
if bucketCnt < 8 {
|
if bucketCnt < 8 {
|
||||||
|
@ -234,7 +234,7 @@ type childInfo struct {
|
|||||||
// dump kinds & offsets of interesting fields in bv
|
// dump kinds & offsets of interesting fields in bv
|
||||||
func dumpbv(cbv *bitvector, offset uintptr) {
|
func dumpbv(cbv *bitvector, offset uintptr) {
|
||||||
bv := gobv(*cbv)
|
bv := gobv(*cbv)
|
||||||
for i := uintptr(0); i < uintptr(bv.n); i++ {
|
for i := uintptr(0); i < bv.n; i++ {
|
||||||
if bv.bytedata[i/8]>>(i%8)&1 == 1 {
|
if bv.bytedata[i/8]>>(i%8)&1 == 1 {
|
||||||
dumpint(fieldKindPtr)
|
dumpint(fieldKindPtr)
|
||||||
dumpint(uint64(offset + i*sys.PtrSize))
|
dumpint(uint64(offset + i*sys.PtrSize))
|
||||||
|
@ -203,7 +203,7 @@ func assertI2T2(t *_type, i iface, r unsafe.Pointer) bool {
|
|||||||
tab := i.tab
|
tab := i.tab
|
||||||
if tab == nil || tab._type != t {
|
if tab == nil || tab._type != t {
|
||||||
if r != nil {
|
if r != nil {
|
||||||
memclr(r, uintptr(t.size))
|
memclr(r, t.size)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -241,7 +241,7 @@ func assertE2T2(t *_type, e eface, r unsafe.Pointer) bool {
|
|||||||
GC()
|
GC()
|
||||||
}
|
}
|
||||||
if e._type != t {
|
if e._type != t {
|
||||||
memclr(r, uintptr(t.size))
|
memclr(r, t.size)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if isDirectIface(t) {
|
if isDirectIface(t) {
|
||||||
|
@ -408,7 +408,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
|
|||||||
// Keep everything page-aligned.
|
// Keep everything page-aligned.
|
||||||
// Our pages are bigger than hardware pages.
|
// Our pages are bigger than hardware pages.
|
||||||
h.arena_end = p + p_size
|
h.arena_end = p + p_size
|
||||||
used := p + (-uintptr(p) & (_PageSize - 1))
|
used := p + (-p & (_PageSize - 1))
|
||||||
h.mapBits(used)
|
h.mapBits(used)
|
||||||
h.mapSpans(used)
|
h.mapSpans(used)
|
||||||
h.arena_used = used
|
h.arena_used = used
|
||||||
@ -434,7 +434,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
|
|||||||
racemapshadow(unsafe.Pointer(p), n)
|
racemapshadow(unsafe.Pointer(p), n)
|
||||||
}
|
}
|
||||||
|
|
||||||
if uintptr(p)&(_PageSize-1) != 0 {
|
if p&(_PageSize-1) != 0 {
|
||||||
throw("misrounded allocation in MHeap_SysAlloc")
|
throw("misrounded allocation in MHeap_SysAlloc")
|
||||||
}
|
}
|
||||||
return unsafe.Pointer(p)
|
return unsafe.Pointer(p)
|
||||||
@ -454,7 +454,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if p < h.arena_start || uintptr(p)+p_size-h.arena_start >= _MaxArena32 {
|
if p < h.arena_start || p+p_size-h.arena_start >= _MaxArena32 {
|
||||||
top := ^uintptr(0)
|
top := ^uintptr(0)
|
||||||
if top-h.arena_start > _MaxArena32 {
|
if top-h.arena_start > _MaxArena32 {
|
||||||
top = h.arena_start + _MaxArena32
|
top = h.arena_start + _MaxArena32
|
||||||
@ -466,7 +466,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
|
|||||||
|
|
||||||
p_end := p + p_size
|
p_end := p + p_size
|
||||||
p += -p & (_PageSize - 1)
|
p += -p & (_PageSize - 1)
|
||||||
if uintptr(p)+n > h.arena_used {
|
if p+n > h.arena_used {
|
||||||
h.mapBits(p + n)
|
h.mapBits(p + n)
|
||||||
h.mapSpans(p + n)
|
h.mapSpans(p + n)
|
||||||
h.arena_used = p + n
|
h.arena_used = p + n
|
||||||
@ -478,7 +478,7 @@ func (h *mheap) sysAlloc(n uintptr) unsafe.Pointer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if uintptr(p)&(_PageSize-1) != 0 {
|
if p&(_PageSize-1) != 0 {
|
||||||
throw("misrounded allocation in MHeap_SysAlloc")
|
throw("misrounded allocation in MHeap_SysAlloc")
|
||||||
}
|
}
|
||||||
return unsafe.Pointer(p)
|
return unsafe.Pointer(p)
|
||||||
@ -661,10 +661,10 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer {
|
|||||||
var s *mspan
|
var s *mspan
|
||||||
shouldhelpgc = true
|
shouldhelpgc = true
|
||||||
systemstack(func() {
|
systemstack(func() {
|
||||||
s = largeAlloc(size, uint32(flags))
|
s = largeAlloc(size, flags)
|
||||||
})
|
})
|
||||||
x = unsafe.Pointer(uintptr(s.start << pageShift))
|
x = unsafe.Pointer(uintptr(s.start << pageShift))
|
||||||
size = uintptr(s.elemsize)
|
size = s.elemsize
|
||||||
}
|
}
|
||||||
|
|
||||||
if flags&flagNoScan != 0 {
|
if flags&flagNoScan != 0 {
|
||||||
@ -778,7 +778,7 @@ func newobject(typ *_type) unsafe.Pointer {
|
|||||||
if typ.kind&kindNoPointers != 0 {
|
if typ.kind&kindNoPointers != 0 {
|
||||||
flags |= flagNoScan
|
flags |= flagNoScan
|
||||||
}
|
}
|
||||||
return mallocgc(uintptr(typ.size), typ, flags)
|
return mallocgc(typ.size, typ, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname reflect_unsafe_New reflect.unsafe_New
|
//go:linkname reflect_unsafe_New reflect.unsafe_New
|
||||||
@ -792,10 +792,10 @@ func newarray(typ *_type, n uintptr) unsafe.Pointer {
|
|||||||
if typ.kind&kindNoPointers != 0 {
|
if typ.kind&kindNoPointers != 0 {
|
||||||
flags |= flagNoScan
|
flags |= flagNoScan
|
||||||
}
|
}
|
||||||
if int(n) < 0 || (typ.size > 0 && n > _MaxMem/uintptr(typ.size)) {
|
if int(n) < 0 || (typ.size > 0 && n > _MaxMem/typ.size) {
|
||||||
panic("runtime: allocation size out of range")
|
panic("runtime: allocation size out of range")
|
||||||
}
|
}
|
||||||
return mallocgc(uintptr(typ.size)*n, typ, flags)
|
return mallocgc(typ.size*n, typ, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname reflect_unsafe_NewArray reflect.unsafe_NewArray
|
//go:linkname reflect_unsafe_NewArray reflect.unsafe_NewArray
|
||||||
@ -847,7 +847,7 @@ func nextSample() int32 {
|
|||||||
// x = -log_e(q) * period
|
// x = -log_e(q) * period
|
||||||
// x = log_2(q) * (-log_e(2)) * period ; Using log_2 for efficiency
|
// x = log_2(q) * (-log_e(2)) * period ; Using log_2 for efficiency
|
||||||
const randomBitCount = 26
|
const randomBitCount = 26
|
||||||
q := uint32(fastrand1())%(1<<randomBitCount) + 1
|
q := fastrand1()%(1<<randomBitCount) + 1
|
||||||
qlog := fastlog2(float64(q)) - randomBitCount
|
qlog := fastlog2(float64(q)) - randomBitCount
|
||||||
if qlog > 0 {
|
if qlog > 0 {
|
||||||
qlog = 0
|
qlog = 0
|
||||||
|
@ -247,8 +247,8 @@ func typedslicecopy(typ *_type, dst, src slice) int {
|
|||||||
if n == 0 {
|
if n == 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
dstp := unsafe.Pointer(dst.array)
|
dstp := dst.array
|
||||||
srcp := unsafe.Pointer(src.array)
|
srcp := src.array
|
||||||
|
|
||||||
if raceenabled {
|
if raceenabled {
|
||||||
callerpc := getcallerpc(unsafe.Pointer(&typ))
|
callerpc := getcallerpc(unsafe.Pointer(&typ))
|
||||||
@ -304,7 +304,7 @@ func typedslicecopy(typ *_type, dst, src slice) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return int(n)
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname reflect_typedslicecopy reflect.typedslicecopy
|
//go:linkname reflect_typedslicecopy reflect.typedslicecopy
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
// which prevents us from allocating more stack.
|
// which prevents us from allocating more stack.
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {
|
func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {
|
||||||
v := unsafe.Pointer(mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0))
|
v := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
|
||||||
if uintptr(v) < 4096 {
|
if uintptr(v) < 4096 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ func sysReserve(v unsafe.Pointer, n uintptr, reserved *bool) unsafe.Pointer {
|
|||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
p := unsafe.Pointer(mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0))
|
p := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
|
||||||
if uintptr(p) < 4096 {
|
if uintptr(p) < 4096 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import "unsafe"
|
|||||||
// which prevents us from allocating more stack.
|
// which prevents us from allocating more stack.
|
||||||
//go:nosplit
|
//go:nosplit
|
||||||
func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {
|
func sysAlloc(n uintptr, sysStat *uint64) unsafe.Pointer {
|
||||||
v := unsafe.Pointer(mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0))
|
v := mmap(nil, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
|
||||||
if uintptr(v) < 4096 {
|
if uintptr(v) < 4096 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ func sysFault(v unsafe.Pointer, n uintptr) {
|
|||||||
|
|
||||||
func sysReserve(v unsafe.Pointer, n uintptr, reserved *bool) unsafe.Pointer {
|
func sysReserve(v unsafe.Pointer, n uintptr, reserved *bool) unsafe.Pointer {
|
||||||
*reserved = true
|
*reserved = true
|
||||||
p := unsafe.Pointer(mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0))
|
p := mmap(v, n, _PROT_NONE, _MAP_ANON|_MAP_PRIVATE, -1, 0)
|
||||||
if uintptr(p) < 4096 {
|
if uintptr(p) < 4096 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ const (
|
|||||||
|
|
||||||
func sysMap(v unsafe.Pointer, n uintptr, reserved bool, sysStat *uint64) {
|
func sysMap(v unsafe.Pointer, n uintptr, reserved bool, sysStat *uint64) {
|
||||||
mSysStatInc(sysStat, n)
|
mSysStatInc(sysStat, n)
|
||||||
p := unsafe.Pointer(mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0))
|
p := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, -1, 0)
|
||||||
if uintptr(p) == _ENOMEM {
|
if uintptr(p) == _ENOMEM {
|
||||||
throw("runtime: out of memory")
|
throw("runtime: out of memory")
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ func runfinq() {
|
|||||||
for i := fb.cnt; i > 0; i-- {
|
for i := fb.cnt; i > 0; i-- {
|
||||||
f := &fb.fin[i-1]
|
f := &fb.fin[i-1]
|
||||||
|
|
||||||
framesz := unsafe.Sizeof((interface{})(nil)) + uintptr(f.nret)
|
framesz := unsafe.Sizeof((interface{})(nil)) + f.nret
|
||||||
if framecap < framesz {
|
if framecap < framesz {
|
||||||
// The frame does not contain pointers interesting for GC,
|
// The frame does not contain pointers interesting for GC,
|
||||||
// all not yet finalized objects are stored in finq.
|
// all not yet finalized objects are stored in finq.
|
||||||
@ -360,7 +360,7 @@ okarg:
|
|||||||
// compute size needed for return parameters
|
// compute size needed for return parameters
|
||||||
nret := uintptr(0)
|
nret := uintptr(0)
|
||||||
for _, t := range ft.out {
|
for _, t := range ft.out {
|
||||||
nret = round(nret, uintptr(t.align)) + uintptr(t.size)
|
nret = round(nret, uintptr(t.align)) + t.size
|
||||||
}
|
}
|
||||||
nret = round(nret, sys.PtrSize)
|
nret = round(nret, sys.PtrSize)
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ func findObject(v unsafe.Pointer) (s *mspan, x unsafe.Pointer, n uintptr) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n = uintptr(s.elemsize)
|
n = s.elemsize
|
||||||
if s.sizeclass != 0 {
|
if s.sizeclass != 0 {
|
||||||
x = add(x, (uintptr(v)-uintptr(x))/n*n)
|
x = add(x, (uintptr(v)-uintptr(x))/n*n)
|
||||||
}
|
}
|
||||||
|
@ -1114,7 +1114,7 @@ func gcDumpObject(label string, obj, off uintptr) {
|
|||||||
print(" ...\n")
|
print(" ...\n")
|
||||||
skipped = false
|
skipped = false
|
||||||
}
|
}
|
||||||
print(" *(", label, "+", i, ") = ", hex(*(*uintptr)(unsafe.Pointer(obj + uintptr(i)))))
|
print(" *(", label, "+", i, ") = ", hex(*(*uintptr)(unsafe.Pointer(obj + i))))
|
||||||
if i == off {
|
if i == off {
|
||||||
print(" <==")
|
print(" <==")
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ func recordspan(vh unsafe.Pointer, p unsafe.Pointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
h_allspans = new
|
h_allspans = new
|
||||||
h.allspans = (**mspan)(unsafe.Pointer(sp.array))
|
h.allspans = (**mspan)(sp.array)
|
||||||
}
|
}
|
||||||
h_allspans = append(h_allspans, s)
|
h_allspans = append(h_allspans, s)
|
||||||
h.nspan = uint32(len(h_allspans))
|
h.nspan = uint32(len(h_allspans))
|
||||||
@ -275,7 +275,7 @@ func mlookup(v uintptr, base *uintptr, size *uintptr, sp **mspan) int32 {
|
|||||||
|
|
||||||
n := s.elemsize
|
n := s.elemsize
|
||||||
if base != nil {
|
if base != nil {
|
||||||
i := (uintptr(v) - uintptr(p)) / n
|
i := (v - p) / n
|
||||||
*base = p + i*n
|
*base = p + i*n
|
||||||
}
|
}
|
||||||
if size != nil {
|
if size != nil {
|
||||||
|
@ -448,7 +448,7 @@ func iterate_memprof(fn func(*bucket, uintptr, *uintptr, uintptr, uintptr, uintp
|
|||||||
lock(&proflock)
|
lock(&proflock)
|
||||||
for b := mbuckets; b != nil; b = b.allnext {
|
for b := mbuckets; b != nil; b = b.allnext {
|
||||||
mp := b.mp()
|
mp := b.mp()
|
||||||
fn(b, uintptr(b.nstk), &b.stk()[0], b.size, mp.allocs, mp.frees)
|
fn(b, b.nstk, &b.stk()[0], b.size, mp.allocs, mp.frees)
|
||||||
}
|
}
|
||||||
unlock(&proflock)
|
unlock(&proflock)
|
||||||
}
|
}
|
||||||
@ -478,8 +478,8 @@ func BlockProfile(p []BlockProfileRecord) (n int, ok bool) {
|
|||||||
for b := bbuckets; b != nil; b = b.allnext {
|
for b := bbuckets; b != nil; b = b.allnext {
|
||||||
bp := b.bp()
|
bp := b.bp()
|
||||||
r := &p[0]
|
r := &p[0]
|
||||||
r.Count = int64(bp.count)
|
r.Count = bp.count
|
||||||
r.Cycles = int64(bp.cycles)
|
r.Cycles = bp.cycles
|
||||||
i := copy(r.Stack0[:], b.stk())
|
i := copy(r.Stack0[:], b.stk())
|
||||||
for ; i < len(r.Stack0); i++ {
|
for ; i < len(r.Stack0); i++ {
|
||||||
r.Stack0[i] = 0
|
r.Stack0[i] = 0
|
||||||
|
@ -309,13 +309,13 @@ func updatememstats(stats *gcstats) {
|
|||||||
memstats.nfree += mheap_.nsmallfree[i]
|
memstats.nfree += mheap_.nsmallfree[i]
|
||||||
memstats.by_size[i].nfree = mheap_.nsmallfree[i]
|
memstats.by_size[i].nfree = mheap_.nsmallfree[i]
|
||||||
memstats.by_size[i].nmalloc += mheap_.nsmallfree[i]
|
memstats.by_size[i].nmalloc += mheap_.nsmallfree[i]
|
||||||
smallfree += uint64(mheap_.nsmallfree[i]) * uint64(class_to_size[i])
|
smallfree += mheap_.nsmallfree[i] * uint64(class_to_size[i])
|
||||||
}
|
}
|
||||||
memstats.nfree += memstats.tinyallocs
|
memstats.nfree += memstats.tinyallocs
|
||||||
memstats.nmalloc += memstats.nfree
|
memstats.nmalloc += memstats.nfree
|
||||||
|
|
||||||
// Calculate derived stats.
|
// Calculate derived stats.
|
||||||
memstats.total_alloc = uint64(memstats.alloc) + uint64(mheap_.largefree) + smallfree
|
memstats.total_alloc = memstats.alloc + mheap_.largefree + smallfree
|
||||||
memstats.heap_alloc = memstats.alloc
|
memstats.heap_alloc = memstats.alloc
|
||||||
memstats.heap_objects = memstats.nmalloc - memstats.nfree
|
memstats.heap_objects = memstats.nmalloc - memstats.nfree
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ func net_runtime_pollClose(pd *pollDesc) {
|
|||||||
if pd.rg != 0 && pd.rg != pdReady {
|
if pd.rg != 0 && pd.rg != pdReady {
|
||||||
throw("netpollClose: blocked read on closing descriptor")
|
throw("netpollClose: blocked read on closing descriptor")
|
||||||
}
|
}
|
||||||
netpollclose(uintptr(pd.fd))
|
netpollclose(pd.fd)
|
||||||
pollcache.free(pd)
|
pollcache.free(pd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ type overlappedEntry struct {
|
|||||||
var iocphandle uintptr = _INVALID_HANDLE_VALUE // completion port io handle
|
var iocphandle uintptr = _INVALID_HANDLE_VALUE // completion port io handle
|
||||||
|
|
||||||
func netpollinit() {
|
func netpollinit() {
|
||||||
iocphandle = uintptr(stdcall4(_CreateIoCompletionPort, _INVALID_HANDLE_VALUE, 0, 0, _DWORD_MAX))
|
iocphandle = stdcall4(_CreateIoCompletionPort, _INVALID_HANDLE_VALUE, 0, 0, _DWORD_MAX)
|
||||||
if iocphandle == 0 {
|
if iocphandle == 0 {
|
||||||
println("netpoll: failed to create iocp handle (errno=", getlasterror(), ")")
|
println("netpoll: failed to create iocp handle (errno=", getlasterror(), ")")
|
||||||
throw("netpoll: failed to create iocp handle")
|
throw("netpoll: failed to create iocp handle")
|
||||||
|
@ -55,8 +55,8 @@ func sighandler(_ureg *ureg, note *byte, gp *g) int {
|
|||||||
gp.sig = uint32(sig)
|
gp.sig = uint32(sig)
|
||||||
gp.sigpc = c.pc()
|
gp.sigpc = c.pc()
|
||||||
|
|
||||||
pc := uintptr(c.pc())
|
pc := c.pc()
|
||||||
sp := uintptr(c.sp())
|
sp := c.sp()
|
||||||
|
|
||||||
// If we don't recognize the PC as code
|
// If we don't recognize the PC as code
|
||||||
// but we do recognize the top pointer on the stack as code,
|
// but we do recognize the top pointer on the stack as code,
|
||||||
|
@ -209,7 +209,7 @@ func printstring(s string) {
|
|||||||
func printslice(s []byte) {
|
func printslice(s []byte) {
|
||||||
sp := (*slice)(unsafe.Pointer(&s))
|
sp := (*slice)(unsafe.Pointer(&s))
|
||||||
print("[", len(s), "/", cap(s), "]")
|
print("[", len(s), "/", cap(s), "]")
|
||||||
printpointer(unsafe.Pointer(sp.array))
|
printpointer(sp.array)
|
||||||
}
|
}
|
||||||
|
|
||||||
func printeface(e eface) {
|
func printeface(e eface) {
|
||||||
|
@ -242,7 +242,7 @@ func check() {
|
|||||||
|
|
||||||
k = unsafe.Pointer(uintptr(0xfedcb123))
|
k = unsafe.Pointer(uintptr(0xfedcb123))
|
||||||
if sys.PtrSize == 8 {
|
if sys.PtrSize == 8 {
|
||||||
k = unsafe.Pointer(uintptr(unsafe.Pointer(k)) << 10)
|
k = unsafe.Pointer(uintptr(k) << 10)
|
||||||
}
|
}
|
||||||
if casp(&k, nil, nil) {
|
if casp(&k, nil, nil) {
|
||||||
throw("casp1")
|
throw("casp1")
|
||||||
|
@ -107,7 +107,7 @@ func semacquire(addr *uint32, profile bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.releasetime > 0 {
|
if s.releasetime > 0 {
|
||||||
blockevent(int64(s.releasetime)-t0, 3)
|
blockevent(s.releasetime-t0, 3)
|
||||||
}
|
}
|
||||||
releaseSudog(s)
|
releaseSudog(s)
|
||||||
}
|
}
|
||||||
@ -240,7 +240,7 @@ func syncsemacquire(s *syncSema) {
|
|||||||
s.tail = w
|
s.tail = w
|
||||||
goparkunlock(&s.lock, "semacquire", traceEvGoBlockCond, 3)
|
goparkunlock(&s.lock, "semacquire", traceEvGoBlockCond, 3)
|
||||||
if t0 != 0 {
|
if t0 != 0 {
|
||||||
blockevent(int64(w.releasetime)-t0, 2)
|
blockevent(w.releasetime-t0, 2)
|
||||||
}
|
}
|
||||||
releaseSudog(w)
|
releaseSudog(w)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||||||
c.set_sp(sp)
|
c.set_sp(sp)
|
||||||
*(*uint32)(unsafe.Pointer(uintptr(sp))) = c.lr()
|
*(*uint32)(unsafe.Pointer(uintptr(sp))) = c.lr()
|
||||||
|
|
||||||
pc := uintptr(gp.sigpc)
|
pc := gp.sigpc
|
||||||
|
|
||||||
// If we don't recognize the PC as code
|
// If we don't recognize the PC as code
|
||||||
// but we do recognize the link register as code,
|
// but we do recognize the link register as code,
|
||||||
|
@ -86,7 +86,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||||||
c.set_sp(sp)
|
c.set_sp(sp)
|
||||||
*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.lr()
|
*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.lr()
|
||||||
|
|
||||||
pc := uintptr(gp.sigpc)
|
pc := gp.sigpc
|
||||||
|
|
||||||
// If we don't recognize the PC as code
|
// If we don't recognize the PC as code
|
||||||
// but we do recognize the link register as code,
|
// but we do recognize the link register as code,
|
||||||
|
@ -32,11 +32,11 @@ func (c *sigctxt) r14() uint64 { return c.regs().mc_r14 }
|
|||||||
func (c *sigctxt) r15() uint64 { return c.regs().mc_r15 }
|
func (c *sigctxt) r15() uint64 { return c.regs().mc_r15 }
|
||||||
func (c *sigctxt) rip() uint64 { return c.regs().mc_rip }
|
func (c *sigctxt) rip() uint64 { return c.regs().mc_rip }
|
||||||
func (c *sigctxt) rflags() uint64 { return c.regs().mc_rflags }
|
func (c *sigctxt) rflags() uint64 { return c.regs().mc_rflags }
|
||||||
func (c *sigctxt) cs() uint64 { return uint64(c.regs().mc_cs) }
|
func (c *sigctxt) cs() uint64 { return c.regs().mc_cs }
|
||||||
func (c *sigctxt) fs() uint64 { return uint64(c.regs().mc_ss) }
|
func (c *sigctxt) fs() uint64 { return c.regs().mc_ss }
|
||||||
func (c *sigctxt) gs() uint64 { return uint64(c.regs().mc_ss) }
|
func (c *sigctxt) gs() uint64 { return c.regs().mc_ss }
|
||||||
func (c *sigctxt) sigcode() uint64 { return uint64(c.info.si_code) }
|
func (c *sigctxt) sigcode() uint64 { return uint64(c.info.si_code) }
|
||||||
func (c *sigctxt) sigaddr() uint64 { return uint64(c.info.si_addr) }
|
func (c *sigctxt) sigaddr() uint64 { return c.info.si_addr }
|
||||||
|
|
||||||
func (c *sigctxt) set_rip(x uint64) { c.regs().mc_rip = x }
|
func (c *sigctxt) set_rip(x uint64) { c.regs().mc_rip = x }
|
||||||
func (c *sigctxt) set_rsp(x uint64) { c.regs().mc_rsp = x }
|
func (c *sigctxt) set_rsp(x uint64) { c.regs().mc_rsp = x }
|
||||||
|
@ -22,9 +22,9 @@ func (c *sigctxt) ebp() uint32 { return c.regs().mc_ebp }
|
|||||||
func (c *sigctxt) esp() uint32 { return c.regs().mc_esp }
|
func (c *sigctxt) esp() uint32 { return c.regs().mc_esp }
|
||||||
func (c *sigctxt) eip() uint32 { return c.regs().mc_eip }
|
func (c *sigctxt) eip() uint32 { return c.regs().mc_eip }
|
||||||
func (c *sigctxt) eflags() uint32 { return c.regs().mc_eflags }
|
func (c *sigctxt) eflags() uint32 { return c.regs().mc_eflags }
|
||||||
func (c *sigctxt) cs() uint32 { return uint32(c.regs().mc_cs) }
|
func (c *sigctxt) cs() uint32 { return c.regs().mc_cs }
|
||||||
func (c *sigctxt) fs() uint32 { return uint32(c.regs().mc_fs) }
|
func (c *sigctxt) fs() uint32 { return c.regs().mc_fs }
|
||||||
func (c *sigctxt) gs() uint32 { return uint32(c.regs().mc_gs) }
|
func (c *sigctxt) gs() uint32 { return c.regs().mc_gs }
|
||||||
func (c *sigctxt) sigcode() uint32 { return uint32(c.info.si_code) }
|
func (c *sigctxt) sigcode() uint32 { return uint32(c.info.si_code) }
|
||||||
func (c *sigctxt) sigaddr() uint32 { return uint32(c.info.si_addr) }
|
func (c *sigctxt) sigaddr() uint32 { return uint32(c.info.si_addr) }
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@ func (c *sigctxt) r14() uint64 { return c.regs().mc_r14 }
|
|||||||
func (c *sigctxt) r15() uint64 { return c.regs().mc_r15 }
|
func (c *sigctxt) r15() uint64 { return c.regs().mc_r15 }
|
||||||
func (c *sigctxt) rip() uint64 { return c.regs().mc_rip }
|
func (c *sigctxt) rip() uint64 { return c.regs().mc_rip }
|
||||||
func (c *sigctxt) rflags() uint64 { return c.regs().mc_rflags }
|
func (c *sigctxt) rflags() uint64 { return c.regs().mc_rflags }
|
||||||
func (c *sigctxt) cs() uint64 { return uint64(c.regs().mc_cs) }
|
func (c *sigctxt) cs() uint64 { return c.regs().mc_cs }
|
||||||
func (c *sigctxt) fs() uint64 { return uint64(c.regs().mc_fs) }
|
func (c *sigctxt) fs() uint64 { return uint64(c.regs().mc_fs) }
|
||||||
func (c *sigctxt) gs() uint64 { return uint64(c.regs().mc_gs) }
|
func (c *sigctxt) gs() uint64 { return uint64(c.regs().mc_gs) }
|
||||||
func (c *sigctxt) sigcode() uint64 { return uint64(c.info.si_code) }
|
func (c *sigctxt) sigcode() uint64 { return uint64(c.info.si_code) }
|
||||||
func (c *sigctxt) sigaddr() uint64 { return uint64(c.info.si_addr) }
|
func (c *sigctxt) sigaddr() uint64 { return c.info.si_addr }
|
||||||
|
|
||||||
func (c *sigctxt) set_rip(x uint64) { c.regs().mc_rip = x }
|
func (c *sigctxt) set_rip(x uint64) { c.regs().mc_rip = x }
|
||||||
func (c *sigctxt) set_rsp(x uint64) { c.regs().mc_rsp = x }
|
func (c *sigctxt) set_rsp(x uint64) { c.regs().mc_rsp = x }
|
||||||
|
@ -88,7 +88,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||||||
c.set_sp(sp)
|
c.set_sp(sp)
|
||||||
*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
|
*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
|
||||||
|
|
||||||
pc := uintptr(gp.sigpc)
|
pc := gp.sigpc
|
||||||
|
|
||||||
// If we don't recognize the PC as code
|
// If we don't recognize the PC as code
|
||||||
// but we do recognize the link register as code,
|
// but we do recognize the link register as code,
|
||||||
|
@ -22,12 +22,12 @@ func (c *sigctxt) ebp() uint32 { return c.regs().__gregs[_REG_EBP] }
|
|||||||
func (c *sigctxt) esp() uint32 { return c.regs().__gregs[_REG_UESP] }
|
func (c *sigctxt) esp() uint32 { return c.regs().__gregs[_REG_UESP] }
|
||||||
func (c *sigctxt) eip() uint32 { return c.regs().__gregs[_REG_EIP] }
|
func (c *sigctxt) eip() uint32 { return c.regs().__gregs[_REG_EIP] }
|
||||||
func (c *sigctxt) eflags() uint32 { return c.regs().__gregs[_REG_EFL] }
|
func (c *sigctxt) eflags() uint32 { return c.regs().__gregs[_REG_EFL] }
|
||||||
func (c *sigctxt) cs() uint32 { return uint32(c.regs().__gregs[_REG_CS]) }
|
func (c *sigctxt) cs() uint32 { return c.regs().__gregs[_REG_CS] }
|
||||||
func (c *sigctxt) fs() uint32 { return uint32(c.regs().__gregs[_REG_FS]) }
|
func (c *sigctxt) fs() uint32 { return c.regs().__gregs[_REG_FS] }
|
||||||
func (c *sigctxt) gs() uint32 { return uint32(c.regs().__gregs[_REG_GS]) }
|
func (c *sigctxt) gs() uint32 { return c.regs().__gregs[_REG_GS] }
|
||||||
func (c *sigctxt) sigcode() uint32 { return uint32(c.info._code) }
|
func (c *sigctxt) sigcode() uint32 { return uint32(c.info._code) }
|
||||||
func (c *sigctxt) sigaddr() uint32 {
|
func (c *sigctxt) sigaddr() uint32 {
|
||||||
return uint32(*(*uint32)(unsafe.Pointer(&c.info._reason[0])))
|
return *(*uint32)(unsafe.Pointer(&c.info._reason[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sigctxt) set_eip(x uint32) { c.regs().__gregs[_REG_EIP] = x }
|
func (c *sigctxt) set_eip(x uint32) { c.regs().__gregs[_REG_EIP] = x }
|
||||||
|
@ -37,7 +37,7 @@ func (c *sigctxt) fs() uint64 { return c.regs().__gregs[_REG_FS] }
|
|||||||
func (c *sigctxt) gs() uint64 { return c.regs().__gregs[_REG_GS] }
|
func (c *sigctxt) gs() uint64 { return c.regs().__gregs[_REG_GS] }
|
||||||
func (c *sigctxt) sigcode() uint64 { return uint64(c.info._code) }
|
func (c *sigctxt) sigcode() uint64 { return uint64(c.info._code) }
|
||||||
func (c *sigctxt) sigaddr() uint64 {
|
func (c *sigctxt) sigaddr() uint64 {
|
||||||
return uint64(*(*uint64)(unsafe.Pointer(&c.info._reason[0])))
|
return *(*uint64)(unsafe.Pointer(&c.info._reason[0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *sigctxt) set_rip(x uint64) { c.regs().__gregs[_REG_RIP] = x }
|
func (c *sigctxt) set_rip(x uint64) { c.regs().__gregs[_REG_RIP] = x }
|
||||||
|
@ -90,7 +90,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
|
|||||||
c.set_sp(sp)
|
c.set_sp(sp)
|
||||||
*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
|
*(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
|
||||||
|
|
||||||
pc := uintptr(gp.sigpc)
|
pc := gp.sigpc
|
||||||
|
|
||||||
// If we don't recognize the PC as code
|
// If we don't recognize the PC as code
|
||||||
// but we do recognize the link register as code,
|
// but we do recognize the link register as code,
|
||||||
|
@ -88,7 +88,7 @@ func exceptionhandler(info *exceptionrecord, r *context, gp *g) int32 {
|
|||||||
// won't get to see who faulted.)
|
// won't get to see who faulted.)
|
||||||
if r.ip() != 0 {
|
if r.ip() != 0 {
|
||||||
sp := unsafe.Pointer(r.sp())
|
sp := unsafe.Pointer(r.sp())
|
||||||
sp = add(sp, ^uintptr(unsafe.Sizeof(uintptr(0))-1)) // sp--
|
sp = add(sp, ^(unsafe.Sizeof(uintptr(0)) - 1)) // sp--
|
||||||
*((*uintptr)(sp)) = r.ip()
|
*((*uintptr)(sp)) = r.ip()
|
||||||
r.setsp(uintptr(sp))
|
r.setsp(uintptr(sp))
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ func sigpanic() {
|
|||||||
throw("unexpected signal during runtime execution")
|
throw("unexpected signal during runtime execution")
|
||||||
}
|
}
|
||||||
|
|
||||||
switch uint32(g.sig) {
|
switch g.sig {
|
||||||
case _EXCEPTION_ACCESS_VIOLATION:
|
case _EXCEPTION_ACCESS_VIOLATION:
|
||||||
if g.sigcode1 < 0x1000 || g.paniconfault {
|
if g.sigcode1 < 0x1000 || g.paniconfault {
|
||||||
panicmem()
|
panicmem()
|
||||||
|
@ -22,11 +22,11 @@ func makeslice(t *slicetype, len64, cap64 int64) slice {
|
|||||||
// but since the cap is only being supplied implicitly, saying len is clearer.
|
// but since the cap is only being supplied implicitly, saying len is clearer.
|
||||||
// See issue 4085.
|
// See issue 4085.
|
||||||
len := int(len64)
|
len := int(len64)
|
||||||
if len64 < 0 || int64(len) != len64 || t.elem.size > 0 && uintptr(len) > _MaxMem/uintptr(t.elem.size) {
|
if len64 < 0 || int64(len) != len64 || t.elem.size > 0 && uintptr(len) > _MaxMem/t.elem.size {
|
||||||
panic(errorString("makeslice: len out of range"))
|
panic(errorString("makeslice: len out of range"))
|
||||||
}
|
}
|
||||||
cap := int(cap64)
|
cap := int(cap64)
|
||||||
if cap < len || int64(cap) != cap64 || t.elem.size > 0 && uintptr(cap) > _MaxMem/uintptr(t.elem.size) {
|
if cap < len || int64(cap) != cap64 || t.elem.size > 0 && uintptr(cap) > _MaxMem/t.elem.size {
|
||||||
panic(errorString("makeslice: cap out of range"))
|
panic(errorString("makeslice: cap out of range"))
|
||||||
}
|
}
|
||||||
p := newarray(t.elem, uintptr(cap))
|
p := newarray(t.elem, uintptr(cap))
|
||||||
@ -49,7 +49,7 @@ func growslice_n(t *slicetype, old slice, n int) slice {
|
|||||||
// and it returns a new slice with at least that capacity, with the old data
|
// and it returns a new slice with at least that capacity, with the old data
|
||||||
// copied into it.
|
// copied into it.
|
||||||
func growslice(t *slicetype, old slice, cap int) slice {
|
func growslice(t *slicetype, old slice, cap int) slice {
|
||||||
if cap < old.cap || t.elem.size > 0 && uintptr(cap) > _MaxMem/uintptr(t.elem.size) {
|
if cap < old.cap || t.elem.size > 0 && uintptr(cap) > _MaxMem/t.elem.size {
|
||||||
panic(errorString("growslice: cap out of range"))
|
panic(errorString("growslice: cap out of range"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,12 +84,12 @@ func growslice(t *slicetype, old slice, cap int) slice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if uintptr(newcap) >= _MaxMem/uintptr(et.size) {
|
if uintptr(newcap) >= _MaxMem/et.size {
|
||||||
panic(errorString("growslice: cap out of range"))
|
panic(errorString("growslice: cap out of range"))
|
||||||
}
|
}
|
||||||
lenmem := uintptr(old.len) * uintptr(et.size)
|
lenmem := uintptr(old.len) * et.size
|
||||||
capmem := roundupsize(uintptr(newcap) * uintptr(et.size))
|
capmem := roundupsize(uintptr(newcap) * et.size)
|
||||||
newcap = int(capmem / uintptr(et.size))
|
newcap = int(capmem / et.size)
|
||||||
var p unsafe.Pointer
|
var p unsafe.Pointer
|
||||||
if et.kind&kindNoPointers != 0 {
|
if et.kind&kindNoPointers != 0 {
|
||||||
p = rawmem(capmem)
|
p = rawmem(capmem)
|
||||||
@ -142,7 +142,7 @@ func slicecopy(to, fm slice, width uintptr) int {
|
|||||||
} else {
|
} else {
|
||||||
memmove(to.array, fm.array, size)
|
memmove(to.array, fm.array, size)
|
||||||
}
|
}
|
||||||
return int(n)
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func slicestringcopy(to []byte, fm string) int {
|
func slicestringcopy(to []byte, fm string) int {
|
||||||
@ -164,6 +164,6 @@ func slicestringcopy(to []byte, fm string) int {
|
|||||||
msanwrite(unsafe.Pointer(&to[0]), uintptr(n))
|
msanwrite(unsafe.Pointer(&to[0]), uintptr(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
memmove(unsafe.Pointer(&to[0]), unsafe.Pointer(stringStructOf(&fm).str), uintptr(n))
|
memmove(unsafe.Pointer(&to[0]), stringStructOf(&fm).str, uintptr(n))
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ func sfloat2(pc uint32, regs *[15]uint32) uint32 {
|
|||||||
pc = uint32(funcPC(_sfloatpanic))
|
pc = uint32(funcPC(_sfloatpanic))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
pc += 4 * uint32(skip)
|
pc += 4 * skip
|
||||||
}
|
}
|
||||||
if first {
|
if first {
|
||||||
print("sfloat2 ", pc, " ", hex(*(*uint32)(unsafe.Pointer(uintptr(pc)))), "\n")
|
print("sfloat2 ", pc, " ", hex(*(*uint32)(unsafe.Pointer(uintptr(pc)))), "\n")
|
||||||
|
@ -563,7 +563,7 @@ func adjustpointers(scanp unsafe.Pointer, cbv *bitvector, adjinfo *adjustinfo, f
|
|||||||
minp := adjinfo.old.lo
|
minp := adjinfo.old.lo
|
||||||
maxp := adjinfo.old.hi
|
maxp := adjinfo.old.hi
|
||||||
delta := adjinfo.delta
|
delta := adjinfo.delta
|
||||||
num := uintptr(bv.n)
|
num := bv.n
|
||||||
for i := uintptr(0); i < num; i++ {
|
for i := uintptr(0); i < num; i++ {
|
||||||
if stackDebug >= 4 {
|
if stackDebug >= 4 {
|
||||||
print(" ", add(scanp, i*sys.PtrSize), ":", ptrnames[ptrbit(&bv, i)], ":", hex(*(*uintptr)(add(scanp, i*sys.PtrSize))), " # ", i, " ", bv.bytedata[i/8], "\n")
|
print(" ", add(scanp, i*sys.PtrSize), ":", ptrnames[ptrbit(&bv, i)], ":", hex(*(*uintptr)(add(scanp, i*sys.PtrSize))), " # ", i, " ", bv.bytedata[i/8], "\n")
|
||||||
@ -665,7 +665,7 @@ func adjustframe(frame *stkframe, arg unsafe.Pointer) bool {
|
|||||||
} else {
|
} else {
|
||||||
stackmap := (*stackmap)(funcdata(f, _FUNCDATA_ArgsPointerMaps))
|
stackmap := (*stackmap)(funcdata(f, _FUNCDATA_ArgsPointerMaps))
|
||||||
if stackmap == nil || stackmap.n <= 0 {
|
if stackmap == nil || stackmap.n <= 0 {
|
||||||
print("runtime: frame ", funcname(f), " untyped args ", frame.argp, "+", uintptr(frame.arglen), "\n")
|
print("runtime: frame ", funcname(f), " untyped args ", frame.argp, "+", frame.arglen, "\n")
|
||||||
throw("missing stackmap")
|
throw("missing stackmap")
|
||||||
}
|
}
|
||||||
if pcdata < 0 || pcdata >= stackmap.n {
|
if pcdata < 0 || pcdata >= stackmap.n {
|
||||||
|
@ -155,7 +155,7 @@ func stringtoslicebytetmp(s string) []byte {
|
|||||||
// for i, c := range []byte(str)
|
// for i, c := range []byte(str)
|
||||||
|
|
||||||
str := stringStructOf(&s)
|
str := stringStructOf(&s)
|
||||||
ret := slice{array: unsafe.Pointer(str.str), len: str.len, cap: str.len}
|
ret := slice{array: str.str, len: str.len, cap: str.len}
|
||||||
return *(*[]byte)(unsafe.Pointer(&ret))
|
return *(*[]byte)(unsafe.Pointer(&ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ func rawstring(size int) (s string, b []byte) {
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
ms := maxstring
|
ms := maxstring
|
||||||
if uintptr(size) <= uintptr(ms) || atomic.Casuintptr((*uintptr)(unsafe.Pointer(&maxstring)), uintptr(ms), uintptr(size)) {
|
if uintptr(size) <= ms || atomic.Casuintptr((*uintptr)(unsafe.Pointer(&maxstring)), ms, uintptr(size)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ func tracebackdefers(gp *g, callback func(*stkframe, unsafe.Pointer) bool, v uns
|
|||||||
frame.arglen = 0
|
frame.arglen = 0
|
||||||
frame.argmap = nil
|
frame.argmap = nil
|
||||||
} else {
|
} else {
|
||||||
frame.pc = uintptr(fn.fn)
|
frame.pc = fn.fn
|
||||||
f := findfunc(frame.pc)
|
f := findfunc(frame.pc)
|
||||||
if f == nil {
|
if f == nil {
|
||||||
print("runtime: unknown pc in defer ", hex(frame.pc), "\n")
|
print("runtime: unknown pc in defer ", hex(frame.pc), "\n")
|
||||||
@ -174,7 +174,7 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in
|
|||||||
printing := pcbuf == nil && callback == nil
|
printing := pcbuf == nil && callback == nil
|
||||||
_defer := gp._defer
|
_defer := gp._defer
|
||||||
|
|
||||||
for _defer != nil && uintptr(_defer.sp) == _NoArgs {
|
for _defer != nil && _defer.sp == _NoArgs {
|
||||||
_defer = _defer.link
|
_defer = _defer.link
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +600,7 @@ func traceback1(pc, sp, lr uintptr, gp *g, flags uint) {
|
|||||||
|
|
||||||
func callers(skip int, pcbuf []uintptr) int {
|
func callers(skip int, pcbuf []uintptr) int {
|
||||||
sp := getcallersp(unsafe.Pointer(&skip))
|
sp := getcallersp(unsafe.Pointer(&skip))
|
||||||
pc := uintptr(getcallerpc(unsafe.Pointer(&skip)))
|
pc := getcallerpc(unsafe.Pointer(&skip))
|
||||||
gp := getg()
|
gp := getg()
|
||||||
var n int
|
var n int
|
||||||
systemstack(func() {
|
systemstack(func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user