OSDN Git Service

2010-09-18 Kai Tietz <kai.tietz@onevision.com>
[pf3gnuchains/gcc-fork.git] / gcc / java / class.c
index f346ad4..ece261b 100644 (file)
@@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 #include "java-tree.h"
 #include "jcf.h"
 #include "obstack.h"
+#include "diagnostic-core.h"
 #include "toplev.h"
 #include "output.h"
 #include "parse.h"
@@ -382,6 +383,12 @@ make_class (void)
      loading works.  */
   TYPE_BINFO (type) = make_tree_binfo (0);
   MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC (type);
+  TYPE_CATCH_CLASSES (type) = NULL;
+  /* Push a dummy entry; we can't call make_catch_class_record here
+     because other infrastructure may not be set up yet.  We'll come
+     back and fill it in later once said infrastructure is
+     initialized.  */
+  CONSTRUCTOR_APPEND_ELT (TYPE_CATCH_CLASSES (type), NULL_TREE, NULL_TREE);
 
   return type;
 }
@@ -763,20 +770,19 @@ add_method_1 (tree this_class, int access_flags, tree name, tree function_type)
   DECL_CONTEXT (fndecl) = this_class;
 
   DECL_LANG_SPECIFIC (fndecl)
-    = GGC_CNEW (struct lang_decl);
+    = ggc_alloc_cleared_lang_decl(sizeof (struct lang_decl));
   DECL_LANG_SPECIFIC (fndecl)->desc = LANG_DECL_FUNC;
 
   /* Initialize the static initializer test table.  */
-  
-  DECL_FUNCTION_INIT_TEST_TABLE (fndecl) = 
-    java_treetreehash_create (10, 1);
+
+  DECL_FUNCTION_INIT_TEST_TABLE (fndecl) = java_treetreehash_create (10);
 
   /* Initialize the initialized (static) class table. */
   if (access_flags & ACC_STATIC)
     DECL_FUNCTION_INITIALIZED_CLASS_TABLE (fndecl) =
       htab_create_ggc (50, htab_hash_pointer, htab_eq_pointer, NULL);
 
-  TREE_CHAIN (fndecl) = TYPE_METHODS (this_class);
+  DECL_CHAIN (fndecl) = TYPE_METHODS (this_class);
   TYPE_METHODS (this_class) = fndecl;
 
   /* If pointers to member functions use the least significant bit to
@@ -847,7 +853,7 @@ add_field (tree klass, tree name, tree field_type, int flags)
   tree field;
   field = build_decl (input_location,
                      is_static ? VAR_DECL : FIELD_DECL, name, field_type);
-  TREE_CHAIN (field) = TYPE_FIELDS (klass);
+  DECL_CHAIN (field) = TYPE_FIELDS (klass);
   TYPE_FIELDS (klass) = field;
   DECL_CONTEXT (field) = klass;
   MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field);
@@ -977,6 +983,7 @@ build_utf8_ref (tree name)
   TREE_READONLY (decl) = 1;
   TREE_THIS_VOLATILE (decl) = 0;
   DECL_INITIAL (decl) = cinit;
+  DECL_USER_ALIGN (decl) = 1;
 
   if (HAVE_GAS_SHF_MERGE)
     {
@@ -1448,20 +1455,21 @@ make_field_value (tree fdecl)
 
   {
     tree field_address = integer_zero_node;
+    tree index, value;
     if ((DECL_INITIAL (fdecl) || ! flag_indirect_classes) 
        && FIELD_STATIC (fdecl))
       field_address = build_address_of (fdecl);
 
+    index = (FIELD_STATIC (fdecl)
+            ? DECL_CHAIN (TYPE_FIELDS (field_info_union_node))
+            : TYPE_FIELDS (field_info_union_node));
+    value = (FIELD_STATIC (fdecl)
+            ? field_address
+            : byte_position (fdecl));
+
     PUSH_FIELD_VALUE
       (v, "info",
-       build_constructor_from_list (field_info_union_node,
-        build_tree_list
-          ((FIELD_STATIC (fdecl)
-            ? TREE_CHAIN (TYPE_FIELDS (field_info_union_node))
-            : TYPE_FIELDS (field_info_union_node)),
-           (FIELD_STATIC (fdecl)
-            ? field_address
-            : byte_position (fdecl)))));
+       build_constructor_single (field_info_union_node, index, value));
   }
 
   FINISH_RECORD_CONSTRUCTOR (finit, v, field_type_node);
@@ -1519,26 +1527,35 @@ make_method_value (tree mdecl)
   {
     /* Compute the `throws' information for the method.  */
     tree table = null_pointer_node;
