OSDN Git Service

Uniquization of constants at the Tree level
[pf3gnuchains/gcc-fork.git] / gcc / java / decl.c
index fcc1c12..81d4d6e 100644 (file)
@@ -1,7 +1,7 @@
 /* Process declarations and variables for the GNU compiler for the
    Java(TM) language.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007,
-   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -31,7 +31,6 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "tm.h"
 #include "tree.h"
 #include "rtl.h"
-#include "real.h"
 #include "toplev.h"
 #include "flags.h"
 #include "java-tree.h"
@@ -49,6 +48,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "version.h"
 #include "tree-iterator.h"
 #include "langhooks.h"
+#include "cgraph.h"
 
 #if defined (DEBUG_JAVA_BINDING_LEVELS)
 extern void indent (void);
@@ -273,7 +273,7 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
       tree name;
       sprintf (buf, "#slot#%d#%d", index, uniq++);
       name = get_identifier (buf);
-      decl = build_decl (VAR_DECL, name, type);
+      decl = build_decl (input_location, VAR_DECL, name, type);
       DECL_IGNORED_P (decl) = 1;
       DECL_ARTIFICIAL (decl) = 1;
       decl = push_jvm_slot (index, decl);
@@ -296,7 +296,7 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
       name = get_identifier (buf);
       base_decl
        = TREE_VEC_ELT (base_decl_map, index)
-       = build_decl (VAR_DECL, name, ptr_type_node);
+       = build_decl (input_location, VAR_DECL, name, ptr_type_node);
       pushdecl_function_level (base_decl);
       DECL_IGNORED_P (base_decl) = 1;
       DECL_ARTIFICIAL (base_decl) = 1;
@@ -305,13 +305,13 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
   return decl;
 }
 
-/* Called during gimplification for every variable.  If the variable
+/* Called during genericization for every variable.  If the variable
    is a temporary of pointer type, replace it with a common variable
    thath is used to hold all pointer types that are ever stored in
    that slot.  Set WANT_LVALUE if you want a variable that is to be
    written to.  */
 
-tree 
+static tree 
 java_replace_reference (tree var_decl, bool want_lvalue)
 {
   tree decl_type;
@@ -340,6 +340,43 @@ java_replace_reference (tree var_decl, bool want_lvalue)
   return var_decl;
 }
 
+/* Helper for java_genericize.  */
+
+tree
+java_replace_references (tree *tp, int *walk_subtrees,
+                        void *data ATTRIBUTE_UNUSED)
+{
+  if (TREE_CODE (*tp) == MODIFY_EXPR)
+    {
+      source_location loc = EXPR_LOCATION (*tp);
+      tree lhs = TREE_OPERAND (*tp, 0);
+      /* This is specific to the bytecode compiler.  If a variable has
+        LOCAL_SLOT_P set, replace an assignment to it with an assignment
+        to the corresponding variable that holds all its aliases.  */
+      if (TREE_CODE (lhs) == VAR_DECL
+         && DECL_LANG_SPECIFIC (lhs)
+         && LOCAL_SLOT_P (lhs)
+         && TREE_CODE (TREE_TYPE (lhs)) == POINTER_TYPE)
+       {
+         tree new_lhs = java_replace_reference (lhs, /* want_lvalue */ true);
+         tree new_rhs = build1 (NOP_EXPR, TREE_TYPE (new_lhs),
+                                TREE_OPERAND (*tp, 1));
+         tree tem = build2 (MODIFY_EXPR, TREE_TYPE (new_lhs),
+                            new_lhs, new_rhs);
+         *tp = build1 (NOP_EXPR, TREE_TYPE (lhs), tem);
+         SET_EXPR_LOCATION (tem, loc);
+         SET_EXPR_LOCATION (new_rhs, loc);
+         SET_EXPR_LOCATION (*tp, loc);
+       }
+    }
+  if (TREE_CODE (*tp) == VAR_DECL)
+    {
+      *tp = java_replace_reference (*tp, /* want_lvalue */ false);
+      *walk_subtrees = 0;
+    }
+
+  return NULL_TREE;
+}
 
 /* Same as find_local_index, except that INDEX is a stack index. */
 
