diff options
| author | David Chase <drchase@google.com> | 2023-01-13 16:12:47 -0500 |
|---|---|---|
| committer | David Chase <drchase@google.com> | 2023-01-23 15:51:32 +0000 |
| commit | e22bd2348c8e3bfdf12197d0b0e194b66bbf5a36 (patch) | |
| tree | 0c61869dae136d804b1e82091fc562cde4bf7efe /src/internal | |
| parent | e2fe35363d070bf37326d04ed28964e6ba3892da (diff) | |
| download | go-e22bd2348c8e3bfdf12197d0b0e194b66bbf5a36.tar.xz | |
internal/abi,runtime: refactor map constants into one place
Previously TryBot-tested with bucket bits = 4.
Also tested locally with bucket bits = 5.
This makes it much easier to change the size of map
buckets, and hopefully provides pointers to all the
code that in some way depends on details of map layout.
Change-Id: I9f6669d1eadd02f182d0bc3f959dc5f385fa1683
Reviewed-on: https://go-review.googlesource.com/c/go/+/462115
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/internal')
| -rw-r--r-- | src/internal/abi/abi.go | 24 | ||||
| -rw-r--r-- | src/internal/abi/funcpc.go | 35 | ||||
| -rw-r--r-- | src/internal/abi/map.go | 14 |
3 files changed, 49 insertions, 24 deletions
diff --git a/src/internal/abi/abi.go b/src/internal/abi/abi.go index 11acac346f..e1c8adccc7 100644 --- a/src/internal/abi/abi.go +++ b/src/internal/abi/abi.go @@ -100,27 +100,3 @@ func (b *IntArgRegBitmap) Set(i int) { func (b *IntArgRegBitmap) Get(i int) bool { return b[i/8]&(uint8(1)<<(i%8)) != 0 } - -// FuncPC* intrinsics. -// -// CAREFUL: In programs with plugins, FuncPC* can return different values -// for the same function (because there are actually multiple copies of -// the same function in the address space). To be safe, don't use the -// results of this function in any == expression. It is only safe to -// use the result as an address at which to start executing code. - -// FuncPCABI0 returns the entry PC of the function f, which must be a -// direct reference of a function defined as ABI0. Otherwise it is a -// compile-time error. -// -// Implemented as a compile intrinsic. -func FuncPCABI0(f any) uintptr - -// FuncPCABIInternal returns the entry PC of the function f. If f is a -// direct reference of a function, it must be defined as ABIInternal. -// Otherwise it is a compile-time error. If f is not a direct reference -// of a defined function, it assumes that f is a func value. Otherwise -// the behavior is undefined. -// -// Implemented as a compile intrinsic. -func FuncPCABIInternal(f any) uintptr diff --git a/src/internal/abi/funcpc.go b/src/internal/abi/funcpc.go new file mode 100644 index 0000000000..f617e2d757 --- /dev/null +++ b/src/internal/abi/funcpc.go @@ -0,0 +1,35 @@ +// Copyright 2023 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. + +//go:build !compiler_bootstrap +// +build !compiler_bootstrap + +package abi + +// The bootstrapping compiler doesn't understand "any" in the function signatures, +// and also does not implement these intrinsics. + +// FuncPC* intrinsics. +// +// CAREFUL: In programs with plugins, FuncPC* can return different values +// for the same function (because there are actually multiple copies of +// the same function in the address space). To be safe, don't use the +// results of this function in any == expression. It is only safe to +// use the result as an address at which to start executing code. + +// FuncPCABI0 returns the entry PC of the function f, which must be a +// direct reference of a function defined as ABI0. Otherwise it is a +// compile-time error. +// +// Implemented as a compile intrinsic. +func FuncPCABI0(f any) uintptr + +// FuncPCABIInternal returns the entry PC of the function f. If f is a +// direct reference of a function, it must be defined as ABIInternal. +// Otherwise it is a compile-time error. If f is not a direct reference +// of a defined function, it assumes that f is a func value. Otherwise +// the behavior is undefined. +// +// Implemented as a compile intrinsic. +func FuncPCABIInternal(f any) uintptr diff --git a/src/internal/abi/map.go b/src/internal/abi/map.go new file mode 100644 index 0000000000..e5b0a0bb6f --- /dev/null +++ b/src/internal/abi/map.go @@ -0,0 +1,14 @@ +// Copyright 2023 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. + +package abi + +// Map constants common to several packages +// runtime/runtime-gdb.py:MapTypePrinter contains its own copy +const ( + MapBucketCountBits = 3 // log2 of number of elements in a bucket. + MapBucketCount = 1 << MapBucketCountBits + MapMaxKeyBytes = 128 // Must fit in a uint8. + MapMaxElemBytes = 128 // Must fit in a uint8. +) |
