go/test/fixedbugs/issue27732a.go
David Chase 037ac2bd84 cmd/compile: add -smallframes gc flag for GC latency diagnosis
Shrinks the size of things that can be stack allocated from
10M to 128k for declared variables and from 64k to 16k for
implicit allocations (new(T), &T{}, etc).

Usage: "go build -gcflags -smallframes hello.go"

An earlier GOEXPERIMENT version of this caused only one
problem, when a gc-should-detect-oversize-stack test no
longer had an oversized stack to detect.  The change was
converted to a flag to make it easier to access (for
diagnosing "long" GC-related single-thread pauses) and to
remove interference with the test.

Includes test to verify behavior.

Updates #27732.

Change-Id: I1255d484331e77185e07c78389a8b594041204c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/180817
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-06 11:38:40 +00:00

24 lines
488 B
Go

// errorcheck -0 -m -l -smallframes -newescape=true
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This checks that the -smallframes flag forces a large variable to heap.
package main
const (
bufferLen = 200000
)
type kbyte []byte
type circularBuffer [bufferLen]kbyte
var sink byte
func main() {
var c circularBuffer // ERROR "moved to heap: c$"
sink = c[0][0]
}