diff mbox

libgo patch committed: Update to weekly.2012-01-15

Message ID mcrehuntsar.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 25, 2012, 8:56 p.m. UTC
I have committed a patch to update libgo to the weekly.2012-01-15
release.  As usual I have not included the entire patch in this e-mail
message, just the changes to files that are specific to gccgo.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian
diff mbox

Patch

diff -r d24c6bfbe9f1 libgo/MERGE
--- a/libgo/MERGE	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/MERGE	Wed Jan 25 11:52:42 2012 -0800
@@ -1,4 +1,4 @@ 
-4a8268927758
+354b17404643
 
 The first line of this file holds the Mercurial revision number of the
 last merge done from the master library sources.
diff -r d24c6bfbe9f1 libgo/Makefile.am
--- a/libgo/Makefile.am	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/Makefile.am	Wed Jan 25 11:52:42 2012 -0800
@@ -188,7 +188,7 @@ 
 toolexeclibgocryptoopenpgp_DATA = \
 	crypto/openpgp/armor.gox \
 	crypto/openpgp/elgamal.gox \
-	crypto/openpgp/error.gox \
+	crypto/openpgp/errors.gox \
 	crypto/openpgp/packet.gox \
 	crypto/openpgp/s2k.gox
 
@@ -235,6 +235,7 @@ 
 	exp/ebnf.gox \
 	$(exp_inotify_gox) \
 	exp/norm.gox \
+	exp/proxy.gox \
 	exp/spdy.gox \
 	exp/sql.gox \
 	exp/ssh.gox \
@@ -669,17 +670,25 @@ 
 if LIBGO_IS_LINUX
 go_net_cgo_file = go/net/cgo_linux.go
 go_net_sock_file = go/net/sock_linux.go
+go_net_sockopt_file = go/net/sockopt_linux.go
+go_net_sockoptip_file = go/net/sockoptip_linux.go
 else
 if LIBGO_IS_IRIX
 go_net_cgo_file = go/net/cgo_linux.go
 go_net_sock_file = go/net/sock_linux.go
+go_net_sockopt_file = go/net/sockopt_linux.go
+go_net_sockoptip_file = go/net/sockoptip_linux.go
 else
 if LIBGO_IS_SOLARIS
 go_net_cgo_file = go/net/cgo_linux.go
 go_net_sock_file = go/net/sock_linux.go
+go_net_sockopt_file = go/net/sockopt_linux.go
+go_net_sockoptip_file = go/net/sockoptip_linux.go
 else
 go_net_cgo_file = go/net/cgo_bsd.go
 go_net_sock_file = go/net/sock_bsd.go
+go_net_sockopt_file = go/net/sockopt_bsd.go
+go_net_sockoptip_file = go/net/sockoptip_bsd.go
 endif
 endif
 endif
@@ -728,6 +737,10 @@ 
 	$(go_net_sendfile_file) \
 	go/net/sock.go \
 	$(go_net_sock_file) \
+	go/net/sockopt.go \
+	$(go_net_sockopt_file) \
+	go/net/sockoptip.go \
+	$(go_net_sockoptip_file) \
 	go/net/tcpsock.go \
 	go/net/tcpsock_posix.go \
 	go/net/udpsock.go \
@@ -890,8 +903,7 @@ 
 go_testing_files = \
 	go/testing/benchmark.go \
 	go/testing/example.go \
-	go/testing/testing.go \
-	go/testing/wrapper.go
+	go/testing/testing.go
 
 go_time_files = \
 	go/time/format.go \
@@ -1061,8 +1073,8 @@ 
 	go/crypto/openpgp/armor/encode.go
 go_crypto_openpgp_elgamal_files = \
 	go/crypto/openpgp/elgamal/elgamal.go
-go_crypto_openpgp_error_files = \
-	go/crypto/openpgp/error/error.go
+go_crypto_openpgp_errors_files = \
+	go/crypto/openpgp/errors/errors.go
 go_crypto_openpgp_packet_files = \
 	go/crypto/openpgp/packet/compressed.go \
 	go/crypto/openpgp/packet/encrypted_key.go \
@@ -1142,6 +1154,7 @@ 
 go_encoding_xml_files = \
 	go/encoding/xml/marshal.go \
 	go/encoding/xml/read.go \
+	go/encoding/xml/typeinfo.go \
 	go/encoding/xml/xml.go
 
 go_exp_ebnf_files = \
@@ -1157,6 +1170,11 @@ 
 	go/exp/norm/readwriter.go \
 	go/exp/norm/tables.go \
 	go/exp/norm/trie.go
