Skip to content

Commit 1467354

Browse files
rscjproberts
authored andcommitted
all: remove pre-Go 1.17 workarounds
The Go bootstrap toolchain requirement is now Go 1.17. We can finally delete all these pre-Go 1.17 workarounds. For golang#44505. Change-Id: I59d4dff1cde23da022892b5b6a116eb3dbad9ce4 Reviewed-on: https://go-review.googlesource.com/c/go/+/420903 Auto-Submit: Dmitri Shuralyov <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Austin Clements <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent ed76551 commit 1467354

File tree

14 files changed

+41
-199
lines changed

14 files changed

+41
-199
lines changed

src/cmd/compile/internal/gc/bootstrap.go

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/cmd/compile/internal/gc/pprof.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/cmd/compile/internal/gc/trace.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/cmd/compile/internal/gc/util.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import (
88
"os"
99
"runtime"
1010
"runtime/pprof"
11+
tracepkg "runtime/trace"
1112

1213
"cmd/compile/internal/base"
1314
)
1415

15-
var traceHandler func(string)
16-
1716
func startProfile() {
1817
if base.Flag.CPUProfile != "" {
1918
f, err := os.Create(base.Flag.CPUProfile)
@@ -64,13 +63,20 @@ func startProfile() {
6463
if err != nil {
6564
base.Fatalf("%v", err)
6665
}
67-
startMutexProfiling()
66+
runtime.SetMutexProfileFraction(1)
6867
base.AtExit(func() {
6968
pprof.Lookup("mutex").WriteTo(f, 0)
7069
f.Close()
7170
})
7271
}
73-
if base.Flag.TraceProfile != "" && traceHandler != nil {
74-
traceHandler(base.Flag.TraceProfile)
72+
if base.Flag.TraceProfile != "" {
73+
f, err := os.Create(base.Flag.TraceProfile)
74+
if err != nil {
75+
base.Fatalf("%v", err)
76+
}
77+
if err := tracepkg.Start(f); err != nil {
78+
base.Fatalf("%v", err)
79+
}
80+
base.AtExit(tracepkg.Stop)
7581
}
7682
}

src/cmd/compile/internal/logopt/escape.go

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/cmd/compile/internal/logopt/escape_bootstrap.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/cmd/compile/internal/logopt/log_opts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ func writerForLSP(subdirpath, file string) io.WriteCloser {
376376
if lastdot != -1 {
377377
basename = basename[:lastdot]
378378
}
379-
basename = pathEscape(basename)
379+
basename = url.PathEscape(basename)
380380

381381
// Assume a directory, make a file
382382
p := filepath.Join(subdirpath, basename+".json")
@@ -428,7 +428,7 @@ func FlushLoggedOpts(ctxt *obj.Link, slashPkgPath string) {
428428
if slashPkgPath == "" {
429429
slashPkgPath = "\000"
430430
}
431-
subdirpath := filepath.Join(dest, pathEscape(slashPkgPath))
431+
subdirpath := filepath.Join(dest, url.PathEscape(slashPkgPath))
432432
err := os.MkdirAll(subdirpath, 0755)
433433
if err != nil {
434434
log.Fatalf("Could not create directory %s for logging optimizer actions, %v", subdirpath, err)

src/internal/pkgbits/frames_go1.go

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/internal/pkgbits/frames_go17.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/internal/pkgbits/sync.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package pkgbits
66

77
import (
88
"fmt"
9+
"runtime"
910
"strings"
1011
)
1112

@@ -23,6 +24,24 @@ func fmtFrames(pcs ...uintptr) []string {
2324

2425
type frameVisitor func(file string, line int, name string, offset uintptr)
2526

27+
// walkFrames calls visit for each call frame represented by pcs.
28+
//
29+
// pcs should be a slice of PCs, as returned by runtime.Callers.
30+
func walkFrames(pcs []uintptr, visit frameVisitor) {
31+
if len(pcs) == 0 {
32+
return
33+
}
34+
35+
frames := runtime.CallersFrames(pcs)
36+
for {
37+
frame, more := frames.Next()
38+
visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry)
39+
if !more {
40+
return
41+
}
42+
}
43+
}
44+
2645
// SyncMarker is an enum type that represents markers that may be
2746
// written to export data to ensure the reader and writer stay
2847
// synchronized.

src/sort/slice.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
package sort
66

7-
import "math/bits"
7+
import (
8+
"internal/reflectlite"
9+
"math/bits"
10+
)
811

912
// Slice sorts the slice x given the provided less function.
1013
// It panics if x is not a slice.
@@ -16,8 +19,8 @@ import "math/bits"
1619
// The less function must satisfy the same requirements as
1720
// the Interface type's Less method.
1821
func Slice(x any, less func(i, j int) bool) {
19-
rv := reflectValueOf(x)
20-
swap := reflectSwapper(x)
22+
rv := reflectlite.ValueOf(x)
23+
swap := reflectlite.Swapper(x)
2124
length := rv.Len()
2225
limit := bits.Len(uint(length))
2326
pdqsort_func(lessSwap{less, swap}, 0, length, limit)
@@ -30,15 +33,15 @@ func Slice(x any, less func(i, j int) bool) {
3033
// The less function must satisfy the same requirements as
3134
// the Interface type's Less method.
3235
func SliceStable(x any, less func(i, j int) bool) {
33-
rv := reflectValueOf(x)
34-
swap := reflectSwapper(x)
36+
rv := reflectlite.ValueOf(x)
37+
swap := reflectlite.Swapper(x)
3538
stable_func(lessSwap{less, swap}, rv.Len())
3639
}
3740

3841
// SliceIsSorted reports whether the slice x is sorted according to the provided less function.
3942
// It panics if x is not a slice.
4043
func SliceIsSorted(x any, less func(i, j int) bool) bool {
41-
rv := reflectValueOf(x)
44+
rv := reflectlite.ValueOf(x)
4245
n := rv.Len()
4346
for i := n - 1; i > 0; i-- {
4447
if less(i, i-1) {

src/sort/slice_go113.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/sort/slice_go14.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/sort/slice_go18.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)