Commit f8a34443 authored by Hiroshi Ioka's avatar Hiroshi Ioka Committed by Matthew Dempsky

cmd/compile/internal/gc: remove EscScope

EscScope behaves like EscHeap in current code.
There are no need to handle it specially.
So remove it and use EscHeap instead.

Change-Id: I910106fd147f00e5f4fd52c7dde05128141a5160
Reviewed-on: https://go-review.googlesource.com/32130
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 1e6b12a2
...@@ -351,9 +351,6 @@ const ( ...@@ -351,9 +351,6 @@ const (
EscUnknown = iota EscUnknown = iota
EscNone // Does not escape to heap, result, or parameters. EscNone // Does not escape to heap, result, or parameters.
EscReturn // Is returned or reachable from returned. EscReturn // Is returned or reachable from returned.
EscScope // Allocated in an inner loop scope, assigned to an outer loop scope,
// which allows the construction of non-escaping but arbitrarily large linked
// data structures (i.e., not eligible for allocation in a fixed-size stack frame).
EscHeap // Reachable from the heap EscHeap // Reachable from the heap
EscNever // By construction will not escape. EscNever // By construction will not escape.
EscBits = 3 EscBits = 3
...@@ -366,10 +363,10 @@ const ( ...@@ -366,10 +363,10 @@ const (
// escMax returns the maximum of an existing escape value // escMax returns the maximum of an existing escape value
// (and its additional parameter flow flags) and a new escape type. // (and its additional parameter flow flags) and a new escape type.
func escMax(e, etype uint16) uint16 { func escMax(e, etype uint16) uint16 {
if e&EscMask >= EscScope { if e&EscMask >= EscHeap {
// normalize // normalize
if e&^EscMask != 0 { if e&^EscMask != 0 {
Fatalf("Escape information had unexpected return encoding bits (w/ EscScope, EscHeap, EscNever), e&EscMask=%v", e&EscMask) Fatalf("Escape information had unexpected return encoding bits (w/ EscHeap, EscNever), e&EscMask=%v", e&EscMask)
} }
} }
if e&EscMask > etype { if e&EscMask > etype {
...@@ -1284,9 +1281,6 @@ func describeEscape(em uint16) string { ...@@ -1284,9 +1281,6 @@ func describeEscape(em uint16) string {
if em&EscMask == EscReturn { if em&EscMask == EscReturn {
s = "EscReturn" s = "EscReturn"
} }
if em&EscMask == EscScope {
s = "EscScope"
}
if em&EscContentEscapes != 0 { if em&EscContentEscapes != 0 {
if s != "" { if s != "" {
s += " " s += " "
...@@ -1812,7 +1806,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep, ...@@ -1812,7 +1806,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep,
var osrcesc uint16 // used to prevent duplicate error messages var osrcesc uint16 // used to prevent duplicate error messages
dstE := e.nodeEscState(dst) dstE := e.nodeEscState(dst)
if funcOutputAndInput(dst, src) && src.Esc&EscMask < EscScope && dst.Esc != EscHeap { if funcOutputAndInput(dst, src) && src.Esc&EscMask < EscHeap && dst.Esc != EscHeap {
// This case handles: // This case handles:
// 1. return in // 1. return in
// 2. return &in // 2. return &in
...@@ -1836,7 +1830,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep, ...@@ -1836,7 +1830,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep,
// If parameter content escapes to heap, set EscContentEscapes // If parameter content escapes to heap, set EscContentEscapes
// Note minor confusion around escape from pointer-to-struct vs escape from struct // Note minor confusion around escape from pointer-to-struct vs escape from struct
if dst.Esc == EscHeap && if dst.Esc == EscHeap &&
src.Op == ONAME && src.Class == PPARAM && src.Esc&EscMask < EscScope && src.Op == ONAME && src.Class == PPARAM && src.Esc&EscMask < EscHeap &&
level.int() > 0 { level.int() > 0 {
src.Esc = escMax(EscContentEscapes|src.Esc, EscNone) src.Esc = escMax(EscContentEscapes|src.Esc, EscNone)
if Debug['m'] != 0 { if Debug['m'] != 0 {
...@@ -1851,7 +1845,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep, ...@@ -1851,7 +1845,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep,
osrcesc = src.Esc osrcesc = src.Esc
switch src.Op { switch src.Op {
case ONAME: case ONAME:
if src.Class == PPARAM && (leaks || dstE.Loopdepth < 0) && src.Esc&EscMask < EscScope { if src.Class == PPARAM && (leaks || dstE.Loopdepth < 0) && src.Esc&EscMask < EscHeap {
if level.guaranteedDereference() > 0 { if level.guaranteedDereference() > 0 {
src.Esc = escMax(EscContentEscapes|src.Esc, EscNone) src.Esc = escMax(EscContentEscapes|src.Esc, EscNone)
if Debug['m'] != 0 { if Debug['m'] != 0 {
...@@ -1866,9 +1860,8 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep, ...@@ -1866,9 +1860,8 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep,
} }
} }
} else { } else {
src.Esc = EscScope src.Esc = EscHeap
if Debug['m'] != 0 { if Debug['m'] != 0 {
if Debug['m'] <= 2 { if Debug['m'] <= 2 {
Warnl(src.Lineno, "leaking param: %S", src) Warnl(src.Lineno, "leaking param: %S", src)
step.describe(src) step.describe(src)
...@@ -2105,8 +2098,7 @@ func (e *EscState) esctag(fn *Node) { ...@@ -2105,8 +2098,7 @@ func (e *EscState) esctag(fn *Node) {
} }
} }
case EscHeap, // touched by escflood, moved to heap case EscHeap: // touched by escflood, moved to heap
EscScope: // touched by escflood, value leaves scope
} }
} }
} }
...@@ -317,9 +317,6 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) { ...@@ -317,9 +317,6 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) {
case EscHeap: case EscHeap:
fmt.Fprint(s, " esc(h)") fmt.Fprint(s, " esc(h)")
case EscScope:
fmt.Fprint(s, " esc(s)")
case EscNone: case EscNone:
fmt.Fprint(s, " esc(no)") fmt.Fprint(s, " esc(no)")
......
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