@@ -350,8 +387,8 @@ find_stack_slot (int index, tree type)
                              type, -1);
 }
 
-struct binding_level GTY(())
-  {
+struct GTY(())
+  binding_level {
     /* A chain of _DECL nodes for all variables, constants, functions,
      * and typedef types.  These are in the reverse of the order supplied.
      */
@@ -384,6 +421,9 @@ struct binding_level GTY(())
 
     /* Binding depth at which this level began.  Used only for debugging.  */
     unsigned binding_depth;
+
+    /* The location at which this level began.  */
+    source_location loc;
   };
 
 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
@@ -424,10 +464,11 @@ static const struct binding_level clear_binding_level
     NULL, /* stmts */
     NULL, /* exception_range */
     0, /* binding_depth */
+    0, /* loc */
   };
 
 tree java_global_trees[JTI_MAX];
-  
+
 /* Build (and pushdecl) a "promoted type" for all standard
    types shorter than int.  */
 
@@ -449,7 +490,8 @@ push_promoted_type (const char *name, tree actual_type)
   TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
   TYPE_STRING_FLAG (type) = TYPE_STRING_FLAG (actual_type);
   layout_type (type);
-  pushdecl (build_decl (TYPE_DECL, get_identifier (name), type));
+  pushdecl (build_decl (input_location,
+                       TYPE_DECL, get_identifier (name), type));
   return type;
 }
 
@@ -461,17 +503,12 @@ create_primitive_vtable (const char *name)
   char buf[50];
 
   sprintf (buf, "_Jv_%sVTable", name);
-  r = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+  r = build_decl (input_location,
+                 VAR_DECL, get_identifier (buf), ptr_type_node);
   DECL_EXTERNAL (r) = 1;
   return r;
 }
 
-static tree
-do_nothing (tree t)
-{
-  return t;
-}
-
 /* Parse the version string and compute the ABI version number.  */
 static void
 parse_version (void)
@@ -541,28 +578,36 @@ java_init_decl_processing (void)
   TREE_TYPE (error_mark_node) = error_mark_node;
 
   /* Create sizetype first - needed for other types. */
-  initialize_sizetypes (false);
+  initialize_sizetypes ();
 
   byte_type_node = make_signed_type (8);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node));
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("byte"), byte_type_node));
   short_type_node = make_signed_type (16);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("short"), short_type_node));
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("short"), short_type_node));
   int_type_node = make_signed_type (32);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("int"), int_type_node));
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("int"), int_type_node));
   long_type_node = make_signed_type (64);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("long"), long_type_node));
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("long"), long_type_node));
 
   unsigned_byte_type_node = make_unsigned_type (8);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("unsigned byte"),
                        unsigned_byte_type_node));
   unsigned_short_type_node = make_unsigned_type (16);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned short"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("unsigned short"),
                        unsigned_short_type_node));
   unsigned_int_type_node = make_unsigned_type (32);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("unsigned int"),
                        unsigned_int_type_node));
   unsigned_long_type_node = make_unsigned_type (64);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("unsigned long"),
                        unsigned_long_type_node));
 
   /* This is not a java type, however tree-dfa requires a definition for
@@ -599,7 +644,8 @@ java_init_decl_processing (void)
   long_zero_node = build_int_cst (long_type_node, 0);
 
   void_type_node = make_node (VOID_TYPE);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("void"), void_type_node));
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("void"), void_type_node));
   layout_type (void_type_node);        /* Uses size_zero_node */
 
   ptr_type_node = build_pointer_type (void_type_node);
