[BC ABI] New patches on branch

Andrew Haley aph@redhat.com
Wed Aug 18 15:21:00 GMT 2004


This patch disables reading dependent class files when compiling with
indirect dispatch.  The only classfile now referred to is
java/lang/Object.class.

Extensive testing of this revealed a few remaining problems: these are
fixed here.

Andrew.


2004-08-17  Andrew Haley  <aph@redhat.com>

	* verify.c (defer_merging): Quieten.
	* jcf-parse.c (load_class): Only try to open a class file if it's
	java.lang.Object or if it's part of the current compilation.
	Check that the class we just tried to load is the class we just
	loaded.  Quieten.
	(java_parse_file): Set flag_verify_invocations off if we're
	compiling from .class.
	(parse_zip_file_entries): Abort if we try to read a dummy class.
	* expr.c (can_widen_reference_to): Quieten.
	(build_invokevirtual): Abort if we try to invokevirtual an
	interface.
	(expand_invoke): Don't build a non-interface call to an interface.
	(build_instanceof): Don't do premature optimization if
	flag_verify_invocations is not set.
	* class.c (set_super_info): Disable code that inherits TYPE_DUMMY
	from superclass.
	(build_static_field_ref): Add correct type conversion for
	field_address.
	(add_miranda_methods): Disable generation of Miranda methods for
	dummy classes.
	(layout_class_method): Don't complain about non-static method
	overrides static method with dummy classes.

