This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

TARGET_VTABLE_USES_DESCRIPTORS breaks Java GC; Object.h problem


Garbage collection seems to be completely broken on the trunk when running
on Itanium.  A problem is that when TARGET_VTABLE_USES_DESCRIPTORS was
defined, Java vtable layout changed from

class pointer
gc descriptor
function pointers
...

to

class pointer
0
gc descriptor
0
function descriptors (2 words each)
...

It turns out the garbage collector really wants the descriptor in the second
slot.  (It really wants it in a slot that exists in every heap-allocated
object, and some heap allocated objects only have two words.)  The attached
patch to gcc/java/class.c changes the layout to

class pointer
gc descriptor
gc descriptor
0
function descriptors (2 words each)
...

on Itanium.  This gets me quite a bit further.  But it seems suboptimal,
since it wastes 2 words in very vtable.  Is there any reason not to change
this to:

class pointer
gc descriptor
function descriptors (2 words each)
...  ?

If not, can someone make this change (conditioned on
TARGET_VTABLE_USES_DESCRIPTORS)?  

I don't fully understand all the implications of such a change.  It seems to
me it would require conditionally imstalling a platform-dependent version of
Object.h.  But I think that's already necessary, at least for the trunk, to
fix another current bug:  There's currently a

#ifndef JV_HASH_SYNCHRONIZATION

in Object.h.  That doesn't make any sense if Object.h is included by client
native code.  (I put it there as a stopgap.  I think we forgot about it when
JV_HASH_SYNCHRONIZATION was turned on by default on some platforms.)  Or am
I missing something here?

Hans



Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.115
diff -u -r1.115 class.c
--- class.c	2001/09/21 16:58:21	1.115
+++ class.c	2001/10/29 21:24:59
@@ -1376,6 +1376,7 @@
   tree list = NULL_TREE;
   int nvirtuals = TREE_VEC_LENGTH (vtable);
   int arraysize;
+  tree gc_descr;
 
   for (i = nvirtuals;  --i >= 0; )
     {
@@ -1417,12 +1418,19 @@
      using the Boehm GC we sometimes stash a GC type descriptor
      there. We set the PURPOSE to NULL_TREE not to interfere (reset)
      the emitted byte count during the output to the assembly file. */
+  /* FIXME: The GC wants the descriptor in the second word.
+     The class pointer takes up the first word.  But in the 
+     TARGET_VTABLE_USES_DESCRIPTORS case, we end up using 4 words for the
pair.
+     We currently replicate the GC descriptor in one of the unused ones,
+     just because the code is simpler that way.  The class pointer
+     and GC descriptor together should really only use 2 words. */
   for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
     list = tree_cons (NULL_TREE, null_pointer_node, list);
-  list = tree_cons (NULL_TREE, get_boehm_type_descriptor (type), list);
+  gc_descr =  get_boehm_type_descriptor (type);
+  list = tree_cons (NULL_TREE, gc_descr, list);
 
   for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
-    list = tree_cons (NULL_TREE, null_pointer_node, list);
+    list = tree_cons (NULL_TREE, gc_descr, list);
   list = tree_cons (integer_zero_node, this_class_addr, list);
 
   arraysize = nvirtuals + 2;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]