This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Kill a static constructor in boehm-gc
- To: java-patches at gcc dot gnu dot org, "Boehm, Hans" <hboehm at exch dot hpl dot hp dot com>
- Subject: Kill a static constructor in boehm-gc
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- Date: Mon, 22 Oct 2001 19:50:23 +1300
I managed to track down the last static constructor that was causing
things like "LD_PRELOAD=libgcj.so.2 ls" to segfault. It was
GC_init_parallel in the GC's linux_threads.c. It looks like it is there
to ensure thread safety for the initialization of thread-local
allocation, but it seems a bit dubious since it will be called from the
GC's pthread_create wrapper anyway, and the first pthread_create call
will always be single-threaded, right?
With this patch LD_PROFILE=libgcj.so.2 finally doesn't crash! This means
we can profile libgcj!! Well, nearly, since unfortunatly LD_PROFILE
doesn't understand virtual calls. I'm guessing this might be easy to fix
however if RTH adds the generic stack unwind facility to GCC that he was
talking about a while back?
Even without virtual support the sprof output is quite interesting.
There seems to be a lot (5000+) of Hashtable.get calls for Hello world,
for instance. And 1 more call to _Jv_MonitorEnter than _Jv_MonitorExit?
hmm...
Hans, what do you think of this patch?
regards
Bryce.
2001-10-22 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* linux_threads.c (GC_init_parallel): Do not declare as a static
constructor.
Index: linux_threads.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/linux_threads.c,v
retrieving revision 1.15
diff -u -r1.15 linux_threads.c
--- linux_threads.c 2001/10/17 04:55:27 1.15
+++ linux_threads.c 2001/10/22 06:32:27
@@ -204,11 +204,7 @@
static GC_bool parallel_initialized = FALSE;
-# if defined(__GNUC__)
- void GC_init_parallel() __attribute__ ((constructor));
-# else
- void GC_init_parallel();
-# endif
+void GC_init_parallel();
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)