+go_exp_proxy_files = \
+	go/exp/proxy/direct.go \
+	go/exp/proxy/per_host.go \
+	go/exp/proxy/proxy.go \
+	go/exp/proxy/socks5.go
 go_exp_spdy_files = \
 	go/exp/spdy/read.go \
 	go/exp/spdy/types.go \
@@ -1173,7 +1191,7 @@ 
 	go/exp/ssh/doc.go \
 	go/exp/ssh/messages.go \
 	go/exp/ssh/server.go \
-	go/exp/ssh/server_shell.go \
+	go/exp/ssh/server_terminal.go \
 	go/exp/ssh/session.go \
 	go/exp/ssh/tcpip.go \
 	go/exp/ssh/transport.go
@@ -1210,7 +1228,8 @@ 
 	go/go/doc/doc.go \
 	go/go/doc/example.go \
 	go/go/doc/exports.go \
-	go/go/doc/filter.go
+	go/go/doc/filter.go \
+	go/go/doc/reader.go
 go_go_parser_files = \
 	go/go/parser/interface.go \
 	go/go/parser/parser.go
@@ -1461,8 +1480,15 @@ 
 # Define ForkExec and Exec.
 if LIBGO_IS_RTEMS
 syscall_exec_file = go/syscall/exec_stubs.go
+syscall_exec_os_file =
+else
+if LIBGO_IS_LINUX
+syscall_exec_file = go/syscall/exec_unix.go
+syscall_exec_os_file = go/syscall/exec_linux.go
 else
 syscall_exec_file = go/syscall/exec_unix.go
+syscall_exec_os_file = go/syscall/exec_bsd.go
+endif
 endif
 
 # Define Wait4.
@@ -1573,6 +1599,7 @@ 
 	go/syscall/syscall.go \
 	$(syscall_syscall_file) \
 	$(syscall_exec_file) \
+	$(syscall_exec_os_file) \
 	$(syscall_wait_file) \
 	$(syscall_sleep_file) \
 	$(syscall_errstr_file) \
@@ -1720,7 +1747,7 @@ 
 	crypto/xtea.lo \
 	crypto/openpgp/armor.lo \
 	crypto/openpgp/elgamal.lo \
-	crypto/openpgp/error.lo \
+	crypto/openpgp/errors.lo \
 	crypto/openpgp/packet.lo \
 	crypto/openpgp/s2k.lo \
 	crypto/x509/pkix.lo \
@@ -1743,6 +1770,7 @@ 
 	encoding/xml.lo \
 	exp/ebnf.lo \
 	exp/norm.lo \
+	exp/proxy.lo \
 	exp/spdy.lo \
 	exp/sql.lo \
 	exp/ssh.lo \
@@ -2578,15 +2606,15 @@ 
 	@$(CHECK)
 .PHONY: crypto/openpgp/elgamal/check
 
-@go_include@ crypto/openpgp/error.lo.dep
-crypto/openpgp/error.lo.dep: $(go_crypto_openpgp_error_files)
+@go_include@ crypto/openpgp/errors.lo.dep
+crypto/openpgp/errors.lo.dep: $(go_crypto_openpgp_errors_files)
 	$(BUILDDEPS)
-crypto/openpgp/error.lo: $(go_crypto_openpgp_error_files)
+crypto/openpgp/errors.lo: $(go_crypto_openpgp_errors_files)
 	$(BUILDPACKAGE)
-crypto/openpgp/error/check: $(CHECK_DEPS)
-	@$(MKDIR_P) crypto/openpgp/error
+crypto/openpgp/errors/check: $(CHECK_DEPS)
+	@$(MKDIR_P) crypto/openpgp/errors
 	@$(CHECK)
-.PHONY: crypto/openpgp/error/check
+.PHONY: crypto/openpgp/errors/check
 
 @go_include@ crypto/openpgp/packet.lo.dep
 crypto/openpgp/packet.lo.dep: $(go_crypto_openpgp_packet_files)
@@ -2808,6 +2836,16 @@ 
 	@$(CHECK)
 .PHONY: exp/norm/check
 
+@go_include@ exp/proxy.lo.dep
+exp/proxy.lo.dep: $(go_exp_proxy_files)
+	$(BUILDDEPS)
+exp/proxy.lo: $(go_exp_proxy_files)
+	$(BUILDPACKAGE)
+exp/proxy/check: $(CHECK_DEPS)
+	@$(MKDIR_P) exp/proxy
+	@$(CHECK)
+.PHONY: exp/proxy/check
+
 @go_include@ exp/spdy.lo.dep
 exp/spdy.lo.dep: $(go_exp_spdy_files)
 	$(BUILDDEPS)
