OSDN Git Service

* c-decl.c (c_expand_body): Don't generate RTL if flag_syntax_only.
[pf3gnuchains/gcc-fork.git] / gcc / java / decl.c
index 7619d63..da44ca6 100644 (file)
@@ -37,6 +37,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "except.h"
 #include "defaults.h"
 #include "java-except.h"
+#include "ggc.h"
 
 #if defined (DEBUG_JAVA_BINDING_LEVELS)
 extern void indent PROTO((void));
@@ -48,14 +49,15 @@ static tree push_promoted_type PARAMS ((const char *, tree));
 static struct binding_level *make_binding_level PARAMS ((void));
 static boolean emit_init_test_initialization PARAMS ((struct hash_entry *,
                                                      hash_table_key));
+static tree create_primitive_vtable PARAMS ((const char *));
 
 /* Set to non-zero value in order to emit class initilization code
    before static field references.  */
 extern int always_initialize_class_p;
 
-#ifndef INT_TYPE_SIZE
-#define INT_TYPE_SIZE BITS_PER_WORD
-#endif
+/* Use garbage collection.  */
+
+int ggc_p = 1;
 
 /* The DECL_MAP is a mapping from (index, type) to a decl node.
    If index < max_locals, it is the index of a local variable.
@@ -70,7 +72,9 @@ tree decl_map;
 /* A list of local variables VAR_DECLs for this method that we have seen
    debug information, but we have not reached their starting (byte) PC yet. */
 
-tree pending_local_decls = NULL_TREE;
+static tree pending_local_decls = NULL_TREE;
+
+tree throw_node [2];
 
 /* Push a local variable or stack slot into the decl_map,
    and assign it an rtl. */
@@ -126,7 +130,7 @@ push_jvm_slot (index, decl)
   if (DECL_LANG_SPECIFIC (decl) == NULL)
     {
       DECL_LANG_SPECIFIC (decl)
-       = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var));
+       = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl_var));
       DECL_LOCAL_START_PC (decl) = 0;
       DECL_LOCAL_END_PC (decl) = DECL_CODE_LENGTH (current_function_decl);
       DECL_LOCAL_SLOT_NUMBER (decl) = index;
@@ -286,121 +290,10 @@ static int keep_next_level_flag;
    if it has subblocks.  */
 
 static int keep_next_if_subblocks;
+
+tree java_global_trees[JTI_MAX];
   
-tree object_type_node;
-tree unqualified_object_id_node;
-tree object_ptr_type_node;
-tree string_type_node;
-tree string_ptr_type_node;
-tree throwable_type_node;
-tree runtime_exception_type_node;
-tree error_exception_type_node;
-tree rawdata_ptr_type_node;
-tree *predef_filenames;
-int  predef_filenames_size;
-
-tree boolean_type_node;
-
-tree return_address_type_node;
-
-tree byte_type_node;
-tree short_type_node;
-tree int_type_node;
-tree long_type_node;
-
-tree promoted_byte_type_node;
-tree promoted_short_type_node;
-tree promoted_char_type_node;
-tree promoted_boolean_type_node;
-
-tree unsigned_byte_type_node;
-tree unsigned_short_type_node;
-tree unsigned_int_type_node;
-tree unsigned_long_type_node;
-
-/* The type for struct methodtable. */
-tree methodtable_type;
-tree methodtable_ptr_type;
-
-tree utf8const_type;
-tree utf8const_ptr_type;
-tree class_type_node;
-tree class_ptr_type;
-tree field_type_node;
-tree field_ptr_type_node;
-tree field_info_union_node;
-tree jexception_type;
-tree jexception_ptr_type;
-tree lineNumberEntry_type;
-tree lineNumbers_type;
-tree constants_type_node;
-tree dtable_type;
-tree dtable_ptr_type;
-tree method_type_node;
-tree method_ptr_type_node;
-tree nativecode_ptr_array_type_node;
-tree one_elt_array_domain_type;
-tree access_flags_type_node;
-tree class_dtable_decl;
-
-/* Expressions that are constants with value zero, of types
-   `long', `float' and `double'.  */
-tree long_zero_node;
-tree float_zero_node;
-tree double_zero_node;
-
-tree empty_stmt_node;
-
-/* Nodes for boolean constants TRUE and FALSE. */
-tree boolean_true_node;
-tree boolean_false_node;
-
-tree TYPE_identifier_node;
-tree init_identifier_node;
-tree clinit_identifier_node;
-tree finit_identifier_node;
-tree void_signature_node;
-tree length_identifier_node;
-tree this_identifier_node;
-tree super_identifier_node;
-tree continue_identifier_node;
-tree access0_identifier_node;  /* 1.1 */
-tree end_params_node;
-
-/* References to internal libjava functions we use. */
-tree alloc_object_node;
-tree soft_instanceof_node;
-tree soft_checkcast_node;
-tree soft_initclass_node;
-tree soft_newarray_node;
-tree soft_anewarray_node;
-tree soft_multianewarray_node;
-tree soft_badarrayindex_node;
-tree soft_nullpointer_node;
-tree throw_node [2];
-tree soft_checkarraystore_node;
-tree soft_monitorenter_node;
-tree soft_monitorexit_node;
-tree soft_lookupinterfacemethod_node;
-tree soft_lookupjnimethod_node;
-tree soft_getjnienvnewframe_node;
-tree soft_jnipopsystemframe_node;
-tree soft_fmod_node;
-tree soft_exceptioninfo_call_node;
-tree soft_idiv_node;
-tree soft_irem_node;
-tree soft_ldiv_node;
-tree soft_lrem_node;
-
-/* Declarations for vtables for primitive arrays.  */
-tree boolean_array_vtable;
-tree byte_array_vtable;
-tree char_array_vtable;
-tree short_array_vtable;
-tree int_array_vtable;
-tree long_array_vtable;
-tree float_array_vtable;
-tree double_array_vtable;
+tree predef_filenames[PREDEF_FILENAMES_SIZE];
 
 /* Build (and pushdecl) a "promoted type" for all standard
    types shorter than int.  */
