aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-01-07 21:44:06 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-01-07 21:44:06 +0000
commitfdcef314bcb0728d883cd87d6950d85217e82755 (patch)
treef1a09ca36cb906a2fd919ddc7f148f232e58109b /libgo
parent575eb8f58b06657c9cadfe6f7ddfd9e530fe5dea (diff)
downloadgcc-fdcef314bcb0728d883cd87d6950d85217e82755.zip
gcc-fdcef314bcb0728d883cd87d6950d85217e82755.tar.gz
gcc-fdcef314bcb0728d883cd87d6950d85217e82755.tar.bz2
compiler: move slice construction to callers of makeslice
This is the gccgo version of https://golang.org/cl/141822: Only return a pointer p to the new slices backing array from makeslice. Makeslice callers then construct sliceheader{p, len, cap} explictly instead of makeslice returning the slice. This change caused the GCC backend to break the runtime/pprof test by merging together the identical functions allocateReflectTransient and allocateTransient2M. This caused the traceback to be other than expected. Fix that by making the functions not identical. This is a step toward updating libgo to the Go1.12beta1 release. Reviewed-on: https://go-review.googlesource.com/c/155937 From-SVN: r267660
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/runtime/pprof/mprof_test.go4
-rw-r--r--libgo/go/runtime/slice.go7
2 files changed, 5 insertions, 6 deletions
diff --git a/libgo/go/runtime/pprof/mprof_test.go b/libgo/go/runtime/pprof/mprof_test.go
index f428827..6fe892b 100644
--- a/libgo/go/runtime/pprof/mprof_test.go
+++ b/libgo/go/runtime/pprof/mprof_test.go
@@ -45,7 +45,7 @@ func allocatePersistent1K() {
// Allocate transient memory using reflect.Call.
func allocateReflectTransient() {
- memSink = make([]byte, 2<<20)
+ memSink = make([]byte, 3<<20)
}
func allocateReflect() {
@@ -106,7 +106,7 @@ func TestMemoryProfiler(t *testing.T) {
// GC means that sometimes the value is not collected.
fmt.Sprintf(`(0|%v): (0|%v) \[%v: %v\] @( 0x[0-9,a-f]+)+
# 0x[0-9,a-f]+ pprof\.allocateReflectTransient\+0x[0-9,a-f]+ .*/mprof_test.go:48
-`, memoryProfilerRun, (2<<20)*memoryProfilerRun, memoryProfilerRun, (2<<20)*memoryProfilerRun),
+`, memoryProfilerRun, (3<<20)*memoryProfilerRun, memoryProfilerRun, (3<<20)*memoryProfilerRun),
}
for _, test := range tests {
diff --git a/libgo/go/runtime/slice.go b/libgo/go/runtime/slice.go
index 2e874cc..7f9db4e 100644
--- a/libgo/go/runtime/slice.go
+++ b/libgo/go/runtime/slice.go
@@ -61,7 +61,7 @@ func panicmakeslicecap() {
panic(errorString("makeslice: cap out of range"))
}
-func makeslice(et *_type, len, cap int) slice {
+func makeslice(et *_type, len, cap int) unsafe.Pointer {
// NOTE: The len > maxElements check here is not strictly necessary,
// but it produces a 'len out of range' error instead of a 'cap out of range' error
// when someone does make([]T, bignumber). 'cap out of range' is true too,
@@ -76,11 +76,10 @@ func makeslice(et *_type, len, cap int) slice {
panicmakeslicecap()
}
- p := mallocgc(et.size*uintptr(cap), et, true)
- return slice{p, len, cap}
+ return mallocgc(et.size*uintptr(cap), et, true)
}
-func makeslice64(et *_type, len64, cap64 int64) slice {
+func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer {
len := int(len64)
if int64(len) != len64 {
panicmakeslicelen()