@@ -3622,7 +3660,7 @@ 
 	$(BUILDGOX)
 crypto/openpgp/elgamal.gox: crypto/openpgp/elgamal.lo
 	$(BUILDGOX)
-crypto/openpgp/error.gox: crypto/openpgp/error.lo
+crypto/openpgp/errors.gox: crypto/openpgp/errors.lo
 	$(BUILDGOX)
 crypto/openpgp/packet.gox: crypto/openpgp/packet.lo
 	$(BUILDGOX)
@@ -3674,6 +3712,8 @@ 
 	$(BUILDGOX)
 exp/norm.gox: exp/norm.lo
 	$(BUILDGOX)
+exp/proxy.gox: exp/proxy.lo
+	$(BUILDGOX)
 exp/spdy.gox: exp/spdy.lo
 	$(BUILDGOX)
 exp/sql.gox: exp/sql.lo
@@ -3920,6 +3960,7 @@ 
 	exp/ebnf/check \
 	$(exp_inotify_check) \
 	exp/norm/check \
+	exp/proxy/check \
 	exp/spdy/check \
 	exp/sql/check \
 	exp/ssh/check \
diff -r d24c6bfbe9f1 libgo/configure.ac
--- a/libgo/configure.ac	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/configure.ac	Wed Jan 25 11:52:42 2012 -0800
@@ -451,7 +451,7 @@ 
   ;;
 esac
 
-AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h)
+AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h)
 
 AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
diff -r d24c6bfbe9f1 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/mksysinfo.sh	Wed Jan 25 11:52:42 2012 -0800
@@ -55,6 +55,9 @@ 
 #if defined(HAVE_SYS_MMAN_H)
 #include <sys/mman.h>
 #endif
+#if defined(HAVE_SYS_PRCTL_H)
+#include <sys/prctl.h>
+#endif
 #if defined(HAVE_SYS_PTRACE_H)
 #include <sys/ptrace.h>
 #endif
@@ -210,6 +213,10 @@ 
   echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
 fi
 
+# Prctl constants.
+grep '^const _PR_' gen-sysinfo.go |
+  sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+
 # Ptrace constants.
 grep '^const _PTRACE' gen-sysinfo.go |
   sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
@@ -505,6 +512,26 @@ 
   echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
 fi
 
+# The size of the ipv6_mreq struct.
+echo 'var SizeofIPv6Mreq = int(unsafe.Sizeof(IPv6Mreq{}))' >> ${OUT}
+
+# The ip_mreqn struct.
+grep '^type _ip_mreqn ' gen-sysinfo.go | \
+    sed -e 's/_ip_mreqn/IPMreqn/' \
+      -e 's/imr_multiaddr/Multiaddr/' \
+      -e 's/imr_address/Address/' \
+      -e 's/imr_ifindex/Ifindex/' \
+      -e 's/_in_addr/[4]byte/g' \
+    >> ${OUT}
+
+# We need IPMreq to compile the net package.
+if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then
+  echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT}
+fi
+
+# The size of the ip_mreqn struct.
+echo 'var SizeofIPMreqn = int(unsafe.Sizeof(IPMreqn{}))' >> ${OUT}
+
 # Try to guess the type to use for fd_set.
 fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
 fds_bits_type="_C_long"
diff -r d24c6bfbe9f1 libgo/runtime/malloc.goc
--- a/libgo/runtime/malloc.goc	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/malloc.goc	Wed Jan 25 11:52:42 2012 -0800
@@ -129,7 +129,7 @@ 
 	if(v == nil)
 		return;
 	
-	// If you change this also change mgc0.c:/^sweepspan,
+	// If you change this also change mgc0.c:/^sweep,
 	// which has a copy of the guts of free.
 
 	m = runtime_m();
diff -r d24c6bfbe9f1 libgo/runtime/malloc.h
--- a/libgo/runtime/malloc.h	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/malloc.h	Wed Jan 25 11:52:42 2012 -0800
@@ -123,10 +123,9 @@ 
 
 	// Max number of threads to run garbage collection.
 	// 2, 3, and 4 are all plausible maximums depending
-	// on the hardware details of the machine.  The second
-	// proc is the one that helps the most (after the first),
-	// so start with just 2 for now.
-	MaxGcproc = 2,
+	// on the hardware details of the machine.  The garbage
+	// collector scales well to 4 cpus.
+	MaxGcproc = 4,
 };
 
 // A generic linked list of blocks.  (Typically the block is bigger than sizeof(MLink).)
