Skip to content

Commit

Permalink
runtime,internal: move runtime/internal/sys to internal/runtime/sys
Browse files Browse the repository at this point in the history
Cleanup and friction reduction

For golang#65355.

Change-Id: Ia14c9dc584a529a35b97801dd3e95b9acc99a511
Reviewed-on: https://go-review.googlesource.com/c/go/+/600436
Reviewed-by: Keith Randall <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
dr2chase committed Jul 23, 2024
1 parent f9eb3e3 commit fc5073b
Show file tree
Hide file tree
Showing 70 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _testmain.go
/src/go/build/zcgo.go
/src/go/doc/headscan
/src/internal/buildcfg/zbootstrap.go
/src/runtime/internal/sys/zversion.go
/src/internal/runtime/sys/zversion.go
/src/unicode/maketables
/src/time/tzdata/zzipdata.go
/test.out
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/noder/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
26 changes: 13 additions & 13 deletions src/cmd/compile/internal/ssagen/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
},
Expand All @@ -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 ********/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ********/

Expand Down
8 changes: 4 additions & 4 deletions src/cmd/compile/internal/test/inl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestIntendedInlining(t *testing.T) {
"traceLocker.ok",
"traceEnabled",
},
"runtime/internal/sys": {},
"internal/runtime/sys": {},
"internal/runtime/math": {
"MulUintptr",
},
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/dist/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/distpack/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/distpack/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
}

Expand Down
6 changes: 3 additions & 3 deletions src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal/objabi/pkgspecial.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal/objabi/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion src/go/build/deps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/internal/coverage/pkid.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package sys_test

import (
"runtime/internal/sys"
"internal/runtime/sys"
"testing"
)

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/reflect/deepequal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ import (
"internal/goarch"
"internal/runtime/atomic"
"internal/runtime/math"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgo/cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cgocall.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import (
"internal/abi"
"internal/goarch"
"internal/goexperiment"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/cpuprof.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package runtime

import (
"internal/abi"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/debuglog.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package runtime
import (
"internal/abi"
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"internal/goarch"
"internal/goos"
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package runtime

import (
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"internal/abi"
"internal/goarch"
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
6 changes: 3 additions & 3 deletions src/runtime/malloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import (
"internal/goos"
"internal/runtime/atomic"
"internal/runtime/math"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mbitmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import (
"internal/abi"
"internal/goarch"
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package runtime

import (
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mcentral.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mcheckmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package runtime
import (
"internal/goarch"
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/mfinal.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"internal/abi"
"internal/goarch"
"internal/runtime/atomic"
"runtime/internal/sys"
"internal/runtime/sys"
"unsafe"
)

Expand Down
Loading

0 comments on commit fc5073b

Please sign in to comment.