-    if (DECL_FUNCTION_THROWS (mdecl) != NULL)
+
+    if (!VEC_empty (tree, DECL_FUNCTION_THROWS (mdecl)))
       {
        int length = 1 + VEC_length (tree, DECL_FUNCTION_THROWS (mdecl));
        tree t, type, array;
        char buf[60];
-        unsigned ix;
+       VEC(constructor_elt,gc) *v = NULL;
+       int idx = length - 1;
+       unsigned ix;
+       constructor_elt *e;
+
+       v = VEC_alloc (constructor_elt, gc, length);
+       VEC_safe_grow_cleared (constructor_elt, gc, v, length);
 
-       table = tree_cons (NULL_TREE, table, NULL_TREE);
-       for (ix = 0;
-            VEC_iterate (tree, DECL_FUNCTION_THROWS (mdecl), ix, t);
-            ix++)
+       e = VEC_index (constructor_elt, v, idx--);
+       e->value = null_pointer_node;
+
+       FOR_EACH_VEC_ELT (tree, DECL_FUNCTION_THROWS (mdecl), ix, t)
          {
            tree sig = DECL_NAME (TYPE_NAME (t));
            tree utf8
              = build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (sig),
                                                    IDENTIFIER_LENGTH (sig)));
-           table = tree_cons (NULL_TREE, utf8, table);
+           e = VEC_index (constructor_elt, v, idx--);
+           e->value = utf8;
          }
+       gcc_assert (idx == -1);
        type = build_prim_array_type (ptr_type_node, length);
-       table = build_constructor_from_list (type, table);
+       table = build_constructor (type, v);
        /* Compute something unique enough.  */
        sprintf (buf, "_methods%d", method_name_count++);
        array = build_decl (input_location,
@@ -1581,7 +1598,7 @@ get_dispatch_vector (tree type)
        }
 
       for (method = TYPE_METHODS (type);  method != NULL_TREE;
-          method = TREE_CHAIN (method))
+          method = DECL_CHAIN (method))
        {
          tree method_index = get_method_index (method);
          if (method_index != NULL_TREE
@@ -1599,11 +1616,22 @@ get_dispatch_table (tree type, tree this_class_addr)
   int abstract_p = CLASS_ABSTRACT (TYPE_NAME (type));
   tree vtable = get_dispatch_vector (type);
   int i, j;
-  tree list = NULL_TREE;
   int nvirtuals = TREE_VEC_LENGTH (vtable);
   int arraysize;
   tree gc_descr;
+  VEC(constructor_elt,gc) *v = NULL;
+  constructor_elt *e;
+  tree arraytype;
 
+  arraysize = (TARGET_VTABLE_USES_DESCRIPTORS? nvirtuals + 1 : nvirtuals + 2);
+  if (TARGET_VTABLE_USES_DESCRIPTORS)
+    arraysize *= TARGET_VTABLE_USES_DESCRIPTORS;
+  arraysize += 2;
+
+  VEC_safe_grow_cleared (constructor_elt, gc, v, arraysize);
+  e = VEC_index (constructor_elt, v, arraysize - 1);
+
+#define CONSTRUCTOR_PREPEND_VALUE(E, V) E->value = V, E--
   for (i = nvirtuals;  --i >= 0; )
     {
       tree method = TREE_VEC_ELT (vtable, i);
@@ -1615,9 +1643,9 @@ get_dispatch_table (tree type, tree this_class_addr)
 
          if (TARGET_VTABLE_USES_DESCRIPTORS)
            for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
-             list = tree_cons (NULL_TREE, null_pointer_node, list);
+             CONSTRUCTOR_PREPEND_VALUE (e, null_pointer_node);
          else
-           list = tree_cons (NULL_TREE, null_pointer_node, list);
+           CONSTRUCTOR_PREPEND_VALUE (e, null_pointer_node);
        }
       else
        {
@@ -1627,13 +1655,13 @@ get_dispatch_table (tree type, tree this_class_addr)
                tree fdesc = build2 (FDESC_EXPR, nativecode_ptr_type_node, 
                                     method, build_int_cst (NULL_TREE, j));
                TREE_CONSTANT (fdesc) = 1;
-               list = tree_cons (NULL_TREE, fdesc, list);
+               CONSTRUCTOR_PREPEND_VALUE (e, fdesc);
              }
          else
-           list = tree_cons (NULL_TREE,
-                             build1 (ADDR_EXPR, nativecode_ptr_type_node,
-                                     method),
-                             list);
+           CONSTRUCTOR_PREPEND_VALUE (e,
+                                      build1 (ADDR_EXPR,
+                                              nativecode_ptr_type_node,
+                                              method));
        }
     }
 