diff -r d24c6bfbe9f1 libgo/runtime/mgc0.c
--- a/libgo/runtime/mgc0.c	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/mgc0.c	Wed Jan 25 11:52:42 2012 -0800
@@ -62,9 +62,6 @@ 
 #define bitMask (bitBlockBoundary | bitAllocated | bitMarked | bitSpecial)
 
 // TODO: Make these per-M.
-static uint64 nlookup;
-static uint64 nsizelookup;
-static uint64 naddrlookup;
 static uint64 nhandoff;
 
 static int32 gctrace;
@@ -218,8 +215,6 @@ 
 
 			// Otherwise consult span table to find beginning.
 			// (Manually inlined copy of MHeap_LookupMaybe.)
-			nlookup++;
-			naddrlookup++;
 			k = (uintptr)obj>>PageShift;
 			x = k;
 			if(sizeof(void*) == 8)
@@ -307,49 +302,8 @@ 
 		b = *--wp;
 		nobj--;
 
-		// Figure out n = size of b.  Start by loading bits for b.
-		off = (uintptr*)b - (uintptr*)arena_start;
-		bitp = (uintptr*)arena_start - off/wordsPerBitmapWord - 1;
-		shift = off % wordsPerBitmapWord;
-		xbits = *bitp;
-		bits = xbits >> shift;
-
-		// Might be small; look for nearby block boundary.
-		// A block boundary is marked by either bitBlockBoundary
-		// or bitAllocated being set (see notes near their definition).
-		enum {
-			boundary = bitBlockBoundary|bitAllocated
-		};
-		// Look for a block boundary both after and before b
-		// in the same bitmap word.
-		//
-		// A block boundary j words after b is indicated by
-		//	bits>>j & boundary
-		// assuming shift+j < bitShift.  (If shift+j >= bitShift then
-		// we'll be bleeding other bit types like bitMarked into our test.)
-		// Instead of inserting the conditional shift+j < bitShift into the loop,
-		// we can let j range from 1 to bitShift as long as we first
-		// apply a mask to keep only the bits corresponding
-		// to shift+j < bitShift aka j < bitShift-shift.
-		bits &= (boundary<<(bitShift-shift)) - boundary;
-
-		// A block boundary j words before b is indicated by
-		//	xbits>>(shift-j) & boundary
-		// (assuming shift >= j).  There is no cleverness here
-		// avoid the test, because when j gets too large the shift
-		// turns negative, which is undefined in C.
-
-		for(j=1; j<bitShift; j++) {
-			if(((bits>>j)&boundary) != 0 || (shift>=j && ((xbits>>(shift-j))&boundary) != 0)) {
-				n = j*PtrSize;
-				goto scan;
-			}
-		}
-
-		// Fall back to asking span about size class.
+		// Ask span about size class.
 		// (Manually inlined copy of MHeap_Lookup.)
-		nlookup++;
-		nsizelookup++;
 		x = (uintptr)b>>PageShift;
 		if(sizeof(void*) == 8)
 			x -= (uintptr)arena_start>>PageShift;
@@ -358,7 +312,6 @@ 
 			n = s->npages<<PageShift;
 		else
 			n = runtime_class_to_size[s->sizeclass];
-	scan:;
 	}
 }
 
@@ -1018,9 +971,6 @@ 
 	}
 
 	t0 = runtime_nanotime();
-	nlookup = 0;
-	nsizelookup = 0;
-	naddrlookup = 0;
 	nhandoff = 0;
 
 	m->gcing = 1;
@@ -1085,11 +1035,11 @@ 
 		runtime_printf("pause %llu\n", (unsigned long long)t3-t0);
 
 	if(gctrace) {
-		runtime_printf("gc%d: %llu+%llu+%llu ms %llu -> %llu MB %llu -> %llu (%llu-%llu) objects %llu pointer lookups (%llu size, %llu addr) %llu handoff\n",
-			mstats.numgc, (unsigned long long)(t1-t0)/1000000, (unsigned long long)(t2-t1)/1000000, (unsigned long long)(t3-t2)/1000000,
+		runtime_printf("gc%d(%d): %llu+%llu+%llu ms %llu -> %llu MB %llu -> %llu (%llu-%llu) objects %llu handoff\n",
+			mstats.numgc, work.nproc, (unsigned long long)(t1-t0)/1000000, (unsigned long long)(t2-t1)/1000000, (unsigned long long)(t3-t2)/1000000,
 			(unsigned long long)heap0>>20, (unsigned long long)heap1>>20, (unsigned long long)obj0, (unsigned long long)obj1,
-			(unsigned long long)mstats.nmalloc, (unsigned long long)mstats.nfree,
-			(unsigned long long)nlookup, (unsigned long long)nsizelookup, (unsigned long long)naddrlookup, (unsigned long long) nhandoff);
+			(unsigned long long) mstats.nmalloc, (unsigned long long)mstats.nfree,
+			(unsigned long long) nhandoff);
 	}
 
 	runtime_semrelease(&gcsema);
