diff options
| author | Andrew Wilkins <axwalk@gmail.com> | 2016-03-15 05:36:43 +0000 |
|---|---|---|
| committer | Andrew Wilkins <axwalk@gmail.com> | 2016-03-15 05:36:43 +0000 |
| commit | 6436a4abd7a2f3a60b230453295dba199d8a59c3 (patch) | |
| tree | 125aef80fc2cf46c5d1758a8ece1fde14e7b13fd /llgo/third_party/gofrontend/libgo/go/runtime/map_test.go | |
| parent | 36761bf92427846ce40fdd849615732c852e44dd (diff) | |
| download | bcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.tar.gz bcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.zip | |
[llgo] Roll gofrontend forward
Switch gofrontend to using go.googlesource.com, and
update to 81eb6a3f425b2158c67ee32c0cc973a72ce9d6be.
There are various changes required to update to the
go 1.5 runtime:
typemap.go is changed to accommodate the change in representation for equal/hash algorithms, and the removal of the zero value/type.
CMakeLists.txt is updated to add the build tree to the package search path, so internal packages, which are not installed, are found.
various files changes due to removal of __go_new_nopointers; the same change as in D11863, but with NoUnwindAttribute added to the added runtime functions which are called with "callOnly".
minor cleanups in ssa.go while investigating issues with unwinding/panic handling.
Differential Revisision: http://reviews.llvm.org/D15188
llvm-svn: 263536
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/runtime/map_test.go')
| -rw-r--r-- | llgo/third_party/gofrontend/libgo/go/runtime/map_test.go | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/runtime/map_test.go b/llgo/third_party/gofrontend/libgo/go/runtime/map_test.go index 9ed183bb9d1..ed0347a453a 100644 --- a/llgo/third_party/gofrontend/libgo/go/runtime/map_test.go +++ b/llgo/third_party/gofrontend/libgo/go/runtime/map_test.go @@ -391,7 +391,7 @@ func TestMapNanGrowIterator(t *testing.T) { nan := math.NaN() const nBuckets = 16 // To fill nBuckets buckets takes LOAD * nBuckets keys. - nKeys := int(nBuckets * *runtime.HashLoad) + nKeys := int(nBuckets * /* *runtime.HashLoad */ 6.5) // Get map to full point with nan keys. for i := 0; i < nKeys; i++ { @@ -537,6 +537,61 @@ func TestMapStringBytesLookup(t *testing.T) { } } +func TestMapLargeKeyNoPointer(t *testing.T) { + const ( + I = 1000 + N = 64 + ) + type T [N]int + m := make(map[T]int) + for i := 0; i < I; i++ { + var v T + for j := 0; j < N; j++ { + v[j] = i + j + } + m[v] = i + } + runtime.GC() + for i := 0; i < I; i++ { + var v T + for j := 0; j < N; j++ { + v[j] = i + j + } + if m[v] != i { + t.Fatalf("corrupted map: want %+v, got %+v", i, m[v]) + } + } +} + +func TestMapLargeValNoPointer(t *testing.T) { + const ( + I = 1000 + N = 64 + ) + type T [N]int + m := make(map[int]T) + for i := 0; i < I; i++ { + var v T + for j := 0; j < N; j++ { + v[j] = i + j + } + m[i] = v + } + runtime.GC() + for i := 0; i < I; i++ { + var v T + for j := 0; j < N; j++ { + v[j] = i + j + } + v1 := m[i] + for j := 0; j < N; j++ { + if v1[j] != v[j] { + t.Fatalf("corrupted map: want %+v, got %+v", v, v1) + } + } + } +} + func benchmarkMapPop(b *testing.B, n int) { m := map[int]int{} for i := 0; i < b.N; i++ { @@ -557,3 +612,14 @@ func benchmarkMapPop(b *testing.B, n int) { func BenchmarkMapPop100(b *testing.B) { benchmarkMapPop(b, 100) } func BenchmarkMapPop1000(b *testing.B) { benchmarkMapPop(b, 1000) } func BenchmarkMapPop10000(b *testing.B) { benchmarkMapPop(b, 10000) } + +func TestNonEscapingMap(t *testing.T) { + t.Skip("does not work on gccgo without better escape analysis") + n := testing.AllocsPerRun(1000, func() { + m := make(map[int]int) + m[0] = 0 + }) + if n != 0 { + t.Fatalf("want 0 allocs, got %v", n) + } +} |

