This is the mail archive of the java-patches@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]
Other format: [Raw text]

[gcjx] Patch: FYI: more jc1 changes


I'm checking this in on the gcjx branch.

This is a bunch of semi-unrelated changes, as I slowly rework the
abi-handling code and other things.  There will be more changes like
this, as I need to make a more organized sweep through the lowering
code to fix up little oddities and make the abi code really work.

We still aren't generating class descriptions, but we do name mangling
now and the resulting assembly for very simple functions ("return
x+y") looks correct.  Many things still provoke crashes however.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

	* decl.cc (initialize_gcc_decls): Removed old comment.
	* classobj.cc (handle_interfaces): Updated.
	* treegen.cc (generate): Updated.
	* tree.hh (tree_generator): Updated.
	* tree.cc (build_class_ref): Updated.
	(visit_new): Updated.
	(handle_invocation): Updated.
	(tree_generator): Added argument.  Initialize class_wrapper.
	(visit_field_ref): Don't emit type assertion.
	* abi.hh (gcj_abi): Added 'current' argument to calls.
	(class cxx_abi): Updated.
	(class bc_abi): Likewise.
	* abi.cc (build_method_call): Generate null check when needed.
	Changed how vtable index is found.
	Updated all methods for API changes.
	(build_field_reference): Correctly build indirect ref.
	* builtins.hh (tree_builtins::find_atable_slot): Removed.
	(tree_builtins::find_otable_slot): Likewise.
	(tree_builtins::check_reference): Updated.
	* builtins.cc (find_atable_slot): Removed.
	(find_otable_slot): Likewise.
	(lay_out_vtable): Rewrote.
	(check_reference): Added 'override' argument.
	(map_method_call): Added 'wrapper' argument.
	(map_field_ref): Likewise.
	(add): Only set name for static fields.
	(lay_out_class): Link to the superclass.  Only lay out class
	once.
	(add): Only chain on instance fields.

	* driver.cc (post_options): Add empty item to class path.

Index: abi.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 abi.cc
--- abi.cc 23 Jan 2005 01:58:51 -0000 1.1.2.2
+++ abi.cc 31 Jan 2005 02:23:27 -0000
@@ -34,8 +34,9 @@
 
 
 tree
-cxx_abi::build_method_call (tree_builtins *builtins, tree obj,
-			    tree args, model_method *meth,
+cxx_abi::build_method_call (tree_builtins *builtins,
+			    aot_class *,
+			    tree obj, tree args, model_method *meth,
 			    bool is_super)
 {
   builtins->lay_out_class (meth->get_declaring_class ());
@@ -53,14 +54,23 @@
     {
       // FIXME: interface call.
     }
-  else if (is_super || meth->final_p () || meth->instance_initializer_p ())
+  else if (is_super || meth->final_p () || meth->constructor_p ())
     {
+      assert (obj != NULL_TREE);
+
       // A final method, a constructor, or a super method should be
       // called directly.  A method in a final class is implicitly
-      // final, and will be caught by this same condition.
+      // final, and will be caught by this same condition.  Private
+      // methods are also caught this way.
       func = build_address_of (meth_tree);
 
-      assert (obj != NULL_TREE);
+      // In some cases we must generate an explicit null check.  We
+      // leave it to the optimizers to deduce that 'this != null' and
+      // remove checks in this case.  We force a real check because in
+      // the case of a final method, a SEGV will not be generated.
+      if (! meth->constructor_p ())
+	obj = builtins->check_reference (obj, true);
+
       args = tree_cons (NULL_TREE, obj, args);
     }
   else
@@ -70,14 +80,26 @@
       assert (obj != NULL_TREE);
       args = tree_cons (NULL_TREE, obj, args);
 
-      tree index = DECL_VINDEX (meth_tree);
+      aot_class *aotk = builtins->get_class (meth->get_declaring_class ());
+
+      tree index = build_int_cst (sizetype, aotk->find_in_vtable (meth));
       index = size_binop (MULT_EXPR, index,
 			  TYPE_SIZE_UNIT (type_nativecode_ptr_ptr));
       if (TARGET_VTABLE_USES_DESCRIPTORS)
 	index = size_binop (MULT_EXPR, index,
 			    size_int (TARGET_VTABLE_USES_DESCRIPTORS));
 
-      tree dtable; // fixme
+      // Dereference the object to find the table.  Check for a null
+      // reference if needed.
+      obj = builtins->check_reference (obj);
+
+      // Find the vtable by looking for the 'vtable' field.
+      tree dtable = build1 (INDIRECT_REF, type_object, obj);
+      dtable = build3 (COMPONENT_REF, type_dtable_ptr,
+		       dtable,
+		       builtins->find_decl (type_object, "vtable"),
+		       NULL_TREE);
+
       func = build2 (PLUS_EXPR, type_nativecode_ptr_ptr, dtable,
 		     convert (type_nativecode_ptr_ptr, index));
       if (TARGET_VTABLE_USES_DESCRIPTORS)
@@ -98,22 +120,24 @@
 }
 
 tree
-cxx_abi::build_field_reference (tree_builtins *builtins, tree obj,
-				model_field *field)
+cxx_abi::build_field_reference (tree_builtins *builtins,
+				aot_class *,
+				tree obj, model_field *field)
 {
   builtins->lay_out_class (field->get_declaring_class ());
   tree result = builtins->map_field (field);
   if (field->static_p ())
     {
       assert (obj == NULL_TREE);
+      // FIXME: initialize class.
     }
   else
     {
       assert (obj != NULL_TREE);
       result = build3 (COMPONENT_REF, TREE_TYPE (result),
 		       build1 (INDIRECT_REF,
-			       TREE_TYPE (TREE_TYPE (result)),
-			       builtins->check_reference (result)),
+			       TREE_TYPE (TREE_TYPE (obj)),
+			       builtins->check_reference (obj)),
 		       result,
 		       NULL_TREE);
     }
@@ -121,7 +145,9 @@
 }
 
 tree
-cxx_abi::build_class_reference (tree_builtins *builtins, tree klass)
+cxx_abi::build_class_reference (tree_builtins *builtins,
+				aot_class *,
+				tree klass)
 {
   assert (TREE_CODE (klass) == POINTER_TYPE);
   tree decl = TYPE_STUB_DECL (TREE_TYPE (klass));
@@ -129,14 +155,15 @@
 }
 
 tree
-cxx_abi::build_new (tree_builtins *builtins, tree klass, tree constructor,
-		    tree arguments)
+cxx_abi::build_new (tree_builtins *builtins, aot_class *current,
+		    tree klass, tree constructor, tree arguments)
 {
   tree allocator = builtin_Jv_AllocObject;  // FIXME: finalizer
   // Allocate the object.
   tree n = build3 (CALL_EXPR, klass, allocator,
 		   build_tree_list (NULL_TREE,
-				    build_class_reference (builtins, klass)),
+				    build_class_reference (builtins, current,
+							   klass)),
 		   NULL_TREE);
   TREE_SIDE_EFFECTS (n) = 1;
   // Call the constructor.
@@ -151,21 +178,25 @@
 
 
 tree
-bc_abi::build_method_call (tree_builtins *, tree obj,
+bc_abi::build_method_call (tree_builtins *, aot_class *current, tree obj,
 			   tree args, model_method *meth, bool is_super)
 {
   return NULL_TREE;
 }
 
 tree
-bc_abi::build_field_reference (tree_builtins *builtins, tree obj,
-			       model_field *field)
+bc_abi::build_field_reference (tree_builtins *builtins,
+			       aot_class *current,
+			       tree obj, model_field *field)
 {
   tree result;
+  int slot = current->register_field_reference (field);
   if (field->static_p ())
     {
       assert (obj == NULL_TREE);
-      tree atable_ref = builtins->find_atable_slot (field);
+      // FIXME: find the class' atable and then build a reference to
+      // the appropriate part of it.
+      tree atable_ref = NULL_TREE;
       result = build1 (INDIRECT_REF,
 		       // Note we don't need ARRAY_REF, we
 		       // just generate a direct reference.
@@ -177,8 +208,9 @@
   else
     {
       assert (obj != NULL_TREE);
-      tree otable_ref = builtins->find_otable_slot (field);
-      // FIXME find_otable_slot must cast to the correct type.
+      // FIXME: find the class' otable and then build a reference to
+      // the appropriate part of it.
+      tree otable_ref = NULL_TREE;
       // FIXME  cast OBJ to pointer to field type -- this works
       // due to structure layout rules ... ?
       result = build4 (ARRAY_REF, builtins->map_type (field->type ()),
@@ -188,14 +220,14 @@
 }
 
 tree
-bc_abi::build_class_reference (tree_builtins *, tree klass)
+bc_abi::build_class_reference (tree_builtins *, aot_class *current, tree klass)
 {
   return NULL_TREE;
 }
 
 tree
-bc_abi::build_new (tree_builtins *builtins, tree klass, tree constructor,
-		   tree arguments)
+bc_abi::build_new (tree_builtins *builtins, aot_class *current,
+		   tree klass, tree constructor, tree arguments)
 {
   return NULL_TREE;
 }
Index: abi.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/abi.hh,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 abi.hh
--- abi.hh 13 Jan 2005 03:40:24 -0000 1.1.2.1
+++ abi.hh 31 Jan 2005 02:23:27 -0000
@@ -1,6 +1,6 @@
 // ABI interface.
 
-// Copyright (C) 2004 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
@@ -67,24 +67,33 @@
   /// reference to a static method.  That must be handled by the
   /// caller.
   ///
+  /// @param builtins The mapper class
+  /// @param current  The class in which this code occurs
   /// @param obj The receiver object for the call; for static methods
   ///            this must be NULL_TREE.
   /// @param args The argument list.
   /// @param meth The method to call.
-  virtual tree build_method_call (tree_builtins *builtins, tree obj,
-				  tree args, model_method *meth,
+  virtual tree build_method_call (tree_builtins *builtins,
+				  aot_class *current,
+				  tree obj, tree args, model_method *meth,
 				  bool is_super) = 0;
 
   /// Note that we explicitly do not handle a non-static reference to
   /// a static field.  That must be handled by the caller.
-  virtual tree build_field_reference (tree_builtins *, tree,
-				      model_field *) = 0;
-
-  virtual tree build_class_reference (tree_builtins *, tree) = 0;
+  virtual tree build_field_reference (tree_builtins *builtins,
+				      aot_class *current,
+				      tree obj, model_field *field) = 0;
+
+  /// Return a tree representing a reference to some other class.
+  virtual tree build_class_reference (tree_builtins *builtins,
+				      aot_class *current,
+				      tree other) = 0;
 
   /// Return an expression that is used to create a new object given
   /// its type, constructor, and arguments to the constructor.
-  virtual tree build_new (tree_builtins *, tree, tree, tree) = 0;
+  virtual tree build_new (tree_builtins *builtins,
+			  aot_class *current,
+			  tree klass, tree constructor, tree args) = 0;
 
   /// Return an expression representing the size of the class in
   /// bytes, or -1 if it can't be known until runtime.
@@ -105,13 +114,15 @@
   {
   }
 
-  tree build_method_call (tree_builtins *, tree, tree, model_method *, bool);
+  tree build_method_call (tree_builtins *, aot_class *,
+			  tree, tree, model_method *, bool);
 
-  tree build_field_reference (tree_builtins *, tree, model_field *);
+  tree build_field_reference (tree_builtins *, aot_class *,
+			      tree, model_field *);
 
-  tree build_class_reference (tree_builtins *, tree);
+  tree build_class_reference (tree_builtins *, aot_class *, tree);
 
-  tree build_new (tree_builtins *, tree, tree, tree);
+  tree build_new (tree_builtins *, aot_class *, tree, tree, tree);
 
   tree get_size_in_bytes (tree klass)
   {
@@ -134,13 +145,15 @@
   {
   }
 
-  tree build_method_call (tree_builtins *, tree, tree, model_method *, bool);
+  tree build_method_call (tree_builtins *, aot_class *,
+			  tree, tree, model_method *, bool);
 
-  tree build_field_reference (tree_builtins *, tree, model_field *);
+  tree build_field_reference (tree_builtins *, aot_class *,
+			      tree, model_field *);
 
-  tree build_class_reference (tree_builtins *, tree);
+  tree build_class_reference (tree_builtins *, aot_class *, tree);
 
-  tree build_new (tree_builtins *, tree, tree, tree);
+  tree build_new (tree_builtins *, aot_class *, tree, tree, tree);
 
   tree get_size_in_bytes (tree klass)
   {
Index: builtins.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 builtins.cc
--- builtins.cc 30 Jan 2005 03:18:36 -0000 1.1.2.3
+++ builtins.cc 31 Jan 2005 02:23:27 -0000
@@ -41,21 +41,9 @@
 }
 
 tree
-tree_builtins::find_atable_slot (model_field *)
+tree_builtins::check_reference (tree ref, bool override)
 {
-  abort ();
-}
-
-tree
-tree_builtins::find_otable_slot (model_field *)
-{
-  abort ();
-}
-
-tree
-tree_builtins::check_reference (tree ref)
-{
-  if (flag_check_references)
+  if (flag_check_references || override)
     {
       ref = save_expr (ref);
       tree npe = builtin_Jv_ThrowNullPointerException;
@@ -182,11 +170,16 @@
   DECL_CONTEXT (result) = context;
   DECL_EXTERNAL (result) = 1;
   TREE_PUBLIC (result) = 1;
-  SET_DECL_ASSEMBLER_NAME (result,
-			   get_identifier (get_mangled_form (field).c_str ()));
+  if (field->static_p ())
+    SET_DECL_ASSEMBLER_NAME (result,
+			     get_identifier (get_mangled_form (field).c_str ()));
 
-  TREE_CHAIN (result) = TYPE_FIELDS (context);
-  TYPE_FIELDS (context) = result;
+  // Only chain instance fields here.
+  if (! field->static_p ())
+    {
+      TREE_CHAIN (result) = TYPE_FIELDS (context);
+      TYPE_FIELDS (context) = result;
+    }
 
   fieldmap[field] = result;
 }
@@ -286,12 +279,13 @@
 }
 
 tree
-tree_builtins::map_field_ref (tree obj, model_field *field)
+tree_builtins::map_field_ref (aot_class *wrapper, tree obj, model_field *field)
 {
   gcj_abi *abi = find_abi (field->get_declaring_class ());
 
   tree result
-    = abi->build_field_reference (this, field->static_p () ? NULL_TREE : obj,
+    = abi->build_field_reference (this, wrapper,
+				  field->static_p () ? NULL_TREE : obj,
 				  field);
 
   if (obj != NULL_TREE && field->static_p ())
@@ -305,7 +299,8 @@
 }
 
 tree
-tree_builtins::map_field_ref (tree, const std::string &, const std::string &,
+tree_builtins::map_field_ref (aot_class *,
+			      tree, const std::string &, const std::string &,
 			      const std::string &)
 {
   // FIXME
@@ -320,11 +315,12 @@
 }
 
 tree
-tree_builtins::map_method_call (tree obj, tree args, model_method *meth,
+tree_builtins::map_method_call (aot_class *wrapper,
+				tree obj, tree args, model_method *meth,
 				bool is_super)
 {
   gcj_abi *abi = find_abi (meth->get_declaring_class ());
-  tree result = abi->build_method_call (this,
+  tree result = abi->build_method_call (this, wrapper,
 					meth->static_p () ? NULL_TREE : obj,
 					args, meth, is_super);
   // FIXME: set this in ABI?
@@ -345,111 +341,49 @@
 tree_builtins::map_new (model_class *klass, tree constructor, tree arguments)
 {
   gcj_abi *abi = find_abi (klass);
-  return abi->build_new (this, map_type (klass), constructor, arguments);
+  return abi->build_new (this, get_class (klass),
+			 map_type (klass), constructor, arguments);
 }
 
 void
-tree_builtins::lay_out_vtable (model_class *klass)
+tree_builtins::lay_out_vtable (model_class *mklass)
 {
-  AllMethodsIterator end_all_methods = klass->end_all_methods ();
-  std::list<ref_method> super_methods;
-  tree super_vtable = NULL_TREE;
-  model_class *super = klass->get_superclass ();
-  if (super != NULL)
-    {
-      for (AllMethodsIterator it = klass->begin_all_methods ();
-           it != end_all_methods;
-           ++it)
-        {
-          super_methods.push_back (*it);
-        }
-      tree super_ptr_type = map_type (super);
-      super_vtable = BINFO_VTABLE (TYPE_BINFO (TREE_TYPE (super_ptr_type)));
-    }
-
-  int last_max = super_vtable ? TREE_VEC_LENGTH (super_vtable) : 0;
-  for (AllMethodsIterator i = klass->begin_all_methods ();
-       i != end_all_methods;
-       ++i)
-    {
-      if ((*i)->static_p ())
-	continue;
-
-      int index = -1;
-      model_class *decl = (*i)->get_declaring_class ();
-      if (decl->interface_p ())
-	{
-	  assert (super != NULL);
-	  // If this interface is implemented by some superclass, then
-	  // the method is already in the vtable.
-	  if (decl->assignable_from_p (super))
-	    continue;
-	}
-      else if (decl != klass)
-	{
-	  // Declared in a concrete superclass, so it is already in
-	  // the vtable.
-	  continue;
-	}
-      else
-	{
-	  // Method is declared here.  It still might overload some
-	  // method from the superclass.
-	  for (std::list<ref_method>::const_iterator si
-		 = super_methods.begin ();
-	       si != super_methods.end ();
-	       ++si)
-	    {
-	      if ((*i)->hides_or_overrides_p ((*si).get (), klass))
-		{
-		  // Re-use the previous slot.
-		  index
-		    = tree_low_cst (DECL_VINDEX (map_method ((*si).get ())),
-				    0);
-		  break;
-		}
-	    }
-	}
-
-      // We've found a method that isn't declared in some superclass,
-      // so assign it a vtable index.
-      if (index == -1)
-	index = last_max++;
-      tree m = map_method ((*i).get ());
-      // FIXME: if M is an interface method then we're screwed here!
-      DECL_VINDEX (m) = size_int_kind (index, SIZETYPE);
-    }
-
-  tree vtable = make_tree_vec (last_max);
+  aot_class *klass = get_class (mklass);
+  const std::vector<model_method *> &vtable (klass->get_vtable ());
 
-  if (super_vtable != NULL_TREE)
-    {
-      for (int i = 0; i < TREE_VEC_LENGTH (super_vtable); ++i)
-	TREE_VEC_ELT (vtable, i) = TREE_VEC_ELT (super_vtable, i);
-    }
-
-  for (AllMethodsIterator i = klass->begin_all_methods ();
-       i != end_all_methods;
+  // Create a new tree vector to represent the vtable, and fill it in.
+  // Note that we have two empty slots at the beginning; this is kept
+  // in sync with aot_class.  FIXME: define a constant.
+  tree vtable_tree = make_tree_vec (2 + vtable.size ());
+  int index = 2;
+  for (std::vector<model_method *>::const_iterator i = vtable.begin ();
+       i != vtable.end ();
        ++i)
     {
-      tree m = map_method ((*i).get ());
-      TREE_VEC_ELT (vtable, tree_low_cst (DECL_VINDEX (m), 0)) = m;
+      TREE_VEC_ELT (vtable_tree, index) = map_method (*i);
+      ++index;
     }
 
-  tree klass_ptr_type = map_type (klass);
-  BINFO_VTABLE (TYPE_BINFO (TREE_TYPE (klass_ptr_type))) = vtable;
+  TREE_VEC_ELT (vtable_tree, 0) = null_pointer_node; // FIXME: pointer to class
+  TREE_VEC_ELT (vtable_tree, 1) = null_pointer_node; // FIXME: GC descriptor
+
+  tree klass_ptr_type = map_type (klass->get ());
+  BINFO_VTABLE (TYPE_BINFO (TREE_TYPE (klass_ptr_type))) = vtable_tree;
 }
 
 tree
 tree_builtins::lay_out_class (model_class *klass)
 {
-  //   if (class laid out)
-  //     return fixme;
   tree klass_tree = map_type (klass);
+  if (TYPE_LANG_FLAG_0 (klass_tree))
+    return klass_tree;
+  TYPE_LANG_FLAG_0 (klass_tree) = 1;
+
   tree klass_record = TREE_TYPE (klass_tree);
 
+  tree super_record = NULL_TREE;
   if (klass->get_superclass () != NULL)
-    lay_out_class (klass->get_superclass ());
+    super_record = TREE_TYPE (lay_out_class (klass->get_superclass ()));
 
   // Ensure all non-static methods have been added.
   std::list<ref_method> methods = klass->get_methods ();
@@ -488,6 +422,17 @@
   // Fix the ordering.
   TYPE_FIELDS (klass_record) = nreverse (TYPE_FIELDS (klass_record));
 
+  // Link to the superclass.
+  if (super_record != NULL_TREE)
+    {
+      tree base = build_decl (FIELD_DECL, NULL_TREE, super_record);
+      DECL_IGNORED_P (base) = 1;
+      TREE_CHAIN (base) = TYPE_FIELDS (klass_record);
+      TYPE_FIELDS (klass_record) = base;
+      DECL_SIZE (base) = TYPE_SIZE (super_record);
+      DECL_SIZE_UNIT (base) = TYPE_SIZE_UNIT (super_record);
+    }
+
   lay_out_vtable (klass);
 
   layout_type (klass_tree);
Index: builtins.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/builtins.hh,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 builtins.hh
--- builtins.hh 30 Jan 2005 03:18:36 -0000 1.1.2.3
+++ builtins.hh 31 Jan 2005 02:23:27 -0000
@@ -45,8 +45,6 @@
   void add (tree, model_method *);
   void add (tree, model_field *);
   tree map_param_or_var (tree_code, tree, model_variable_decl *);
-  tree find_atable_slot (model_field *);
-  tree find_otable_slot (model_field *);
   void lay_out_vtable (model_class *);
 
 
@@ -68,11 +66,12 @@
   tree map_field (model_field *);
   tree map_method (model_method *);
 
-  tree map_field_ref (tree, model_field *);
-  tree map_field_ref (tree, const std::string &, const std::string &,
+  tree map_field_ref (aot_class *, tree, model_field *);
+  tree map_field_ref (aot_class *,
+		      tree, const std::string &, const std::string &,
 		      const std::string &);
 
-  tree map_method_call (tree, tree, model_method *, bool);
+  tree map_method_call (aot_class *, tree, tree, model_method *, bool);
   tree map_new (model_class *, tree, tree);
 
   // Memoize a utf8const.
@@ -84,7 +83,12 @@
 
   tree lay_out_class (model_class *);
 
-  tree check_reference (tree);
+  /// Generate code to check a null reference.  REF is the reference
+  /// to check.  By default, this only generates a check if the target
+  /// architecture requires explicit checks.  If OVERRIDE is true,
+  /// then the check will be generated regardless of the target
+  /// platform.
+  tree check_reference (tree ref, bool override = false);
 
   tree find_decl (tree, const char *);
 
Index: classobj.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/classobj.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 classobj.cc
--- classobj.cc 30 Jan 2005 03:18:36 -0000 1.1.2.3
+++ classobj.cc 31 Jan 2005 02:23:27 -0000
@@ -186,7 +186,7 @@
 	  ++len;
 	  gcj_abi *abi = builtins->find_abi ((*i)->type ());
 	  tree one_iface
-	    = abi->build_class_reference (builtins,
+	    = abi->build_class_reference (builtins, klass,
 					  builtins->map_type ((*i)->type ()));
 	  result = tree_cons (NULL_TREE, one_iface, result);
 	}
Index: decl.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/decl.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 decl.cc
--- decl.cc 23 Jan 2005 01:58:51 -0000 1.1.2.2
+++ decl.cc 31 Jan 2005 02:23:27 -0000
@@ -375,9 +375,10 @@
   // Note that we don't care whether 'char' is signed, as we don't
   // use it.
   build_common_tree_nodes (false, false);
-  // We don't care what the size type is, as we don't use it.
+
   size_type_node = make_unsigned_type (POINTER_SIZE);
   set_sizetype (size_type_node);
+
   // Note that we don't care whether 'double' is short, as we don't
   // use it.
   build_common_tree_nodes_2 (false);
Index: driver.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/driver.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 driver.cc
--- driver.cc 23 Jan 2005 01:58:51 -0000 1.1.2.2
+++ driver.cc 31 Jan 2005 02:23:27 -0000
@@ -365,6 +365,9 @@
       && arguments->dash_i_args.empty ()
       && getenv ("CLASSPATH") != NULL)
     add_cp (facs, split (getenv ("CLASSPATH"), ':'));
+  // We need an empty item to help us find absolute paths.
+  add_cp (facs, split ("", ':'));
+
   our_compiler->set_class_factory (new classpath_class_factory (facs));
 
   // Compute the output directory.
Index: lower.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/lower.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 lower.cc
--- lower.cc 30 Jan 2005 03:18:36 -0000 1.1.2.3
+++ lower.cc 31 Jan 2005 02:23:28 -0000
@@ -1258,7 +1258,8 @@
 	    std::string classname, fieldname, signature;
 	    cpool->get_fieldref (fieldref_index, classname, fieldname,
 				 signature);
-	    tree ref = gcc_builtins->map_field_ref (NULL_TREE,
+	    tree ref = gcc_builtins->map_field_ref (class_wrapper,
+						    NULL_TREE,
 						    classname, fieldname,
 						    signature);
 	    insn = push (ref);
@@ -1272,7 +1273,8 @@
 	    cpool->get_fieldref (fieldref_index, classname, fieldname,
 				 signature);
 	    tree expr = pop (type_object);
-	    tree ref = gcc_builtins->map_field_ref (expr,
+	    tree ref = gcc_builtins->map_field_ref (class_wrapper,
+						    expr,
 						    classname, fieldname,
 						    signature);
 	    insn = push (ref);
@@ -1285,7 +1287,8 @@
 	    std::string classname, fieldname, signature;
 	    cpool->get_fieldref (fieldref_index, classname, fieldname,
 				 signature);
-	    tree ref = gcc_builtins->map_field_ref (NULL_TREE,
+	    tree ref = gcc_builtins->map_field_ref (class_wrapper,
+						    NULL_TREE,
 						    classname, fieldname,
 						    signature);
 	    tree expr = pop (TREE_TYPE (ref));
@@ -1302,7 +1305,8 @@
 	    tree field_type = find_class (signature);
 	    tree value = pop (field_type);
 	    tree obj = pop (type_object);
-	    tree ref = gcc_builtins->map_field_ref (obj,
+	    tree ref = gcc_builtins->map_field_ref (class_wrapper,
+						    obj,
 						    classname, fieldname,
 						    signature);
 	    insn = build2 (MODIFY_EXPR, TREE_TYPE (ref), ref, value);
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 tree.cc
--- tree.cc 30 Jan 2005 03:18:36 -0000 1.1.2.3
+++ tree.cc 31 Jan 2005 02:23:28 -0000
@@ -30,8 +30,9 @@
 /// the documentation is here:
 ///   http://gcc.gnu.org/ml/gcc/2002-08/msg01397.html
 
-tree_generator::tree_generator (tree_builtins *builtins)
+tree_generator::tree_generator (tree_builtins *builtins, aot_class *k)
   : gcc_builtins (builtins),
+    class_wrapper (k),
     current (NULL_TREE),
     this_tree (NULL_TREE),
     method (NULL),
@@ -1401,18 +1402,21 @@
       expr_tree = current;
     }
 
-  // FIXME: where should this go?
+#if 0
+  // FIXME: where should this go?  [ In the ABI ]
   if (expr->type () != field->get_declaring_class ())
     // FIXME: is this right?
     emit_type_assertion (field->get_declaring_class (), expr->type ());
+#endif
+
+  // FIXME: handle inlining constant fields here (this is not
+  // abi-specific)
 
-  // FIXME: should we handle inlining constant fields here or in the
-  // ABI?
+  // FIXME: Note that map_field_ref does not handle the case of a
+  // non-static reference to a static field.
 
-  // Note that map_field_ref handles the case of a non-static
-  // reference to a static field.
   gcc_builtins->lay_out_class (field->get_declaring_class ());
-  current = gcc_builtins->map_field_ref (expr_tree,
+  current = gcc_builtins->map_field_ref (class_wrapper, expr_tree,
 					 const_cast<model_field *> (field));
 }
 
@@ -1593,12 +1597,16 @@
 
   // Handle the reference-checking part of a non-static reference to a
   // static method here.  The rest is handled by map_method_call.
+#if 0
+  // FIXME: wrong!  we must evaluate for side effects, not nullity.
   if (this_expr_tree != NULL_TREE
       && ! meth->static_p ()
       && this_expr_tree != this_tree)
     this_expr_tree = gcc_builtins->check_reference (this_expr_tree);
+#endif
 
-  current = gcc_builtins->map_method_call (this_expr_tree, arg_tree,
+  current = gcc_builtins->map_method_call (class_wrapper,
+					   this_expr_tree, arg_tree,
 					   const_cast<model_method *> (meth),
 					   is_super);
 }
@@ -1672,6 +1680,7 @@
     }
   arg_tree = nreverse (arg_tree);
 
+  // FIXME: layout should be done by the ABI, not us.
   model_class *klassp = assert_cast<model_class *> (klass->type ());
   gcc_builtins->lay_out_class (klassp);
   current
@@ -1897,9 +1906,7 @@
 {
   // FIXME.
   gcj_abi *abi = gcc_builtins->find_abi (NULL);
-  // FIXME: this API is wrong, we want to pass in the class wrapper
-  // instead.
-  return abi->build_class_reference (gcc_builtins, klass);
+  return abi->build_class_reference (gcc_builtins, class_wrapper, klass);
 }
 
 tree
Index: tree.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.hh,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 tree.hh
--- tree.hh 30 Jan 2005 03:18:36 -0000 1.1.2.2
+++ tree.hh 31 Jan 2005 02:23:28 -0000
@@ -160,7 +160,7 @@
 
 public:
 
-  tree_generator (tree_builtins *);
+  tree_generator (tree_builtins *, aot_class *);
 
   virtual ~tree_generator ();
 
Index: treegen.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/treegen.cc,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 treegen.cc
--- treegen.cc 23 Jan 2005 01:58:51 -0000 1.1.2.2
+++ treegen.cc 31 Jan 2005 02:23:28 -0000
@@ -48,6 +48,7 @@
       first_time = false;
     }
 
+  aot_class *wrapper = builtins->get_class (the_class);
   tree class_tree = builtins->lay_out_class (the_class);
 
   std::list<ref_method> methods = the_class->get_methods ();
@@ -55,7 +56,7 @@
        i != methods.end ();
        ++i)
     {
-      tree_generator gen (builtins);
+      tree_generator gen (builtins, wrapper);
       tree method = gen.generate ((*i).get ());
       cgraph_finalize_function (method, 0);
     }


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