diff -r d24c6bfbe9f1 libgo/runtime/runtime.c
--- a/libgo/runtime/runtime.c	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/runtime.c	Wed Jan 25 11:52:42 2012 -0800
@@ -115,7 +115,7 @@ 
 }
 
 void
-runtime_goenvs(void)
+runtime_goenvs_unix(void)
 {
 	String *s;
 	int32 i, n;
@@ -183,3 +183,22 @@ 
 	m->fastrand = x;
 	return x;
 }
+
+struct funcline_go_return
+{
+  String retfile;
+  int32 retline;
+};
+
+struct funcline_go_return
+runtime_funcline_go(void *f, uintptr targetpc)
+  __asm__("libgo_runtime.runtime.funcline_go");
+
+struct funcline_go_return
+runtime_funcline_go(void *f __attribute__((unused)),
+		    uintptr targetpc __attribute__((unused)))
+{
+  struct funcline_go_return ret;
+  runtime_memclr(&ret, sizeof ret);
+  return ret;
+}
diff -r d24c6bfbe9f1 libgo/runtime/runtime.h
--- a/libgo/runtime/runtime.h	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/runtime.h	Wed Jan 25 11:52:42 2012 -0800
@@ -266,6 +266,7 @@ 
 void	runtime_osinit();
 void	runtime_goargs(void);
 void	runtime_goenvs(void);
+void	runtime_goenvs_unix(void);
 void	runtime_throw(const char*) __attribute__ ((noreturn));
 void	runtime_panicstring(const char*) __attribute__ ((noreturn));
 void*	runtime_mal(uintptr);
diff -r d24c6bfbe9f1 libgo/runtime/runtime1.goc
--- a/libgo/runtime/runtime1.goc	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/runtime1.goc	Wed Jan 25 11:52:42 2012 -0800
@@ -8,3 +8,7 @@ 
 func GOMAXPROCS(n int32) (ret int32) {
 	ret = runtime_gomaxprocsfunc(n);
 }
+
+func NumCPU() (ret int32) {
+	ret = runtime_ncpu;
+}
diff -r d24c6bfbe9f1 libgo/runtime/thread-linux.c
--- a/libgo/runtime/thread-linux.c	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/runtime/thread-linux.c	Wed Jan 25 11:52:42 2012 -0800
@@ -103,3 +103,9 @@ 
 {
 	runtime_ncpu = getproccount();
 }
+
+void
+runtime_goenvs(void)
+{
+	runtime_goenvs_unix();
+}
diff -r d24c6bfbe9f1 libgo/testsuite/gotest
--- a/libgo/testsuite/gotest	Wed Jan 25 10:52:47 2012 -0800
+++ b/libgo/testsuite/gotest	Wed Jan 25 11:52:42 2012 -0800
@@ -273,8 +273,18 @@ 
 
 # Split $gofiles into external gofiles (those in *_test packages)
 # and internal ones (those in the main package).
-xgofiles=$(echo $(grep '^package[ 	]' $gofiles /dev/null | grep ':.*_test' | sed 's/:.*//'))
-gofiles=$(echo $(grep '^package[ 	]' $gofiles /dev/null | grep -v ':.*_test' | sed 's/:.*//'))
+for f in $gofiles; do
+    package=`grep '^package[ 	]' $f | sed 1q`
+    case "$package" in
+    *_test)
+	xgofiles="$xgofiles $f"
+	;;
+    *)
+	ngofiles="$ngofiles $f"
+	;;
+    esac
+done
+gofiles=$ngofiles
 
 # External $O file
 xofile=""
@@ -413,9 +423,9 @@ 
 	${GL} *.o ${GOLIBS}
 
 	if test "$trace" = "true"; then
-	    echo ./a.out -test.short -test.timeout=$timeout "$@"
+	    echo ./a.out -test.short -test.timeout=${timeout}s "$@"
 	fi
-	./a.out -test.short -test.timeout=$timeout "$@" &
+	./a.out -test.short -test.timeout=${timeout}s "$@" &
 	pid=$!
 	(sleep `expr $timeout + 10`
 	    echo > gotest-timeout