From 2a4d06261820a8fa78728d40ea51ba4658b6d914 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 24 Jan 2005 19:07:06 +0000 Subject: [PATCH] java-tree.h (gcj_abi_version): Declare. * 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 | 11 +++++++++ gcc/java/class.c | 4 ++-- gcc/java/decl.c | 57 ++++++++++++++++++++++++++++++++++++++++++-- gcc/java/java-tree.h | 3 ++- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index cf7810c4278..116df16036d 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,14 @@ +2005-01-24 Tom Tromey + + * 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 PR java/19295 diff --git a/gcc/java/class.c b/gcc/java/class.c index 94138200d0b..53a31e94031 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -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, diff --git a/gcc/java/decl.c b/gcc/java/decl.c index 5ec5d7846ae..1343ebfe3f0 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -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 (); } diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index e10abac76fd..bd7644604dd 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -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 { -- 2.30.2