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 5669b3f..da44ca6 100644 (file)
@@ -1,7 +1,6 @@
 /* Process declarations and variables for the GNU compiler for the
    Java(TM) language.
-
-   Copyright (C) 1996, 97-99, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -38,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));
@@ -47,10 +47,17 @@ static tree push_jvm_slot PARAMS ((int, tree));
 static tree lookup_name_current_level PARAMS ((tree));
 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 *));
 
-#ifndef INT_TYPE_SIZE
-#define INT_TYPE_SIZE BITS_PER_WORD
-#endif
+/* Set to non-zero value in order to emit class initilization code
+   before static field references.  */
+extern int always_initialize_class_p;
+
+/* 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.
@@ -65,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. */
@@ -121,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;
@@ -133,9 +142,7 @@ push_jvm_slot (index, decl)
 
 /* Find a VAR_DECL (or PARM_DECL) at local index INDEX that has type TYPE,
    that is valid at PC (or -1 if any pc).
-   If there is no existing matching decl, allocate one.
-   If we find a decl with matching modes but different types,
-   we re-use the rtl, but create a new decl. */
+   If there is no existing matching decl, allocate one.  */
 
 tree
 find_local_variable (index, type, pc)
@@ -145,6 +152,7 @@ find_local_variable (index, type, pc)
 {
   tree decl = TREE_VEC_ELT (decl_map, index);
   tree best = NULL_TREE;
+
   while (decl != NULL_TREE)
     {
       int in_range;
@@ -153,6 +161,10 @@ find_local_variable (index, type, pc)
            && pc < DECL_LOCAL_END_PC (decl));
 
       if ((TREE_TYPE (decl) == type
+          || (TREE_CODE (TREE_TYPE (decl)) == TREE_CODE (type)
+              && TYPE_PRECISION (TREE_TYPE (decl)) <= 32
+              && TYPE_PRECISION (type) <= 32
+              && TREE_CODE (type) != POINTER_TYPE)
           || (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
               && type == ptr_type_node))
           && in_range)
@@ -221,6 +233,7 @@ struct binding_level
 
     /* The bytecode PC that marks the end of this level. */
     int end_pc;
+    /* The bytecode PC that marks the start of this level. */
     int start_pc;
 
 #if defined(DEBUG_JAVA_BINDING_LEVELS)
@@ -253,7 +266,7 @@ static struct binding_level *global_binding_level;
 
 static struct binding_level clear_binding_level
   = {NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE,
-       NULL_BINDING_LEVEL, 0, 0, 0, 0, LARGEST_PC, 0, 0};
+       NULL_BINDING_LEVEL, 0, 0, 0, 0, LARGEST_PC, 0};
 
 #if 0
 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
@@ -277,109 +290,10 @@ static int keep_next_level_flag;
    if it has subblocks.  */
 
 static int keep_next_if_subblocks;
+
+tree java_global_trees[JTI_MAX];
   
-/* The FUNCTION_DECL for the function currently being compiled,
-   or 0 if between functions.  */
-tree current_function_decl;
-
-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 *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, 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 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 throw_node [2];
-tree soft_checkarraystore_node;
-tree soft_monitorenter_node;
-tree soft_monitorexit_node;
-tree soft_lookupinterfacemethod_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;
+tree predef_filenames[PREDEF_FILENAMES_SIZE];
 
 /* Build (and pushdecl) a "promoted type" for all standard
    types shorter than int.  */
@@ -397,11 +311,9 @@ push_promoted_type (name, actual_type)
   tree in_min = TYPE_MIN_VALUE (actual_type);
   tree in_max = TYPE_MAX_VALUE (actual_type);
 #endif
-  TYPE_MIN_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_min),
-                                      TREE_INT_CST_HIGH (in_min));
+  TYPE_MIN_VALUE (type) = copy_node (in_min);
   TREE_TYPE (TYPE_MIN_VALUE (type)) = type;
-  TYPE_MAX_VALUE (type) = build_int_2 (TREE_INT_CST_LOW (in_max),
-                                      TREE_INT_CST_HIGH (in_max));
+  TYPE_MAX_VALUE (type) = copy_node (in_max);
   TREE_TYPE (TYPE_MAX_VALUE (type)) = type;
   TYPE_PRECISION (type) = TYPE_PRECISION (int_type_node);
   layout_type (type);
@@ -409,10 +321,6 @@ push_promoted_type (name, actual_type)
   return type;
 }
 
-/* Nodes for integer constants.  */
-tree integer_two_node, 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.
@@ -441,6 +349,21 @@ builtin_function (name, type, function_code, class, library_name)
   return decl;
 }
 
