]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't free the Prog list if we look at it after flush
authorKeith Randall <khr@golang.org>
Wed, 24 Feb 2016 22:07:25 +0000 (14:07 -0800)
committerKeith Randall <khr@golang.org>
Wed, 24 Feb 2016 22:10:27 +0000 (22:10 +0000)
Only tests do this, provide them a hook to disable freeing
after flush.

Change-Id: I810c6c51414a93f476a18ba07b807e16092bf8cf
Reviewed-on: https://go-review.googlesource.com/19907
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/asm/internal/asm/endtoend_test.go
src/cmd/internal/obj/objfile.go

index 4bc7e2fb7493e3602dcfaad45053c788f2ac2adc..4a3e0ee26593c8e3fb07b9e46988a8e3e6dda19a 100644 (file)
@@ -179,7 +179,7 @@ Diff:
                t.Errorf(format, args...)
                ok = false
        }
-       obj.Flushplist(ctxt)
+       obj.FlushplistNoFree(ctxt)
 
        for p := top; p != nil; p = p.Link {
                if p.As == obj.ATEXT {
index 2d5c82376b4f0a70967b891af20efa84adca10a0..6757067dd6d6de954e9aa4b71174157fbb42c9e7 100644 (file)
@@ -116,6 +116,12 @@ func Writeobjdirect(ctxt *Link, b *Biobuf) {
 }
 
 func Flushplist(ctxt *Link) {
+       flushplist(ctxt, true)
+}
+func FlushplistNoFree(ctxt *Link) {
+       flushplist(ctxt, false)
+}
+func flushplist(ctxt *Link, freeProgs bool) {
        var flag int
        var s *LSym
        var p *Prog
@@ -318,7 +324,9 @@ func Flushplist(ctxt *Link) {
        ctxt.Plist = nil
        ctxt.Plast = nil
        ctxt.Curp = nil
-       ctxt.freeProgs()
+       if freeProgs {
+               ctxt.freeProgs()
+       }
 }
 
 func Writeobjfile(ctxt *Link, b *Biobuf) {