From: Russ Cox Date: Fri, 14 Nov 2014 16:37:54 +0000 (-0500) Subject: [dev.garbage] all: merge default (f38460037b72) into dev.garbage X-Git-Tag: go1.5beta1~2684^2~12 X-Git-Url: http://www.git.cypherpunks.ru/?a=commitdiff_plain;h=3dcc62e1dad3c62a1c8df1b6f613f93521124764;p=gostls13.git [dev.garbage] all: merge default (f38460037b72) into dev.garbage This is the revision that dev.cc is branched from. LGTM=austin R=austin CC=golang-codereviews https://golang.org/cl/169590043 --- 3dcc62e1dad3c62a1c8df1b6f613f93521124764 diff --cc src/runtime/malloc.go index a18e77421e,8cf1c3d342..fab8cf2695 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@@ -358,40 -344,9 +358,40 @@@ marked return x } +func loadPtrMask(typ *_type) []uint8 { + var ptrmask *uint8 + nptr := (uintptr(typ.size) + ptrSize - 1) / ptrSize + if typ.kind&kindGCProg != 0 { + masksize := nptr + if masksize%2 != 0 { + masksize *= 2 // repeated + } + masksize = masksize * pointersPerByte / 8 // 4 bits per word + masksize++ // unroll flag in the beginning + if masksize > maxGCMask && typ.gc[1] != 0 { + // write barriers have not been updated to deal with this case yet. + gothrow("maxGCMask too small for now") + } + ptrmask = (*uint8)(unsafe.Pointer(uintptr(typ.gc[0]))) + // Check whether the program is already unrolled + // by checking if the unroll flag byte is set + maskword := uintptr(atomicloadp(unsafe.Pointer(ptrmask))) + if *(*uint8)(unsafe.Pointer(&maskword)) == 0 { + mp := acquirem() + mp.ptrarg[0] = unsafe.Pointer(typ) + onM(unrollgcprog_m) + releasem(mp) + } + ptrmask = (*uint8)(add(unsafe.Pointer(ptrmask), 1)) // skip the unroll flag byte + } else { + ptrmask = (*uint8)(unsafe.Pointer(typ.gc[0])) // pointer to unrolled mask + } + return (*[1 << 30]byte)(unsafe.Pointer(ptrmask))[:(nptr+1)/2] +} + // implementation of new builtin func newobject(typ *_type) unsafe.Pointer { - flags := 0 + flags := uint32(0) if typ.kind&kindNoPointers != 0 { flags |= flagNoScan }