diff options
Diffstat (limited to 'gcc/java')
-rw-r--r-- | gcc/java/ChangeLog | 46 | ||||
-rw-r--r-- | gcc/java/boehm.c | 5 | ||||
-rw-r--r-- | gcc/java/builtins.c | 12 | ||||
-rw-r--r-- | gcc/java/class.c | 204 | ||||
-rw-r--r-- | gcc/java/constants.c | 52 | ||||
-rw-r--r-- | gcc/java/decl.c | 37 | ||||
-rw-r--r-- | gcc/java/except.c | 1 | ||||
-rw-r--r-- | gcc/java/expr.c | 13 | ||||
-rw-r--r-- | gcc/java/java-tree.h | 6 | ||||
-rw-r--r-- | gcc/java/jcf-parse.c | 3 | ||||
-rw-r--r-- | gcc/java/mangle.c | 1 | ||||
-rw-r--r-- | gcc/java/mangle_name.c | 1 | ||||
-rw-r--r-- | gcc/java/resource.c | 1 | ||||
-rw-r--r-- | gcc/java/typeck.c | 9 | ||||
-rw-r--r-- | gcc/java/verify-glue.c | 3 |
15 files changed, 238 insertions, 156 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index e7589638f54..372739ff5a7 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,49 @@ +2010-07-15 Nathan Froyd <froydnj@codesourcery.com> + + * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. + * boehm.c: Likewise. + * class.c: Likewise. + * decl.c: Likewise. + * expr.c: Likewise. + * jcf-parse.c: Likewise. + * typeck.c: Likewise. + * verify-glue.c: Likewise. + +2010-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org> + + * boehm.c: Include diagnostic-core.h in every file that includes + toplev.h. + * class.c: Likewise. + * constants.c: Likewise. + * decl.c: Likewise. + * except.c: Likewise. + * expr.c: Likewise. + * jcf-parse.c: Likewise. + * mangle.c: Likewise. + * mangle_name.c: Likewise. + * resource.c: Likewise. + * typeck.c: Likewise. + * verify-glue.c: Likewise. + +2010-07-05 Nathan Froyd <froydnj@codesourcery.com> + + PR bootstrap/44825 + * class.c (make_class_data): Cast result of VEC_length calls to int. + +2010-07-05 Nathan Froyd <froydnj@codesourcery.com> + + * constants.c (build_constants_constructor): Use build_constructor + instead of build_constructor_from_list. + * class.c (make_method_value): Likewise. + (get_dispatch_table): Likewise. + (make_class_data): Likewise. + (emit_indirect_register_classes): Likewise. + (emit_symbol_table): Likewise. + (add_assertion_table_entry): Likewise. + (emit_assertion_table): Likewise. + (make_field_value): Use build_constructor_single instead of + build_constructor_from_list. + 2010-06-28 Nathan Froyd <froydnj@codesourcery.com> * java-tree.h (struct lang_type) [catch_classes]: Change type to a diff --git a/gcc/java/boehm.c b/gcc/java/boehm.c index 35ba68d0fb3..2a0690ce51d 100644 --- a/gcc/java/boehm.c +++ b/gcc/java/boehm.c @@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "tree.h" #include "java-tree.h" #include "parse.h" +#include "diagnostic-core.h" #include "toplev.h" static void mark_reference_fields (tree, double_int *, unsigned int, @@ -62,10 +63,10 @@ mark_reference_fields (tree field, mask, ubit, pointer_after_end, all_bits_set, last_set_index, last_view_index); - field = TREE_CHAIN (field); + field = DECL_CHAIN (field); } - for (; field != NULL_TREE; field = TREE_CHAIN (field)) + for (; field != NULL_TREE; field = DECL_CHAIN (field)) { HOST_WIDE_INT offset; HOST_WIDE_INT size_bytes; diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index 74859411758..527c4e6fb9a 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -323,7 +323,8 @@ compareAndSwapInt_builtin (tree method_return_type ATTRIBUTE_UNUSED, tree orig_call) { enum machine_mode mode = TYPE_MODE (int_type_node); - if (sync_compare_and_swap[mode] != CODE_FOR_nothing + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing || flag_use_atomic_builtins) { tree addr, stmt; @@ -344,7 +345,8 @@ compareAndSwapLong_builtin (tree method_return_type ATTRIBUTE_UNUSED, tree orig_call) { enum machine_mode mode = TYPE_MODE (long_type_node); - if (sync_compare_and_swap[mode] != CODE_FOR_nothing + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing || (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (word_mode) && flag_use_atomic_builtins)) /* We don't trust flag_use_atomic_builtins for multi-word @@ -368,7 +370,8 @@ compareAndSwapObject_builtin (tree method_return_type ATTRIBUTE_UNUSED, tree orig_call) { enum machine_mode mode = TYPE_MODE (ptr_type_node); - if (sync_compare_and_swap[mode] != CODE_FOR_nothing + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing || flag_use_atomic_builtins) { tree addr, stmt; @@ -448,7 +451,8 @@ VMSupportsCS8_builtin (tree method_return_type, { enum machine_mode mode = TYPE_MODE (long_type_node); gcc_assert (method_return_type == boolean_type_node); - if (sync_compare_and_swap[mode] != CODE_FOR_nothing) + if (direct_optab_handler (sync_compare_and_swap_optab, mode) + != CODE_FOR_nothing) return boolean_true_node; else return boolean_false_node; diff --git a/gcc/java/class.c b/gcc/java/class.c index 7d90a032a81..78f77ab2d26 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -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" @@ -781,7 +782,7 @@ add_method_1 (tree this_class, int access_flags, tree name, tree function_type) 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 @@ -852,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); @@ -1453,20 +1454,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); @@ -1524,14 +1526,23 @@ 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); + + e = VEC_index (constructor_elt, v, idx--); + e->value = null_pointer_node; - table = tree_cons (NULL_TREE, table, NULL_TREE); for (ix = 0; VEC_iterate (tree, DECL_FUNCTION_THROWS (mdecl), ix, t); ix++) @@ -1540,10 +1551,12 @@ make_method_value (tree mdecl) 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, @@ -1586,7 +1599,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 @@ -1604,11 +1617,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); @@ -1620,9 +1644,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 { @@ -1632,13 +1656,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)); } } @@ -1651,23 +1675,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); } @@ -1751,14 +1773,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; @@ -1779,6 +1798,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); @@ -1820,13 +1842,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)) { @@ -1855,7 +1877,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)) { @@ -1872,7 +1894,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)) { @@ -1882,7 +1904,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 @@ -1894,22 +1916,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; @@ -1920,7 +1945,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) @@ -1958,15 +1983,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; @@ -2004,16 +2028,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); @@ -2027,10 +2052,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; @@ -2366,7 +2390,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); @@ -2526,7 +2550,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; @@ -2590,7 +2614,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); @@ -2605,7 +2629,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; @@ -2729,8 +2753,8 @@ 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, @@ -2739,18 +2763,14 @@ emit_indirect_register_classes (tree *list_p) 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)); + 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; @@ -2896,10 +2916,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. */ @@ -2907,21 +2927,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); + 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; @@ -3033,7 +3049,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); @@ -3050,7 +3066,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; } @@ -3060,22 +3076,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), diff --git a/gcc/java/constants.c b/gcc/java/constants.c index f018a707911..14410d1df18 100644 --- a/gcc/java/constants.c +++ b/gcc/java/constants.c @@ -28,6 +28,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "jcf.h" #include "tree.h" #include "java-tree.h" +#include "diagnostic-core.h" #include "toplev.h" #include "ggc.h" @@ -501,11 +502,23 @@ build_constants_constructor (void) CPool *outgoing_cpool = cpool_for_class (current_class); tree tags_value, data_value; tree cons; - tree tags_list = NULL_TREE; - tree data_list = NULL_TREE; VEC(constructor_elt,gc) *v = NULL; int i; + VEC(constructor_elt,gc) *tags = NULL; + VEC(constructor_elt,gc) *data = NULL; + constructor_elt *t = NULL; + constructor_elt *d = NULL; + if (outgoing_cpool->count > 0) + { + int c = outgoing_cpool->count; + VEC_safe_grow_cleared (constructor_elt, gc, tags, c); + VEC_safe_grow_cleared (constructor_elt, gc, data, c); + t = VEC_index (constructor_elt, tags, c-1); + d = VEC_index (constructor_elt, data, c-1); + } + +#define CONSTRUCTOR_PREPEND_VALUE(E, V) E->value = V, E-- for (i = outgoing_cpool->count; --i > 0; ) switch (outgoing_cpool->tags[i] & ~CONSTANT_LazyFlag) { @@ -530,14 +543,11 @@ build_constants_constructor (void) if (BYTES_BIG_ENDIAN && POINTER_SIZE > 32) temp <<= POINTER_SIZE - 32; - tags_list - = tree_cons (NULL_TREE, get_tag_node (outgoing_cpool->tags[i]), - tags_list); - data_list - = tree_cons (NULL_TREE, - fold_convert (ptr_type_node, - (build_int_cst (NULL_TREE, temp))), - data_list); + CONSTRUCTOR_PREPEND_VALUE (t, get_tag_node (outgoing_cpool->tags[i])); + CONSTRUCTOR_PREPEND_VALUE (d, + fold_convert (ptr_type_node, + (build_int_cst (NULL_TREE, + temp)))); } break; @@ -545,17 +555,15 @@ build_constants_constructor (void) case CONSTANT_String: case CONSTANT_Unicode: case CONSTANT_Utf8: - tags_list - = tree_cons (NULL_TREE, get_tag_node (outgoing_cpool->tags[i]), - tags_list); - data_list - = tree_cons (NULL_TREE, build_utf8_ref (outgoing_cpool->data[i].t), - data_list); + CONSTRUCTOR_PREPEND_VALUE (t, get_tag_node (outgoing_cpool->tags[i])); + CONSTRUCTOR_PREPEND_VALUE (d, build_utf8_ref (outgoing_cpool->data[i].t)); break; default: gcc_assert (false); } +#undef CONSTRUCTOR_PREPEND_VALUE + if (outgoing_cpool->count > 0) { tree data_decl, tags_decl, tags_type; @@ -564,8 +572,10 @@ build_constants_constructor (void) tree tem; /* Add dummy 0'th element of constant pool. */ - tags_list = tree_cons (NULL_TREE, get_tag_node (0), tags_list); - data_list = tree_cons (NULL_TREE, null_pointer_node, data_list); + gcc_assert (t == VEC_address (constructor_elt, tags)); + gcc_assert (d == VEC_address (constructor_elt, data)); + t->value = get_tag_node (0); + d->value = null_pointer_node; /* Change the type of the decl to have the proper array size. ??? Make sure to transition the old type-pointer-to list to this @@ -577,8 +587,7 @@ build_constants_constructor (void) TYPE_POINTER_TO (TREE_TYPE (data_decl)) = NULL_TREE; TREE_TYPE (data_decl) = build_array_type (ptr_type_node, index_type); TYPE_POINTER_TO (TREE_TYPE (data_decl)) = tem; - DECL_INITIAL (data_decl) = build_constructor_from_list - (TREE_TYPE (data_decl), data_list); + DECL_INITIAL (data_decl) = build_constructor (TREE_TYPE (data_decl), data); DECL_SIZE (data_decl) = TYPE_SIZE (TREE_TYPE (data_decl)); DECL_SIZE_UNIT (data_decl) = TYPE_SIZE_UNIT (TREE_TYPE (data_decl)); rest_of_decl_compilation (data_decl, 1, 0); @@ -590,8 +599,7 @@ build_constants_constructor (void) current_class), tags_type); TREE_STATIC (tags_decl) = 1; - DECL_INITIAL (tags_decl) = build_constructor_from_list - (tags_type, tags_list); + DECL_INITIAL (tags_decl) = build_constructor (tags_type, tags); rest_of_decl_compilation (tags_decl, 1, 0); tags_value = build_address_of (tags_decl); } diff --git a/gcc/java/decl.c b/gcc/java/decl.c index d3e671067a6..36a2c2916e0 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -29,6 +29,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "system.h" #include "coretypes.h" #include "tree.h" +#include "diagnostic-core.h" #include "toplev.h" #include "flags.h" #include "java-tree.h" @@ -824,7 +825,7 @@ java_init_decl_processing (void) if (! flag_hash_synchronization) 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)) + for (t = TYPE_FIELDS (object_type_node); t != NULL_TREE; t = DECL_CHAIN (t)) FIELD_PRIVATE (t) = 1; FINISH_RECORD (object_type_node); @@ -906,7 +907,7 @@ java_init_decl_processing (void) 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)) + for (t = TYPE_FIELDS (class_type_node); t != NULL_TREE; t = DECL_CHAIN (t)) FIELD_PRIVATE (t) = 1; push_super_field (class_type_node, object_type_node); @@ -1214,7 +1215,7 @@ lookup_name_current_level (tree name) if (IDENTIFIER_LOCAL_VALUE (name) == 0) return 0; - for (t = current_binding_level->names; t; t = TREE_CHAIN (t)) + for (t = current_binding_level->names; t; t = DECL_CHAIN (t)) if (DECL_NAME (t) == name) break; @@ -1283,7 +1284,7 @@ pushdecl (tree x) /* Put decls on list in reverse order. We will reverse them later if necessary. */ - TREE_CHAIN (x) = b->names; + DECL_CHAIN (x) = b->names; b->names = x; return x; @@ -1434,7 +1435,7 @@ poplevel (int keep, int reverse, int functionbody) else decls = current_binding_level->names; - for (decl = decls; decl; decl = TREE_CHAIN (decl)) + for (decl = decls; decl; decl = DECL_CHAIN (decl)) if (TREE_CODE (decl) == VAR_DECL && DECL_LANG_SPECIFIC (decl) != NULL && DECL_LOCAL_SLOT_NUMBER (decl)) @@ -1467,11 +1468,11 @@ poplevel (int keep, int reverse, int functionbody) /* Copy decls from names list, ignoring labels. */ while (decl) { - tree next = TREE_CHAIN (decl); + tree next = DECL_CHAIN (decl); if (TREE_CODE (decl) != LABEL_DECL) { *var = decl; - var = &TREE_CHAIN (decl); + var = &DECL_CHAIN (decl); } decl = next; } @@ -1507,7 +1508,7 @@ poplevel (int keep, int reverse, int functionbody) /* Clear out the meanings of the local variables of this level. */ - for (link = decls; link; link = TREE_CHAIN (link)) + for (link = decls; link; link = DECL_CHAIN (link)) { tree name = DECL_NAME (link); if (name != 0 && IDENTIFIER_LOCAL_VALUE (name) == link) @@ -1603,7 +1604,7 @@ maybe_pushlevels (int pc) while (*ptr != NULL_TREE && DECL_LOCAL_START_PC (*ptr) <= pc && DECL_LOCAL_END_PC (*ptr) == end_pc) - ptr = &TREE_CHAIN (*ptr); + ptr = &DECL_CHAIN (*ptr); pending_local_decls = *ptr; *ptr = NULL_TREE; @@ -1613,7 +1614,7 @@ maybe_pushlevels (int pc) { tree t; end_pc = current_binding_level->end_pc; - for (t = decl; t != NULL_TREE; t = TREE_CHAIN (t)) + for (t = decl; t != NULL_TREE; t = DECL_CHAIN (t)) DECL_LOCAL_END_PC (t) = end_pc; } @@ -1628,7 +1629,7 @@ maybe_pushlevels (int pc) { int index = DECL_LOCAL_SLOT_NUMBER (decl); tree base_decl; - next = TREE_CHAIN (decl); + next = DECL_CHAIN (decl); push_jvm_slot (index, decl); pushdecl (decl); base_decl @@ -1756,8 +1757,8 @@ give_name_to_locals (JCF *jcf) && (DECL_LOCAL_START_PC (*ptr) > start_pc || (DECL_LOCAL_START_PC (*ptr) == start_pc && DECL_LOCAL_END_PC (*ptr) < end_pc))) - ptr = &TREE_CHAIN (*ptr); - TREE_CHAIN (decl) = *ptr; + ptr = &DECL_CHAIN (*ptr); + DECL_CHAIN (decl) = *ptr; *ptr = decl; } } @@ -1766,7 +1767,7 @@ give_name_to_locals (JCF *jcf) /* Fill in default names for the parameters. */ for (parm = DECL_ARGUMENTS (current_function_decl), i = 0; - parm != NULL_TREE; parm = TREE_CHAIN (parm), i++) + parm != NULL_TREE; parm = DECL_CHAIN (parm), i++) { if (DECL_NAME (parm) == NULL_TREE) { @@ -1839,7 +1840,7 @@ start_java_method (tree fndecl) DECL_ARG_TYPE (parm_decl) = parm_type; *ptr = parm_decl; - ptr = &TREE_CHAIN (parm_decl); + ptr = &DECL_CHAIN (parm_decl); /* Add parm_decl to the decl_map. */ push_jvm_slot (i, parm_decl); @@ -1992,7 +1993,7 @@ java_mark_class_local (tree klass) { tree t; - for (t = TYPE_FIELDS (klass); t ; t = TREE_CHAIN (t)) + for (t = TYPE_FIELDS (klass); t ; t = DECL_CHAIN (t)) if (FIELD_STATIC (t)) { if (DECL_EXTERNAL (t)) @@ -2000,7 +2001,7 @@ java_mark_class_local (tree klass) java_mark_decl_local (t); } - for (t = TYPE_METHODS (klass); t ; t = TREE_CHAIN (t)) + for (t = TYPE_METHODS (klass); t ; t = DECL_CHAIN (t)) if (!METHOD_ABSTRACT (t)) { if (METHOD_NATIVE (t) && !flag_jni) @@ -2088,7 +2089,7 @@ java_add_local_var (tree decl) { tree *vars = ¤t_binding_level->names; tree next = *vars; - TREE_CHAIN (decl) = next; + DECL_CHAIN (decl) = next; *vars = decl; DECL_CONTEXT (decl) = current_function_decl; MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl); diff --git a/gcc/java/except.c b/gcc/java/except.c index 0033da30653..2cc03085db4 100644 --- a/gcc/java/except.c +++ b/gcc/java/except.c @@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "java-opcodes.h" #include "jcf.h" #include "java-except.h" +#include "diagnostic-core.h" #include "toplev.h" #include "tree-iterator.h" diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 042ed1b7297..3c987c5fe82 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -35,6 +35,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "jcf.h" #include "java-except.h" #include "parse.h" +#include "diagnostic-core.h" #include "toplev.h" #include "ggc.h" #include "tree-iterator.h" @@ -1633,7 +1634,7 @@ lookup_field (tree *typep, tree name) tree save_field; int i; - for (field = TYPE_FIELDS (*typep); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (*typep); field; field = DECL_CHAIN (field)) if (DECL_NAME (field) == name) return field; @@ -1951,7 +1952,7 @@ attach_init_test_initialization_flags (void **entry, void *ptr) if (TREE_CODE (block) == BIND_EXPR) { tree body = BIND_EXPR_BODY (block); - TREE_CHAIN (ite->value) = BIND_EXPR_VARS (block); + DECL_CHAIN (ite->value) = BIND_EXPR_VARS (block); BIND_EXPR_VARS (block) = ite->value; body = build2 (COMPOUND_EXPR, void_type_node, build1 (DECL_EXPR, void_type_node, ite->value), body); @@ -2238,7 +2239,7 @@ build_known_method_ref (tree method, tree method_type ATTRIBUTE_UNUSED, lookup_field (&class_type_node, methods_ident), NULL_TREE); for (meth = TYPE_METHODS (self_type); - ; meth = TREE_CHAIN (meth)) + ; meth = DECL_CHAIN (meth)) { if (method == meth) break; @@ -2642,7 +2643,7 @@ build_jni_stub (tree method) res_var = build_decl (input_location, VAR_DECL, get_identifier ("res"), TREE_TYPE (TREE_TYPE (method))); DECL_CONTEXT (res_var) = method; - TREE_CHAIN (env_var) = res_var; + DECL_CHAIN (env_var) = res_var; } method_args = DECL_ARGUMENTS (method); @@ -2672,7 +2673,7 @@ build_jni_stub (tree method) /* All the arguments to this method become arguments to the underlying JNI function. If we had to wrap object arguments in a special way, we would do that here. */ - for (tem = method_args; tem != NULL_TREE; tem = TREE_CHAIN (tem)) + for (tem = method_args; tem != NULL_TREE; tem = DECL_CHAIN (tem)) { int arg_bits = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem))); #ifdef PARM_BOUNDARY @@ -3778,7 +3779,7 @@ promote_arguments (void) int i; tree arg; for (arg = DECL_ARGUMENTS (current_function_decl), i = 0; - arg != NULL_TREE; arg = TREE_CHAIN (arg), i++) + arg != NULL_TREE; arg = DECL_CHAIN (arg), i++) { tree arg_type = TREE_TYPE (arg); if (INTEGRAL_TYPE_P (arg_type) diff --git a/gcc/java/java-tree.h b/gcc/java/java-tree.h index ccaa0e34eb7..110eb83e00c 100644 --- a/gcc/java/java-tree.h +++ b/gcc/java/java-tree.h @@ -1461,7 +1461,7 @@ extern tree *type_map; if (TYPE_FIELDS (RTYPE) == NULL_TREE) \ TYPE_FIELDS (RTYPE) = _field; \ else \ - TREE_CHAIN(FIELD) = _field; \ + DECL_CHAIN(FIELD) = _field; \ DECL_CONTEXT (_field) = (RTYPE); \ DECL_ARTIFICIAL (_field) = 1; \ FIELD = _field; } @@ -1485,7 +1485,7 @@ extern tree *type_map; do \ { \ constructor_elt *_elt___ = VEC_last (constructor_elt, V); \ - tree _next___ = TREE_CHAIN (_elt___->index); \ + tree _next___ = DECL_CHAIN (_elt___->index); \ gcc_assert (!DECL_NAME (_elt___->index)); \ _elt___->value = VALUE; \ CONSTRUCTOR_APPEND_ELT (V, _next___, NULL); \ @@ -1499,7 +1499,7 @@ extern tree *type_map; do \ { \ constructor_elt *_elt___ = VEC_last (constructor_elt, V); \ - tree _next___ = TREE_CHAIN (_elt___->index); \ + tree _next___ = DECL_CHAIN (_elt___->index); \ gcc_assert (strcmp (IDENTIFIER_POINTER (DECL_NAME (_elt___->index)), \ NAME) == 0); \ _elt___->value = VALUE; \ diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 37d27b41b43..c27d4b553d8 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -34,6 +34,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "input.h" #include "javaop.h" #include "java-tree.h" +#include "diagnostic-core.h" #include "toplev.h" #include "parse.h" #include "ggc.h" @@ -1570,7 +1571,7 @@ parse_class_file (void) gen_indirect_dispatch_tables (current_class); for (method = TYPE_METHODS (current_class); - method != NULL_TREE; method = TREE_CHAIN (method)) + method != NULL_TREE; method = DECL_CHAIN (method)) { JCF *jcf = current_jcf; diff --git a/gcc/java/mangle.c b/gcc/java/mangle.c index c6a753fa61d..5df5b4ca1b3 100644 --- a/gcc/java/mangle.c +++ b/gcc/java/mangle.c @@ -32,6 +32,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "tree.h" #include "java-tree.h" #include "obstack.h" +#include "diagnostic-core.h" #include "toplev.h" #include "ggc.h" #include "langhooks-def.h" diff --git a/gcc/java/mangle_name.c b/gcc/java/mangle_name.c index 8327d7e86de..8e37b28426f 100644 --- a/gcc/java/mangle_name.c +++ b/gcc/java/mangle_name.c @@ -31,6 +31,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "tree.h" #include "java-tree.h" #include "obstack.h" +#include "diagnostic-core.h" #include "toplev.h" static void append_unicode_mangled_name (const char *, int); diff --git a/gcc/java/resource.c b/gcc/java/resource.c index 56a0a1b04d6..d96d2d8d362 100644 --- a/gcc/java/resource.c +++ b/gcc/java/resource.c @@ -28,6 +28,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "tree.h" #include "java-tree.h" #include "jcf.h" +#include "diagnostic-core.h" #include "toplev.h" #include "output.h" #include "parse.h" diff --git a/gcc/java/typeck.c b/gcc/java/typeck.c index e71b109b7e9..dca14ab5f81 100644 --- a/gcc/java/typeck.c +++ b/gcc/java/typeck.c @@ -33,6 +33,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "java-tree.h" #include "jcf.h" #include "convert.h" +#include "diagnostic-core.h" #include "toplev.h" #include "ggc.h" @@ -210,7 +211,7 @@ java_array_type_length (tree array_type) tree arfld; if (TREE_CODE (array_type) == POINTER_TYPE) array_type = TREE_TYPE (array_type); - arfld = TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (array_type))); + arfld = DECL_CHAIN (DECL_CHAIN (TYPE_FIELDS (array_type))); if (arfld != NULL_TREE) { tree index_type = TYPE_DOMAIN (TREE_TYPE (arfld)); @@ -305,7 +306,7 @@ build_java_array_type (tree element_type, HOST_WIDE_INT length) arfld = build_decl (input_location, FIELD_DECL, get_identifier ("data"), atype); DECL_CONTEXT (arfld) = t; - TREE_CHAIN (fld) = arfld; + DECL_CHAIN (fld) = arfld; DECL_ALIGN (arfld) = TYPE_ALIGN (element_type); /* We could layout_class, but that loads java.lang.Object prematurely. @@ -643,7 +644,7 @@ shallow_find_method (tree searched_class, int flags, tree method_name, { tree method; for (method = TYPE_METHODS (searched_class); - method != NULL_TREE; method = TREE_CHAIN (method)) + method != NULL_TREE; method = DECL_CHAIN (method)) { tree method_sig = (*signature_builder) (TREE_TYPE (method)); if (DECL_NAME (method) == method_name && method_sig == signature) @@ -778,7 +779,7 @@ tree lookup_java_constructor (tree clas, tree method_signature) { tree method = TYPE_METHODS (clas); - for ( ; method != NULL_TREE; method = TREE_CHAIN (method)) + for ( ; method != NULL_TREE; method = DECL_CHAIN (method)) { tree method_sig = build_java_signature (TREE_TYPE (method)); if (DECL_CONSTRUCTOR_P (method) && method_sig == method_signature) diff --git a/gcc/java/verify-glue.c b/gcc/java/verify-glue.c index 77ef45f725e..78d35495478 100644 --- a/gcc/java/verify-glue.c +++ b/gcc/java/verify-glue.c @@ -33,6 +33,7 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */ #include "verify.h" #include "java-tree.h" #include "java-except.h" +#include "diagnostic-core.h" #include "toplev.h" void * @@ -364,7 +365,7 @@ vfy_class_has_field (vfy_jclass klass, vfy_string name, if (DECL_NAME (field) == name && build_java_signature (TREE_TYPE (field)) == signature) return true; - field = TREE_CHAIN (field); + field = DECL_CHAIN (field); } return false; } |