internal/sync: move sync.Mutex implementation into new package

This CL refactors sync.Mutex such that its implementation lives in the
new internal/sync package. The purpose of this change is to eventually
reverse the dependency edge between internal/concurrent and sync, such
that sync can depend on internal/concurrent (or really, its contents,
which will likely end up in internal/sync).

The only change made to the sync.Mutex code is the frame skip count for
mutex profiling, so that the internal/sync frames are omitted in the
profile.

Change-Id: Ib3603d30e8e71508c4ea883a584ae2e51ce40c3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/594056
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Michael Anthony Knyszek 2024-06-21 17:01:23 +00:00 committed by Gopher Robot
parent b5906ac4b7
commit 6c66005285
11 changed files with 348 additions and 236 deletions

View file

@ -1048,6 +1048,16 @@ func maps_fatal(s string) {
fatal(s)
}
//go:linkname internal_sync_throw internal/sync.throw
func internal_sync_throw(s string) {
throw(s)
}
//go:linkname internal_sync_fatal internal/sync.fatal
func internal_sync_fatal(s string) {
fatal(s)
}
// throw triggers a fatal error that dumps a stack trace and exits.
//
// throw should be used for runtime-internal fatal errors where Go itself,