libgo: update to Go 1.8 release candidate 1
Compiler changes: * Change map assignment to use mapassign and assign value directly. * Change string iteration to use decoderune, faster for ASCII strings. * Change makeslice to take int, and use makeslice64 for larger values. * Add new noverflow field to hmap struct used for maps. Unresolved problems, to be fixed later: * Commented out test in go/types/sizes_test.go that doesn't compile. * Commented out reflect.TestStructOf test for padding after zero-sized field. Reviewed-on: https://go-review.googlesource.com/35231 gotools/: Updates for Go 1.8rc1. * Makefile.am (go_cmd_go_files): Add bug.go. (s-zdefaultcc): Write defaultPkgConfig. * Makefile.in: Rebuild. From-SVN: r244456
This commit is contained in:
parent
829afb8f05
commit
c2047754c3
983 changed files with 69318 additions and 17662 deletions
|
@ -5,6 +5,7 @@
|
|||
package runtime_test
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
@ -81,28 +82,50 @@ func BenchmarkCompareStringBig(b *testing.B) {
|
|||
b.SetBytes(int64(len(s1)))
|
||||
}
|
||||
|
||||
func BenchmarkRuneIterate(b *testing.B) {
|
||||
bytes := make([]byte, 100)
|
||||
for i := range bytes {
|
||||
bytes[i] = byte('A')
|
||||
}
|
||||
s := string(bytes)
|
||||
func BenchmarkConcatStringAndBytes(b *testing.B) {
|
||||
s1 := []byte("Gophers!")
|
||||
for i := 0; i < b.N; i++ {
|
||||
for range s {
|
||||
}
|
||||
_ = "Hello " + string(s1)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRuneIterate2(b *testing.B) {
|
||||
bytes := make([]byte, 100)
|
||||
for i := range bytes {
|
||||
bytes[i] = byte('A')
|
||||
}
|
||||
s := string(bytes)
|
||||
for i := 0; i < b.N; i++ {
|
||||
for range s {
|
||||
var stringdata = []struct{ name, data string }{
|
||||
{"ASCII", "01234567890"},
|
||||
{"Japanese", "日本語日本語日本語"},
|
||||
{"MixedLength", "$Ѐࠀက퀀𐀀\U00040000\U0010FFFF"},
|
||||
}
|
||||
|
||||
func BenchmarkRuneIterate(b *testing.B) {
|
||||
b.Run("range", func(b *testing.B) {
|
||||
for _, sd := range stringdata {
|
||||
b.Run(sd.name, func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for range sd.data {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
b.Run("range1", func(b *testing.B) {
|
||||
for _, sd := range stringdata {
|
||||
b.Run(sd.name, func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _ = range sd.data {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
b.Run("range2", func(b *testing.B) {
|
||||
for _, sd := range stringdata {
|
||||
b.Run(sd.name, func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, _ = range sd.data {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func BenchmarkArrayEqual(b *testing.B) {
|
||||
|
@ -149,21 +172,6 @@ func TestLargeStringConcat(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestGostringnocopy(t *testing.T) {
|
||||
max := *runtime.Maxstring
|
||||
b := make([]byte, max+10)
|
||||
for i := uintptr(0); i < max+9; i++ {
|
||||
b[i] = 'a'
|
||||
}
|
||||
_ = runtime.Gostringnocopy(&b[0])
|
||||
newmax := *runtime.Maxstring
|
||||
if newmax != max+9 {
|
||||
t.Errorf("want %d, got %d", max+9, newmax)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func TestCompareTempString(t *testing.T) {
|
||||
s := strings.Repeat("x", sizeNoStack)
|
||||
b := []byte(s)
|
||||
|
@ -277,3 +285,97 @@ func TestString2Slice(t *testing.T) {
|
|||
t.Errorf("extra runes not zeroed")
|
||||
}
|
||||
}
|
||||
|
||||
const intSize = 32 << (^uint(0) >> 63)
|
||||
|
||||
type atoi64Test struct {
|
||||
in string
|
||||
out int64
|
||||
ok bool
|
||||
}
|
||||
|
||||
var atoi64tests = []atoi64Test{
|
||||
{"", 0, false},
|
||||
{"0", 0, true},
|
||||
{"-0", 0, true},
|
||||
{"1", 1, true},
|
||||
{"-1", -1, true},
|
||||
{"12345", 12345, true},
|
||||
{"-12345", -12345, true},
|
||||
{"012345", 12345, true},
|
||||
{"-012345", -12345, true},
|
||||
{"12345x", 0, false},
|
||||
{"-12345x", 0, false},
|
||||
{"98765432100", 98765432100, true},
|
||||
{"-98765432100", -98765432100, true},
|
||||
{"20496382327982653440", 0, false},
|
||||
{"-20496382327982653440", 0, false},
|
||||
{"9223372036854775807", 1<<63 - 1, true},
|
||||
{"-9223372036854775807", -(1<<63 - 1), true},
|
||||
{"9223372036854775808", 0, false},
|
||||
{"-9223372036854775808", -1 << 63, true},
|
||||
{"9223372036854775809", 0, false},
|
||||
{"-9223372036854775809", 0, false},
|
||||
}
|
||||
|
||||
func TestAtoi(t *testing.T) {
|
||||
switch intSize {
|
||||
case 32:
|
||||
for i := range atoi32tests {
|
||||
test := &atoi32tests[i]
|
||||
out, ok := runtime.Atoi(test.in)
|
||||
if test.out != int32(out) || test.ok != ok {
|
||||
t.Errorf("atoi(%q) = (%v, %v) want (%v, %v)",
|
||||
test.in, out, ok, test.out, test.ok)
|
||||
}
|
||||
}
|
||||
case 64:
|
||||
for i := range atoi64tests {
|
||||
test := &atoi64tests[i]
|
||||
out, ok := runtime.Atoi(test.in)
|
||||
if test.out != int64(out) || test.ok != ok {
|
||||
t.Errorf("atoi(%q) = (%v, %v) want (%v, %v)",
|
||||
test.in, out, ok, test.out, test.ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type atoi32Test struct {
|
||||
in string
|
||||
out int32
|
||||
ok bool
|
||||
}
|
||||
|
||||
var atoi32tests = []atoi32Test{
|
||||
{"", 0, false},
|
||||
{"0", 0, true},
|
||||
{"-0", 0, true},
|
||||
{"1", 1, true},
|
||||
{"-1", -1, true},
|
||||
{"12345", 12345, true},
|
||||
{"-12345", -12345, true},
|
||||
{"012345", 12345, true},
|
||||
{"-012345", -12345, true},
|
||||
{"12345x", 0, false},
|
||||
{"-12345x", 0, false},
|
||||
{"987654321", 987654321, true},
|
||||
{"-987654321", -987654321, true},
|
||||
{"2147483647", 1<<31 - 1, true},
|
||||
{"-2147483647", -(1<<31 - 1), true},
|
||||
{"2147483648", 0, false},
|
||||
{"-2147483648", -1 << 31, true},
|
||||
{"2147483649", 0, false},
|
||||
{"-2147483649", 0, false},
|
||||
}
|
||||
|
||||
func TestAtoi32(t *testing.T) {
|
||||
for i := range atoi32tests {
|
||||
test := &atoi32tests[i]
|
||||
out, ok := runtime.Atoi32(test.in)
|
||||
if test.out != out || test.ok != ok {
|
||||
t.Errorf("atoi32(%q) = (%v, %v) want (%v, %v)",
|
||||
test.in, out, ok, test.out, test.ok)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue