diff options
| author | Michael Pratt <mpratt@google.com> | 2024-09-16 16:07:25 -0400 |
|---|---|---|
| committer | Michael Pratt <mpratt@google.com> | 2024-09-17 17:01:26 +0000 |
| commit | d1c3f255fda8b9bf86990b55353ca14fbfe5b257 (patch) | |
| tree | b652f4a29fb9af7e57c1d26b278be82c71a00e7d /src/runtime | |
| parent | 4f881115d4067bda8a236aabcae8c41cdd13b4d0 (diff) | |
| download | go-d1c3f255fda8b9bf86990b55353ca14fbfe5b257.tar.xz | |
runtime: move getclosureptr to internal/runtime/sys
Moving these intrinsics to a base package enables other internal/runtime
packages to use them.
There is no immediate need for getclosureptr outside of runtime, but it
is moved for consistency with the other intrinsics.
For #54766.
Change-Id: Ia68b16a938c8cb84cb222469db28e3a83861be5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/613262
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/alg.go | 3 | ||||
| -rw-r--r-- | src/runtime/stubs.go | 21 |
2 files changed, 2 insertions, 22 deletions
diff --git a/src/runtime/alg.go b/src/runtime/alg.go index 1c373b7f25..e183452fbe 100644 --- a/src/runtime/alg.go +++ b/src/runtime/alg.go @@ -8,6 +8,7 @@ import ( "internal/abi" "internal/cpu" "internal/goarch" + "internal/runtime/sys" "unsafe" ) @@ -34,7 +35,7 @@ func memhash128(p unsafe.Pointer, h uintptr) uintptr { //go:nosplit func memhash_varlen(p unsafe.Pointer, h uintptr) uintptr { - ptr := getclosureptr() + ptr := sys.GetClosurePtr() size := *(*uintptr)(unsafe.Pointer(ptr + unsafe.Sizeof(h))) return memhash(p, h, size) } diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go index 84f478db07..d334190976 100644 --- a/src/runtime/stubs.go +++ b/src/runtime/stubs.go @@ -307,27 +307,6 @@ func goexit(neverCallThisFunction) // data dependency ordering. func publicationBarrier() -// getclosureptr returns the pointer to the current closure. -// getclosureptr can only be used in an assignment statement -// at the entry of a function. Moreover, go:nosplit directive -// must be specified at the declaration of caller function, -// so that the function prolog does not clobber the closure register. -// for example: -// -// //go:nosplit -// func f(arg1, arg2, arg3 int) { -// dx := getclosureptr() -// } -// -// The compiler rewrites calls to this function into instructions that fetch the -// pointer from a well-known register (DX on x86 architecture, etc.) directly. -// -// WARNING: PGO-based devirtualization cannot detect that caller of -// getclosureptr require closure context, and thus must maintain a list of -// these functions, which is in -// cmd/compile/internal/devirtualize/pgo.maybeDevirtualizeFunctionCall. -func getclosureptr() uintptr - //go:noescape func asmcgocall(fn, arg unsafe.Pointer) int32 |