+/* Return tree that represents a vtable for a primitive array.  */
+static tree
+create_primitive_vtable (name)
+     const char *name;
+{
+  tree r;
+  char buf[50];
+
+  sprintf (buf, "_Jv_%sVTable", name);
+  r = build_decl (VAR_DECL, get_identifier (buf), ptr_type_node);
+  DECL_EXTERNAL (r) = 1;
+  make_decl_rtl (r, buf, 1);
+  return r;
+}
+
 void
 init_decl_processing ()
 {
@@ -454,15 +377,13 @@ init_decl_processing ()
   pushlevel (0);       /* make the binding_level structure for global names */
   global_binding_level = current_binding_level;
 
+  /* The code here must be similar to build_common_tree_nodes{,_2} in
+     tree.c, especially as to the order of initializing common nodes.  */
   error_mark_node = make_node (ERROR_MARK);
   TREE_TYPE (error_mark_node) = error_mark_node;
 
   /* Create sizetype first - needed for other types. */
-  sizetype = make_unsigned_type (POINTER_SIZE);
-  size_zero_node = build_int_2 (0, 0);
-  TREE_TYPE (size_zero_node) = sizetype;
-  size_one_node = build_int_2 (1, 0);
-  TREE_TYPE (size_one_node) = sizetype;
+  initialize_sizetypes ();
 
   byte_type_node = make_signed_type (8);
   pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"), byte_type_node));
@@ -486,14 +407,22 @@ init_decl_processing ()
   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned long"),
                        unsigned_long_type_node));
 
-  integer_type_node = type_for_size (INT_TYPE_SIZE, 0);
+  set_sizetype (make_unsigned_type (POINTER_SIZE));
 
+  /* Define these next since types below may used them.  */
+  integer_type_node = type_for_size (INT_TYPE_SIZE, 0);
   integer_zero_node = build_int_2 (0, 0);
   integer_one_node = build_int_2 (1, 0);
   integer_two_node = build_int_2 (2, 0);
   integer_four_node = build_int_2 (4, 0);
   integer_negative_one_node = build_int_2 (-1, 0);
 
+  size_zero_node = size_int (0);
+  size_one_node = size_int (1);
+  bitsize_zero_node = bitsize_int (0);
+  bitsize_one_node = bitsize_int (1);
+  bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
+
   long_zero_node = build_int_2 (0, 0);
   TREE_TYPE (long_zero_node) = long_type_node;
 
@@ -557,7 +486,17 @@ init_decl_processing ()
   float_zero_node = build_real (float_type_node, dconst0);
   double_zero_node = build_real (double_type_node, dconst0);
 
-  /* As your adding items here, please update the code right after
+  /* These are the vtables for arrays of primitives.  */
+  boolean_array_vtable = create_primitive_vtable ("boolean");
+  byte_array_vtable = create_primitive_vtable ("byte");
+  char_array_vtable = create_primitive_vtable ("char");
+  short_array_vtable = create_primitive_vtable ("short");
+  int_array_vtable = create_primitive_vtable ("int");
+  long_array_vtable = create_primitive_vtable ("long");
+  float_array_vtable = create_primitive_vtable ("float");
+  double_array_vtable = create_primitive_vtable ("double");
+
+  /* As you're adding items here, please update the code right after
      this section, so that the filename containing the source code of
      the pre-defined class gets registered correctly. */
   unqualified_object_id_node = get_identifier ("Object");
@@ -571,17 +510,18 @@ init_decl_processing ()
     lookup_class (get_identifier ("java.lang.RuntimeException"));
   error_exception_type_node = 
     lookup_class (get_identifier ("java.lang.Error"));
+  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 = 6;
-  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");
   predef_filenames [3] = get_identifier ("java/lang/RuntimeException.java");
   predef_filenames [4] = get_identifier ("java/lang/String.java");
   predef_filenames [5] = get_identifier ("java/lang/Throwable.java");
+  predef_filenames [6] = get_identifier ("gnu/gcj/RawData.java");
 
   methodtable_type = make_node (RECORD_TYPE);
   layout_type (methodtable_type);
@@ -591,12 +531,18 @@ 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");
   super_identifier_node = get_identifier ("super");
   continue_identifier_node = get_identifier ("continue");
+  access0_identifier_node = get_identifier ("access$0");
 
   /* for lack of a better place to put this stub call */
   init_expr_processing();
@@ -620,7 +566,12 @@ init_decl_processing ()
   dtable_ptr_type = build_pointer_type (dtable_type);
 
   PUSH_FIELD (object_type_node, field, "vtable", dtable_ptr_type);
