]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: eliminate traceStack write barriers
authorAustin Clements <austin@google.com>
Tue, 10 Nov 2015 21:43:33 +0000 (16:43 -0500)
committerAustin Clements <austin@google.com>
Wed, 11 Nov 2015 17:37:26 +0000 (17:37 +0000)
This replaces *traceStack with traceStackPtr, much like the preceding
commit.

Updates #10600.

Change-Id: Ifadc35eb37a405ae877f9740151fb31a0ca1d08f
Reviewed-on: https://go-review.googlesource.com/16813
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/runtime/trace.go

index f8e6649ef921d6e1b29d26f839c86429a590002b..0d3940d327dc3cb24f47e6ddec122d112d323ba1 100644 (file)
@@ -618,18 +618,22 @@ type traceStackTable struct {
        lock mutex
        seq  uint32
        mem  traceAlloc
-       tab  [1 << 13]*traceStack
+       tab  [1 << 13]traceStackPtr
 }
 
 // traceStack is a single stack in traceStackTable.
 type traceStack struct {
-       link *traceStack
+       link traceStackPtr
        hash uintptr
        id   uint32
        n    int
        stk  [0]uintptr // real type [n]uintptr
 }
 
+type traceStackPtr uintptr
+
+func (tp traceStackPtr) ptr() *traceStack { return (*traceStack)(unsafe.Pointer(tp)) }
+
 // stack returns slice of PCs.
 func (ts *traceStack) stack() []uintptr {
        return (*[traceStackSize]uintptr)(unsafe.Pointer(&ts.stk))[:ts.n]
@@ -673,7 +677,7 @@ func (tab *traceStackTable) put(pcs []uintptr) uint32 {
 func (tab *traceStackTable) find(pcs []uintptr, hash uintptr) uint32 {
        part := int(hash % uintptr(len(tab.tab)))
 Search:
-       for stk := tab.tab[part]; stk != nil; stk = stk.link {
+       for stk := tab.tab[part].ptr(); stk != nil; stk = stk.link.ptr() {
                if stk.hash == hash && stk.n == len(pcs) {
                        for i, stkpc := range stk.stack() {
                                if stkpc != pcs[i] {
@@ -697,7 +701,8 @@ func (tab *traceStackTable) dump() {
        var tmp [(2 + traceStackSize) * traceBytesPerNumber]byte
        buf := traceFlush(0).ptr()
        for _, stk := range tab.tab {
-               for ; stk != nil; stk = stk.link {
+               stk := stk.ptr()
+               for ; stk != nil; stk = stk.link.ptr() {
                        maxSize := 1 + (3+stk.n)*traceBytesPerNumber
                        if cap(buf.buf)-len(buf.buf) < maxSize {
                                buf = traceFlush(traceBufPtrOf(buf)).ptr()