public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Update to go1.15rc1
@ 2020-08-01 19:28 Ian Lance Taylor
  2020-08-02  7:50 ` Andreas Schwab
  2020-08-02 20:00 ` Rainer Orth
  0 siblings, 2 replies; 7+ messages in thread
From: Ian Lance Taylor @ 2020-08-01 19:28 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 323 bytes --]

This libgo patch updates the sources to the go1.15rc1 release
candidate.  As usual, the changes for this update are too large to
include in an e-mail message.  I've just included the highlights and
changes to GCC-specific files below.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 13726 bytes --]

f75af8c1464e948b5e166cf5ab09ebf0d82fc253
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 64a655e911e..89d1f3c7623 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-63bc2430187efe5ff47e9c7b9cd6d40b350ee7d7
+2c390ba951e83b547f6387cc9e19436c085b3775
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/MERGE b/libgo/MERGE
index 4f8589371d3..ad43e2924c6 100644
--- a/libgo/MERGE
+++ b/libgo/MERGE
@@ -1,4 +1,4 @@
-edfd6f28486017dcb136cd3f3ec252706d4b326e
+3e8f6b0791a670e52d25d76813d669daa68acfb4
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 52a8330ed2a..88ea2728bc3 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -391,6 +391,11 @@ toolexeclibgotexttemplatedir = $(toolexeclibgotextdir)/template
 toolexeclibgotexttemplate_DATA = \
 	text/template/parse.gox
 
+toolexeclibgotimedir = $(toolexeclibgodir)/time
+
+toolexeclibgotime_DATA = \
+	time/tzdata.gox
+
 toolexeclibgounicodedir = $(toolexeclibgodir)/unicode
 
 toolexeclibgounicode_DATA = \
@@ -400,7 +405,8 @@ toolexeclibgounicode_DATA = \
 # Some internal packages are needed to bootstrap the gc toolchain.
 toolexeclibgointernaldir = $(toolexeclibgodir)/internal
 toolexeclibgointernal_DATA = \
-	internal/reflectlite.gox
+	internal/reflectlite.gox \
+	internal/unsafeheader.gox
 
 # Some packages are only needed for tests, so unlike the other
 # internal packages nothing will explicitly depend on them.
@@ -409,11 +415,11 @@ noinst_DATA = \
 	golang.org/x/net/nettest.gox \
 	internal/cfg.gox \
 	internal/obscuretestdata.gox \
+	internal/profile.gox \
 	internal/testenv.gox \
 	internal/trace.gox \
 	net/internal/socktest.gox \
-	os/signal/internal/pty.gox \
-	runtime/pprof/internal/profile.gox
+	os/signal/internal/pty.gox
 
 if LIBGO_IS_RTEMS
 rtems_task_variable_add_file = runtime/rtems-task-variable-add.c
@@ -706,9 +712,9 @@ syscall_lib_clone_lo =
 endif
 
 if LIBGO_IS_X86
-golangorg_x_sys_cpu_gccgo_lo = golang.org/x/sys/cpu_gccgo.lo
+golangorg_x_sys_cpu_gccgo_x86_lo = golang.org/x/sys/cpu_gccgo_x86.lo
 else
-golangorg_x_sys_cpu_gccgo_lo =
+golangorg_x_sys_cpu_gccgo_x86_lo =
 endif
 
 PACKAGES = $(shell cat $(srcdir)/libgo-packages.txt)
@@ -728,7 +734,7 @@ libgo_go_objs = \
 	runtime/internal/atomic_c.lo \
 	sync/atomic_c.lo \
 	internal/cpu/cpu_gccgo.lo \
-	$(golangorg_x_sys_cpu_gccgo_lo)
+	$(golangorg_x_sys_cpu_gccgo_x86_lo)
 
 libgo_ldflags = \
 	-version-info $(libtool_VERSION) $(PTHREAD_CFLAGS) $(AM_LDFLAGS)
@@ -1008,6 +1014,7 @@ extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a
+extra_check_libs_cmd_go_internal_test = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a
 extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a
 
@@ -1060,9 +1067,9 @@ internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc
 	$(LTCOMPILE) -c -o $@ $(srcdir)/go/internal/cpu/cpu_gccgo.c
 
 # Similarly, golang.org/x/sys/cpu needs some C code.
-golang.org/x/sys/cpu_gccgo.lo: go/golang.org/x/sys/cpu/cpu_gccgo.c runtime.inc
+golang.org/x/sys/cpu_gccgo_x86.lo: go/golang.org/x/sys/cpu/cpu_gccgo_x86.c runtime.inc
 	@$(MKDIR_P) golang.org/x/sys