@@ -1646,23 +1674,21 @@ get_dispatch_table (tree type, tree this_class_addr)
      pointer, and subsequent words (usually one) contain the GC descriptor.
      In all other cases, we reserve two extra vtable slots. */
   gc_descr =  get_boehm_type_descriptor (type);
-  list = tree_cons (NULL_TREE, gc_descr, list);
+  CONSTRUCTOR_PREPEND_VALUE (e, gc_descr);
   for (j = 1; j < TARGET_VTABLE_USES_DESCRIPTORS-1; ++j)
-    list = tree_cons (NULL_TREE, gc_descr, list);
-  list = tree_cons (NULL_TREE, this_class_addr, list);
+    CONSTRUCTOR_PREPEND_VALUE (e, gc_descr);
+  CONSTRUCTOR_PREPEND_VALUE (e, this_class_addr);
 
   /** Pointer to type_info object (to be implemented), according to g++ ABI. */
-  list = tree_cons (NULL_TREE, null_pointer_node, list);
+  CONSTRUCTOR_PREPEND_VALUE (e, null_pointer_node);
   /** Offset to start of whole object.  Always (ptrdiff_t)0 for Java. */
-  list = tree_cons (integer_zero_node, null_pointer_node, list);
+  gcc_assert (e == VEC_address (constructor_elt, v));
+  e->index = integer_zero_node;
+  e->value = null_pointer_node;
+#undef CONSTRUCTOR_PREPEND_VALUE
 
-  arraysize = (TARGET_VTABLE_USES_DESCRIPTORS? nvirtuals + 1 : nvirtuals + 2);
-  if (TARGET_VTABLE_USES_DESCRIPTORS)
-    arraysize *= TARGET_VTABLE_USES_DESCRIPTORS;
-  arraysize += 2;
-  return build_constructor_from_list
-         (build_prim_array_type (nativecode_ptr_type_node,
-                                 arraysize), list);
+  arraytype = build_prim_array_type (nativecode_ptr_type_node, arraysize);
+  return build_constructor (arraytype, v);
 }
 
 