@@ -616,12 +662,14 @@ java_init_decl_processing (void)
   TYPE_STRING_FLAG (char_type_node) = 1;
   TYPE_PRECISION (char_type_node) = 16;
   fixup_unsigned_type (char_type_node);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("char"), char_type_node));
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("char"), char_type_node));
 
   boolean_type_node = make_node (BOOLEAN_TYPE);
   TYPE_PRECISION (boolean_type_node) = 1;
   fixup_unsigned_type (boolean_type_node);
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("boolean"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("boolean"),
                        boolean_type_node));
   boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
   boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
@@ -637,13 +685,15 @@ java_init_decl_processing (void)
 
   float_type_node = make_node (REAL_TYPE);
   TYPE_PRECISION (float_type_node) = 32;
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("float"),
                         float_type_node));
   layout_type (float_type_node);
 
   double_type_node = make_node (REAL_TYPE);
   TYPE_PRECISION (double_type_node) = 64;
-  pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
+  pushdecl (build_decl (BUILTINS_LOCATION,
+                       TYPE_DECL, get_identifier ("double"),
                         double_type_node));
   layout_type (double_type_node);
 
@@ -662,8 +712,10 @@ java_init_decl_processing (void)
 
   one_elt_array_domain_type = build_index_type (integer_one_node);
   utf8const_type = make_node (RECORD_TYPE);
-  PUSH_FIELD (utf8const_type, field, "hash", unsigned_short_type_node);
-  PUSH_FIELD (utf8const_type, field, "length", unsigned_short_type_node);
+  PUSH_FIELD (input_location,
+             utf8const_type, field, "hash", unsigned_short_type_node);
+  PUSH_FIELD (input_location,
+             utf8const_type, field, "length", unsigned_short_type_node);
   FINISH_RECORD (utf8const_type);
   utf8const_ptr_type = build_pointer_type (utf8const_type);
 
@@ -678,9 +730,11 @@ java_init_decl_processing (void)
   itable_ptr_type = build_pointer_type (itable_type);
 
   symbol_type = make_node (RECORD_TYPE);
-  PUSH_FIELD (symbol_type, field, "clname", utf8const_ptr_type);
-  PUSH_FIELD (symbol_type, field, "name", utf8const_ptr_type);
-  PUSH_FIELD (symbol_type, field, "signature", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             symbol_type, field, "clname", utf8const_ptr_type);
+  PUSH_FIELD (input_location, symbol_type, field, "name", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             symbol_type, field, "signature", utf8const_ptr_type);
   FINISH_RECORD (symbol_type);
 
   symbols_array_type = build_array_type (symbol_type, 
@@ -688,9 +742,12 @@ java_init_decl_processing (void)
   symbols_array_ptr_type = build_pointer_type (symbols_array_type);
 
   assertion_entry_type = make_node (RECORD_TYPE);
-  PUSH_FIELD (assertion_entry_type, field, "assertion_code", integer_type_node);
-  PUSH_FIELD (assertion_entry_type, field, "op1", utf8const_ptr_type);
-  PUSH_FIELD (assertion_entry_type, field, "op2", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             assertion_entry_type, field, "assertion_code", integer_type_node);
+  PUSH_FIELD (input_location,
+             assertion_entry_type, field, "op1", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             assertion_entry_type, field, "op2", utf8const_ptr_type);
   FINISH_RECORD (assertion_entry_type);
   
   assertion_table_type = build_array_type (assertion_entry_type,
@@ -728,7 +785,8 @@ java_init_decl_processing (void)
 
   methodtable_type = make_node (RECORD_TYPE);
   layout_type (methodtable_type);
-  build_decl (TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("methodtable"), methodtable_type);
   methodtable_ptr_type = build_pointer_type (methodtable_type);
 
   TYPE_identifier_node = get_identifier ("TYPE");
@@ -746,12 +804,16 @@ java_init_decl_processing (void)
   init_expr_processing();
 
   constants_type_node = make_node (RECORD_TYPE);
-  PUSH_FIELD (constants_type_node, field, "size", unsigned_int_type_node);
-  PUSH_FIELD (constants_type_node, field, "tags", ptr_type_node);
-  PUSH_FIELD (constants_type_node, field, "data", ptr_type_node);
+  PUSH_FIELD (input_location,
+             constants_type_node, field, "size", unsigned_int_type_node);
+  PUSH_FIELD (input_location,
+             constants_type_node, field, "tags", ptr_type_node);
+  PUSH_FIELD (input_location,
+             constants_type_node, field, "data", ptr_type_node);
   constants_data_field_decl_node = field;
   FINISH_RECORD (constants_type_node);
-  build_decl (TYPE_DECL, get_identifier ("constants"), constants_type_node);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("constants"), constants_type_node);
 
   access_flags_type_node = unsigned_short_type_node;
 
@@ -763,7 +825,8 @@ java_init_decl_processing (void)
   TYPE_NONALIASED_COMPONENT (otable_type) = 1;
   otable_ptr_type = build_pointer_type (otable_type);
 
-  PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type);
+  PUSH_FIELD (input_location,
+             object_type_node, field, "vtable", dtable_ptr_type);
   DECL_FCONTEXT (field) = object_type_node;
   TYPE_VFIELD (object_type_node) = field;
 
@@ -771,7 +834,7 @@ java_init_decl_processing (void)
      There is an unresolved issue here, which is whether the vtable
      should be marked by the GC.  */
   if (! flag_hash_synchronization)
-    PUSH_FIELD (object_type_node, field, "sync_info",
+    PUSH_FIELD (input_location, object_type_node, field, "sync_info",
                build_pointer_type (object_type_node));
   for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
     FIELD_PRIVATE (t) = 1;
@@ -786,101 +849,154 @@ 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_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);
-  PUSH_FIELD (class_type_node, field, "constants", constants_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "next_or_version", class_ptr_type);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "name", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "accflags", access_flags_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "superclass", class_ptr_type);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "constants", constants_type_node);
   constants_field_decl_node = field;
-  PUSH_FIELD (class_type_node, field, "methods", method_ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "method_count", short_type_node);
-  PUSH_FIELD (class_type_node, field, "vtable_method_count", short_type_node);
-  PUSH_FIELD (class_type_node, field, "fields", field_ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "size_in_bytes", int_type_node);
-  PUSH_FIELD (class_type_node, field, "field_count", short_type_node);
-  PUSH_FIELD (class_type_node, field, "static_field_count", short_type_node);
-  PUSH_FIELD (class_type_node, field, "vtable", dtable_ptr_type);
-  PUSH_FIELD (class_type_node, field, "otable", otable_ptr_type);
-  PUSH_FIELD (class_type_node, field, "otable_syms", 
+  PUSH_FIELD (input_location,
+             class_type_node, field, "methods", method_ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "method_count", short_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "vtable_method_count", short_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "fields", field_ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "size_in_bytes", int_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "field_count", short_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "static_field_count", short_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "vtable", dtable_ptr_type);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "otable", otable_ptr_type);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "otable_syms", 
              symbols_array_ptr_type);
-  PUSH_FIELD (class_type_node, field, "atable", atable_ptr_type);
-  PUSH_FIELD (class_type_node, field, "atable_syms", 
+  PUSH_FIELD (input_location,
+             class_type_node, field, "atable", atable_ptr_type);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "atable_syms", 
              symbols_array_ptr_type);