-	$(LTCOMPILE) -c -o $@ $(srcdir)/go/golang.org/x/sys/cpu/cpu_gccgo.c
+	$(LTCOMPILE) -c -o $@ $(srcdir)/go/golang.org/x/sys/cpu/cpu_gccgo_x86.c
 
 # Solaris 11.4 changed the type of fields in struct stat.
 # Use a build tag, based on a configure check, to cope.
@@ -1238,7 +1245,7 @@ all-local: $(ALL_LOCAL_DEPS)
 
 MAJOR=$(firstword $(subst :, ,$(libtool_VERSION)))
 add-aix-fat-library: all-multi
-    @if test "$(MULTIBUILDTOP)" = ""; then \
-        ${AR} -X$(AIX_DEFAULT_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
-        ${AR} -X$(AIX_DEFAULT_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
-    fi
+	@if test "$(MULTIBUILDTOP)" = ""; then \
+	  ${AR} -X$(AIX_DEFAULT_ARCH) rc .libs/$(PACKAGE).a ../ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
+	  ${AR} -X$(AIX_DEFAULT_ARCH) rc ../pthread/$(PACKAGE)/.libs/$(PACKAGE).a ../pthread/ppc$(AIX_DEFAULT_ARCH)/$(PACKAGE)/.libs/$(PACKAGE).so.$(MAJOR); \
+	fi
diff --git a/libgo/VERSION b/libgo/VERSION
index 398d25321fb..0bcf07d0280 100644
--- a/libgo/VERSION
+++ b/libgo/VERSION
@@ -1 +1 @@
-go1.14.6
+go1.15rc1
diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt
index 48c4dfdbc91..efa7d191180 100644
--- a/libgo/check-packages.txt
+++ b/libgo/check-packages.txt
@@ -16,6 +16,7 @@ cmd/go/internal/modload
 cmd/go/internal/mvs
 cmd/go/internal/par
 cmd/go/internal/search
+cmd/go/internal/test
 cmd/go/internal/txtar
 cmd/go/internal/work
 cmd/internal/buildid
@@ -104,9 +105,11 @@ index/suffixarray
 internal/cpu
 internal/fmtsort
 internal/poll
+internal/profile
 internal/reflectlite
 internal/singleflight
 internal/trace
+internal/unsafeheader
 internal/xcoff
 io
 io/ioutil
@@ -152,7 +155,6 @@ runtime/internal/atomic
 runtime/internal/math
 runtime/internal/sys
 runtime/pprof
-runtime/pprof/internal/profile
 runtime/trace
 sort
 strconv
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 841cba1768e..db5848e36ad 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -10,7 +10,7 @@ AC_INIT(package-unused, version-unused,, libgo)
 AC_CONFIG_SRCDIR(Makefile.am)
 AC_CONFIG_HEADER(config.h)
 
-libtool_VERSION=16:0:0
+libtool_VERSION=17:0:0
 AC_SUBST(libtool_VERSION)
 
 AM_ENABLE_MULTILIB(, ..)
diff --git a/libgo/go/internal/bytealg/bytealg.go b/libgo/go/internal/bytealg/bytealg.go
index e46ee7c4fba..abdba5fb580 100644
--- a/libgo/go/internal/bytealg/bytealg.go
+++ b/libgo/go/internal/bytealg/bytealg.go
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build ignore_for_gccgo
-
 package bytealg
 
 import (
@@ -22,4 +20,130 @@ const (
 )
 
 // MaxLen is the maximum length of the string to be searched for (argument b) in Index.
+// If MaxLen is not 0, make sure MaxLen >= 4.
 var MaxLen int = 32
+
+// FIXME: the logic of HashStrBytes, HashStrRevBytes, IndexRabinKarpBytes and HashStr, HashStrRev,
+// IndexRabinKarp are exactly the same, except that the types are different. Can we eliminate
+// three of them without causing allocation?
+
+// PrimeRK is the prime base used in Rabin-Karp algorithm.
+const PrimeRK = 16777619
+
+// HashStrBytes returns the hash and the appropriate multiplicative
+// factor for use in Rabin-Karp algorithm.
+func HashStrBytes(sep []byte) (uint32, uint32) {
+	hash := uint32(0)
+	for i := 0; i < len(sep); i++ {
+		hash = hash*PrimeRK + uint32(sep[i])
+	}
+	var pow, sq uint32 = 1, PrimeRK
+	for i := len(sep); i > 0; i >>= 1 {
+		if i&1 != 0 {
+			pow *= sq
+		}
+		sq *= sq
+	}
+	return hash, pow
+}
+
+// HashStr returns the hash and the appropriate multiplicative
+// factor for use in Rabin-Karp algorithm.
+func HashStr(sep string) (uint32, uint32) {
+	hash := uint32(0)
+	for i := 0; i < len(sep); i++ {
+		hash = hash*PrimeRK + uint32(sep[i])
+	}
+	var pow, sq uint32 = 1, PrimeRK
+	for i := len(sep); i > 0; i >>= 1 {
+		if i&1 != 0 {
+			pow *= sq
+		}
+		sq *= sq
+	}
+	return hash, pow
+}
+
+// HashStrRevBytes returns the hash of the reverse of sep and the
+// appropriate multiplicative factor for use in Rabin-Karp algorithm.
+func HashStrRevBytes(sep []byte) (uint32, uint32) {
+	hash := uint32(0)
+	for i := len(sep) - 1; i >= 0; i-- {
+		hash = hash*PrimeRK + uint32(sep[i])
+	}
+	var pow, sq uint32 = 1, PrimeRK
+	for i := len(sep); i > 0; i >>= 1 {
+		if i&1 != 0 {
+			pow *= sq
+		}
+		sq *= sq
+	}
+	return hash, pow
+}
+
+// HashStrRev returns the hash of the reverse of sep and the
+// appropriate multiplicative factor for use in Rabin-Karp algorithm.
+func HashStrRev(sep string) (uint32, uint32) {
+	hash := uint32(0)
+	for i := len(sep) - 1; i >= 0; i-- {
+		hash = hash*PrimeRK + uint32(sep[i])
+	}
+	var pow, sq uint32 = 1, PrimeRK
+	for i := len(sep); i > 0; i >>= 1 {
+		if i&1 != 0 {
+			pow *= sq
+		}
+		sq *= sq
+	}
+	return hash, pow
+}
+
+// IndexRabinKarpBytes uses the Rabin-Karp search algorithm to return the index of the
+// first occurence of substr in s, or -1 if not present.
+func IndexRabinKarpBytes(s, sep []byte) int {
+	// Rabin-Karp search
+	hashsep, pow := HashStrBytes(sep)
+	n := len(sep)
+	var h uint32
+	for i := 0; i < n; i++ {
+		h = h*PrimeRK + uint32(s[i])
+	}
+	if h == hashsep && Equal(s[:n], sep) {
+		return 0
+	}
+	for i := n; i < len(s); {
+		h *= PrimeRK
+		h += uint32(s[i])
+		h -= pow * uint32(s[i-n])
+		i++
+		if h == hashsep && Equal(s[i-n:i], sep) {
+			return i - n
+		}
+	}
+	return -1
+}
+
+// IndexRabinKarp uses the Rabin-Karp search algorithm to return the index of the
+// first occurence of substr in s, or -1 if not present.
+func IndexRabinKarp(s, substr string) int {
+	// Rabin-Karp search
+	hashss, pow := HashStr(substr)
+	n := len(substr)
+	var h uint32
+	for i := 0; i < n; i++ {
+		h = h*PrimeRK + uint32(s[i])
+	}
+	if h == hashss && s[:n] == substr {
+		return 0
+	}
+	for i := n; i < len(s); {
+		h *= PrimeRK
+		h += uint32(s[i])
+		h -= pow * uint32(s[i-n])
+		i++
+		if h == hashss && s[i-n:i] == substr {
+			return i - n
+		}
+	}
+	return -1
+}
diff --git a/libgo/go/internal/bytealg/gccgo.go b/libgo/go/internal/bytealg/gccgo.go
index 8c78b631dee..05b39e3e2ca 100644
--- a/libgo/go/internal/bytealg/gccgo.go
+++ b/libgo/go/internal/bytealg/gccgo.go
@@ -6,7 +6,4 @@
 
 package bytealg
 
-// MaxLen is the maximum length of the string to be searched for (argument b) in Index.
-var MaxLen int = 32
-
 const MaxBruteForce = 64
diff --git a/libgo/go/internal/bytealg/index_generic.go b/libgo/go/internal/bytealg/index_generic.go
index c595c231cf0..3dc1c6b2232 100644
--- a/libgo/go/internal/bytealg/index_generic.go
+++ b/libgo/go/internal/bytealg/index_generic.go
@@ -17,8 +17,42 @@ func Index(a, b []byte) int {
 
 // IndexString returns the index of the first instance of b in a, or -1 if b is not present in a.
 // Requires 2 <= len(b) <= MaxLen.
-func IndexString(a, b string) int {
-	panic("unimplemented")
+func IndexString(s, substr string) int {
+	// This is a partial copy of strings.Index, here because bytes.IndexAny and bytes.LastIndexAny
+	// call bytealg.IndexString. Some platforms have an optimized assembly version of this function.
+	// This implementation is used for those that do not. Although the pure Go implementation here
+	// works for the case of len(b) > MaxLen, we do not require that its assembly implementation also
+	// supports the case of len(b) > MaxLen. And we do not guarantee that this function supports the
+	// case of len(b) > MaxLen.
+	n := len(substr)
+	c0 := substr[0]
+	c1 := substr[1]
+	i := 0
+	t := len(s) - n + 1
+	fails := 0
+	for i < t {
+		if s[i] != c0 {
+			o := IndexByteString(s[i:t], c0)
+			if o < 0 {
+				return -1
+			}
+			i += o
+		}
+		if s[i+1] == c1 && s[i:i+n] == substr {
+			return i
+		}
+		i++
+		fails++
+		if fails >= 4+i>>4 && i < t {
+			// See comment in src/bytes/bytes.go.
+			j := IndexRabinKarp(s[i:], substr)
+			if j < 0 {
+				return -1
+			}
+			return i + j
+		}
+	}
+	return -1
 }
 
 // Cutover reports the number of failures of IndexByte we should tolerate
diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt
index 90521ae0b50..745c34cd2e6 100644
--- a/libgo/gotool-packages.txt
+++ b/libgo/gotool-packages.txt
@@ -70,6 +70,7 @@ golang.org/x/tools/go/analysis/passes/copylock
 golang.org/x/tools/go/analysis/passes/ctrlflow
 golang.org/x/tools/go/analysis/passes/errorsas
 golang.org/x/tools/go/analysis/passes/httpresponse
+golang.org/x/tools/go/analysis/passes/ifaceassert
 golang.org/x/tools/go/analysis/passes/inspect
 golang.org/x/tools/go/analysis/passes/internal/analysisutil
 golang.org/x/tools/go/analysis/passes/loopclosure
@@ -79,6 +80,7 @@ golang.org/x/tools/go/analysis/passes/pkgfact
 golang.org/x/tools/go/analysis/passes/printf
 golang.org/x/tools/go/analysis/passes/shift
 golang.org/x/tools/go/analysis/passes/stdmethods
+golang.org/x/tools/go/analysis/passes/stringintconv
 golang.org/x/tools/go/analysis/passes/structtag
 golang.org/x/tools/go/analysis/passes/tests
 golang.org/x/tools/go/analysis/passes/unmarshal
@@ -91,5 +93,6 @@ golang.org/x/tools/go/ast/inspector
 golang.org/x/tools/go/cfg
 golang.org/x/tools/go/types/objectpath
 golang.org/x/tools/go/types/typeutil
+golang.org/x/tools/internal/analysisinternal
 golang.org/x/xerrors
 golang.org/x/xerrors/internal
diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt
index a3bdb948499..0b02988d11d 100644
--- a/libgo/libgo-packages.txt
+++ b/libgo/libgo-packages.txt
@@ -120,6 +120,7 @@ internal/nettrace
 internal/obscuretestdata
 internal/oserror
 internal/poll
+internal/profile
 internal/race
 internal/reflectlite
 internal/singleflight
@@ -128,6 +129,7 @@ internal/syscall/unix
 internal/testenv
 internal/testlog
 internal/trace
+internal/unsafeheader
 internal/xcoff
 io
 io/ioutil
@@ -174,7 +176,6 @@ runtime/internal/atomic
 runtime/internal/math
 runtime/internal/sys
 runtime/pprof
-runtime/pprof/internal/profile
 runtime/trace
 sort
 strconv
@@ -191,6 +192,7 @@ text/tabwriter
 text/template
 text/template/parse
 time
+time/tzdata
 unicode
 unicode/utf16
 unicode/utf8

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-08-04 17:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-01 19:28 libgo patch committed: Update to go1.15rc1 Ian Lance Taylor
2020-08-02  7:50 ` Andreas Schwab
2020-08-03 17:13   ` Ian Lance Taylor
2020-08-03 17:28     ` Andreas Schwab
2020-08-03 18:04       ` Ian Lance Taylor
2020-08-02 20:00 ` Rainer Orth
2020-08-04 17:21   ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).