]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: make stack value size threshold comparisons consistent
authorgo101 <tapir.liu@gmail.com>
Thu, 1 Jul 2021 14:25:45 +0000 (14:25 +0000)
committerKeith Randall <khr@golang.org>
Thu, 1 Jul 2021 17:07:36 +0000 (17:07 +0000)
Consistency is beautiful.

Change-Id: Ib110dcff0ce2fa87b5576c79cd79c83aab385a7c
GitHub-Last-Rev: b8758f8ae02cb025267aa87ebc5c2f9b4c32e742
GitHub-Pull-Request: golang/go#47011
Reviewed-on: https://go-review.googlesource.com/c/go/+/332230
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/compile/internal/escape/escape.go
src/cmd/compile/internal/walk/builtin.go

index 3ac7ff1ebe1a3c7e1c1560272cf7fbd95e33bd4f..cd56f07b6147a431cf0347e65c5c91df2d98d29d 100644 (file)
@@ -2013,14 +2013,14 @@ func HeapAllocReason(n ir.Node) string {
                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"
        }
 
-       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"
        }
-       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"
        }
 
@@ -2033,7 +2033,7 @@ func HeapAllocReason(n ir.Node) string {
                if !ir.IsSmallIntConst(r) {
                        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"
                }
        }
index 1f08e4d31283082fb7774d8639311a56a4ed106e..14efc05e32753727502e42f4e805ebe134522125 100644 (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())
        }
        if n.Esc() == ir.EscNone {
-               if t.Size() >= ir.MaxImplicitStackVarSize {
+               if t.Size() > ir.MaxImplicitStackVarSize {
                        base.Fatalf("large ONEW with EscNone: %v", n)
                }
                return stackTempAddr(init, t)