1
0
mirror of https://github.com/golang/go synced 2024-11-22 22:30:02 -07:00

make stack value size threshold comparisons consistent

This commit is contained in:
go101 2021-07-01 10:12:08 -04:00
parent 9d65578b83
commit b8758f8ae0
2 changed files with 5 additions and 5 deletions

View File

@ -2013,14 +2013,14 @@ func HeapAllocReason(n ir.Node) string {
return "too large for stack" return "too large for stack"
} }
if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width >= ir.MaxImplicitStackVarSize { if (n.Op() == ir.ONEW || n.Op() == ir.OPTRLIT) && n.Type().Elem().Width > ir.MaxImplicitStackVarSize {
return "too large for stack" return "too large for stack"
} }
if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() >= ir.MaxImplicitStackVarSize { if n.Op() == ir.OCLOSURE && typecheck.ClosureType(n.(*ir.ClosureExpr)).Size() > ir.MaxImplicitStackVarSize {
return "too large for stack" return "too large for stack"
} }
if n.Op() == ir.OCALLPART && typecheck.PartialCallType(n.(*ir.SelectorExpr)).Size() >= ir.MaxImplicitStackVarSize { if n.Op() == ir.OCALLPART && typecheck.PartialCallType(n.(*ir.SelectorExpr)).Size() > ir.MaxImplicitStackVarSize {
return "too large for stack" return "too large for stack"
} }
@ -2033,7 +2033,7 @@ func HeapAllocReason(n ir.Node) string {
if !ir.IsSmallIntConst(r) { if !ir.IsSmallIntConst(r) {
return "non-constant size" return "non-constant size"
} }
if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) >= ir.MaxImplicitStackVarSize/t.Elem().Width { if t := n.Type(); t.Elem().Width != 0 && ir.Int64Val(r) > ir.MaxImplicitStackVarSize/t.Elem().Width {
return "too large for stack" return "too large for stack"
} }
} }

View File

@ -489,7 +489,7 @@ func walkNew(n *ir.UnaryExpr, init *ir.Nodes) ir.Node {
base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", n.Type().Elem()) base.Errorf("%v can't be allocated in Go; it is incomplete (or unallocatable)", n.Type().Elem())
} }
if n.Esc() == ir.EscNone { if n.Esc() == ir.EscNone {
if t.Size() >= ir.MaxImplicitStackVarSize { if t.Size() > ir.MaxImplicitStackVarSize {
base.Fatalf("large ONEW with EscNone: %v", n) base.Fatalf("large ONEW with EscNone: %v", n)
} }
return stackTempAddr(init, t) return stackTempAddr(init, t)