Commit dc53ea77 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: change Func.FCurfn to IsHiddenClosure

IsHiddenClosure is more descriptive.

Change-Id: I06651072925a958b148b64ab0db3a9bfc839af9b
Reviewed-on: https://go-review.googlesource.com/32224
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 4f6d4791
...@@ -347,7 +347,7 @@ func newname(s *Sym) *Node { ...@@ -347,7 +347,7 @@ func newname(s *Sym) *Node {
func newfuncname(s *Sym) *Node { func newfuncname(s *Sym) *Node {
n := newname(s) n := newname(s)
n.Func = new(Func) n.Func = new(Func)
n.Func.FCurfn = Curfn n.Func.IsHiddenClosure = Curfn != nil
return n return n
} }
......
...@@ -18,7 +18,7 @@ import ( ...@@ -18,7 +18,7 @@ import (
// The algorithm (known as Tarjan's algorithm) for doing that is taken from // The algorithm (known as Tarjan's algorithm) for doing that is taken from
// Sedgewick, Algorithms, Second Edition, p. 482, with two adaptations. // Sedgewick, Algorithms, Second Edition, p. 482, with two adaptations.
// //
// First, a hidden closure function (n.Func.FCurfn != nil) cannot be the // First, a hidden closure function (n.Func.IsHiddenClosure) cannot be the
// root of a connected component. Refusing to use it as a root // root of a connected component. Refusing to use it as a root
// forces it into the component of the function in which it appears. // forces it into the component of the function in which it appears.
// This is more convenient for escape analysis. // This is more convenient for escape analysis.
...@@ -58,7 +58,7 @@ func visitBottomUp(list []*Node, analyze func(list []*Node, recursive bool)) { ...@@ -58,7 +58,7 @@ func visitBottomUp(list []*Node, analyze func(list []*Node, recursive bool)) {
v.analyze = analyze v.analyze = analyze
v.nodeID = make(map[*Node]uint32) v.nodeID = make(map[*Node]uint32)
for _, n := range list { for _, n := range list {
if n.Op == ODCLFUNC && n.Func.FCurfn == nil { if n.Op == ODCLFUNC && !n.Func.IsHiddenClosure {
v.visit(n) v.visit(n)
} }
} }
...@@ -78,7 +78,7 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 { ...@@ -78,7 +78,7 @@ func (v *bottomUpVisitor) visit(n *Node) uint32 {
v.stack = append(v.stack, n) v.stack = append(v.stack, n)
min = v.visitcodelist(n.Nbody, min) min = v.visitcodelist(n.Nbody, min)
if (min == id || min == id+1) && n.Func.FCurfn == nil { if (min == id || min == id+1) && !n.Func.IsHiddenClosure {
// This node is the root of a strongly connected component. // This node is the root of a strongly connected component.
// The original min passed to visitcodelist was v.nodeID[n]+1. // The original min passed to visitcodelist was v.nodeID[n]+1.
......
...@@ -22,7 +22,7 @@ func TestSizeof(t *testing.T) { ...@@ -22,7 +22,7 @@ func TestSizeof(t *testing.T) {
_32bit uintptr // size on 32bit platforms _32bit uintptr // size on 32bit platforms
_64bit uintptr // size on 64bit platforms _64bit uintptr // size on 64bit platforms
}{ }{
{Func{}, 96, 168}, {Func{}, 92, 160},
{Name{}, 52, 80}, {Name{}, 52, 80},
{Node{}, 92, 144}, {Node{}, 92, 144},
{Sym{}, 60, 112}, {Sym{}, 60, 112},
......
...@@ -361,7 +361,7 @@ func nod(op Op, nleft *Node, nright *Node) *Node { ...@@ -361,7 +361,7 @@ func nod(op Op, nleft *Node, nright *Node) *Node {
switch op { switch op {
case OCLOSURE, ODCLFUNC: case OCLOSURE, ODCLFUNC:
n.Func = new(Func) n.Func = new(Func)
n.Func.FCurfn = Curfn n.Func.IsHiddenClosure = Curfn != nil
case ONAME: case ONAME:
n.Name = new(Name) n.Name = new(Name)
n.Name.Param = new(Param) n.Name.Param = new(Param)
......
...@@ -284,7 +284,6 @@ type Func struct { ...@@ -284,7 +284,6 @@ type Func struct {
Ntype *Node // signature Ntype *Node // signature
Top int // top context (Ecall, Eproc, etc) Top int // top context (Ecall, Eproc, etc)
Closure *Node // OCLOSURE <-> ODCLFUNC Closure *Node // OCLOSURE <-> ODCLFUNC
FCurfn *Node
Nname *Node Nname *Node
Inl Nodes // copy of the body for use in inlining Inl Nodes // copy of the body for use in inlining
...@@ -296,11 +295,12 @@ type Func struct { ...@@ -296,11 +295,12 @@ type Func struct {
Endlineno int32 Endlineno int32
WBLineno int32 // line number of first write barrier WBLineno int32 // line number of first write barrier
Pragma Pragma // go:xxx function annotations Pragma Pragma // go:xxx function annotations
Dupok bool // duplicate definitions ok Dupok bool // duplicate definitions ok
Wrapper bool // is method wrapper Wrapper bool // is method wrapper
Needctxt bool // function uses context register (has closure variables) Needctxt bool // function uses context register (has closure variables)
ReflectMethod bool // function calls reflect.Type.Method or MethodByName ReflectMethod bool // function calls reflect.Type.Method or MethodByName
IsHiddenClosure bool
} }
type Op uint8 type Op uint8
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment