4.1/4.2/4.3 PATCH: Switch boehm-gc to pthreads on Solaris (boehm-gc/21940, boehm-gc/21942)

Rainer Orth ro@techfak.uni-bielefeld.de
Mon Jun 18 21:22:00 GMT 2007


As described in PR boehm-gc/21940, gctest fails on Solaris 10/x86.  PR
boehm-gc/21942 describes that the 64-bit version of boehm-gc doesn't build
at all.  Hans Boehm had long ago suggested to switch from the Solaris
threads support to pthreads, and the hacky patch in the PR demonstrated
that this works.

I've finally cleaned up the patch and tested it on both sparc and x86.  gc
7.0 alpha already includes the Solaris 2/amd64 clause in gcconfig.h and
made the switch to pthreads.  Unlike that version, I had to use
GC_SOLARIS_PTHREADS to mean pthreads on Solaris because it turned out to
be quite invasive to untangle all uses of GC_SOLARIS_THREADS.

With this patch, gctest works in both 32 and 64 bit versions on Solaris 10
(both sparc and x86).

The patch massively improves libjava testsuite results on both platforms,
which makes the switch even more desirable.

Right now, mainline libjava fails to build on x86 since several object
files contain non-PIC code.  I still need to investigate this, but it might
be related to the libtool upgrade.

Bootstrapped without regressions on sparc-sun-solaris2.10 and
i386-pc-solaris2.10 (mainline and 4.2 branch on sparc, 4.2 branch only on
x86).   Ok for both (mainline after the lockdown)?

I might also test the patch on the 4.1 branch if there's interest.

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Mon Jun 18 19:26:10 2007  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	PR boehm-gc/21940
	PR boehm-gc/21942
	* configure.ac (GC_SOLARIS_THREADS): Don't define on *-*-solaris*.
	* configure: Regenerate.
	* dyn_load.c: Use GC_SOLARIS_PTHREADS.
	* include/gc_config_macros.h (GC_SOLARIS_THREADS): Don't define.
	* include/private/gcconfig.h: Handle 64-bit Solaris 2/x86.
	(GC_SOLARIS_THREADS): Don't define.
	* include/private/solaris_threads.h: Remove.
	* pthread_support.c (GC_thr_init) [GC_SOLARIS_PTHREADS]: Determine
	GC_nprocs via sysconf().
	* Makefile.am (libgcjgc_la_SOURCES): Remove solaris_pthreads.c and
	solaris_threads.c.
	* Makefile.in: Regenerate.	 
	* solaris_pthreads.c: Remove.
	* solaris_threads.c: Remove.
	
Index: configure.ac
===================================================================
--- configure.ac	(revision 125718)
+++ configure.ac	(working copy)
@@ -173,8 +173,8 @@ case "$THREADS" in
 	THREADLIBS=-pthread
       	;;
      *-*-solaris*)
-	AC_DEFINE(GC_SOLARIS_THREADS,1,[support for Solaris (thr_) threads])
 	AC_DEFINE(GC_SOLARIS_PTHREADS,1,[support for Solaris pthreads])
+	THREADLIBS="-lpthread -lrt"
 	;;
      *-*-irix*)
 	AC_DEFINE(GC_IRIX_THREADS,1,[support for Irix pthreads])
Index: include/gc_config_macros.h
===================================================================
--- include/gc_config_macros.h	(revision 125718)
+++ include/gc_config_macros.h	(working copy)
@@ -72,10 +72,6 @@
 # define GC_WIN32_THREADS
 #endif
 
-#if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
-#   define GC_SOLARIS_THREADS
-#endif
-
 # define __GC
 # ifndef _WIN32_WCE
 #   include <stddef.h>
Index: include/private/gcconfig.h
===================================================================
--- include/private/gcconfig.h	(revision 125718)
+++ include/private/gcconfig.h	(working copy)
@@ -153,6 +153,11 @@
 #    define SUNOS5
 #    define mach_type_known
 # endif
+# if defined(sun) && defined(__amd64)
+#    define X86_64
+#    define SUNOS5
+#    define mach_type_known
+# endif
 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
 #    define I386
 #    define OS2
@@ -2041,6 +2046,36 @@
 	extern char etext[];
 #	define SEARCH_FOR_DATA_START
 #   endif
+#   ifdef SUNOS5
+#	define ELF_CLASS ELFCLASS64
+#	define OS_TYPE "SUNOS5"
+        extern int _etext[], _end[];
+  	extern ptr_t GC_SysVGetDataStart();
+#       define DATASTART GC_SysVGetDataStart(0x1000, _etext)
+#	define DATAEND (_end)
+/*	# define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7,  	*/
+/*      but reportedly breaks under 2.8.  It appears that the stack	*/
+/* 	base is a property of the executable, so this should not break	*/
+/* 	old executables.						*/
+/*  	HEURISTIC2 probably works, but this appears to be preferable.	*/
+/* #       include <sys/vm.h> */
+/* #	define STACKBOTTOM USRSTACK */
+#	define HEURISTIC2
+#	define PROC_VDB
+#	define DYNAMIC_LOADING
+#	if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
+#	    define USE_MMAP
+	    /* Otherwise we now use calloc.  Mmap may result in the	*/
+	    /* heap interleaved with thread stacks, which can result in	*/
+	    /* excessive blacklisting.  Sbrk is unusable since it	*/
+	    /* doesn't interact correctly with the system malloc.	*/
+#	endif
+#       ifdef USE_MMAP
+#         define HEAP_START (ptr_t)0x40000000
+#       else
+#	  define HEAP_START DATAEND
+#       endif
+#   endif
 # endif
 
 #if defined(LINUX) && defined(USE_MMAP)
@@ -2186,11 +2221,6 @@
 		((word*)x)[1] = 0;
 # endif /* CLEAR_DOUBLE */
 
-	/* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
-# if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
-#   define GC_SOLARIS_THREADS
-# endif
-
 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
 	--> inconsistent configuration
 # endif
Index: pthread_support.c
===================================================================
--- pthread_support.c	(revision 125718)
+++ pthread_support.c	(working copy)
@@ -883,7 +883,8 @@ void GC_thr_init()
 #       if defined(GC_HPUX_THREADS)
 	  GC_nprocs = pthread_num_processors_np();
 #       endif
-#	if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS)
+#	if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) || \
+	   defined(GC_SOLARIS_PTHREADS)
 	  GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN);
 	  if (GC_nprocs <= 0) GC_nprocs = 1;
 #	endif
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 125718)
+++ Makefile.am	(working copy)
@@ -21,7 +21,7 @@ libgcjgc_la_SOURCES = allchblk.c alloc.c
 dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c \
 malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
 obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
-solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \
+specific.c stubborn.c typd_mlc.c \
 backgraph.c win32_threads.c \
 pthread_support.c pthread_stop_world.c darwin_stop_world.c \
 $(asm_libgcjgc_sources)
Index: dyn_load.c
===================================================================
--- dyn_load.c	(revision 125718)
+++ dyn_load.c	(working copy)
@@ -225,7 +225,7 @@ static ptr_t GC_first_common()
 
 # if defined(SUNOS4) || defined(SUNOS5DL)
 /* Add dynamic library data sections to the root set.		*/
-# if !defined(PCR) && !defined(GC_SOLARIS_THREADS) && defined(THREADS)
+# if !defined(PCR) && !defined(GC_SOLARIS_PTHREADS) && defined(THREADS)
 #   ifndef SRC_M3
 	--> fix mutual exclusion with dlopen
 #   endif  /* We assume M3 programs don't call dlopen for now */



More information about the Java-patches mailing list