From a30f8d1e69238984fcb43fbd9d1c64d46602f6dd Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 29 Nov 2018 09:47:11 -0800 Subject: [PATCH] doc: add relnotes for stack objects and mid-stack inlining Change-Id: Ief11612b67def93311707165910124d3ce28fb89 Reviewed-on: https://go-review.googlesource.com/c/151777 Reviewed-by: Brad Fitzpatrick --- doc/go1.12.html | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/go1.12.html b/doc/go1.12.html index 7a2a50bacc..9a5d4bc621 100644 --- a/doc/go1.12.html +++ b/doc/go1.12.html @@ -66,6 +66,48 @@ Go 1.13 will require macOS 10.11 El Capitan or later. has no effect in Go 1.12.

+

Compiler toolchain

+ +

+ The compiler's live variable analysis has improved. This may mean that + finalizers will be executed sooner in this release than in previous + releases. If that is a problem, consider the appropriate addition of a + runtime.KeepAlive call. +

+ +

+ More functions are now eligible for inlining by default, including + functions that do nothing but call another function. + This extra inlining makes it additionally important to use + runtime.CallersFrames + instead of iterating over the result of + runtime.Callers directly. +

+// Old code which no longer works correctly (it will miss inlined call frames).
+var pcs [10]uintptr
+n := runtime.Callers(1, pcs[:])
+for _, pc := range pcs[:n] {
+	f := runtime.FuncForPC(pc)
+	if f != nil {
+		fmt.Println(f.Name())
+	}
+}
+
+
+// New code which will work correctly.
+var pcs [10]uintptr
+n := runtime.Callers(1, pcs[:])
+frames := runtime.CallersFrames(pcs[:n])
+for {
+	frame, more := frames.Next()
+	fmt.Println(frame.Function)
+	if !more {
+		break
+	}
+}
+
+

+

Godoc

-- 2.50.0