From 5c90e1cf8ab39625b1f73c499cf47c06a60e9c08 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 3 Feb 2017 14:28:32 -0800 Subject: [PATCH] cmd/compile/internal/ssa: remove Func.StaticData field Rather than collecting static data nodes to be written out later, just write them out immediately. Change-Id: I51708b690e94bc3e288b4d6ba3307bf738a80f64 Reviewed-on: https://go-review.googlesource.com/36352 Run-TryBot: Matthew Dempsky TryBot-Result: Gobot Gobot Reviewed-by: Josh Bleecher Snyder --- src/cmd/compile/internal/gc/ssa.go | 19 +++---------------- src/cmd/compile/internal/ssa/func.go | 17 ++++++++--------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 05e97a904f3..a1060d9a2b3 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -642,15 +642,11 @@ func (s *state) stmt(n *Node) { b.AddEdgeTo(lab.target) case OAS, OASWB: - // Check whether we can generate static data rather than code. - // If so, ignore n and defer data generation until codegen. - // Failure to do this causes writes to readonly symbols. + // Generate static data rather than code, if possible. if gen_as_init(n, true) { - var data []*Node - if s.f.StaticData != nil { - data = s.f.StaticData.([]*Node) + if !gen_as_init(n, false) { + Fatalf("non-static data marked as static: %v\n\n", n) } - s.f.StaticData = append(data, n) return } @@ -4487,15 +4483,6 @@ func genssa(f *ssa.Func, ptxt *obj.Prog, gcargs, gclocals *Sym) { } } - // Emit static data - if f.StaticData != nil { - for _, n := range f.StaticData.([]*Node) { - if !gen_as_init(n, false) { - Fatalf("non-static data marked as static: %v\n\n", n) - } - } - } - // Generate gc bitmaps. liveness(Curfn, ptxt, gcargs, gclocals) diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go index 3f3c0d68889..ea259190da9 100644 --- a/src/cmd/compile/internal/ssa/func.go +++ b/src/cmd/compile/internal/ssa/func.go @@ -14,15 +14,14 @@ import ( // A Func represents a Go func declaration (or function literal) and // its body. This package compiles each Func independently. type Func struct { - Config *Config // architecture information - pass *pass // current pass information (name, options, etc.) - Name string // e.g. bytes·Compare - Type Type // type signature of the function. - StaticData interface{} // associated static data, untouched by the ssa package - Blocks []*Block // unordered set of all basic blocks (note: not indexable by ID) - Entry *Block // the entry basic block - bid idAlloc // block ID allocator - vid idAlloc // value ID allocator + Config *Config // architecture information + pass *pass // current pass information (name, options, etc.) + Name string // e.g. bytes·Compare + Type Type // type signature of the function. + Blocks []*Block // unordered set of all basic blocks (note: not indexable by ID) + Entry *Block // the entry basic block + bid idAlloc // block ID allocator + vid idAlloc // value ID allocator scheduled bool // Values in Blocks are in final order NoSplit bool // true if function is marked as nosplit. Used by schedule check pass.