-  PUSH_FIELD (object_type_node, field, "sync_info", ptr_type_node);
+  /* This isn't exactly true, but it is what we have in the source.
+     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",
+               build_pointer_type (object_type_node));
   for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = TREE_CHAIN (t))
     FIELD_PRIVATE (t) = 1;
   FINISH_RECORD (object_type_node);
@@ -659,6 +610,9 @@ init_decl_processing ()
   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);  
   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);
@@ -732,12 +686,13 @@ init_decl_processing ()
                                        build_function_type (ptr_type_node, t),
                                        0, NOT_BUILT_IN, NULL_PTR);
   DECL_IS_MALLOC (alloc_object_node) = 1;
+
+  t = tree_cons (NULL_TREE, ptr_type_node, endlink);
   soft_initclass_node = builtin_function ("_Jv_InitClass",
                                          build_function_type (void_type_node,
                                                               t),
                                          0, NOT_BUILT_IN,
                                          NULL_PTR);
-  t = tree_cons (NULL_TREE, ptr_type_node, endlink);
   throw_node[0] = builtin_function ("_Jv_Throw",
                                    build_function_type (ptr_type_node, t),
                                    0, NOT_BUILT_IN, NULL_PTR);
@@ -793,6 +748,15 @@ init_decl_processing ()
   TREE_THIS_VOLATILE (soft_badarrayindex_node) = 1;
   TREE_SIDE_EFFECTS (soft_badarrayindex_node) = 1;
 
+  soft_nullpointer_node
+    = builtin_function ("_Jv_ThrowNullPointerException",
+                       build_function_type (void_type_node, endlink),
+                       0, NOT_BUILT_IN, NULL_PTR);
+  /* Mark soft_nullpointer_node as a `noreturn' function with side
+     effects.  */
+  TREE_THIS_VOLATILE (soft_nullpointer_node) = 1;
+  TREE_SIDE_EFFECTS (soft_nullpointer_node) = 1;
+
   t = tree_cons (NULL_TREE, class_ptr_type,
                 tree_cons (NULL_TREE, object_ptr_type_node, endlink));
   soft_checkcast_node
@@ -803,7 +767,7 @@ init_decl_processing ()
                 tree_cons (NULL_TREE, class_ptr_type, endlink));
   soft_instanceof_node
     = builtin_function ("_Jv_IsInstanceOf",
-                       build_function_type (promoted_boolean_type_node, t),
+                       build_function_type (boolean_type_node, t),
                        0, NOT_BUILT_IN, NULL_PTR);
   t = tree_cons (NULL_TREE, object_ptr_type_node,
                 tree_cons (NULL_TREE, object_ptr_type_node, endlink));
@@ -813,11 +777,29 @@ init_decl_processing ()
                        0, NOT_BUILT_IN, NULL_PTR);
   t = tree_cons (NULL_TREE, ptr_type_node,
                 tree_cons (NULL_TREE, ptr_type_node,
-                           tree_cons (NULL_TREE, ptr_type_node, endlink)));
+                           tree_cons (NULL_TREE, int_type_node, endlink)));
   soft_lookupinterfacemethod_node 
-    = builtin_function ("_Jv_LookupInterfaceMethod",
+    = builtin_function ("_Jv_LookupInterfaceMethodIdx",
+                       build_function_type (ptr_type_node, t),
+                       0, NOT_BUILT_IN, NULL_PTR);
+
+  t = tree_cons (NULL_TREE, object_ptr_type_node,
+                tree_cons (NULL_TREE, ptr_type_node,
+                           tree_cons (NULL_TREE, ptr_type_node, endlink)));
+  soft_lookupjnimethod_node
+    = builtin_function ("_Jv_LookupJNIMethod",
+                       build_function_type (ptr_type_node, t),
+                       0, NOT_BUILT_IN, NULL_PTR);
+  t = tree_cons (NULL_TREE, ptr_type_node, endlink);
+  soft_getjnienvnewframe_node
+    = builtin_function ("_Jv_GetJNIEnvNewFrame",
+                       build_function_type (ptr_type_node, t),
+                       0, NOT_BUILT_IN, NULL_PTR);
+  soft_jnipopsystemframe_node
+    = builtin_function ("_Jv_JNI_PopSystemFrame",
                        build_function_type (ptr_type_node, t),
                        0, NOT_BUILT_IN, NULL_PTR);
+
   t = tree_cons (NULL_TREE, double_type_node,
                 tree_cons (NULL_TREE, double_type_node, endlink));
   soft_fmod_node
@@ -864,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);
 }
 
 
