Patch: gcc/java/boehm.c bug fixes

Tom Tromey tromey@cygnus.com
Wed Mar 15 17:31:00 GMT 2000


I'm checking in this patch.  It fixes a number of bugs in
gcc/java/boehm.c.  It also changes the declared type of the
`sync_info' pointer in Object; this might be controversial but it
makes gcc match with the libgcj source (which has been in place a
long, long time).


2000-03-15  Tom Tromey  <tromey@cygnus.com>

	* decl.c (init_decl_processing): Set type of `sync_info' to be
	pointer to Object.

	* boehm.c (get_boehm_type_descriptor): Correctly compute `bits'.
	Correctly compute bit number for current slot.  Zero `high' and
	`low' in DS_LENGTH case.  Don't skip inherited fields.  Use
	mark_reference_fields.
	(mark_reference_fields): New function.

Tom

Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/decl.c,v
retrieving revision 1.55
diff -u -r1.55 decl.c
--- decl.c	2000/03/14 05:01:04	1.55
+++ decl.c	2000/03/16 01:26:58
@@ -626,7 +626,11 @@
   dtable_ptr_type = build_pointer_type (dtable_type);
 
   PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type);
-  PUSH_FIELD (object_type_node, field, "sync_info", ptr_type_node);
+  /* This isn't exactly true, but it is what we have in the source.
+     There is an unresolved issue here, which is whether the vtable
+     should be marked by the GC.  */
+  PUSH_FIELD (object_type_node, field, "sync_info",
+	      build_pointer_type (object_type_node));
   for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
     FIELD_PRIVATE (t) = 1;
   FINISH_RECORD (object_type_node);
Index: boehm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/boehm.c,v
retrieving revision 1.1
diff -u -r1.1 boehm.c
--- boehm.c	2000/03/04 22:27:35	1.1
+++ boehm.c	2000/03/16 01:26:58
@@ -58,6 +58,50 @@
   *which |= (HOST_WIDE_INT) 1 << n;
 }
 
+/* Recursively mark reference fields.  */
+static unsigned int
+mark_reference_fields (field, low, high, ubit,
+		       pointer_after_end, all_bits_set, last_set_index)
+     tree field;
+     unsigned HOST_WIDE_INT *low, *high;
+     unsigned int ubit;
+     int *pointer_after_end, *all_bits_set, *last_set_index;
+{
+  unsigned int count = 0;
+
+  /* See if we have fields from our superclass.  */
+  if (DECL_NAME (field) == NULL_TREE)
+    {
+      count += mark_reference_fields (TYPE_FIELDS (TREE_TYPE (field)),
+				      low, high, ubit,
+				      pointer_after_end, all_bits_set,
+				      last_set_index);
+      field = TREE_CHAIN (field);
+    }
+
+  for (; field != NULL_TREE; field = TREE_CHAIN (field))
+    {
+      if (FIELD_STATIC (field))
+	continue;
+
+      if (JREFERENCE_TYPE_P (TREE_TYPE (field)))
+	{
+	  *last_set_index = count;
+	  /* First word in object corresponds to most significant byte
+	     of bitmap.  */
+	  set_bit (low, high, ubit - count - 1);
+	  if (count > ubit - 2)
+	    *pointer_after_end = 1;
+	}
+      else
+	*all_bits_set = 0;
+
+      ++count;
+    }
+
+  return count;
+}
+
 /* Return the marking bitmap for the class TYPE.  For now this is a
    single word describing the type.  */
 tree
@@ -79,7 +123,7 @@
   if (int_size_in_bytes (type) == -1)
     return PROCEDURE_OBJECT_DESCRIPTOR;
 
-  bit = POINTER_SIZE;
+  bit = POINTER_SIZE / BITS_PER_UNIT;
   /* The size of this node has to be known.  And, we only support 32
      and 64 bit targets, so we need to know that the log2 is one of
      our values.  */
@@ -97,27 +141,9 @@
   ubit = (unsigned int) bit;
 
   field = TYPE_FIELDS (type);
-  if (DECL_NAME (field) == NULL_TREE)
-    field = TREE_CHAIN (field);  /* Skip dummy field for inherited data. */
-  for (count = 0; field != NULL_TREE; field = TREE_CHAIN (field))
-    {
-      if (FIELD_STATIC (field))
-	continue;
-
-      if (JREFERENCE_TYPE_P (TREE_TYPE (field)))
-	{
-	  last_set_index = count;
-	  /* First word in object corresponds to most significant byte
-	     of bitmap.  */
-	  set_bit (&low, &high, ubit - count);
-	  if (count > ubit - 2)
-	    pointer_after_end = 1;
-	}
-      else
-	all_bits_set = 0;
-
-      ++count;
-    }
+  count = mark_reference_fields (field, &low, &high, ubit,
+				 &pointer_after_end, &all_bits_set,
+				 &last_set_index);
 
   /* If the object is all pointers, or if the part with pointers fits
      in our bitmap, then we are ok.  Otherwise we have to allocate it
@@ -129,6 +155,8 @@
 	 DS_LENGTH is 0.
 	 WORDS_TO_BYTES shifts by log2(bytes-per-pointer).  */
       count = 0;
+      low = 0;
+      high = 0;
       ++last_set_index;
       while (last_set_index)
 	{


More information about the Gcc-patches mailing list