From fc5073bc155545dde4856cccdfcbb31880d1eb66 Mon Sep 17 00:00:00 2001 From: David Chase Date: Tue, 23 Jul 2024 11:43:23 -0400 Subject: runtime,internal: move runtime/internal/sys to internal/runtime/sys Cleanup and friction reduction For #65355. Change-Id: Ia14c9dc584a529a35b97801dd3e95b9acc99a511 Reviewed-on: https://go-review.googlesource.com/c/go/+/600436 Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- src/cmd/compile/internal/noder/helpers.go | 4 +- src/cmd/compile/internal/ssagen/ssa.go | 26 ++-- src/cmd/compile/internal/test/inl_test.go | 8 +- src/cmd/compile/internal/types/pkg.go | 2 +- src/cmd/compile/internal/types/type.go | 2 +- src/cmd/dist/build.go | 4 +- src/cmd/distpack/pack.go | 2 +- src/cmd/distpack/test.go | 2 +- src/cmd/go/go_test.go | 6 +- src/cmd/internal/objabi/pkgspecial.go | 2 +- src/cmd/internal/objabi/stack.go | 2 +- src/go/build/deps_test.go | 2 +- src/internal/coverage/pkid.go | 4 +- src/internal/runtime/sys/consts.go | 36 +++++ src/internal/runtime/sys/consts_norace.go | 9 ++ src/internal/runtime/sys/consts_race.go | 9 ++ src/internal/runtime/sys/intrinsics.go | 208 ++++++++++++++++++++++++++++ src/internal/runtime/sys/intrinsics_test.go | 42 ++++++ src/internal/runtime/sys/nih.go | 41 ++++++ src/internal/runtime/sys/sys.go | 7 + src/reflect/deepequal.go | 2 +- src/runtime/HACKING.md | 2 +- src/runtime/arena.go | 2 +- src/runtime/cgo/cgo.go | 2 +- src/runtime/cgocall.go | 2 +- src/runtime/cpuprof.go | 2 +- src/runtime/debuglog.go | 2 +- src/runtime/export_test.go | 2 +- src/runtime/histogram.go | 2 +- src/runtime/iface.go | 2 +- src/runtime/internal/sys/consts.go | 36 ----- src/runtime/internal/sys/consts_norace.go | 9 -- src/runtime/internal/sys/consts_race.go | 9 -- src/runtime/internal/sys/intrinsics.go | 208 ---------------------------- src/runtime/internal/sys/intrinsics_test.go | 42 ------ src/runtime/internal/sys/nih.go | 41 ------ src/runtime/internal/sys/sys.go | 7 - src/runtime/malloc.go | 6 +- src/runtime/mbitmap.go | 2 +- src/runtime/mcache.go | 2 +- src/runtime/mcentral.go | 2 +- src/runtime/mcheckmark.go | 2 +- src/runtime/mfinal.go | 2 +- src/runtime/mfixalloc.go | 4 +- src/runtime/mgcmark.go | 2 +- src/runtime/mgcscavenge.go | 2 +- src/runtime/mgcstack.go | 2 +- src/runtime/mgcwork.go | 2 +- src/runtime/mheap.go | 2 +- src/runtime/mpagecache.go | 2 +- src/runtime/mpallocbits.go | 2 +- src/runtime/mprof.go | 2 +- src/runtime/netpoll.go | 4 +- src/runtime/panic.go | 2 +- src/runtime/proc.go | 2 +- src/runtime/runtime2.go | 2 +- src/runtime/signal_arm64.go | 2 +- src/runtime/signal_linux_s390x.go | 2 +- src/runtime/signal_mipsx.go | 2 +- src/runtime/signal_ppc64x.go | 2 +- src/runtime/signal_unix.go | 2 +- src/runtime/signal_windows.go | 2 +- src/runtime/slice.go | 4 +- src/runtime/stack.go | 2 +- src/runtime/stkframe.go | 2 +- src/runtime/symtab.go | 2 +- src/runtime/symtabinl_test.go | 2 +- src/runtime/sys_wasm.go | 2 +- src/runtime/time.go | 2 +- src/runtime/traceallocfree.go | 2 +- src/runtime/traceback.go | 2 +- src/runtime/tracebuf.go | 2 +- src/runtime/traceevent.go | 2 +- src/runtime/tracemap.go | 2 +- src/runtime/traceregion.go | 2 +- 75 files changed, 438 insertions(+), 438 deletions(-) create mode 100644 src/internal/runtime/sys/consts.go create mode 100644 src/internal/runtime/sys/consts_norace.go create mode 100644 src/internal/runtime/sys/consts_race.go create mode 100644 src/internal/runtime/sys/intrinsics.go create mode 100644 src/internal/runtime/sys/intrinsics_test.go create mode 100644 src/internal/runtime/sys/nih.go create mode 100644 src/internal/runtime/sys/sys.go delete mode 100644 src/runtime/internal/sys/consts.go delete mode 100644 src/runtime/internal/sys/consts_norace.go delete mode 100644 src/runtime/internal/sys/consts_race.go delete mode 100644 src/runtime/internal/sys/intrinsics.go delete mode 100644 src/runtime/internal/sys/intrinsics_test.go delete mode 100644 src/runtime/internal/sys/nih.go delete mode 100644 src/runtime/internal/sys/sys.go (limited to 'src') diff --git a/src/cmd/compile/internal/noder/helpers.go b/src/cmd/compile/internal/noder/helpers.go index 0bff71e658..45512706d2 100644 --- a/src/cmd/compile/internal/noder/helpers.go +++ b/src/cmd/compile/internal/noder/helpers.go @@ -114,11 +114,11 @@ func isTypeParam(t types2.Type) bool { } // isNotInHeap reports whether typ is or contains an element of type -// runtime/internal/sys.NotInHeap. +// internal/runtime/sys.NotInHeap. func isNotInHeap(typ types2.Type) bool { typ = types2.Unalias(typ) if named, ok := typ.(*types2.Named); ok { - if obj := named.Obj(); obj.Name() == "nih" && obj.Pkg().Path() == "runtime/internal/sys" { + if obj := named.Obj(); obj.Name() == "nih" && obj.Pkg().Path() == "internal/runtime/sys" { return true } typ = named.Underlying() diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index d0ca5b7f30..e6d5a13957 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -4287,13 +4287,13 @@ func InitTables() { // make it worthwhile as an intrinsic brev_arch = append(brev_arch, sys.PPC64) } - /******** runtime/internal/sys ********/ - addF("runtime/internal/sys", "Bswap32", + /******** internal/runtime/sys ********/ + addF("internal/runtime/sys", "Bswap32", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return s.newValue1(ssa.OpBswap32, types.Types[types.TUINT32], args[0]) }, brev_arch...) - addF("runtime/internal/sys", "Bswap64", + addF("internal/runtime/sys", "Bswap64", func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value { return s.newValue1(ssa.OpBswap64, types.Types[types.TUINT64], args[0]) }, @@ -4309,9 +4309,9 @@ func InitTables() { // Make Prefetch intrinsics for supported platforms // On the unsupported platforms stub function will be eliminated - addF("runtime/internal/sys", "Prefetch", makePrefetchFunc(ssa.OpPrefetchCache), + addF("internal/runtime/sys", "Prefetch", makePrefetchFunc(ssa.OpPrefetchCache), sys.AMD64, sys.ARM64, sys.PPC64) - addF("runtime/internal/sys", "PrefetchStreamed", makePrefetchFunc(ssa.OpPrefetchCacheStreamed), + addF("internal/runtime/sys", "PrefetchStreamed", makePrefetchFunc(ssa.OpPrefetchCacheStreamed), sys.AMD64, sys.ARM64, sys.PPC64) /******** internal/runtime/atomic ********/ @@ -4837,8 +4837,8 @@ func InitTables() { return s.newValue1(ssa.OpCtz64, types.Types[types.TINT], y) }, sys.S390X) - alias("math/bits", "ReverseBytes64", "runtime/internal/sys", "Bswap64", all...) - alias("math/bits", "ReverseBytes32", "runtime/internal/sys", "Bswap32", all...) + alias("math/bits", "ReverseBytes64", "internal/runtime/sys", "Bswap64", all...) + alias("math/bits", "ReverseBytes32", "internal/runtime/sys", "Bswap32", all...) // ReverseBytes inlines correctly, no need to intrinsify it. // Nothing special is needed for targets where ReverseBytes16 lowers to a rotate // On Power10, 16-bit rotate is not available so use BRH instruction @@ -5051,12 +5051,12 @@ func InitTables() { sys.AMD64) alias("math/bits", "Div", "math/bits", "Div64", sys.ArchAMD64) - alias("runtime/internal/sys", "TrailingZeros8", "math/bits", "TrailingZeros8", all...) - alias("runtime/internal/sys", "TrailingZeros32", "math/bits", "TrailingZeros32", all...) - alias("runtime/internal/sys", "TrailingZeros64", "math/bits", "TrailingZeros64", all...) - alias("runtime/internal/sys", "Len8", "math/bits", "Len8", all...) - alias("runtime/internal/sys", "Len64", "math/bits", "Len64", all...) - alias("runtime/internal/sys", "OnesCount64", "math/bits", "OnesCount64", all...) + alias("internal/runtime/sys", "TrailingZeros8", "math/bits", "TrailingZeros8", all...) + alias("internal/runtime/sys", "TrailingZeros32", "math/bits", "TrailingZeros32", all...) + alias("internal/runtime/sys", "TrailingZeros64", "math/bits", "TrailingZeros64", all...) + alias("internal/runtime/sys", "Len8", "math/bits", "Len8", all...) + alias("internal/runtime/sys", "Len64", "math/bits", "Len64", all...) + alias("internal/runtime/sys", "OnesCount64", "math/bits", "OnesCount64", all...) /******** sync/atomic ********/ diff --git a/src/cmd/compile/internal/test/inl_test.go b/src/cmd/compile/internal/test/inl_test.go index 4626269582..58f5df953b 100644 --- a/src/cmd/compile/internal/test/inl_test.go +++ b/src/cmd/compile/internal/test/inl_test.go @@ -97,7 +97,7 @@ func TestIntendedInlining(t *testing.T) { "traceLocker.ok", "traceEnabled", }, - "runtime/internal/sys": {}, + "internal/runtime/sys": {}, "internal/runtime/math": { "MulUintptr", }, @@ -246,9 +246,9 @@ func TestIntendedInlining(t *testing.T) { if runtime.GOARCH != "386" { // As explained above, TrailingZeros64 and TrailingZeros32 are not Go code on 386. // The same applies to Bswap32. - want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "TrailingZeros64") - want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "TrailingZeros32") - want["runtime/internal/sys"] = append(want["runtime/internal/sys"], "Bswap32") + want["internal/runtime/sys"] = append(want["internal/runtime/sys"], "TrailingZeros64") + want["internal/runtime/sys"] = append(want["internal/runtime/sys"], "TrailingZeros32") + want["internal/runtime/sys"] = append(want["internal/runtime/sys"], "Bswap32") } if runtime.GOARCH == "amd64" || runtime.GOARCH == "arm64" || runtime.GOARCH == "loong64" || runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "riscv64" || runtime.GOARCH == "s390x" { // internal/runtime/atomic.Loaduintptr is only intrinsified on these platforms. diff --git a/src/cmd/compile/internal/types/pkg.go b/src/cmd/compile/internal/types/pkg.go index c6ce7889af..9f64b84db4 100644 --- a/src/cmd/compile/internal/types/pkg.go +++ b/src/cmd/compile/internal/types/pkg.go @@ -16,7 +16,7 @@ import ( var pkgMap = make(map[string]*Pkg) type Pkg struct { - Path string // string literal used in import statement, e.g. "runtime/internal/sys" + Path string // string literal used in import statement, e.g. "internal/runtime/sys" Name string // package name, e.g. "sys" Prefix string // escaped path for use in symbol table Syms map[string]*Sym diff --git a/src/cmd/compile/internal/types/type.go b/src/cmd/compile/internal/types/type.go index 88052dc97b..41fdefe830 100644 --- a/src/cmd/compile/internal/types/type.go +++ b/src/cmd/compile/internal/types/type.go @@ -1650,7 +1650,7 @@ func NewNamed(obj Object) *Type { t.SetIsShape(true) t.SetHasShape(true) } - if sym.Pkg.Path == "runtime/internal/sys" && sym.Name == "nih" { + if sym.Pkg.Path == "internal/runtime/sys" && sym.Name == "nih" { // Recognize the special not-in-heap type. Any type including // this type will also be not-in-heap. // This logic is duplicated in go/types and diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index c033beabdb..910d5290e5 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -639,7 +639,7 @@ var gentab = []struct { }{ {"go/build", "zcgo.go", mkzcgo}, {"cmd/go/internal/cfg", "zdefaultcc.go", mkzdefaultcc}, - {"runtime/internal/sys", "zversion.go", mkzversion}, + {"internal/runtime/sys", "zversion.go", mkzversion}, {"time/tzdata", "zzipdata.go", mktzdata}, } @@ -1707,7 +1707,7 @@ func checkNotStale(env []string, goBinary string, targets ...string) { out := runEnv(workdir, CheckExit, env, append(goCmd, targets...)...) if strings.Contains(out, "\tSTALE ") { os.Setenv("GODEBUG", "gocachehash=1") - for _, target := range []string{"runtime/internal/sys", "cmd/dist", "cmd/link"} { + for _, target := range []string{"internal/runtime/sys", "cmd/dist", "cmd/link"} { if strings.Contains(out, "STALE "+target) { run(workdir, ShowOutput|CheckExit, goBinary, "list", "-f={{.ImportPath}} {{.Stale}}", target) break diff --git a/src/cmd/distpack/pack.go b/src/cmd/distpack/pack.go index 5525249366..a4f18da8bd 100644 --- a/src/cmd/distpack/pack.go +++ b/src/cmd/distpack/pack.go @@ -132,7 +132,7 @@ func main() { // Generated during cmd/dist. See ../dist/build.go:/gentab. "src/cmd/go/internal/cfg/zdefaultcc.go", "src/go/build/zcgo.go", - "src/runtime/internal/sys/zversion.go", + "src/internal/runtime/sys/zversion.go", "src/time/tzdata/zzipdata.go", // Generated during cmd/dist by bootstrapBuildTools. diff --git a/src/cmd/distpack/test.go b/src/cmd/distpack/test.go index 22b54b5fe1..108907d0e6 100644 --- a/src/cmd/distpack/test.go +++ b/src/cmd/distpack/test.go @@ -35,7 +35,7 @@ var srcRules = []testRule{ {name: "go/pkg/**", exclude: true}, {name: "go/src/cmd/dist/dist", exclude: true}, {name: "go/src/cmd/dist/dist.exe", exclude: true}, - {name: "go/src/runtime/internal/sys/zversion.go", exclude: true}, + {name: "go/src/internal/runtime/sys/zversion.go", exclude: true}, {name: "go/src/time/tzdata/zzipdata.go", exclude: true}, } diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index b45a905880..5720a397f7 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -943,14 +943,14 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) { tg.run("install", "p1") tg.wantNotStale("p1", "", "./testgo list claims p1 is stale, incorrectly, before any changes") - // Changing mtime of runtime/internal/sys/sys.go + // Changing mtime of internal/runtime/sys/sys.go // should have no effect: only the content matters. // In fact this should be true even outside a release branch. - sys := tg.path("goroot/src/runtime/internal/sys/sys.go") + sys := tg.path("goroot/src/internal/runtime/sys/sys.go") tg.sleep() restore := addVar(sys, 0) restore() - tg.wantNotStale("p1", "", "./testgo list claims p1 is stale, incorrectly, after updating mtime of runtime/internal/sys/sys.go") + tg.wantNotStale("p1", "", "./testgo list claims p1 is stale, incorrectly, after updating mtime of internal/runtime/sys/sys.go") // But changing content of any file should have an effect. // Previously zversion.go was the only one that mattered; diff --git a/src/cmd/internal/objabi/pkgspecial.go b/src/cmd/internal/objabi/pkgspecial.go index 2772226c93..f288096a02 100644 --- a/src/cmd/internal/objabi/pkgspecial.go +++ b/src/cmd/internal/objabi/pkgspecial.go @@ -48,7 +48,7 @@ var runtimePkgs = []string{ "internal/runtime/atomic", "internal/runtime/exithook", "internal/runtime/math", - "runtime/internal/sys", + "internal/runtime/sys", "internal/runtime/syscall", "internal/abi", diff --git a/src/cmd/internal/objabi/stack.go b/src/cmd/internal/objabi/stack.go index 7c7ff4e058..d50a7c1afd 100644 --- a/src/cmd/internal/objabi/stack.go +++ b/src/cmd/internal/objabi/stack.go @@ -18,7 +18,7 @@ func StackNosplit(race bool) int { // stack guard size. Larger multipliers are used for non-optimized // builds that have larger stack frames or for specific targets. func stackGuardMultiplier(race bool) int { - // This arithmetic must match that in runtime/internal/sys/consts.go:StackGuardMultiplier. + // This arithmetic must match that in internal/runtime/sys/consts.go:StackGuardMultiplier. n := 1 // On AIX, a larger stack is needed for syscalls. if buildcfg.GOOS == "aix" { diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go index 9e22955eda..a0bcb4f27a 100644 --- a/src/go/build/deps_test.go +++ b/src/go/build/deps_test.go @@ -83,7 +83,7 @@ var depsRules = ` < internal/stringslite < internal/itoa < internal/unsafeheader - < runtime/internal/sys + < internal/runtime/sys < internal/runtime/syscall < internal/runtime/atomic < internal/runtime/exithook diff --git a/src/internal/coverage/pkid.go b/src/internal/coverage/pkid.go index a764cc4205..46de9fd0ce 100644 --- a/src/internal/coverage/pkid.go +++ b/src/internal/coverage/pkid.go @@ -26,7 +26,7 @@ package coverage // slot: 1 path='internal/goarch' hard-coded id: 2 // slot: 2 path='internal/runtime/atomic' hard-coded id: 3 // slot: 3 path='internal/goos' -// slot: 4 path='runtime/internal/sys' hard-coded id: 5 +// slot: 4 path='internal/runtime/sys' hard-coded id: 5 // slot: 5 path='internal/abi' hard-coded id: 4 // slot: 6 path='internal/runtime/math' hard-coded id: 6 // slot: 7 path='internal/bytealg' hard-coded id: 7 @@ -50,7 +50,7 @@ var rtPkgs = [...]string{ "internal/runtime/atomic", "internal/goos", "internal/chacha8rand", - "runtime/internal/sys", + "internal/runtime/sys", "internal/abi", "internal/runtime/math", "internal/bytealg", diff --git a/src/internal/runtime/sys/consts.go b/src/internal/runtime/sys/consts.go new file mode 100644 index 0000000000..98c0f09ef1 --- /dev/null +++ b/src/internal/runtime/sys/consts.go @@ -0,0 +1,36 @@ +// Copyright 2014 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 sys + +import ( + "internal/goarch" + "internal/goos" +) + +// AIX requires a larger stack for syscalls. +// The race build also needs more stack. See issue 54291. +// This arithmetic must match that in cmd/internal/objabi/stack.go:stackGuardMultiplier. +const StackGuardMultiplier = 1 + goos.IsAix + isRace + +// DefaultPhysPageSize is the default physical page size. +const DefaultPhysPageSize = goarch.DefaultPhysPageSize + +// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems). +// The various PC tables record PC deltas pre-divided by PCQuantum. +const PCQuantum = goarch.PCQuantum + +// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit). +const Int64Align = goarch.PtrSize + +// MinFrameSize is the size of the system-reserved words at the bottom +// of a frame (just above the architectural stack pointer). +// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems. +// On PowerPC it is larger, to cover three more reserved words: +// the compiler word, the link editor word, and the TOC save word. +const MinFrameSize = goarch.MinFrameSize + +// StackAlign is the required alignment of the SP register. +// The stack must be at least word aligned, but some architectures require more. +const StackAlign = goarch.StackAlign diff --git a/src/internal/runtime/sys/consts_norace.go b/src/internal/runtime/sys/consts_norace.go new file mode 100644 index 0000000000..a9613b8843 --- /dev/null +++ b/src/internal/runtime/sys/consts_norace.go @@ -0,0 +1,9 @@ +// Copyright 2022 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 !race + +package sys + +const isRace = 0 diff --git a/src/internal/runtime/sys/consts_race.go b/src/internal/runtime/sys/consts_race.go new file mode 100644 index 0000000000..f824fb39d3 --- /dev/null +++ b/src/internal/runtime/sys/consts_race.go @@ -0,0 +1,9 @@ +// Copyright 2022 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 race + +package sys + +const isRace = 1 diff --git a/src/internal/runtime/sys/intrinsics.go b/src/internal/runtime/sys/intrinsics.go new file mode 100644 index 0000000000..e6a3758447 --- /dev/null +++ b/src/internal/runtime/sys/intrinsics.go @@ -0,0 +1,208 @@ +// Copyright 2016 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 sys + +// Copied from math/bits to avoid dependence. + +var deBruijn32tab = [32]byte{ + 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, +} + +const deBruijn32 = 0x077CB531 + +var deBruijn64tab = [64]byte{ + 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, + 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, + 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, + 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6, +} + +const deBruijn64 = 0x03f79d71b4ca8b09 + +const ntz8tab = "" + + "\x08\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x06\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x07\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x06\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + + "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + +// TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0. +func TrailingZeros32(x uint32) int { + if x == 0 { + return 32 + } + // see comment in TrailingZeros64 + return int(deBruijn32tab[(x&-x)*deBruijn32>>(32-5)]) +} + +// TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0. +func TrailingZeros64(x uint64) int { + if x == 0 { + return 64 + } + // If popcount is fast, replace code below with return popcount(^x & (x - 1)). + // + // x & -x leaves only the right-most bit set in the word. Let k be the + // index of that bit. Since only a single bit is set, the value is two + // to the power of k. Multiplying by a power of two is equivalent to + // left shifting, in this case by k bits. The de Bruijn (64 bit) constant + // is such that all six bit, consecutive substrings are distinct. + // Therefore, if we have a left shifted version of this constant we can + // find by how many bits it was shifted by looking at which six bit + // substring ended up at the top of the word. + // (Knuth, volume 4, section 7.3.1) + return int(deBruijn64tab[(x&-x)*deBruijn64>>(64-6)]) +} + +// TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0. +func TrailingZeros8(x uint8) int { + return int(ntz8tab[x]) +} + +const len8tab = "" + + "\x00\x01\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04" + + "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05" + + "\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06" + + "\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06" + + "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + + "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + + "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + + "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + + "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + +// Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0. +// +// nosplit because this is used in src/runtime/histogram.go, which make run in sensitive contexts. +// +//go:nosplit +func Len64(x uint64) (n int) { + if x >= 1<<32 { + x >>= 32 + n = 32 + } + if x >= 1<<16 { + x >>= 16 + n += 16 + } + if x >= 1<<8 { + x >>= 8 + n += 8 + } + return n + int(len8tab[x]) +} + +// --- OnesCount --- + +const m0 = 0x5555555555555555 // 01010101 ... +const m1 = 0x3333333333333333 // 00110011 ... +const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... + +// OnesCount64 returns the number of one bits ("population count") in x. +func OnesCount64(x uint64) int { + // Implementation: Parallel summing of adjacent bits. + // See "Hacker's Delight", Chap. 5: Counting Bits. + // The following pattern shows the general approach: + // + // x = x>>1&(m0&m) + x&(m0&m) + // x = x>>2&(m1&m) + x&(m1&m) + // x = x>>4&(m2&m) + x&(m2&m) + // x = x>>8&(m3&m) + x&(m3&m) + // x = x>>16&(m4&m) + x&(m4&m) + // x = x>>32&(m5&m) + x&(m5&m) + // return int(x) + // + // Masking (& operations) can be left away when there's no + // danger that a field's sum will carry over into the next + // field: Since the result cannot be > 64, 8 bits is enough + // and we can ignore the masks for the shifts by 8 and up. + // Per "Hacker's Delight", the first line can be simplified + // more, but it saves at best one instruction, so we leave + // it alone for clarity. + const m = 1<<64 - 1 + x = x>>1&(m0&m) + x&(m0&m) + x = x>>2&(m1&m) + x&(m1&m) + x = (x>>4 + x) & (m2 & m) + x += x >> 8 + x += x >> 16 + x += x >> 32 + return int(x) & (1<<7 - 1) +} + +// LeadingZeros64 returns the number of leading zero bits in x; the result is 64 for x == 0. +func LeadingZeros64(x uint64) int { return 64 - Len64(x) } + +// LeadingZeros8 returns the number of leading zero bits in x; the result is 8 for x == 0. +func LeadingZeros8(x uint8) int { return 8 - Len8(x) } + +// Len8 returns the minimum number of bits required to represent x; the result is 0 for x == 0. +func Len8(x uint8) int { + return int(len8tab[x]) +} + +// Bswap64 returns its input with byte order reversed +// 0x0102030405060708 -> 0x0807060504030201 +func Bswap64(x uint64) uint64 { + c8 := uint64(0x00ff00ff00ff00ff) + a := x >> 8 & c8 + b := (x & c8) << 8 + x = a | b + c16 := uint64(0x0000ffff0000ffff) + a = x >> 16 & c16 + b = (x & c16) << 16 + x = a | b + c32 := uint64(0x00000000ffffffff) + a = x >> 32 & c32 + b = (x & c32) << 32 + x = a | b + return x +} + +// Bswap32 returns its input with byte order reversed +// 0x01020304 -> 0x04030201 +func Bswap32(x uint32) uint32 { + c8 := uint32(0x00ff00ff) + a := x >> 8 & c8 + b := (x & c8) << 8 + x = a | b + c16 := uint32(0x0000ffff) + a = x >> 16 & c16 + b = (x & c16) << 16 + x = a | b + return x +} + +// Prefetch prefetches data from memory addr to cache +// +// AMD64: Produce PREFETCHT0 instruction +// +// ARM64: Produce PRFM instruction with PLDL1KEEP option +func Prefetch(addr uintptr) {} + +// PrefetchStreamed prefetches data from memory addr, with a hint that this data is being streamed. +// That is, it is likely to be accessed very soon, but only once. If possible, this will avoid polluting the cache. +// +// AMD64: Produce PREFETCHNTA instruction +// +// ARM64: Produce PRFM instruction with PLDL1STRM option +func PrefetchStreamed(addr uintptr) {} diff --git a/src/internal/runtime/sys/intrinsics_test.go b/src/internal/runtime/sys/intrinsics_test.go new file mode 100644 index 0000000000..d466f3e539 --- /dev/null +++ b/src/internal/runtime/sys/intrinsics_test.go @@ -0,0 +1,42 @@ +// Copyright 2016 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 sys_test + +import ( + "internal/runtime/sys" + "testing" +) + +func TestTrailingZeros64(t *testing.T) { + for i := 0; i <= 64; i++ { + x := uint64(5) << uint(i) + if got := sys.TrailingZeros64(x); got != i { + t.Errorf("TrailingZeros64(%d)=%d, want %d", x, got, i) + } + } +} +func TestTrailingZeros32(t *testing.T) { + for i := 0; i <= 32; i++ { + x := uint32(5) << uint(i) + if got := sys.TrailingZeros32(x); got != i { + t.Errorf("TrailingZeros32(%d)=%d, want %d", x, got, i) + } + } +} + +func TestBswap64(t *testing.T) { + x := uint64(0x1122334455667788) + y := sys.Bswap64(x) + if y != 0x8877665544332211 { + t.Errorf("Bswap(%x)=%x, want 0x8877665544332211", x, y) + } +} +func TestBswap32(t *testing.T) { + x := uint32(0x11223344) + y := sys.Bswap32(x) + if y != 0x44332211 { + t.Errorf("Bswap(%x)=%x, want 0x44332211", x, y) + } +} diff --git a/src/internal/runtime/sys/nih.go b/src/internal/runtime/sys/nih.go new file mode 100644 index 0000000000..17eab67345 --- /dev/null +++ b/src/internal/runtime/sys/nih.go @@ -0,0 +1,41 @@ +// Copyright 2014 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 sys + +// NOTE: keep in sync with cmd/compile/internal/types.CalcSize +// to make the compiler recognize this as an intrinsic type. +type nih struct{} + +// NotInHeap is a type must never be allocated from the GC'd heap or on the stack, +// and is called not-in-heap. +// +// Other types can embed NotInHeap to make it not-in-heap. Specifically, pointers +// to these types must always fail the `runtime.inheap` check. The type may be used +// for global variables, or for objects in unmanaged memory (e.g., allocated with +// `sysAlloc`, `persistentalloc`, r`fixalloc`, or from a manually-managed span). +// +// Specifically: +// +// 1. `new(T)`, `make([]T)`, `append([]T, ...)` and implicit heap +// allocation of T are disallowed. (Though implicit allocations are +// disallowed in the runtime anyway.) +// +// 2. A pointer to a regular type (other than `unsafe.Pointer`) cannot be +// converted to a pointer to a not-in-heap type, even if they have the +// same underlying type. +// +// 3. Any type that containing a not-in-heap type is itself considered as not-in-heap. +// +// - Structs and arrays are not-in-heap if their elements are not-in-heap. +// - Maps and channels contains no-in-heap types are disallowed. +// +// 4. Write barriers on pointers to not-in-heap types can be omitted. +// +// The last point is the real benefit of NotInHeap. The runtime uses +// it for low-level internal structures to avoid memory barriers in the +// scheduler and the memory allocator where they are illegal or simply +// inefficient. This mechanism is reasonably safe and does not compromise +// the readability of the runtime. +type NotInHeap struct{ _ nih } diff --git a/src/internal/runtime/sys/sys.go b/src/internal/runtime/sys/sys.go new file mode 100644 index 0000000000..694101d36f --- /dev/null +++ b/src/internal/runtime/sys/sys.go @@ -0,0 +1,7 @@ +// Copyright 2015 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 sys contains system- and configuration- and architecture-specific +// constants used by the runtime. +package sys diff --git a/src/reflect/deepequal.go b/src/reflect/deepequal.go index 502ea9f146..041c3e1f7e 100644 --- a/src/reflect/deepequal.go +++ b/src/reflect/deepequal.go @@ -41,7 +41,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool { case Pointer: if !v1.typ().Pointers() { // not-in-heap pointers can't be cyclic. - // At least, all of our current uses of runtime/internal/sys.NotInHeap + // At least, all of our current uses of internal/runtime/sys.NotInHeap // have that property. The runtime ones aren't cyclic (and we don't use // DeepEqual on them anyway), and the cgo-generated ones are // all empty structs. diff --git a/src/runtime/HACKING.md b/src/runtime/HACKING.md index e1a43ba88e..f0c60f3af9 100644 --- a/src/runtime/HACKING.md +++ b/src/runtime/HACKING.md @@ -235,7 +235,7 @@ There are three mechanisms for allocating unmanaged memory: objects of the same type. In general, types that are allocated using any of these should be -marked as not in heap by embedding `runtime/internal/sys.NotInHeap`. +marked as not in heap by embedding `internal/runtime/sys.NotInHeap`. Objects that are allocated in unmanaged memory **must not** contain heap pointers unless the following rules are also obeyed: diff --git a/src/runtime/arena.go b/src/runtime/arena.go index 96197099ca..936e3604bf 100644 --- a/src/runtime/arena.go +++ b/src/runtime/arena.go @@ -87,7 +87,7 @@ import ( "internal/goarch" "internal/runtime/atomic" "internal/runtime/math" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/cgo/cgo.go b/src/runtime/cgo/cgo.go index 1e3a502918..c37135fbbe 100644 --- a/src/runtime/cgo/cgo.go +++ b/src/runtime/cgo/cgo.go @@ -32,7 +32,7 @@ package cgo */ import "C" -import "runtime/internal/sys" +import "internal/runtime/sys" // Incomplete is used specifically for the semantics of incomplete C types. type Incomplete struct { diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go index b943b1c2d6..ae91627972 100644 --- a/src/runtime/cgocall.go +++ b/src/runtime/cgocall.go @@ -88,7 +88,7 @@ import ( "internal/abi" "internal/goarch" "internal/goexperiment" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/cpuprof.go b/src/runtime/cpuprof.go index 100a78258a..ea4d3a8cb0 100644 --- a/src/runtime/cpuprof.go +++ b/src/runtime/cpuprof.go @@ -14,7 +14,7 @@ package runtime import ( "internal/abi" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/debuglog.go b/src/runtime/debuglog.go index 695cd204f5..25186af7e0 100644 --- a/src/runtime/debuglog.go +++ b/src/runtime/debuglog.go @@ -18,7 +18,7 @@ package runtime import ( "internal/abi" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index d55da1028d..759463755a 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -11,7 +11,7 @@ import ( "internal/goarch" "internal/goos" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/histogram.go b/src/runtime/histogram.go index 95230d1f39..920a9561d2 100644 --- a/src/runtime/histogram.go +++ b/src/runtime/histogram.go @@ -6,7 +6,7 @@ package runtime import ( "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/iface.go b/src/runtime/iface.go index 41a10ae012..5316182f4a 100644 --- a/src/runtime/iface.go +++ b/src/runtime/iface.go @@ -8,7 +8,7 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/internal/sys/consts.go b/src/runtime/internal/sys/consts.go deleted file mode 100644 index 98c0f09ef1..0000000000 --- a/src/runtime/internal/sys/consts.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 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 sys - -import ( - "internal/goarch" - "internal/goos" -) - -// AIX requires a larger stack for syscalls. -// The race build also needs more stack. See issue 54291. -// This arithmetic must match that in cmd/internal/objabi/stack.go:stackGuardMultiplier. -const StackGuardMultiplier = 1 + goos.IsAix + isRace - -// DefaultPhysPageSize is the default physical page size. -const DefaultPhysPageSize = goarch.DefaultPhysPageSize - -// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems). -// The various PC tables record PC deltas pre-divided by PCQuantum. -const PCQuantum = goarch.PCQuantum - -// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit). -const Int64Align = goarch.PtrSize - -// MinFrameSize is the size of the system-reserved words at the bottom -// of a frame (just above the architectural stack pointer). -// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems. -// On PowerPC it is larger, to cover three more reserved words: -// the compiler word, the link editor word, and the TOC save word. -const MinFrameSize = goarch.MinFrameSize - -// StackAlign is the required alignment of the SP register. -// The stack must be at least word aligned, but some architectures require more. -const StackAlign = goarch.StackAlign diff --git a/src/runtime/internal/sys/consts_norace.go b/src/runtime/internal/sys/consts_norace.go deleted file mode 100644 index a9613b8843..0000000000 --- a/src/runtime/internal/sys/consts_norace.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2022 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 !race - -package sys - -const isRace = 0 diff --git a/src/runtime/internal/sys/consts_race.go b/src/runtime/internal/sys/consts_race.go deleted file mode 100644 index f824fb39d3..0000000000 --- a/src/runtime/internal/sys/consts_race.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2022 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 race - -package sys - -const isRace = 1 diff --git a/src/runtime/internal/sys/intrinsics.go b/src/runtime/internal/sys/intrinsics.go deleted file mode 100644 index e6a3758447..0000000000 --- a/src/runtime/internal/sys/intrinsics.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2016 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 sys - -// Copied from math/bits to avoid dependence. - -var deBruijn32tab = [32]byte{ - 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, - 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9, -} - -const deBruijn32 = 0x077CB531 - -var deBruijn64tab = [64]byte{ - 0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4, - 62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5, - 63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11, - 54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6, -} - -const deBruijn64 = 0x03f79d71b4ca8b09 - -const ntz8tab = "" + - "\x08\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x06\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x07\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x06\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x05\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" + - "\x04\x00\x01\x00\x02\x00\x01\x00\x03\x00\x01\x00\x02\x00\x01\x00" - -// TrailingZeros32 returns the number of trailing zero bits in x; the result is 32 for x == 0. -func TrailingZeros32(x uint32) int { - if x == 0 { - return 32 - } - // see comment in TrailingZeros64 - return int(deBruijn32tab[(x&-x)*deBruijn32>>(32-5)]) -} - -// TrailingZeros64 returns the number of trailing zero bits in x; the result is 64 for x == 0. -func TrailingZeros64(x uint64) int { - if x == 0 { - return 64 - } - // If popcount is fast, replace code below with return popcount(^x & (x - 1)). - // - // x & -x leaves only the right-most bit set in the word. Let k be the - // index of that bit. Since only a single bit is set, the value is two - // to the power of k. Multiplying by a power of two is equivalent to - // left shifting, in this case by k bits. The de Bruijn (64 bit) constant - // is such that all six bit, consecutive substrings are distinct. - // Therefore, if we have a left shifted version of this constant we can - // find by how many bits it was shifted by looking at which six bit - // substring ended up at the top of the word. - // (Knuth, volume 4, section 7.3.1) - return int(deBruijn64tab[(x&-x)*deBruijn64>>(64-6)]) -} - -// TrailingZeros8 returns the number of trailing zero bits in x; the result is 8 for x == 0. -func TrailingZeros8(x uint8) int { - return int(ntz8tab[x]) -} - -const len8tab = "" + - "\x00\x01\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04" + - "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05" + - "\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06" + - "\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06\x06" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" + - "\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08\x08" - -// Len64 returns the minimum number of bits required to represent x; the result is 0 for x == 0. -// -// nosplit because this is used in src/runtime/histogram.go, which make run in sensitive contexts. -// -//go:nosplit -func Len64(x uint64) (n int) { - if x >= 1<<32 { - x >>= 32 - n = 32 - } - if x >= 1<<16 { - x >>= 16 - n += 16 - } - if x >= 1<<8 { - x >>= 8 - n += 8 - } - return n + int(len8tab[x]) -} - -// --- OnesCount --- - -const m0 = 0x5555555555555555 // 01010101 ... -const m1 = 0x3333333333333333 // 00110011 ... -const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ... - -// OnesCount64 returns the number of one bits ("population count") in x. -func OnesCount64(x uint64) int { - // Implementation: Parallel summing of adjacent bits. - // See "Hacker's Delight", Chap. 5: Counting Bits. - // The following pattern shows the general approach: - // - // x = x>>1&(m0&m) + x&(m0&m) - // x = x>>2&(m1&m) + x&(m1&m) - // x = x>>4&(m2&m) + x&(m2&m) - // x = x>>8&(m3&m) + x&(m3&m) - // x = x>>16&(m4&m) + x&(m4&m) - // x = x>>32&(m5&m) + x&(m5&m) - // return int(x) - // - // Masking (& operations) can be left away when there's no - // danger that a field's sum will carry over into the next - // field: Since the result cannot be > 64, 8 bits is enough - // and we can ignore the masks for the shifts by 8 and up. - // Per "Hacker's Delight", the first line can be simplified - // more, but it saves at best one instruction, so we leave - // it alone for clarity. - const m = 1<<64 - 1 - x = x>>1&(m0&m) + x&(m0&m) - x = x>>2&(m1&m) + x&(m1&m) - x = (x>>4 + x) & (m2 & m) - x += x >> 8 - x += x >> 16 - x += x >> 32 - return int(x) & (1<<7 - 1) -} - -// LeadingZeros64 returns the number of leading zero bits in x; the result is 64 for x == 0. -func LeadingZeros64(x uint64) int { return 64 - Len64(x) } - -// LeadingZeros8 returns the number of leading zero bits in x; the result is 8 for x == 0. -func LeadingZeros8(x uint8) int { return 8 - Len8(x) } - -// Len8 returns the minimum number of bits required to represent x; the result is 0 for x == 0. -func Len8(x uint8) int { - return int(len8tab[x]) -} - -// Bswap64 returns its input with byte order reversed -// 0x0102030405060708 -> 0x0807060504030201 -func Bswap64(x uint64) uint64 { - c8 := uint64(0x00ff00ff00ff00ff) - a := x >> 8 & c8 - b := (x & c8) << 8 - x = a | b - c16 := uint64(0x0000ffff0000ffff) - a = x >> 16 & c16 - b = (x & c16) << 16 - x = a | b - c32 := uint64(0x00000000ffffffff) - a = x >> 32 & c32 - b = (x & c32) << 32 - x = a | b - return x -} - -// Bswap32 returns its input with byte order reversed -// 0x01020304 -> 0x04030201 -func Bswap32(x uint32) uint32 { - c8 := uint32(0x00ff00ff) - a := x >> 8 & c8 - b := (x & c8) << 8 - x = a | b - c16 := uint32(0x0000ffff) - a = x >> 16 & c16 - b = (x & c16) << 16 - x = a | b - return x -} - -// Prefetch prefetches data from memory addr to cache -// -// AMD64: Produce PREFETCHT0 instruction -// -// ARM64: Produce PRFM instruction with PLDL1KEEP option -func Prefetch(addr uintptr) {} - -// PrefetchStreamed prefetches data from memory addr, with a hint that this data is being streamed. -// That is, it is likely to be accessed very soon, but only once. If possible, this will avoid polluting the cache. -// -// AMD64: Produce PREFETCHNTA instruction -// -// ARM64: Produce PRFM instruction with PLDL1STRM option -func PrefetchStreamed(addr uintptr) {} diff --git a/src/runtime/internal/sys/intrinsics_test.go b/src/runtime/internal/sys/intrinsics_test.go deleted file mode 100644 index 6799885001..0000000000 --- a/src/runtime/internal/sys/intrinsics_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2016 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 sys_test - -import ( - "runtime/internal/sys" - "testing" -) - -func TestTrailingZeros64(t *testing.T) { - for i := 0; i <= 64; i++ { - x := uint64(5) << uint(i) - if got := sys.TrailingZeros64(x); got != i { - t.Errorf("TrailingZeros64(%d)=%d, want %d", x, got, i) - } - } -} -func TestTrailingZeros32(t *testing.T) { - for i := 0; i <= 32; i++ { - x := uint32(5) << uint(i) - if got := sys.TrailingZeros32(x); got != i { - t.Errorf("TrailingZeros32(%d)=%d, want %d", x, got, i) - } - } -} - -func TestBswap64(t *testing.T) { - x := uint64(0x1122334455667788) - y := sys.Bswap64(x) - if y != 0x8877665544332211 { - t.Errorf("Bswap(%x)=%x, want 0x8877665544332211", x, y) - } -} -func TestBswap32(t *testing.T) { - x := uint32(0x11223344) - y := sys.Bswap32(x) - if y != 0x44332211 { - t.Errorf("Bswap(%x)=%x, want 0x44332211", x, y) - } -} diff --git a/src/runtime/internal/sys/nih.go b/src/runtime/internal/sys/nih.go deleted file mode 100644 index 17eab67345..0000000000 --- a/src/runtime/internal/sys/nih.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 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 sys - -// NOTE: keep in sync with cmd/compile/internal/types.CalcSize -// to make the compiler recognize this as an intrinsic type. -type nih struct{} - -// NotInHeap is a type must never be allocated from the GC'd heap or on the stack, -// and is called not-in-heap. -// -// Other types can embed NotInHeap to make it not-in-heap. Specifically, pointers -// to these types must always fail the `runtime.inheap` check. The type may be used -// for global variables, or for objects in unmanaged memory (e.g., allocated with -// `sysAlloc`, `persistentalloc`, r`fixalloc`, or from a manually-managed span). -// -// Specifically: -// -// 1. `new(T)`, `make([]T)`, `append([]T, ...)` and implicit heap -// allocation of T are disallowed. (Though implicit allocations are -// disallowed in the runtime anyway.) -// -// 2. A pointer to a regular type (other than `unsafe.Pointer`) cannot be -// converted to a pointer to a not-in-heap type, even if they have the -// same underlying type. -// -// 3. Any type that containing a not-in-heap type is itself considered as not-in-heap. -// -// - Structs and arrays are not-in-heap if their elements are not-in-heap. -// - Maps and channels contains no-in-heap types are disallowed. -// -// 4. Write barriers on pointers to not-in-heap types can be omitted. -// -// The last point is the real benefit of NotInHeap. The runtime uses -// it for low-level internal structures to avoid memory barriers in the -// scheduler and the memory allocator where they are illegal or simply -// inefficient. This mechanism is reasonably safe and does not compromise -// the readability of the runtime. -type NotInHeap struct{ _ nih } diff --git a/src/runtime/internal/sys/sys.go b/src/runtime/internal/sys/sys.go deleted file mode 100644 index 694101d36f..0000000000 --- a/src/runtime/internal/sys/sys.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2015 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 sys contains system- and configuration- and architecture-specific -// constants used by the runtime. -package sys diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index cbb4f67ee8..b24ebec27d 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -105,7 +105,7 @@ import ( "internal/goos" "internal/runtime/atomic" "internal/runtime/math" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) @@ -1555,7 +1555,7 @@ var persistentChunks *notInHeap // sysStat must be non-nil. // // Consider marking persistentalloc'd types not in heap by embedding -// runtime/internal/sys.NotInHeap. +// internal/runtime/sys.NotInHeap. func persistentalloc(size, align uintptr, sysStat *sysMemStat) unsafe.Pointer { var p *notInHeap systemstack(func() { @@ -1697,7 +1697,7 @@ func (l *linearAlloc) alloc(size, align uintptr, sysStat *sysMemStat) unsafe.Poi // like sysAlloc or persistentAlloc. // // In general, it's better to use real types which embed -// runtime/internal/sys.NotInHeap, but this serves as a generic type +// internal/runtime/sys.NotInHeap, but this serves as a generic type // for situations where that isn't possible (like in the allocators). // // TODO: Use this as the return type of sysAlloc, persistentAlloc, etc? diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go index 689fac103c..a25995f46f 100644 --- a/src/runtime/mbitmap.go +++ b/src/runtime/mbitmap.go @@ -59,7 +59,7 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mcache.go b/src/runtime/mcache.go index e8da133a69..97a5f70e9c 100644 --- a/src/runtime/mcache.go +++ b/src/runtime/mcache.go @@ -6,7 +6,7 @@ package runtime import ( "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mcentral.go b/src/runtime/mcentral.go index bf597e1936..1a4819bc2c 100644 --- a/src/runtime/mcentral.go +++ b/src/runtime/mcentral.go @@ -14,7 +14,7 @@ package runtime import ( "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" ) // Central list of free objects of a given size. diff --git a/src/runtime/mcheckmark.go b/src/runtime/mcheckmark.go index 258f889272..f5560cf50f 100644 --- a/src/runtime/mcheckmark.go +++ b/src/runtime/mcheckmark.go @@ -15,7 +15,7 @@ package runtime import ( "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mfinal.go b/src/runtime/mfinal.go index 78313fb74c..a926a8ec35 100644 --- a/src/runtime/mfinal.go +++ b/src/runtime/mfinal.go @@ -10,7 +10,7 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mfixalloc.go b/src/runtime/mfixalloc.go index 7760ada397..be977af737 100644 --- a/src/runtime/mfixalloc.go +++ b/src/runtime/mfixalloc.go @@ -9,7 +9,7 @@ package runtime import ( - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) @@ -27,7 +27,7 @@ import ( // smashed by freeing and reallocating. // // Consider marking fixalloc'd types not in heap by embedding -// runtime/internal/sys.NotInHeap. +// internal/runtime/sys.NotInHeap. type fixalloc struct { size uintptr first func(arg, p unsafe.Pointer) // called first time p is returned diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 61e917df41..9a48d15552 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -10,7 +10,7 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index 4f0bd9c28d..3d869ecdd2 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -93,7 +93,7 @@ package runtime import ( "internal/goos" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mgcstack.go b/src/runtime/mgcstack.go index f4a83f5f59..bc5911f141 100644 --- a/src/runtime/mgcstack.go +++ b/src/runtime/mgcstack.go @@ -96,7 +96,7 @@ package runtime import ( "internal/goarch" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mgcwork.go b/src/runtime/mgcwork.go index b91a6bd464..2d66fa4002 100644 --- a/src/runtime/mgcwork.go +++ b/src/runtime/mgcwork.go @@ -7,7 +7,7 @@ package runtime import ( "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mheap.go b/src/runtime/mheap.go index 35fd08af50..e4b1fa0574 100644 --- a/src/runtime/mheap.go +++ b/src/runtime/mheap.go @@ -12,7 +12,7 @@ import ( "internal/cpu" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mpagecache.go b/src/runtime/mpagecache.go index 245b0cbfef..0ed3e80c30 100644 --- a/src/runtime/mpagecache.go +++ b/src/runtime/mpagecache.go @@ -5,7 +5,7 @@ package runtime import ( - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/mpallocbits.go b/src/runtime/mpallocbits.go index d8a9d25789..e8e70f36be 100644 --- a/src/runtime/mpallocbits.go +++ b/src/runtime/mpallocbits.go @@ -5,7 +5,7 @@ package runtime import ( - "runtime/internal/sys" + "internal/runtime/sys" ) // pageBits is a bitmap representing one bit per page in a palloc chunk. diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index 006274757e..a9adc7b6f7 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -12,7 +12,7 @@ import ( "internal/goarch" "internal/profilerecord" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go index 7b37d91b24..36b9edfe21 100644 --- a/src/runtime/netpoll.go +++ b/src/runtime/netpoll.go @@ -8,7 +8,7 @@ package runtime import ( "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) @@ -714,7 +714,7 @@ func (c *pollCache) alloc() *pollDesc { // makeArg converts pd to an interface{}. // makeArg does not do any allocation. Normally, such // a conversion requires an allocation because pointers to -// types which embed runtime/internal/sys.NotInHeap (which pollDesc is) +// types which embed internal/runtime/sys.NotInHeap (which pollDesc is) // must be stored in interfaces indirectly. See issue 42076. func (pd *pollDesc) makeArg() (i any) { x := (*eface)(unsafe.Pointer(&i)) diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 98e96b12bf..bd1ea096aa 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -8,8 +8,8 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" + "internal/runtime/sys" "internal/stringslite" - "runtime/internal/sys" "unsafe" ) diff --git a/src/runtime/proc.go b/src/runtime/proc.go index c4f175b0b7..2cf8a31971 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -11,8 +11,8 @@ import ( "internal/goos" "internal/runtime/atomic" "internal/runtime/exithook" + "internal/runtime/sys" "internal/stringslite" - "runtime/internal/sys" "unsafe" ) diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 4a78963961..62ed77aae5 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -9,7 +9,7 @@ import ( "internal/chacha8rand" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/signal_arm64.go b/src/runtime/signal_arm64.go index 4a96b3c2e7..af7d29f9de 100644 --- a/src/runtime/signal_arm64.go +++ b/src/runtime/signal_arm64.go @@ -9,7 +9,7 @@ package runtime import ( "internal/abi" "internal/goarch" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/signal_linux_s390x.go b/src/runtime/signal_linux_s390x.go index 18c3b115ef..54e9d1fb9d 100644 --- a/src/runtime/signal_linux_s390x.go +++ b/src/runtime/signal_linux_s390x.go @@ -7,7 +7,7 @@ package runtime import ( "internal/abi" "internal/goarch" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/signal_mipsx.go b/src/runtime/signal_mipsx.go index ba92655152..924e654c6c 100644 --- a/src/runtime/signal_mipsx.go +++ b/src/runtime/signal_mipsx.go @@ -8,7 +8,7 @@ package runtime import ( "internal/abi" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/signal_ppc64x.go b/src/runtime/signal_ppc64x.go index b5722f99c6..20f874c2ec 100644 --- a/src/runtime/signal_ppc64x.go +++ b/src/runtime/signal_ppc64x.go @@ -8,7 +8,7 @@ package runtime import ( "internal/abi" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 8ba498bdb2..a42972bb35 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -9,7 +9,7 @@ package runtime import ( "internal/abi" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/signal_windows.go b/src/runtime/signal_windows.go index 4b7960c1f0..b0c653ee46 100644 --- a/src/runtime/signal_windows.go +++ b/src/runtime/signal_windows.go @@ -6,7 +6,7 @@ package runtime import ( "internal/abi" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/slice.go b/src/runtime/slice.go index 65883ea2f3..ecc2e2921b 100644 --- a/src/runtime/slice.go +++ b/src/runtime/slice.go @@ -8,7 +8,7 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/math" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) @@ -18,7 +18,7 @@ type slice struct { cap int } -// A notInHeapSlice is a slice backed by runtime/internal/sys.NotInHeap memory. +// A notInHeapSlice is a slice backed by internal/runtime/sys.NotInHeap memory. type notInHeapSlice struct { array *notInHeap len int diff --git a/src/runtime/stack.go b/src/runtime/stack.go index cdf859a7ff..bdfeb21c18 100644 --- a/src/runtime/stack.go +++ b/src/runtime/stack.go @@ -10,7 +10,7 @@ import ( "internal/goarch" "internal/goos" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/stkframe.go b/src/runtime/stkframe.go index 42b6947751..2bab5a3a0e 100644 --- a/src/runtime/stkframe.go +++ b/src/runtime/stkframe.go @@ -7,7 +7,7 @@ package runtime import ( "internal/abi" "internal/goarch" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/symtab.go b/src/runtime/symtab.go index 10cdcf9c6e..f889d66992 100644 --- a/src/runtime/symtab.go +++ b/src/runtime/symtab.go @@ -8,7 +8,7 @@ import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/symtabinl_test.go b/src/runtime/symtabinl_test.go index 3c7cb2e595..db682e0c9c 100644 --- a/src/runtime/symtabinl_test.go +++ b/src/runtime/symtabinl_test.go @@ -6,8 +6,8 @@ package runtime import ( "internal/abi" + "internal/runtime/sys" "internal/stringslite" - "runtime/internal/sys" ) func XTestInlineUnwinder(t TestingT) { diff --git a/src/runtime/sys_wasm.go b/src/runtime/sys_wasm.go index 27f9432bd4..f88b992e9c 100644 --- a/src/runtime/sys_wasm.go +++ b/src/runtime/sys_wasm.go @@ -6,7 +6,7 @@ package runtime import ( "internal/goarch" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/time.go b/src/runtime/time.go index fc664f49eb..79f0514c6e 100644 --- a/src/runtime/time.go +++ b/src/runtime/time.go @@ -9,7 +9,7 @@ package runtime import ( "internal/abi" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/traceallocfree.go b/src/runtime/traceallocfree.go index e6a2a79c69..985d90eacb 100644 --- a/src/runtime/traceallocfree.go +++ b/src/runtime/traceallocfree.go @@ -8,7 +8,7 @@ package runtime import ( "internal/abi" - "runtime/internal/sys" + "internal/runtime/sys" ) // Batch type values for the alloc/free experiment. diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 03c02f7771..8946ec2528 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -8,8 +8,8 @@ import ( "internal/abi" "internal/bytealg" "internal/goarch" + "internal/runtime/sys" "internal/stringslite" - "runtime/internal/sys" "unsafe" ) diff --git a/src/runtime/tracebuf.go b/src/runtime/tracebuf.go index db4adf53e9..908a63d273 100644 --- a/src/runtime/tracebuf.go +++ b/src/runtime/tracebuf.go @@ -7,7 +7,7 @@ package runtime import ( - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/traceevent.go b/src/runtime/traceevent.go index 2a869fb515..9adbc52fd3 100644 --- a/src/runtime/traceevent.go +++ b/src/runtime/traceevent.go @@ -8,7 +8,7 @@ package runtime import ( "internal/abi" - "runtime/internal/sys" + "internal/runtime/sys" ) // Event types in the trace, args are given in square brackets. diff --git a/src/runtime/tracemap.go b/src/runtime/tracemap.go index 5b2718c8d6..9efa325c11 100644 --- a/src/runtime/tracemap.go +++ b/src/runtime/tracemap.go @@ -19,7 +19,7 @@ import ( "internal/cpu" "internal/goarch" "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) diff --git a/src/runtime/traceregion.go b/src/runtime/traceregion.go index 43eef9c92b..b45093ec86 100644 --- a/src/runtime/traceregion.go +++ b/src/runtime/traceregion.go @@ -8,7 +8,7 @@ package runtime import ( "internal/runtime/atomic" - "runtime/internal/sys" + "internal/runtime/sys" "unsafe" ) -- cgit v1.3