-  PUSH_FIELD (class_type_node, field, "itable", itable_ptr_type);
-  PUSH_FIELD (class_type_node, field, "itable_syms", 
+  PUSH_FIELD (input_location,
+             class_type_node, field, "itable", itable_ptr_type);
+  PUSH_FIELD (input_location, class_type_node, field, "itable_syms", 
              symbols_array_ptr_type);
-  PUSH_FIELD (class_type_node, field, "catch_classes", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "interfaces",
+  PUSH_FIELD (input_location,
+             class_type_node, field, "catch_classes", ptr_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "interfaces",
              build_pointer_type (class_ptr_type));
-  PUSH_FIELD (class_type_node, field, "loader", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "interface_count", short_type_node);
-  PUSH_FIELD (class_type_node, field, "state", byte_type_node);
-  PUSH_FIELD (class_type_node, field, "thread", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "depth", short_type_node);
-  PUSH_FIELD (class_type_node, field, "ancestors", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "idt", ptr_type_node);  
-  PUSH_FIELD (class_type_node, field, "arrayclass", ptr_type_node);  
-  PUSH_FIELD (class_type_node, field, "protectionDomain", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "assertion_table", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "hack_signers", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "chain", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "aux_info", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "engine", ptr_type_node);
-  PUSH_FIELD (class_type_node, field, "reflection_data", ptr_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "loader", ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "interface_count", short_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "state", byte_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "thread", ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "depth", short_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "ancestors", ptr_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "idt", ptr_type_node);  
+  PUSH_FIELD (input_location,
+             class_type_node, field, "arrayclass", ptr_type_node);  
+  PUSH_FIELD (input_location,
+             class_type_node, field, "protectionDomain", ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "assertion_table", ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "hack_signers", ptr_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "chain", ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "aux_info", ptr_type_node);
+  PUSH_FIELD (input_location, class_type_node, field, "engine", ptr_type_node);
+  PUSH_FIELD (input_location,
+             class_type_node, field, "reflection_data", ptr_type_node);
   for (t = TYPE_FIELDS (class_type_node);  t != NULL_TREE;  t = TREE_CHAIN (t))
     FIELD_PRIVATE (t) = 1;
   push_super_field (class_type_node, object_type_node);
 
   FINISH_RECORD (class_type_node);
-  build_decl (TYPE_DECL, get_identifier ("Class"), class_type_node);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("Class"), class_type_node);
 
   field_info_union_node = make_node (UNION_TYPE);
-  PUSH_FIELD (field_info_union_node, field, "boffset", int_type_node);
-  PUSH_FIELD (field_info_union_node, field, "addr", ptr_type_node);
+  PUSH_FIELD (input_location,
+             field_info_union_node, field, "boffset", int_type_node);
+  PUSH_FIELD (input_location,
+             field_info_union_node, field, "addr", ptr_type_node);
   layout_type (field_info_union_node);
 
-  PUSH_FIELD (field_type_node, field, "name", utf8const_ptr_type);
-  PUSH_FIELD (field_type_node, field, "type", class_ptr_type);
-  PUSH_FIELD (field_type_node, field, "accflags", access_flags_type_node);
-  PUSH_FIELD (field_type_node, field, "bsize", unsigned_short_type_node);
-  PUSH_FIELD (field_type_node, field, "info", field_info_union_node);
+  PUSH_FIELD (input_location,
+             field_type_node, field, "name", utf8const_ptr_type);
+  PUSH_FIELD (input_location, field_type_node, field, "type", class_ptr_type);
+  PUSH_FIELD (input_location,
+             field_type_node, field, "accflags", access_flags_type_node);
+  PUSH_FIELD (input_location,
+             field_type_node, field, "bsize", unsigned_short_type_node);
+  PUSH_FIELD (input_location,
+             field_type_node, field, "info", field_info_union_node);
   FINISH_RECORD (field_type_node);
-  build_decl (TYPE_DECL, get_identifier ("Field"), field_type_node);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("Field"), field_type_node);
 
   nativecode_ptr_array_type_node
     = build_array_type (nativecode_ptr_type_node, one_elt_array_domain_type);
 
-  PUSH_FIELD (dtable_type, field, "class", class_ptr_type);
-  PUSH_FIELD (dtable_type, field, "methods", nativecode_ptr_array_type_node);
+  PUSH_FIELD (input_location,
+             dtable_type, field, "class", class_ptr_type);
+  PUSH_FIELD (input_location,
+             dtable_type, field, "methods", nativecode_ptr_array_type_node);
   FINISH_RECORD (dtable_type);
-  build_decl (TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("dispatchTable"), dtable_type);
 
   jexception_type = make_node (RECORD_TYPE);
-  PUSH_FIELD (jexception_type, field, "start_pc", ptr_type_node);
-  PUSH_FIELD (jexception_type, field, "end_pc", ptr_type_node);
-  PUSH_FIELD (jexception_type, field, "handler_pc", ptr_type_node);
-  PUSH_FIELD (jexception_type, field, "catch_type", class_ptr_type);
+  PUSH_FIELD (input_location,
+             jexception_type, field, "start_pc", ptr_type_node);
+  PUSH_FIELD (input_location, jexception_type, field, "end_pc", ptr_type_node);
+  PUSH_FIELD (input_location,
+             jexception_type, field, "handler_pc", ptr_type_node);
+  PUSH_FIELD (input_location,
+             jexception_type, field, "catch_type", class_ptr_type);
   FINISH_RECORD (jexception_type);
-  build_decl (TYPE_DECL, get_identifier ("jexception"), field_type_node);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("jexception"), field_type_node);
   jexception_ptr_type = build_pointer_type (jexception_type);
 
   lineNumberEntry_type = make_node (RECORD_TYPE);
-  PUSH_FIELD (lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
-  PUSH_FIELD (lineNumberEntry_type, field, "start_pc", ptr_type_node);
+  PUSH_FIELD (input_location,
+             lineNumberEntry_type, field, "line_nr", unsigned_short_type_node);
+  PUSH_FIELD (input_location,
+             lineNumberEntry_type, field, "start_pc", ptr_type_node);
   FINISH_RECORD (lineNumberEntry_type);
 
   lineNumbers_type = make_node (RECORD_TYPE);
-  PUSH_FIELD (lineNumbers_type, field, "length", unsigned_int_type_node);
+  PUSH_FIELD (input_location,
+             lineNumbers_type, field, "length", unsigned_int_type_node);
   FINISH_RECORD (lineNumbers_type);
 
-  PUSH_FIELD (method_type_node, field, "name", utf8const_ptr_type);
-  PUSH_FIELD (method_type_node, field, "signature", utf8const_ptr_type);
-  PUSH_FIELD (method_type_node, field, "accflags", access_flags_type_node);
-  PUSH_FIELD (method_type_node, field, "index", unsigned_short_type_node);
-  PUSH_FIELD (method_type_node, field, "ncode", nativecode_ptr_type_node);
-  PUSH_FIELD (method_type_node, field, "throws", ptr_type_node);
+  PUSH_FIELD (input_location,
+             method_type_node, field, "name", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             method_type_node, field, "signature", utf8const_ptr_type);
+  PUSH_FIELD (input_location,
+             method_type_node, field, "accflags", access_flags_type_node);
+  PUSH_FIELD (input_location,
+             method_type_node, field, "index", unsigned_short_type_node);
+  PUSH_FIELD (input_location,
+             method_type_node, field, "ncode", nativecode_ptr_type_node);
+  PUSH_FIELD (input_location,
+             method_type_node, field, "throws", ptr_type_node);
   FINISH_RECORD (method_type_node);
-  build_decl (TYPE_DECL, get_identifier ("Method"), method_type_node);
+  build_decl (BUILTINS_LOCATION,
+             TYPE_DECL, get_identifier ("Method"), method_type_node);
 
   endlink = end_params_node = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
 
@@ -1071,18 +1187,8 @@ java_init_decl_processing (void)
                            build_function_type (long_type_node, t),
                            0, NOT_BUILT_IN, NULL, NULL_TREE);
 
-  /* Initialize variables for except.c.  */
-  eh_personality_libfunc = init_one_libfunc (USING_SJLJ_EXCEPTIONS
-                                             ? "__gcj_personality_sj0"
-                                             : "__gcj_personality_v0");
-  if (targetm.arm_eabi_unwinder)
-    unwind_resume_libfunc = init_one_libfunc ("__cxa_end_cleanup");
-  else
-    default_init_unwind_resume_libfunc ();
-
-  lang_eh_runtime_type = do_nothing;
-
   initialize_builtins ();
+
   soft_fmod_node = built_in_decls[BUILT_IN_FMOD];
 
   parse_version ();
@@ -1254,7 +1360,7 @@ static struct binding_level *
 make_binding_level (void)
 {
   /* NOSTRICT */
-  return ggc_alloc_cleared (sizeof (struct binding_level));
+  return GGC_CNEW (struct binding_level);
 }
 
 void
@@ -1279,7 +1385,8 @@ pushlevel (int unused ATTRIBUTE_UNUSED)
 
   *newlevel = clear_binding_level;
   newlevel->level_chain = current_binding_level;
-  current_binding_level = newlevel;
+  newlevel->loc = input_location;
+  current_binding_level = newlevel;  
 #if defined(DEBUG_JAVA_BINDING_LEVELS)
   newlevel->binding_depth = binding_depth;
   indent ();
@@ -1394,6 +1501,8 @@ poplevel (int keep, int reverse, int functionbody)
          if (BIND_EXPR_BODY (bind) == NULL)
            BIND_EXPR_BODY (bind) = build_java_empty_stmt ();
 
+         SET_EXPR_LOCATION (bind, current_binding_level->loc);
+
          current_binding_level->stmts = NULL;
        }
       else
@@ -1593,7 +1702,7 @@ java_dup_lang_specific_decl (tree node)
     return;
 
   lang_decl_size = sizeof (struct lang_decl);
-  x = ggc_alloc (lang_decl_size);
+  x = GGC_NEW (struct lang_decl);
   memcpy (x, DECL_LANG_SPECIFIC (node), lang_decl_size);
   DECL_LANG_SPECIFIC (node) = x;
 }
@@ -1631,7 +1740,7 @@ give_name_to_locals (JCF *jcf)
        {
          tree *ptr;
          int end_pc = start_pc + length;
-         tree decl = build_decl (VAR_DECL, name, type);
+         tree decl = build_decl (input_location, VAR_DECL, name, type);
          if (end_pc > DECL_CODE_LENGTH (current_function_decl))
            {
              warning (0, "bad PC range for debug info for local %q+D",
@@ -1693,11 +1802,8 @@ build_result_decl (tree fndecl)
   tree result = DECL_RESULT (fndecl);
   if (! result)
     {
-      /* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
-      if (INTEGRAL_TYPE_P (restype)
-         && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
-       restype = integer_type_node;
-      result = build_decl (RESULT_DECL, NULL_TREE, restype);
+      result = build_decl (DECL_SOURCE_LOCATION (fndecl),
+                          RESULT_DECL, NULL_TREE, restype);
       DECL_ARTIFICIAL (result) = 1;
       DECL_IGNORED_P (result) = 1;
       DECL_CONTEXT (result) = fndecl;
@@ -1720,7 +1826,7 @@ start_java_method (tree fndecl)
   i = DECL_MAX_LOCALS(fndecl) + DECL_MAX_STACK(fndecl);
   decl_map = make_tree_vec (i);
   base_decl_map = make_tree_vec (i);
-  type_map = xrealloc (type_map, i * sizeof (tree));
+  type_map = XRESIZEVEC (tree, type_map, i);
 
 #if defined(DEBUG_JAVA_BINDING_LEVELS)
   fprintf (stderr, "%s:\n", lang_printable_name (fndecl, 2));
@@ -1736,7 +1842,7 @@ start_java_method (tree fndecl)
       tree parm_type = TREE_VALUE (tem);
       gcc_assert (i < DECL_MAX_LOCALS (fndecl));
 
-      parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
+      parm_decl = build_decl (input_location, PARM_DECL, parm_name, parm_type);
       DECL_CONTEXT (parm_decl) = fndecl;
       if (targetm.calls.promote_prototypes (parm_type)
          && TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
@@ -1750,6 +1856,10 @@ start_java_method (tree fndecl)
       /* Add parm_decl to the decl_map. */
       push_jvm_slot (i, parm_decl);
 
+      /* The this parameter of methods is artificial.  */
+      if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE && i == 0)
+       DECL_ARTIFICIAL (parm_decl) = 1;
+
       type_map[i] = TREE_TYPE (parm_decl);
       if (TYPE_IS_WIDE (TREE_TYPE (parm_decl)))
        {
@@ -1764,6 +1874,7 @@ start_java_method (tree fndecl)
     type_map[i++] = NULL_TREE;
 
   build_result_decl (fndecl);
+  DECL_SOURCE_LOCATION (fndecl) = input_location;
 
   /* Push local variables.  */
   pushlevel (2);
@@ -1797,15 +1908,8 @@ end_java_method (void)
 
   finish_method (fndecl);
 
-  if (! flag_unit_at_a_time)
-    {
-      /* Nulling these fields when we no longer need them saves
-        memory.  */
-      DECL_SAVED_TREE (fndecl) = NULL;
-      DECL_STRUCT_FUNCTION (fndecl) = NULL;
-      DECL_INITIAL (fndecl) = NULL_TREE;
-    }
   current_function_decl = NULL_TREE;
+  base_decl_map = NULL_TREE;
 }
 
 /* Prepare a method for expansion.  */
@@ -1854,15 +1958,12 @@ java_mark_decl_local (tree decl)
 {
   DECL_EXTERNAL (decl) = 0;
 
-  /* 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);
+#ifdef ENABLE_CHECKING
+  /* Double check that we didn't pass the function to the callgraph early.  */
+  if (TREE_CODE (decl) == FUNCTION_DECL)
+    gcc_assert (!cgraph_node (decl)->local.finalized);
+#endif
+  gcc_assert (!DECL_RTL_SET_P (decl));
 }
 
 /* Given appropriate target support, G++ will emit hidden aliases for native
@@ -1899,15 +2000,15 @@ java_mark_cni_decl_local (tree decl)
 /* Use the preceding two functions and mark all members of the class.  */
 
 void
-java_mark_class_local (tree class)
+java_mark_class_local (tree klass)
 {
   tree t;
 
-  for (t = TYPE_FIELDS (class); t ; t = TREE_CHAIN (t))
+  for (t = TYPE_FIELDS (klass); t ; t = TREE_CHAIN (t))
     if (FIELD_STATIC (t))
       java_mark_decl_local (t);
 
-  for (t = TYPE_METHODS (class); t ; t = TREE_CHAIN (t))
+  for (t = TYPE_METHODS (klass); t ; t = TREE_CHAIN (t))
     if (!METHOD_ABSTRACT (t))
       {
        if (METHOD_NATIVE (t) && !flag_jni)
@@ -1935,6 +2036,26 @@ add_stmt_to_compound (tree existing, tree type, tree stmt)
     return stmt;
 }
 
+/* If this node is an expr, mark its input location.  Called from
+   walk_tree().  */
+
+static tree
+set_input_location (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
+                   void *data ATTRIBUTE_UNUSED)
+{
+  tree t = *tp;
+
+  if (CAN_HAVE_LOCATION_P (t))
+    {
+      if (EXPR_HAS_LOCATION(t))
+       return t;  /* Don't walk any further into this expr.   */
+      else
+       SET_EXPR_LOCATION (t, input_location);
+    }
+
+  return NULL_TREE;  /* Continue walking this expr.   */
+}
+
 /* Add a statement to the statement_list currently being constructed.
    If the statement_list is null, we don't create a singleton list.
    This is necessary because poplevel() assumes that adding a
@@ -1947,8 +2068,8 @@ java_add_stmt (tree new_stmt)
   tree_stmt_iterator i;
 
   if (input_filename)
-    SET_EXPR_LOCATION (new_stmt, input_location);
-  
+    walk_tree (&new_stmt, set_input_location, NULL, NULL);
+
   if (stmts == NULL)
     return current_binding_level->stmts = new_stmt;