@@ -428,11 +321,6 @@ push_promoted_type (name, actual_type)
   return type;
 }
 
-/* Nodes for integer constants.  */
-tree integer_two_node;
-tree integer_four_node;
-tree integer_negative_one_node;
-
 /* Return a definition for a builtin function named NAME and whose data type
    is TYPE.  TYPE should be a function type with argument types.
    FUNCTION_CODE tells later passes how to compile calls to this function.
@@ -625,10 +513,8 @@ init_decl_processing ()
   rawdata_ptr_type_node
     = promote_type (lookup_class (get_identifier ("gnu.gcj.RawData")));
 
-  /* This section has to be updated as items are added to the previous
-     section. */
-  predef_filenames_size = 7;
-  predef_filenames = (tree *)xmalloc (predef_filenames_size * sizeof (tree));
+  /* If you add to this section, don't forget to increase
+     PREDEF_FILENAMES_SIZE.  */
   predef_filenames [0] = get_identifier ("java/lang/Class.java");
   predef_filenames [1] = get_identifier ("java/lang/Error.java");
   predef_filenames [2] = get_identifier ("java/lang/Object.java");
@@ -645,7 +531,12 @@ init_decl_processing ()
   TYPE_identifier_node = get_identifier ("TYPE");
   init_identifier_node = get_identifier ("<init>");
   clinit_identifier_node = get_identifier ("<clinit>");
-  finit_identifier_node = get_identifier ("$finit$");
+  /* Legacy `$finit$' special method identifier. This needs to be
+     recognized as equivalent to `finit$' but isn't generated anymore.  */
+  finit_leg_identifier_node = get_identifier ("$finit$");
+  /* The new `finit$' special method identifier. This one is now
+     generated in place of `$finit$'.  */
+  finit_identifier_node = get_identifier ("finit$");
   void_signature_node = get_identifier ("()V");
   length_identifier_node = get_identifier ("length");
   this_identifier_node = get_identifier ("this");
@@ -955,6 +846,17 @@ init_decl_processing ()
                        0, NOT_BUILT_IN, NULL_PTR);
 
   init_class_processing ();
+  init_jcf_parse ();
+
+  /* Register nodes with the garbage collector.  */
+  ggc_add_tree_root (java_global_trees, 
+                    sizeof (java_global_trees) / sizeof (tree));
+  ggc_add_tree_root (throw_node,
+                    sizeof (throw_node) / sizeof (tree));
+  ggc_add_tree_root (predef_filenames,
+                    sizeof (predef_filenames) / sizeof (tree));
+  ggc_add_tree_root (&decl_map, 1);
+  ggc_add_tree_root (&pending_local_decls, 1);
 }
 
 
@@ -1652,7 +1554,7 @@ give_name_to_locals (jcf)
              end_pc = DECL_CODE_LENGTH (current_function_decl);
            }
          DECL_LANG_SPECIFIC (decl)
-           = (struct lang_decl *) permalloc (sizeof (struct lang_decl_var));
+           = (struct lang_decl *) ggc_alloc (sizeof (struct lang_decl_var));
          DECL_LOCAL_SLOT_NUMBER (decl) = slot;
          DECL_LOCAL_START_PC (decl) = start_pc;
 #if 0
@@ -1922,3 +1824,57 @@ end_java_method ()
   permanent_allocation (1);
   asynchronous_exceptions = flag_asynchronous_exceptions;
 }
+
+/* Mark language-specific parts of T for garbage-collection.  */
+
+void
+lang_mark_tree (t)
+     tree t;
+{
+  if (TREE_CODE (t) == IDENTIFIER_NODE)
+    {
+      struct lang_identifier *li = (struct lang_identifier *) t;
+      ggc_mark_tree (li->global_value);
+      ggc_mark_tree (li->local_value);
+      ggc_mark_tree (li->utf8_ref);
+    }
+  else if (TREE_CODE (t) == VAR_DECL
+          || TREE_CODE (t) == PARM_DECL)
+    {
+      struct lang_decl_var *ldv = 
+       ((struct lang_decl_var *) DECL_LANG_SPECIFIC (t));
+      if (ldv)
+       {
+         ggc_mark (ldv);
+         ggc_mark_tree (ldv->slot_chain);
+       }
+    }
+  else if (TREE_CODE (t) == FUNCTION_DECL)
+    {
+      struct lang_decl *ld = DECL_LANG_SPECIFIC (t);
+      
+      if (ld)
+       {
+         ggc_mark (ld);
+         ggc_mark_tree (ld->throws_list);
+         ggc_mark_tree (ld->function_decl_body);
+         ggc_mark_tree (ld->called_constructor);
+         ggc_mark_tree (ld->inner_access);
+       }
+    }
+  else if (TYPE_P (t))
+    {
+      struct lang_type *lt = TYPE_LANG_SPECIFIC (t);
+      
+      if (lt)
+       {
+         ggc_mark (lt);
+         ggc_mark_tree (lt->signature);
+         ggc_mark_tree (lt->cpool_data_ref);
+         ggc_mark_tree (lt->finit_stmt_list);
+         ggc_mark_tree (lt->clinit_stmt_list);
+         ggc_mark_tree (lt->ii_block);
+         ggc_mark_tree (lt->dot_class);
+       }
+    }
+}