aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2024-10-25 15:08:54 -0400
committerGopher Robot <gobot@golang.org>2024-10-30 15:43:54 +0000
commit63ba2b9d84dede1df107db30b4ff8139711402eb (patch)
treeab604c55740391f9205499bd0745685191a91020 /test
parentaefb173b0a1c1edfdd631b8b4ac752b947ab80a8 (diff)
downloadgo-63ba2b9d84dede1df107db30b4ff8139711402eb.tar.xz
cmd/compile,internal/runtime/maps: stack allocated maps and small alloc
The compiler will stack allocate the Map struct and initial group if possible. Stack maps are initialized inline without calling into the runtime. Small heap allocated maps use makemap_small. These are the same heuristics as existing maps. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: I6c371d1309716fd1c38a3212d417b3c76db5c9b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/622042 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/live.go10
-rw-r--r--test/live_noswiss.go32
-rw-r--r--test/live_regabi.go10
-rw-r--r--test/live_regabi_noswiss.go31
-rw-r--r--test/live_regabi_swiss.go31
-rw-r--r--test/live_swiss.go32
6 files changed, 20 insertions, 126 deletions
diff --git a/test/live.go b/test/live.go
index aef7c50c64..250a77cdac 100644
--- a/test/live.go
+++ b/test/live.go
@@ -659,6 +659,16 @@ func newT40() *T40 {
return &ret
}
+func good40() {
+ ret := T40{} // ERROR "stack object ret T40$"
+ ret.m = make(map[int]int) // ERROR "live at call to rand(32)?: .autotmp_[0-9]+$" "stack object .autotmp_[0-9]+ (runtime.hmap|internal/runtime/maps.Map)$"
+ t := &ret
+ printnl() // ERROR "live at call to printnl: ret$"
+ // Note: ret is live at the printnl because the compiler moves &ret
+ // from before the printnl to after.
+ useT40(t)
+}
+
func bad40() {
t := newT40()
_ = t
diff --git a/test/live_noswiss.go b/test/live_noswiss.go
deleted file mode 100644
index e72073196a..0000000000
--- a/test/live_noswiss.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
-
-//go:build !goexperiment.swissmap && !goexperiment.regabiargs
-
-// For register ABI, liveness info changes slightly. See live_regabi.go.
-
-// Copyright 2024 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.
-
-// non-swissmap-specific tests for live.go
-
-package main
-
-func printnl()
-
-type T40 struct {
- m map[int]int
-}
-
-//go:noescape
-func useT40(*T40)
-
-func good40() {
- ret := T40{} // ERROR "stack object ret T40$"
- ret.m = make(map[int]int) // ERROR "live at call to rand32: .autotmp_[0-9]+$" "stack object .autotmp_[0-9]+ runtime.hmap$"
- t := &ret
- printnl() // ERROR "live at call to printnl: ret$"
- // Note: ret is live at the printnl because the compiler moves &ret
- // from before the printnl to after.
- useT40(t)
-}
diff --git a/test/live_regabi.go b/test/live_regabi.go
index 196294a138..090e2ec577 100644
--- a/test/live_regabi.go
+++ b/test/live_regabi.go
@@ -657,6 +657,16 @@ func newT40() *T40 {
return &ret
}
+func good40() {
+ ret := T40{} // ERROR "stack object ret T40$"
+ ret.m = make(map[int]int) // ERROR "live at call to rand(32)?: .autotmp_[0-9]+$" "stack object .autotmp_[0-9]+ (runtime.hmap|internal/runtime/maps.Map)$"
+ t := &ret
+ printnl() // ERROR "live at call to printnl: ret$"
+ // Note: ret is live at the printnl because the compiler moves &ret
+ // from before the printnl to after.
+ useT40(t)
+}
+
func bad40() {
t := newT40()
_ = t
diff --git a/test/live_regabi_noswiss.go b/test/live_regabi_noswiss.go
deleted file mode 100644
index 6404d65d27..0000000000
--- a/test/live_regabi_noswiss.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
-
-//go:build !goexperiment.swissmap && ((amd64 && goexperiment.regabiargs) || (arm64 && goexperiment.regabiargs))
-
-// Copyright 2024 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.
-
-// non-swissmap-specific tests for live_regabi.go
-// TODO(#54766): temporary while fast variants are disabled.
-
-package main
-
-func printnl()
-
-type T40 struct {
- m map[int]int
-}
-
-//go:noescape
-func useT40(*T40)
-
-func good40() {
- ret := T40{} // ERROR "stack object ret T40$"
- ret.m = make(map[int]int) // ERROR "live at call to rand32: .autotmp_[0-9]+$" "stack object .autotmp_[0-9]+ runtime.hmap$"
- t := &ret
- printnl() // ERROR "live at call to printnl: ret$"
- // Note: ret is live at the printnl because the compiler moves &ret
- // from before the printnl to after.
- useT40(t)
-}
diff --git a/test/live_regabi_swiss.go b/test/live_regabi_swiss.go
deleted file mode 100644
index ef347d27f8..0000000000
--- a/test/live_regabi_swiss.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
-
-//go:build goexperiment.swissmap && ((amd64 && goexperiment.regabiargs) || (arm64 && goexperiment.regabiargs))
-
-// Copyright 2024 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.
-
-// swissmap-specific tests for live_regabi.go
-// TODO(#54766): temporary while fast variants are disabled.
-
-package main
-
-func printnl()
-
-type T40 struct {
- m map[int]int
-}
-
-//go:noescape
-func useT40(*T40)
-
-func good40() {
- ret := T40{} // ERROR "stack object ret T40$"
- ret.m = make(map[int]int) // ERROR "stack object .autotmp_[0-9]+ internal/runtime/maps.Map$"
- t := &ret
- printnl() // ERROR "live at call to printnl: ret$"
- // Note: ret is live at the printnl because the compiler moves &ret
- // from before the printnl to after.
- useT40(t)
-}
diff --git a/test/live_swiss.go b/test/live_swiss.go
deleted file mode 100644
index eacd23ab5a..0000000000
--- a/test/live_swiss.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// errorcheckwithauto -0 -l -live -wb=0 -d=ssa/insert_resched_checks/off
-
-//go:build goexperiment.swissmap && !goexperiment.regabiargs
-
-// For register ABI, liveness info changes slightly. See live_regabi.go.
-
-// Copyright 2024 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.
-
-// swissmap-specific tests for live.go
-
-package main
-
-func printnl()
-
-type T40 struct {
- m map[int]int
-}
-
-//go:noescape
-func useT40(*T40)
-
-func good40() {
- ret := T40{} // ERROR "stack object ret T40$"
- ret.m = make(map[int]int) // ERROR "stack object .autotmp_[0-9]+ internal/runtime/maps.Map$"
- t := &ret
- printnl() // ERROR "live at call to printnl: ret$"
- // Note: ret is live at the printnl because the compiler moves &ret
- // from before the printnl to after.
- useT40(t)
-}