mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/gc: move check for large-hence-heap-allocated types into escape analysis
Before this change, the check for too-large arrays (and other large types) occurred after escape analysis. If the data moved off stack and onto the heap contained any pointers, it would therefore escape, but because the too-large check occurred after escape analysis this would not be recorded and a stack pointer would leak to the heap (see the modified escape_array.go for an example). Some of these appear to remain, in calls to typecheck from within walk. Also corrected a few comments in escape_array.go about "BAD" analysis that is now done correctly. Enhanced to move aditional EscNone-but-large-so-heap checks into esc.c. Change-Id: I770c111baff28a9ed5f8beb601cf09dacc561b83 Reviewed-on: https://go-review.googlesource.com/10268 Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
b19ec6842d
commit
e5060c7f75
6 changed files with 96 additions and 35 deletions
|
|
@ -301,25 +301,6 @@ func allocauto(ptxt *obj.Prog) {
|
|||
}
|
||||
}
|
||||
|
||||
func movelarge(l *NodeList) {
|
||||
for ; l != nil; l = l.Next {
|
||||
if l.N.Op == ODCLFUNC {
|
||||
movelargefn(l.N)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func movelargefn(fn *Node) {
|
||||
var n *Node
|
||||
|
||||
for l := fn.Func.Dcl; l != nil; l = l.Next {
|
||||
n = l.N
|
||||
if n.Class == PAUTO && n.Type != nil && n.Type.Width > MaxStackVarSize {
|
||||
addrescapes(n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func Cgen_checknil(n *Node) {
|
||||
if Disable_checknil != 0 {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue