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]

[java/rfc] don't call make_decl_rtl from the front end


This is patch 2 of 3 trying to fix the CNT plt problem.  The main
goal here is to avoid creating rtl too early, and indirectly forcing 
DECL_ASSEMBLER_NAME to be set too early.  I very much want that to
be done after java_mark_class_local, which happens after all parsing.

A secondary cleanliness goal says that a front end shouldn't have to
concern itself with such low-level details as rtl.

One thing for review is what build_class_ref played with DECL_SIZE?
It would seem that would have been done by layout_decl, which is 
called by build_decl when presented with a complete type.

Tested by itself on i686-linux, and with other patches on ia64 and
alpha linux.

Ok?


r~


	* builtins.c (define_builtin): Don't call make_decl_rtl.
	* constants.c (build_constant_data_ref): Likewise.
	* class.c (build_utf8_ref): Likewise.
	(build_fieldref_cache_entry, build_static_field_ref): Likewise.
	(get_dispatch_table, layout_class_method): Likewise.
	(build_class_ref): Likewise. Don't set DECL_SIZE or DECL_SIZE_UNIT
	by hand.
	(make_local_function_alias): Don't SET_DECL_ASSEMBLER_NAME.
	(make_method_value): Use METHOD_ABSTRACT instead of DECL_RTL_SET_P
	to determine if we need a non-zero address.
	* decl.c (builtin_function): Don't call make_decl_rtl.
	(give_name_to_locals): Don't SET_DECL_ASSEMBLER_NAME.
	* expr.c (build_known_method_ref): Don't call make_decl_rtl.
	* resource.c (compile_resource_data): Likewise.
	* parse.y (resolve_field_access): Re-word comment to avoid
	building DECL_RTL.

Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/builtins.c,v
retrieving revision 1.30
diff -u -p -d -r1.30 builtins.c
--- builtins.c	29 Apr 2005 18:43:25 -0000	1.30
+++ builtins.c	24 May 2005 18:35:09 -0000
@@ -144,7 +144,6 @@ define_builtin (enum built_in_function v
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
   SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
-  make_decl_rtl (decl);
   pushdecl (decl);
   DECL_BUILT_IN_CLASS (decl) = BUILT_IN_NORMAL;
   DECL_FUNCTION_CODE (decl) = val;
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.226
diff -u -p -d -r1.226 class.c
--- class.c	10 May 2005 13:23:32 -0000	1.226
+++ class.c	24 May 2005 18:35:09 -0000
@@ -914,7 +914,6 @@ build_utf8_ref (tree name)
   rest_of_decl_compilation (decl, global_bindings_p (), 0);
   cgraph_varpool_mark_needed_node (cgraph_varpool_node (decl));
   utf8_decl_list = decl;
-  make_decl_rtl (decl);
   ref = build1 (ADDR_EXPR, utf8const_ptr_type, decl);
   IDENTIFIER_UTF8_REF (name) = ref;
   return ref;
@@ -946,9 +945,9 @@ build_class_ref (tree type)
       if (TREE_CODE (type) == POINTER_TYPE)
 	type = TREE_TYPE (type);
 
-      if  (flag_indirect_dispatch
-	   && type != output_class
-	   && TREE_CODE (type) == RECORD_TYPE)
+      if (flag_indirect_dispatch
+	  && type != output_class
+	  && TREE_CODE (type) == RECORD_TYPE)
 	return build_indirect_class_ref (type);
 
       if (TREE_CODE (type) == RECORD_TYPE)
@@ -961,8 +960,6 @@ build_class_ref (tree type)
 	  if (decl == NULL_TREE)
 	    {
 	      decl = build_decl (VAR_DECL, decl_name, class_type_node);
-	      DECL_SIZE (decl) = TYPE_SIZE (class_type_node);
-	      DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (class_type_node);
 	      TREE_STATIC (decl) = 1;
 	      TREE_PUBLIC (decl) = 1;
 	      DECL_IGNORED_P (decl) = 1;
@@ -972,7 +969,6 @@ build_class_ref (tree type)
 	      SET_DECL_ASSEMBLER_NAME (decl, 
 				       java_mangle_class_field
 				       (&temporary_obstack, type));
-	      make_decl_rtl (decl);
 	      pushdecl_top_level (decl);
 	    }
 	}
@@ -1025,7 +1021,6 @@ build_class_ref (tree type)
 	      TREE_PUBLIC (decl) = 1;
 	      DECL_EXTERNAL (decl) = 1;
 	      DECL_ARTIFICIAL (decl) = 1;
-	      make_decl_rtl (decl);
 	      pushdecl_top_level (decl);
 	    }
 	}
@@ -1056,7 +1051,6 @@ build_fieldref_cache_entry (int index, t
       TREE_PUBLIC (decl) = 0;
       DECL_EXTERNAL (decl) = 0;
       DECL_ARTIFICIAL (decl) = 1;
-      make_decl_rtl (decl);
       pushdecl_top_level (decl);
     }
   return decl;
@@ -1081,12 +1075,8 @@ build_static_field_ref (tree fdecl)
 	      || JNUMERIC_TYPE_P (TREE_TYPE (fdecl)))
 	  && TREE_CONSTANT (DECL_INITIAL (fdecl))))
     {
-      if (!DECL_RTL_SET_P (fdecl))
-	{
-	  if (is_compiled == 1)
-	    DECL_EXTERNAL (fdecl) = 1;
-	  make_decl_rtl (fdecl);
-	}
+      if (is_compiled == 1)
+	DECL_EXTERNAL (fdecl) = 1;
     }
   else
     {
@@ -1238,7 +1228,6 @@ make_local_function_alias (tree method)
   DECL_INITIAL (alias) = error_mark_node;
   TREE_ADDRESSABLE (alias) = 1;
   TREE_USED (alias) = 1;
-  SET_DECL_ASSEMBLER_NAME (alias, DECL_NAME (alias));
   TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (alias)) = 1;
   if (!flag_syntax_only)
     assemble_alias (alias, DECL_ASSEMBLER_NAME (method));
@@ -1318,7 +1307,7 @@ make_method_value (tree mdecl)
     index = integer_minus_one_node;
 
   code = null_pointer_node;
-  if (DECL_RTL_SET_P (mdecl))
+  if (!METHOD_ABSTRACT (mdecl))
     code = build1 (ADDR_EXPR, nativecode_ptr_type_node, 
 		   make_local_function_alias (mdecl));
   START_RECORD_CONSTRUCTOR (minit, method_type_node);
@@ -1440,9 +1429,6 @@ get_dispatch_table (tree type, tree this
 	}
       else
 	{
-	  if (!DECL_RTL_SET_P (method))
-	    make_decl_rtl (method);
-
 	  if (TARGET_VTABLE_USES_DESCRIPTORS)
 	    for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
 	      {
@@ -2333,12 +2319,6 @@ layout_class_method (tree this_class, tr
   SET_DECL_ASSEMBLER_NAME (method_decl,
 			   java_mangle_decl (&temporary_obstack, 
 					     method_decl));
-  /* We don't generate a RTL for the method if it's abstract, or if
-     it's an interface method that isn't clinit. */
-  if (! METHOD_ABSTRACT (method_decl) 
-      || (CLASS_INTERFACE (TYPE_NAME (this_class)) 
-	  && (DECL_CLINIT_P (method_decl))))
-    make_decl_rtl (method_decl);
 
   if (ID_INIT_P (method_name))
     {
Index: constants.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/constants.c,v
retrieving revision 1.42
diff -u -p -d -r1.42 constants.c
--- constants.c	3 May 2005 18:47:48 -0000	1.42
+++ constants.c	24 May 2005 18:35:10 -0000
@@ -446,7 +446,6 @@ build_constant_data_ref (void)
 
       decl = build_decl (VAR_DECL, decl_name, type);
       TREE_STATIC (decl) = 1;
-      make_decl_rtl (decl);
       TYPE_CPOOL_DATA_REF (output_class) = decl;
     }
 
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.220
diff -u -p -d -r1.220 decl.c
--- decl.c	12 May 2005 01:26:50 -0000	1.220
+++ decl.c	24 May 2005 18:35:10 -0000
@@ -558,7 +558,6 @@ builtin_function (const char *name,
   TREE_PUBLIC (decl) = 1;
   if (library_name)
     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
-  make_decl_rtl (decl);
   pushdecl (decl);
   DECL_BUILT_IN_CLASS (decl) = cl;
   DECL_FUNCTION_CODE (decl) = function_code;
@@ -1854,7 +1853,6 @@ give_name_to_locals (JCF *jcf)
 	{
 	  tree decl = TREE_VEC_ELT (decl_map, slot);
 	  DECL_NAME (decl) = name;
-	  SET_DECL_ASSEMBLER_NAME (decl, name);
 	  if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type)
 	    warning (0, "bad type in parameter debug info");
 	}
@@ -1921,7 +1919,6 @@ give_name_to_locals (JCF *jcf)
 	      sprintf (buffer, "ARG_%d", arg_i);
 	      DECL_NAME (parm) = get_identifier (buffer);
 	    }
-	  SET_DECL_ASSEMBLER_NAME (parm, DECL_NAME (parm));
 	}
     }
 }
@@ -2127,6 +2124,11 @@ java_mark_decl_local (tree decl)
 
   /* If we've already constructed DECL_RTL, give encode_section_info
      a second chance, now that we've changed the flags.  */
+  /* ??? Ideally, we'd have flag_unit_at_a_time set, and not have done
+     anything that would have referenced DECL_RTL so far.  But at the
+     moment we force flag_unit_at_a_time off due to excessive memory
+     consumption when compiling large jar files.  Which probably means
+     that we need to re-order how we process jar files...  */
   if (DECL_RTL_SET_P (decl))
     make_decl_rtl (decl);
 }
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.227
diff -u -p -d -r1.227 expr.c
--- expr.c	15 May 2005 18:31:26 -0000	1.227
+++ expr.c	24 May 2005 18:35:11 -0000
@@ -2050,7 +2050,6 @@ build_known_method_ref (tree method, tre
       if (! flag_indirect_dispatch 
 	  || (! DECL_EXTERNAL (method) && ! TREE_PUBLIC (method)))
 	{
-	  make_decl_rtl (method);
 	  func = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (method)),
 			 method);
 	}
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.534
diff -u -p -d -r1.534 parse.y
--- parse.y	19 May 2005 11:16:26 -0000	1.534
+++ parse.y	24 May 2005 18:35:14 -0000
@@ -9550,11 +9550,7 @@ resolve_field_access (tree qual_wfl, tre
       field_ref = length;
 
       /* In case we're dealing with a static array, we need to
-	 initialize its class before the array length can be fetched.
-	 It's also a good time to create a DECL_RTL for the field if
-	 none already exists, otherwise if the field was declared in a
-	 class found in an external file and hasn't been (and won't
-	 be) accessed for its value, none will be created. */
+	 initialize its class before the array length can be fetched.  */
       if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found))
 	{
 	  build_static_field_ref (where_found);
Index: resource.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/resource.c,v
retrieving revision 1.20
diff -u -p -d -r1.20 resource.c
--- resource.c	3 May 2005 18:47:49 -0000	1.20
+++ resource.c	24 May 2005 18:35:14 -0000
@@ -93,7 +93,6 @@ compile_resource_data (const char *name,
   layout_decl (decl, 0);
   pushdecl (decl);
   rest_of_decl_compilation (decl, global_bindings_p (), 0);
-  make_decl_rtl (decl);
   cgraph_varpool_finalize_decl (decl);
 
   resources = tree_cons (NULL_TREE, decl, resources);


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