[gcjx] Patch: FYI: set abi version

Tom Tromey tromey@redhat.com
Sun Feb 13 04:06:00 GMT 2005


I'm checking this in on the gcjx branch.

This adds some support for computing the ABI version.  It is actually
wrong, due to momentary confusion on my part.  Other parts of the
patch are still needed; I'll clean up the actual computation later.

Tom

# 
# patch "gcc/gcc/java/ChangeLog"
#  from [11adee3ebe14e5679540cf49f610af3b7cfa2411]
#    to [f66993e80757d0bca17c5c4668ed64eda858df02]
# 
# patch "gcc/gcc/java/classobj.cc"
#  from [be3a1b80dd209963741abfa39ab49293ed7e3c97]
#    to [e87b717200dad29abaf83b7550a7bb67e07eee23]
# 
# patch "gcc/gcc/java/decl.cc"
#  from [350ebe257f9df0506910d1e7f488f467c14fecc6]
#    to [e41b966b7da6e8a2abe96eda9eaad2b12bd9e3d1]
# 
# patch "gcc/gcc/java/hooks.hh"
#  from [407fa2f0b9e38b63e2527db431ddde9846ed0a10]
#    to [8e335fd6277f3dddb97f83c2a97740644c219d13]
# 
# patch "gcc/gcjx/TODO"
#  from [036d431af3081b83084c41017bd3143491ad207c]
#    to [270b749f478583769fe968da0b4921728366c7b3]
# 
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,5 +1,13 @@
 2005-02-09  Tom Tromey  <tromey@redhat.com>
 
+	* hooks.hh (gcj_abi_version): Declare.
+	* classobj.cc (create_class_instance): Rename 'next' field.
+	and initialize it properly.
+	* decl.cc (build_class_type): Renamed 'next' field.
+	(gcj_abi_version): New global.
+	(initialize_version): New function.
+	(initialize_decls): Call it.
+
 	* classobj.cc (record_creator): Initialize new fields.
 	(set_field): Updated.
 	(create_class_instance): Initialize fields of Object.
--- gcc/gcc/java/classobj.cc
+++ gcc/gcc/java/classobj.cc
@@ -250,7 +250,7 @@
     inst.set_field ("sync_info", null_pointer_node);
 
   // Now fields from Class.
-  inst.set_field ("next", null_pointer_node);
+  inst.set_field ("next_or_version", gcj_abi_version);
   inst.set_field ("name",
 		  builtins->map_utf8const (real_class->get_fully_qualified_name ()));
 
--- gcc/gcc/java/decl.cc
+++ gcc/gcc/java/decl.cc
@@ -137,6 +137,9 @@
 tree field_slot_d;
 tree field_slot_o;
 
+// Version number.
+tree gcj_abi_version;
+
 
 
 static void
@@ -300,7 +303,7 @@
 build_class_type ()
 {
   tree field = NULL_TREE;
-  push_field (type_class, field, "next", type_class_ptr, true);
+  push_field (type_class, field, "next_or_version", type_class_ptr, true);
   push_field (type_class, field, "name", type_utf8const_ptr, true);
   push_field (type_class, field, "accflags", type_jushort, true);
   push_field (type_class, field, "superclass", type_class_ptr, true);
@@ -703,6 +706,16 @@
   // FIXME: initialize builtin_fmod.
 }
 
+static void
+initialize_version ()
+{
+  int version = __GNUC__ * 10000 + __GNUC_MINOR__ * 10;
+  if (flag_indirect_dispatch)
+    version += 5;
+  gcj_abi_version = build1 (NOP_EXPR, type_class_ptr,
+			    build_int_cst (type_jint, version));
+}
+
 tree
 gcjx::builtin_function (const char *name,
 			tree type,
@@ -745,6 +758,8 @@
   build_class_type ();
   build_class_union ();
   initialize_builtin_functions ();
+
+  initialize_version ();
 }
 
 #include "gt-java-hooks.h"
--- gcc/gcc/java/hooks.hh
+++ gcc/gcc/java/hooks.hh
@@ -1,6 +1,6 @@
 // Declare functions we use in lang hooks.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -98,6 +98,7 @@
 extern GTY (()) tree field_slot_f;
 extern GTY (()) tree field_slot_d;
 extern GTY (()) tree field_slot_o;
+extern GTY (()) tree gcj_abi_version;
 
 
 extern tree build_address_of (tree);
--- gcc/gcjx/TODO
+++ gcc/gcjx/TODO
@@ -278,6 +278,10 @@
 
 Tree generation
 
+the verifier needs a mode to be more lazy
+but not always...
+in this situation should put a type assertion in the class
+
 we should factor out things like object layout, etc, so that
 we can reuse the bulk of this code with LLVM
   [ done ]



More information about the Java-patches mailing list