@@ -958,8 +951,9 @@ pushdecl (x)
   register tree t;
   register tree name = DECL_NAME (x);
   register struct binding_level *b = current_binding_level;
-
-  DECL_CONTEXT (x) = current_function_decl;
+  
+  if (TREE_CODE (x) != TYPE_DECL)
+    DECL_CONTEXT (x) = current_function_decl;
   if (name)
     {
       const char *file;
@@ -1068,6 +1062,7 @@ pushdecl (x)
 
   return x;
 }
+
 void
 pushdecl_force_head (x)
      tree x;
@@ -1111,8 +1106,7 @@ getdecls ()
 
 /* Create a new `struct binding_level'.  */
 
-static
-struct binding_level *
+static struct binding_level *
 make_binding_level ()
 {
   /* NOSTRICT */
@@ -1330,7 +1324,7 @@ poplevel (keep, reverse, functionbody)
              define_label (input_filename, lineno,
                            DECL_NAME (label));
            }
-         else if (warn_unused && !TREE_USED (label))
+         else if (warn_unused[UNUSED_LABEL] && !TREE_USED (label))
            warning_with_decl (label, "label `%s' defined but not used");
          IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
 
@@ -1443,7 +1437,6 @@ maybe_poplevels (pc)
 
   while (current_binding_level->end_pc <= pc)
     {
-      tree decls = getdecls ();        
       expand_end_bindings (getdecls (), 1, 0);
       maybe_end_try (current_binding_level->start_pc, pc);
       poplevel (1, 0, 0);
@@ -1462,7 +1455,6 @@ force_poplevels (start_pc)
 {
   while (current_binding_level->start_pc > start_pc)
     {
-      tree decls = getdecls ();        
       if (pedantic && current_binding_level->start_pc > start_pc)
        warning_with_decl (current_function_decl, 
                           "In %s: overlapped variable and exception ranges at %d",
@@ -1562,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
@@ -1624,6 +1616,35 @@ build_result_decl (fndecl)
   return (DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, restype));
 }
 
+/* Called for every element in DECL_FUNCTION_INIT_TEST_TABLE in order
+   to emit initialization code for each test flag.  */
+
+static boolean
+emit_init_test_initialization (entry, key)
+  struct hash_entry *entry;
+  hash_table_key key ATTRIBUTE_UNUSED;
+{
+  struct init_test_hash_entry *ite = (struct init_test_hash_entry *) entry;
+  tree klass = build_class_ref ((tree) entry->key);
+  expand_decl (ite->init_test_decl);
+
+  /* We initialize the class init check variable by looking at the
+     `state' field of the class to see if it is already initialized.
+     This makes things a bit faster if the class is already
+     initialized, which should be the common case.  */
+  expand_expr_stmt
+    (build (MODIFY_EXPR, boolean_type_node, 
+           ite->init_test_decl,
+           build (GE_EXPR, boolean_type_node,
+                  build (COMPONENT_REF, byte_type_node,
+                         build1 (INDIRECT_REF, class_type_node, klass),
+                         lookup_field (&class_type_node,
+                                       get_identifier ("state"))),
+                  build_int_2 (JV_STATE_DONE, 0))));
+
+  return true;
+}
+
 void
 complete_start_java_method (fndecl)
   tree fndecl;
@@ -1635,6 +1656,11 @@ complete_start_java_method (fndecl)
 
       /* Set up parameters and prepare for return, for the function.  */
       expand_function_start (fndecl, 0);
+
+      /* Emit initialization code for test flags.  */
+      if (! always_initialize_class_p)
+       hash_traverse (&DECL_FUNCTION_INIT_TEST_TABLE (fndecl),
+                      emit_init_test_initialization, 0);
     }
 
   /* Allocate further tree nodes temporarily during compilation
@@ -1651,6 +1677,7 @@ complete_start_java_method (fndecl)
 
   if (METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)
       && ! flag_emit_class_files
+      && ! DECL_CLINIT_P (fndecl)
       && ! CLASS_INTERFACE (TYPE_NAME (current_class)))
     {
       tree clas = DECL_CONTEXT (fndecl);
@@ -1674,7 +1701,7 @@ complete_start_java_method (fndecl)
 
   if (METHOD_SYNCHRONIZED (fndecl) && ! flag_emit_class_files)
     {
-      /* Warp function body with a monitorenter plus monitorexit cleanup. */
+      /* Wrap function body with a monitorenter plus monitorexit cleanup. */
       tree enter, exit, lock;
       if (METHOD_STATIC (fndecl))
        lock = build_class_ref (DECL_CONTEXT (fndecl));
@@ -1797,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);
+       }
+    }
+}