Index: verify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/verify.c,v
retrieving revision 1.59.10.2
diff -w -p -2 -c -r1.59.10.2 verify.c
*** verify.c	21 Jul 2004 16:00:46 -0000	1.59.10.2
--- verify.c	17 Aug 2004 13:38:01 -0000
*************** defer_merging (tree type1, tree type2)
*** 127,130 ****
--- 127,131 ----
    if (TYPE_DUMMY (type1) || TYPE_DUMMY (type2))
      {
+       if (! quiet_flag)
  	warning ("assert: cannot merge types %s and %s", 
  		 xstrdup (lang_printable_name (type1, 0)),
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.158.4.5
diff -w -p -2 -c -r1.158.4.5 jcf-parse.c
*** jcf-parse.c	6 Aug 2004 14:55:23 -0000	1.158.4.5
--- jcf-parse.c	17 Aug 2004 13:38:01 -0000
*************** load_class (tree class_or_name, int verb
*** 566,569 ****
--- 566,571 ----
    tree name, saved;
    int class_loaded = 0;
+   tree class_decl = NULL_TREE;
+   bool is_compiled_class = false;
  
    /* We've already failed, don't try again.  */
*************** load_class (tree class_or_name, int verb
*** 583,588 ****
--- 585,607 ----
      name = DECL_NAME (TYPE_NAME (class_or_name));
  
+   class_decl = IDENTIFIER_CLASS_VALUE (name);
+   if (class_decl != NULL_TREE)
+     {
+       tree type = TREE_TYPE (class_decl);
+       is_compiled_class
+ 	= ((TYPE_JCF (type) && JCF_SEEN_IN_ZIP (TYPE_JCF (type)))
+ 	   || CLASS_FROM_CURRENTLY_COMPILED_P (type));
+     }
+ 
    saved = name;
    
+   /* If flag_verify_invocations is unset, we don't try to load a class
+      unless we're looking for Object (which is fixed by the ABI) or
+      it's a class that we're going to compile.  */
+   if (flag_verify_invocations
+       || class_or_name == object_type_node
+       || is_compiled_class
+       || TREE_CODE (class_or_name) == IDENTIFIER_NODE)
+     {
        while (1)
  	{
*************** load_class (tree class_or_name, int verb
*** 592,597 ****
        if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE)
  	{
! 	  tree type_decl = IDENTIFIER_CLASS_VALUE (name);
! 	  if (CLASS_PARSED_P (TREE_TYPE (type_decl)))
  	    break;
  	}
--- 611,616 ----
  	  if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE)
  	    {
! 	      tree tmp_decl = IDENTIFIER_CLASS_VALUE (name);
! 	      if (CLASS_PARSED_P (TREE_TYPE (tmp_decl)))
  		break;
  	    }
*************** load_class (tree class_or_name, int verb
*** 621,624 ****
--- 640,644 ----
  	class_loaded = type && CLASS_PARSED_P (type);
        }	      
+     }
    
    if (!class_loaded)
*************** load_class (tree class_or_name, int verb
*** 633,636 ****
--- 653,657 ----
  	{
  	  /* This is just a diagnostic during testing, not a real problem.  */
+ 	  if (!quiet_flag)
  	    warning("cannot find file for class %s", 
  		    IDENTIFIER_POINTER (saved));
*************** parse_source_file_2 (void)
*** 877,880 ****
--- 898,902 ----
  {
    int save_error_count = java_error_count;
+   flag_verify_invocations = true;
    java_complete_class ();	    /* Parse unsatisfied class decl. */
    java_parse_abort_on_error ();
*************** java_parse_file (int set_yydebug ATTRIBU
*** 1142,1145 ****
--- 1164,1171 ----
        if (CLASS_FILE_P (node))
  	{
+ 	  /* FIXME: These two flags really should be independent.  We
+ 	     should be able to compile fully binary compatible, but
+ 	     with flag_verify_invocations on.  */
+ 	  flag_verify_invocations = ! flag_indirect_dispatch;
  	  output_class = current_class = TREE_PURPOSE (node);
  	  current_jcf = TYPE_JCF (current_class);
*************** parse_zip_file_entries (void)
*** 1237,1240 ****
--- 1263,1274 ----
  	    output_class = current_class = class;
  
+ 	    if (TYPE_DUMMY (class))
+ 	      {
+ 		/* This is a dummy class, and now we're compiling it
+ 		   for real.  Forget everything we thought we knew
+ 		   about its structure.  */
+ 		abort ();
+ 	      }
+ 
  	    if (! CLASS_LOADED_P (class))
  	      {
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.185.2.7
diff -w -p -2 -c -r1.185.2.7 expr.c
*** expr.c	21 Jul 2004 16:00:45 -0000	1.185.2.7
--- expr.c	17 Aug 2004 13:38:02 -0000
*************** can_widen_reference_to (tree source_type
*** 413,416 ****
--- 413,417 ----
    if (TYPE_DUMMY (source_type) || TYPE_DUMMY (target_type))
      {
+       if (!quiet_flag)
  	warning ("assert: %s is assign compatible with %s", 
  		 xstrdup (lang_printable_name (target_type, 0)),
*************** can_widen_reference_to (tree source_type
*** 453,456 ****
--- 454,458 ----
  	  if (TYPE_DUMMY (source_type) || TYPE_DUMMY (target_type))
  	    {
+ 	      if (! quiet_flag)
  		warning ("assert: %s is assign compatible with %s", 
  			 xstrdup (lang_printable_name (target_type, 0)),
*************** can_widen_reference_to (tree source_type
*** 458,461 ****
--- 460,464 ----
  	      return 1;
  	    }
+ 
   	  /* class_depth can return a negative depth if an error occurred */
  	  if (source_depth < 0 || target_depth < 0)
*************** build_instanceof (tree value, tree type)
*** 1266,1270 ****
        expr = build (NE_EXPR, itype, value, null_pointer_node);
      }
!   else if (! TYPE_ARRAY_P (type)
  	   && ! TYPE_ARRAY_P (valtype)
  	   && DECL_P (klass) && DECL_P (valclass)
--- 1269,1274 ----
        expr = build (NE_EXPR, itype, value, null_pointer_node);
      }
!   else if (flag_verify_invocations
! 	   && ! TYPE_ARRAY_P (type)
  	   && ! TYPE_ARRAY_P (valtype)
  	   && DECL_P (klass) && DECL_P (valclass)
*************** build_invokevirtual (tree dtable, tree m
*** 1982,1985 ****
--- 1986,1992 ----
    if (flag_indirect_dispatch)
      {
+       if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
+ 	abort ();
+ 
        otable_index 
  	= build_int_2 (get_symbol_table_index 
*************** expand_invoke (int opcode, int method_re
*** 2112,2115 ****
--- 2119,2129 ----
    else
      method = lookup_java_method (self_type, method_name, method_signature);
+ 
+   /* We've found a method in an interface, but this isn't an interface call.  */
+   if (opcode != OPCODE_invokeinterface
+       && method
+       && (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method)))))
+     method = NULL_TREE;
+ 
    if (method == NULL_TREE)
      {
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.180.2.8
diff -w -p -2 -c -r1.180.2.8 class.c
*** class.c	13 Aug 2004 20:26:05 -0000	1.180.2.8
--- class.c	17 Aug 2004 13:38:03 -0000
*************** set_super_info (int access_flags, tree t
*** 489,496 ****
--- 489,498 ----
  	= super_binfo;
        CLASS_HAS_SUPER (this_class) = 1;
+ #if 0
        /* FIXME: This is wrong.  */
        if (TYPE_LANG_SPECIFIC (this_class)
  	  && TYPE_LANG_SPECIFIC (super_class))
  	TYPE_DUMMY (this_class) = TYPE_DUMMY (super_class);
+ #endif
      }
  
*************** build_static_field_ref (tree fdecl)
*** 1094,1099 ****
  		       (fdecl, &TYPE_ATABLE_METHODS (output_class)), 0);
        tree field_address
! 	= build (ARRAY_REF, build_pointer_type (TREE_TYPE (fdecl)), 
  		 TYPE_ATABLE_DECL (output_class), table_index);
        return fold (build1 (INDIRECT_REF, TREE_TYPE (fdecl), 
  			   field_address));
--- 1096,1104 ----
  		       (fdecl, &TYPE_ATABLE_METHODS (output_class)), 0);
        tree field_address
! 	= build (ARRAY_REF, TREE_TYPE (TREE_TYPE (TYPE_ATABLE_DECL (output_class))), 
  		 TYPE_ATABLE_DECL (output_class), table_index);
+ 
+       field_address = convert (build_pointer_type (TREE_TYPE (fdecl)),
+ 			       field_address);
        return fold (build1 (INDIRECT_REF, TREE_TYPE (fdecl), 
  			   field_address));
*************** add_miranda_methods (tree base_class, tr
*** 2096,2099 ****
--- 2101,2109 ----
        elt = BINFO_TYPE (elt);
  
+       /* FIXME: This is totally bogus.  We should not be handling
+ 	 Miranda methods at all if we're using the BC ABI.  */
+       if (TYPE_DUMMY (elt))
+ 	continue;
+ 
        /* Ensure that interface methods are seen in declared order.  */
        layout_class_methods (elt);
*************** layout_class_method (tree this_class, tr
*** 2234,2237 ****
--- 2244,2248 ----
  						  method_sig);
        if (super_method != NULL_TREE && ! METHOD_PRIVATE (super_method)
+ 	  && ! METHOD_DUMMY (super_method)
  	  && ! DECL_ARTIFICIAL (super_method))
  	{



More information about the Java-patches mailing list