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]

Re: Alpha vs. new ABI



Tom Tromey writes:

> Definitely.  And I think we need to fix this before gcc 3.0, since it
> is the only thing keeping the alpha port from working.  Alex said
> today that he'd look into it.

Well, as previously mentioned gcj was fixed this summer to align on
the alignment of Object, or the alignment of the array element type if
found to be bigger, without going above BIGGEST_FIELD_ALIGNMENT if
defined (I found it defined for rs6000.)

Maybe we can change that to comply with what the C++ compiler actually
does (and it might have done that before the new ABI was rolled in.)
It seems that I can naively trace the execution of cc1plus to that
point:

  cp/class.c:check_field_decl():

  ...
  /* Non-bit-fields are aligned for their type, except packed fields
     which require only BITS_PER_UNIT alignment.  */
  DECL_ALIGN (field) = MAX (DECL_ALIGN (field), 
			    (DECL_PACKED (field) 
			     ? BITS_PER_UNIT
			     : TYPE_ALIGN (TREE_TYPE (field))));
  ...

And see `data' being naturally aligned according to its type. So maybe
the bug stems from the fact that the new ABI specifies this rather
sane behavior.

So we could simplify the code in typeck.c like below, or am I
definitively missing something obvious? I haven't tried this patch
yet, especially on alpha (disk space problem.)

./A

Index: typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/typeck.c,v
retrieving revision 1.34
diff -u -p -r1.34 typeck.c
--- typeck.c	2001/01/25 22:25:22	1.34
+++ typeck.c	2001/01/31 01:17:17
@@ -420,32 +420,10 @@ build_java_array_type (element_type, len
       
       DECL_CONTEXT (arfld) = t;
       TREE_CHAIN (fld) = arfld;
-
-      /* We need to force the data field to begin at an alignment at
-       least equal to the biggest alignment in an object type node
-       in order to be compatible with the way that JArray is defined
-       in CNI.  However, we can't exceed BIGGEST_FIELD_ALIGNMENT. */
-      {
-      unsigned desired_align = TYPE_ALIGN (object_type_node);
-      desired_align = MAX (desired_align, TYPE_ALIGN (element_type));
-#ifdef BIGGEST_FIELD_ALIGNMENT
-      desired_align = MIN (desired_align, 
-                           (unsigned) BIGGEST_FIELD_ALIGNMENT);
-#endif
-#ifdef ADJUST_FIELD_ALIGN
-      desired_align = ADJUST_FIELD_ALIGN (fld, desired_align);
-#endif
-      DECL_ALIGN (arfld) = desired_align;
-      }
+      DECL_ALIGN (arfld) = TYPE_ALIGN (element_type);
     }
   else
-    {
-      unsigned desired_align = TYPE_ALIGN (element_type);
-#ifdef BIGGEST_FIELD_ALIGNMENT
-      desired_align = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT);
-#endif
-      TYPE_ALIGN (t) = desired_align;
-    }
+    TYPE_ALIGN (t) = TYPE_ALIGN (element_type);
 
   /* We could layout_class, but that loads java.lang.Object prematurely.
    * This is called by the parser, and it is a bad idea to do load_class

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