From 45c2e38b37e40c3b6bdc508065edce0643f79110 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 24 Feb 2016 09:12:51 -0800 Subject: cmd/compile: Drop references to Prog structs after each function Don't accumulate a massive list of Prog structs during compilation and write them all out at the end of compilation. Instead, convert them to code+relocs (or data+relocs) after each function is compiled. Track down a few other places that were keeping Progs alive and nil them out so the Progs get GCd promptly. Saves ~20% in peak memory usage for the compiler. Surprisingly not much help speed-wise (only because we end up doing more GCs. With a compensating GOGC=120, it does help a bit), but this provides a base for more changes (e.g. reusing a cache of Progs). Change-Id: I838e01017c228995a687a8110d0cd67bf8596407 Reviewed-on: https://go-review.googlesource.com/19867 Run-TryBot: Keith Randall TryBot-Result: Gobot Gobot Reviewed-by: Josh Bleecher Snyder Reviewed-by: Ian Lance Taylor --- src/cmd/internal/obj/objfile.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/cmd/internal/obj') diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index 40c92dd152..3dc5152f54 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -302,16 +302,22 @@ func Flushplist(ctxt *Link) { ctxt.Arch.Assemble(ctxt, s) fieldtrack(ctxt, s) linkpcln(ctxt, s) + s.Text = nil + s.Etext = nil } // Add to running list in ctxt. - if ctxt.Etext == nil { - ctxt.Text = text - } else { - ctxt.Etext.Next = text + if text != nil { + if ctxt.Text == nil { + ctxt.Text = text + } else { + ctxt.Etext.Next = text + } + ctxt.Etext = etext } - ctxt.Etext = etext ctxt.Plist = nil + ctxt.Plast = nil + ctxt.Curp = nil } func Writeobjfile(ctxt *Link, b *Biobuf) { -- cgit v1.3