java-tree.h (gcj_abi_version): Declare.
authorTom Tromey <tromey@redhat.com>
Mon, 24 Jan 2005 19:07:06 +0000 (19:07 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 24 Jan 2005 19:07:06 +0000 (19:07 +0000)
* java-tree.h (gcj_abi_version): Declare.
* class.c (make_class_data): Push gcj_abi_version into "next"
field.  Renamed field.
* decl.c (gcj_abi_version): New global.
(parse_version): New function.
(java_init_decl_processing): Call it.  Renamed 'next' field.
Include version.h.
(GCJ_BINARYCOMPAT_ADDITION): New define.

From-SVN: r94174

gcc/java/ChangeLog
gcc/java/class.c
gcc/java/decl.c
gcc/java/java-tree.h

index cf7810c4278cd56cbc3b55d36d6ded5ea6434465..116df16036da79011363caea57c0e00296f58eda 100644 (file)
@@ -1,3 +1,14 @@
+2005-01-24  Tom Tromey  <tromey@redhat.com>
+
+       * java-tree.h (gcj_abi_version): Declare.
+       * class.c (make_class_data): Push gcj_abi_version into "next"
+       field.  Renamed field.
+       * decl.c (gcj_abi_version): New global.
+       (parse_version): New function.
+       (java_init_decl_processing): Call it.  Renamed 'next' field.
+       Include version.h.
+       (GCJ_BINARYCOMPAT_ADDITION): New define.
+
 2005-01-24  Roger Sayle  <roger@eyesopen.com>
 
        PR java/19295
index 94138200d0b1965983c5d0b6d829d6e7add5cd40..53a31e940319bbdf1d746724f658556e2e9ed9cb 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions related to building classes and their related objects.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -1741,7 +1741,7 @@ make_class_data (tree type)
   FINISH_RECORD_CONSTRUCTOR (temp);
   START_RECORD_CONSTRUCTOR (cons, class_type_node);
   PUSH_SUPER_VALUE (cons, temp);
-  PUSH_FIELD_VALUE (cons, "next", null_pointer_node);
+  PUSH_FIELD_VALUE (cons, "next_or_version", gcj_abi_version);
   PUSH_FIELD_VALUE (cons, "name", build_utf8_ref (DECL_NAME (type_decl)));
   PUSH_FIELD_VALUE (cons, "accflags",
                    build_int_cst (NULL_TREE,
index 5ec5d7846ae8ecf470e2051c70db09993b3cef9a..1343ebfe3f056455d44b6c3edf209d171142b702 100644 (file)
@@ -1,6 +1,6 @@
 /* Process declarations and variables for the GNU compiler for the
    Java(TM) language.
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -47,6 +47,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "cgraph.h"
 #include "tree-inline.h"
 #include "target.h"
+#include "version.h"
 
 #if defined (DEBUG_JAVA_BINDING_LEVELS)
 extern void indent (void);
@@ -58,6 +59,13 @@ static tree push_promoted_type (const char *, tree);
 static struct binding_level *make_binding_level (void);
 static tree create_primitive_vtable (const char *);
 static tree check_local_unnamed_variable (tree, tree, tree);
+static void parse_version (void);
+
+/* Used when computing the ABI version.  */
+#define GCJ_BINARYCOMPAT_ADDITION 5
+
+/* The ABI version number.  */
+tree gcj_abi_version;
 
 /* Name of the Cloneable class.  */
 tree java_lang_cloneable_identifier_node;
@@ -559,6 +567,49 @@ do_nothing (tree t)
   return t;
 }
 
+/* Parse the version string and compute the ABI version number.  */
+static void
+parse_version (void)
+{
+  const char *p = version_string;
+  unsigned int major = 0, minor = 0;
+  unsigned int abi_version;
+
+  /* Skip leading junk.  */
+  while (*p && !ISDIGIT (*p))
+    ++p;
+  gcc_assert (*p);
+
+  /* Extract major version.  */
+  while (ISDIGIT (*p))
+    {
+      major = major * 10 + *p - '0';
+      ++p;
+    }
+
+  gcc_assert (*p == '.' && ISDIGIT (p[1]));
+  ++p;
+
+  /* Extract minor version.  */
+  while (ISDIGIT (*p))
+    {
+      minor = minor * 10 + *p - '0';
+      ++p;
+    }
+
+  /* Implicit in this computation is the idea that we won't break the
+     old-style binary ABI in a sub-minor release (e.g., from 4.0.0 to
+     4.0.1).  */
+  abi_version = 10000 * major + 10 * minor;
+  /* It is helpful to distinguish BC ABI from ordinary ABI at this
+     level, since at some point we will recognize a variety of BC ABIs
+     (objects generated by different version of gcj), but will
+     probably always require strict matching for ordinary ABI.  */
+  if (flag_indirect_dispatch)
+    abi_version += GCJ_BINARYCOMPAT_ADDITION;
+
+  gcj_abi_version = build_int_cstu (ptr_type_node, abi_version);
+}
 
 void
 java_init_decl_processing (void)
@@ -835,7 +886,7 @@ java_init_decl_processing (void)
   set_super_info (0, string_type_node, object_type_node, 0);
   class_ptr_type = build_pointer_type (class_type_node);
 
-  PUSH_FIELD (class_type_node, field, "next", class_ptr_type);
+  PUSH_FIELD (class_type_node, field, "next_or_version", class_ptr_type);
   PUSH_FIELD (class_type_node, field, "name", utf8const_ptr_type);
   PUSH_FIELD (class_type_node, field, "accflags", access_flags_type_node);
   PUSH_FIELD (class_type_node, field, "superclass", class_ptr_type);
@@ -1100,6 +1151,8 @@ java_init_decl_processing (void)
 #if 0
   soft_fmodf_node = built_in_decls[BUILT_IN_FMODF];
 #endif
+
+  parse_version ();
 }
 
 
index e10abac76fd84863cfcdbb96888b1b91e17181a7..bd7644604dd5ab894af1e7d43efa650584ae9d9b 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions for parsing and type checking for the GNU compiler for
    the Java(TM) language.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -274,6 +274,7 @@ typedef struct CPool constant_pool;
 
 extern GTY(()) tree java_lang_cloneable_identifier_node;
 extern GTY(()) tree java_io_serializable_identifier_node;
+extern GTY(()) tree gcj_abi_version;
 
 enum java_tree_index
 {