@@ -1746,14 +1772,11 @@ make_class_data (tree type)
 {
   tree decl, cons, temp;
   tree field, fields_decl;
-  tree static_fields = NULL_TREE;
-  tree instance_fields = NULL_TREE;
   HOST_WIDE_INT static_field_count = 0;
   HOST_WIDE_INT instance_field_count = 0;
   HOST_WIDE_INT field_count;
   tree field_array_type;
   tree method;
-  tree methods = NULL_TREE;
   tree dtable_decl = NULL_TREE;
   HOST_WIDE_INT method_count = 0;
   tree method_array_type;
@@ -1774,6 +1797,9 @@ make_class_data (tree type)
   tree first_real_field;
   VEC(constructor_elt,gc) *v1 = NULL, *v2 = NULL;
   tree reflection_data;
+  VEC(constructor_elt,gc) *static_fields = NULL;
+  VEC(constructor_elt,gc) *instance_fields = NULL;
+  VEC(constructor_elt,gc) *methods = NULL;
 
   this_class_addr = build_static_class_ref (type);
   decl = TREE_OPERAND (this_class_addr, 0);
@@ -1815,13 +1841,13 @@ make_class_data (tree type)
   /* Build Field array. */
   field = TYPE_FIELDS (type);
   while (field && DECL_ARTIFICIAL (field))
-    field = TREE_CHAIN (field);  /* Skip dummy fields.  */
+    field = DECL_CHAIN (field);  /* Skip dummy fields.  */
   if (field && DECL_NAME (field) == NULL_TREE)
-    field = TREE_CHAIN (field);  /* Skip dummy field for inherited data. */
+    field = DECL_CHAIN (field);  /* Skip dummy field for inherited data. */
   first_real_field = field;
 
   /* First count static and instance fields.  */
-  for ( ; field != NULL_TREE; field = TREE_CHAIN (field))
+  for ( ; field != NULL_TREE; field = DECL_CHAIN (field))
     {
       if (! DECL_ARTIFICIAL (field))
        {
@@ -1850,7 +1876,7 @@ make_class_data (tree type)
 
     for (i = 0, field = first_real_field; 
         field != NULL_TREE; 
-        field = TREE_CHAIN (field), i++)
+        field = DECL_CHAIN (field), i++)
     {
       if (! DECL_ARTIFICIAL (field))
        {
@@ -1867,7 +1893,7 @@ make_class_data (tree type)
   }
 
   for (field = first_real_field; field != NULL_TREE; 
-       field = TREE_CHAIN (field))
+       field = DECL_CHAIN (field))
     {
       if (! DECL_ARTIFICIAL (field))
        {
@@ -1877,7 +1903,7 @@ make_class_data (tree type)
                  as it is used in the creation of the field itself. */
               tree init = make_field_value (field);
              tree initial = DECL_INITIAL (field);
-             static_fields = tree_cons (NULL_TREE, init, static_fields);
+              CONSTRUCTOR_APPEND_ELT (static_fields, NULL_TREE, init);
              /* If the initial value is a string constant,
                 prevent output_constant from trying to assemble the value. */
              if (initial != NULL_TREE
@@ -1889,22 +1915,25 @@ make_class_data (tree type)
          else if (uses_jv_markobj || !flag_reduced_reflection)
            {
               tree init = make_field_value (field);
-             instance_fields = tree_cons (NULL_TREE, init, instance_fields);
+              CONSTRUCTOR_APPEND_ELT (instance_fields, NULL_TREE, init);
            }
        }
     }
 
+  gcc_assert (static_field_count
+              == (int) VEC_length (constructor_elt, static_fields));
+  gcc_assert (instance_field_count
+              == (int) VEC_length (constructor_elt, instance_fields));
+
   if (field_count > 0)
     {
-      static_fields = nreverse (static_fields);
-      instance_fields = nreverse (instance_fields);
-      static_fields = chainon (static_fields, instance_fields);
+      VEC_safe_splice (constructor_elt, gc, static_fields, instance_fields);
       field_array_type = build_prim_array_type (field_type_node, field_count);
       fields_decl = build_decl (input_location,
                                VAR_DECL, mangled_classname ("_FL_", type),
                                field_array_type);
-      DECL_INITIAL (fields_decl) = build_constructor_from_list
-                                   (field_array_type, static_fields);
+      DECL_INITIAL (fields_decl)
+        = build_constructor (field_array_type, static_fields);
       TREE_STATIC (fields_decl) = 1;
       DECL_ARTIFICIAL (fields_decl) = 1;
       DECL_IGNORED_P (fields_decl) = 1;
@@ -1915,7 +1944,7 @@ make_class_data (tree type)
 
   /* Build Method array. */
   for (method = TYPE_METHODS (type);
-       method != NULL_TREE; method = TREE_CHAIN (method))
+       method != NULL_TREE; method = DECL_CHAIN (method))
     {
       tree init;
       if (METHOD_PRIVATE (method)
@@ -1953,15 +1982,14 @@ make_class_data (tree type)
         {
           init = make_method_value (method);
           method_count++;
-          methods = tree_cons (NULL_TREE, init, methods);
+          CONSTRUCTOR_APPEND_ELT (methods, NULL_TREE, init);
         }
     }
   method_array_type = build_prim_array_type (method_type_node, method_count);
   methods_decl = build_decl (input_location,
                             VAR_DECL, mangled_classname ("_MT_", type),
                             method_array_type);
-  DECL_INITIAL (methods_decl) = build_constructor_from_list
-                                (method_array_type, nreverse (methods));
+  DECL_INITIAL (methods_decl) = build_constructor (method_array_type, methods);
   TREE_STATIC (methods_decl) = 1;
   DECL_ARTIFICIAL (methods_decl) = 1;
   DECL_IGNORED_P (methods_decl) = 1;
@@ -1999,16 +2027,17 @@ make_class_data (tree type)
   
   if (interface_len > 0)
     {
-      tree init = NULL_TREE;
       int i;
       tree interface_array_type, idecl;
+      VEC(constructor_elt,gc) *init = VEC_alloc (constructor_elt, gc,
+                                                interface_len);
       interface_array_type
        = build_prim_array_type (class_ptr_type, interface_len);
       idecl = build_decl (input_location,
                          VAR_DECL, mangled_classname ("_IF_", type),
                          interface_array_type);
       
-      for (i = interface_len;  i > 0; i--)
+      for (i = 1; i <= interface_len; i++)
        {
          tree child = BINFO_BASE_BINFO (TYPE_BINFO (type), i);
          tree iclass = BINFO_TYPE (child);
@@ -2022,10 +2051,9 @@ make_class_data (tree type)
              int int_index = alloc_class_constant (iclass);
              index = build_int_cst (ptr_type_node, int_index);
            }
-         init = tree_cons (NULL_TREE, index, init); 
+         CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, index);
        }
-      DECL_INITIAL (idecl) = build_constructor_from_list (interface_array_type,
-                                                         init);
+      DECL_INITIAL (idecl) = build_constructor (interface_array_type, init);
       TREE_STATIC (idecl) = 1;
       DECL_ARTIFICIAL (idecl) = 1;
       DECL_IGNORED_P (idecl) = 1;
@@ -2361,7 +2389,7 @@ push_super_field (tree this_class, tree super_class)
   base_decl = build_decl (input_location,
                          FIELD_DECL, NULL_TREE, super_class);
   DECL_IGNORED_P (base_decl) = 1;
-  TREE_CHAIN (base_decl) = TYPE_FIELDS (this_class);
+  DECL_CHAIN (base_decl) = TYPE_FIELDS (this_class);
   TYPE_FIELDS (this_class) = base_decl;
   DECL_SIZE (base_decl) = TYPE_SIZE (super_class);
   DECL_SIZE_UNIT (base_decl) = TYPE_SIZE_UNIT (super_class);
@@ -2521,7 +2549,7 @@ add_miranda_methods (tree base_class, tree search_class)
          will be correct.  This code must match similar layout code in the 
          runtime.  */
       for (method_decl = TYPE_METHODS (elt);
-          method_decl; method_decl = TREE_CHAIN (method_decl))
+          method_decl; method_decl = DECL_CHAIN (method_decl))
        {
          tree sig, override;
 
@@ -2585,7 +2613,7 @@ layout_class_methods (tree this_class)
   TYPE_METHODS (this_class) = nreverse (TYPE_METHODS (this_class));
 
   for (method_decl = TYPE_METHODS (this_class);
-       method_decl; method_decl = TREE_CHAIN (method_decl))
+       method_decl; method_decl = DECL_CHAIN (method_decl))
     dtable_count = layout_class_method (this_class, super_class,
                                        method_decl, dtable_count);
 
@@ -2600,7 +2628,7 @@ get_interface_method_index (tree method, tree interface)
   tree meth;
   int i = 1;
 
-  for (meth = TYPE_METHODS (interface); ; meth = TREE_CHAIN (meth))
+  for (meth = TYPE_METHODS (interface); ; meth = DECL_CHAIN (meth))
     {
       if (meth == method)
        return i;
@@ -2724,28 +2752,24 @@ emit_indirect_register_classes (tree *list_p)
   tree klass, t, register_class_fn;
   int i;
 
-  tree init = NULL_TREE;
   int size = VEC_length (tree, registered_class) * 2 + 1;
+  VEC(constructor_elt,gc) *init = VEC_alloc (constructor_elt, gc, size);
   tree class_array_type
     = build_prim_array_type (ptr_type_node, size);
   tree cdecl = build_decl (input_location,
                           VAR_DECL, get_identifier ("_Jv_CLS"),
                           class_array_type);
   tree reg_class_list;
-  for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
-    {
-      init = tree_cons (NULL_TREE, 
-                       fold_convert (ptr_type_node, 
-                                     build_static_class_ref (klass)), init);
-      init = tree_cons 
-       (NULL_TREE, 
-        fold_convert (ptr_type_node, 
-                      build_address_of (build_classdollar_field (klass))),
-        init);
-    }
-  init = tree_cons (NULL_TREE, integer_zero_node, init); 
-  DECL_INITIAL (cdecl) = build_constructor_from_list (class_array_type,
-                                                     nreverse (init));
+  FOR_EACH_VEC_ELT (tree, registered_class, i, klass)
+    {
+      t = fold_convert (ptr_type_node, build_static_class_ref (klass));
+      CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, t);
+      t = fold_convert (ptr_type_node,
+                        build_address_of (build_classdollar_field (klass)));
+      CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, t);
+    }
+  CONSTRUCTOR_APPEND_ELT (init, NULL_TREE, integer_zero_node);
+  DECL_INITIAL (cdecl) = build_constructor (class_array_type, init);
   TREE_CONSTANT (DECL_INITIAL (cdecl)) = 1;
   TREE_STATIC (cdecl) = 1;
   DECL_ARTIFICIAL (cdecl) = 1;
@@ -2808,7 +2832,7 @@ emit_register_classes (tree *list_p)
 #endif
       assemble_align (POINTER_SIZE);
 
-      for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
+      FOR_EACH_VEC_ELT (tree, registered_class, i, klass)
        {
          t = build_fold_addr_expr (klass);
          output_constant (t, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE);
@@ -2826,7 +2850,7 @@ emit_register_classes (tree *list_p)
       DECL_EXTERNAL (t) = 1;
       register_class_fn = t;
 
-      for (i = 0; VEC_iterate (tree, registered_class, i, klass); ++i)
+      FOR_EACH_VEC_ELT (tree, registered_class, i, klass)
        {
          t = build_fold_addr_expr (klass);
          t = build_call_expr (register_class_fn, 1, t);
@@ -2891,10 +2915,10 @@ emit_symbol_table (tree name, tree the_table,
                    tree the_syms_decl, tree the_array_element_type,
                   int element_size)
 {
-  tree table, list, null_symbol;
-  tree table_size, the_array_type;
+  tree table, null_symbol, table_size, the_array_type;
   unsigned index;
   method_entry *e;
+  VEC(constructor_elt,gc) *v = NULL;
   
   /* Only emit a table if this translation unit actually made any
      references via it. */
@@ -2902,21 +2926,17 @@ emit_symbol_table (tree name, tree the_table,
     return the_table;
 
   /* Build a list of _Jv_MethodSymbols for each entry in otable_methods. */
-  list = NULL_TREE;
-  for (index = 0; VEC_iterate (method_entry, decl_table, index, e); index++)
-    list = tree_cons (NULL_TREE,
-                     build_symbol_entry (e->method, e->special),
-                     list);
+  FOR_EACH_VEC_ELT (method_entry, decl_table, index, e)
+    CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
+                           build_symbol_entry (e->method, e->special));
 
   /* Terminate the list with a "null" entry. */
   null_symbol = build_symbol_table_entry (null_pointer_node,
                                           null_pointer_node,
                                           null_pointer_node);
-  list = tree_cons (NULL_TREE, null_symbol, list);
+  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, null_symbol);
 
-  /* Put the list in the right order and make it a constructor. */
-  list = nreverse (list);
-  table = build_constructor_from_list (symbols_array_type, list);  
+  table = build_constructor (symbols_array_type, v);
 
   /* Make it the initial value for otable_syms and emit the decl. */
   DECL_INITIAL (the_syms_decl) = table;
@@ -2961,18 +2981,17 @@ tree
 emit_catch_table (tree this_class)
 {
   tree table, table_size, array_type;
-  TYPE_CATCH_CLASSES (this_class) =
-    tree_cons (NULL,
-              make_catch_class_record (null_pointer_node, null_pointer_node),
-              TYPE_CATCH_CLASSES (this_class));
-  TYPE_CATCH_CLASSES (this_class) = nreverse (TYPE_CATCH_CLASSES (this_class));
-  TYPE_CATCH_CLASSES (this_class) = 
-    tree_cons (NULL,
-              make_catch_class_record (null_pointer_node, null_pointer_node),
-              TYPE_CATCH_CLASSES (this_class));
-  table_size = build_index_type
-    (build_int_cst (NULL_TREE,
-                   list_length (TYPE_CATCH_CLASSES (this_class))));
+  int n_catch_classes;
+  constructor_elt *e;
+  /* Fill in the dummy entry that make_class created.  */
+  e = VEC_index (constructor_elt, TYPE_CATCH_CLASSES (this_class), 0);
+  e->value = make_catch_class_record (null_pointer_node, null_pointer_node);
+  CONSTRUCTOR_APPEND_ELT (TYPE_CATCH_CLASSES (this_class), NULL_TREE,
+                         make_catch_class_record (null_pointer_node,
+                                                  null_pointer_node));
+  n_catch_classes = VEC_length (constructor_elt,
+                               TYPE_CATCH_CLASSES (this_class));
+  table_size = build_index_type (build_int_cst (NULL_TREE, n_catch_classes));
   array_type 
     = build_array_type (TREE_TYPE (TREE_TYPE (TYPE_CTABLE_DECL (this_class))),
                        table_size);
@@ -2980,7 +2999,7 @@ emit_catch_table (tree this_class)
     build_decl (input_location,
                VAR_DECL, DECL_NAME (TYPE_CTABLE_DECL (this_class)), array_type);
   DECL_INITIAL (table) = 
-    build_constructor_from_list (array_type, TYPE_CATCH_CLASSES (this_class));
+    build_constructor (array_type, TYPE_CATCH_CLASSES (this_class));
   TREE_STATIC (table) = 1;
   TREE_READONLY (table) = 1;  
   DECL_IGNORED_P (table) = 1;
@@ -3029,7 +3048,7 @@ add_assertion_table_entry (void **htab_entry, void *ptr)
 {
   tree entry;
   tree code_val, op1_utf8, op2_utf8;
-  tree *list = (tree *) ptr;
+  VEC(constructor_elt,gc) **v = (VEC(constructor_elt,gc) **) ptr;
   type_assertion *as = (type_assertion *) *htab_entry;
 
   code_val = build_int_cst (NULL_TREE, as->assertion_code);
@@ -3046,7 +3065,7 @@ add_assertion_table_entry (void **htab_entry, void *ptr)
 
   entry = build_assertion_table_entry (code_val, op1_utf8, op2_utf8);
   
-  *list = tree_cons (NULL_TREE, entry, *list);
+  CONSTRUCTOR_APPEND_ELT (*v, NULL_TREE, entry);
   return true;
 }
 
@@ -3056,22 +3075,20 @@ static tree
 emit_assertion_table (tree klass)
 {
   tree null_entry, ctor, table_decl;
-  tree list = NULL_TREE;
   htab_t assertions_htab = TYPE_ASSERTIONS (klass);
+  VEC(constructor_elt,gc) *v = NULL;
 
   /* Iterate through the hash table.  */
-  htab_traverse (assertions_htab, add_assertion_table_entry, &list);
+  htab_traverse (assertions_htab, add_assertion_table_entry, &v);
 
   /* Finish with a null entry.  */
   null_entry = build_assertion_table_entry (integer_zero_node,
                                             null_pointer_node,
                                             null_pointer_node);
   
-  list = tree_cons (NULL_TREE, null_entry, list);
+  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, null_entry);
   
-  /* Put the list in the right order and make it a constructor. */
-  list = nreverse (list);
-  ctor = build_constructor_from_list (assertion_table_type, list);
+  ctor = build_constructor (assertion_table_type, v);
 
   table_decl = build_decl (input_location,
                           VAR_DECL, mangled_classname ("_type_assert_", klass),
@@ -3144,7 +3161,7 @@ java_treetreehash_new (htab_t ht, tree t)
   e = htab_find_slot_with_hash (ht, t, hv, INSERT);
   if (*e == NULL)
     {
-      tthe = (struct treetreehash_entry *) (*ht->alloc_f) (1, sizeof (*tthe));
+      tthe = ggc_alloc_cleared_treetreehash_entry ();
       tthe->key = t;
       *e = tthe;
     }
@@ -3154,14 +3171,10 @@ java_treetreehash_new (htab_t ht, tree t)
 }
 
 htab_t
-java_treetreehash_create (size_t size, int gc)
+java_treetreehash_create (size_t size)
 {
-  if (gc)
-    return htab_create_ggc (size, java_treetreehash_hash,
-                           java_treetreehash_compare, NULL);
-  else
-    return htab_create_alloc (size, java_treetreehash_hash,
-                             java_treetreehash_compare, free, xcalloc, free);
+  return htab_create_ggc (size, java_treetreehash_hash,
+                         java_treetreehash_compare, NULL);
 }
 
 /* Break down qualified IDENTIFIER into package and class-name components.