This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH,java] convert DECL_FUNCTION_THROWS to a VEC
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Wed, 26 May 2010 12:07:07 -0700
- Subject: [PATCH,java] convert DECL_FUNCTION_THROWS to a VEC
This patch does just what the subject suggests. Less TREE_LIST bits are
a good thing.
Tested on x86_64-unknown-linux-gnu with the libjava testsuite. No
regressions. OK to commit?
-Nathan
* java-tree.h (struct lang_decl_func): Change type of throws_list
field to a VEC.
* jcf-parse.c (HANDLE_EXCEPTIONS_ATTRIBUTE): Adjust for changed type
of DECL_FUNCTION_THROWS.
* class.c (make_method_value): Likewise.
Index: class.c
===================================================================
--- class.c (revision 159870)
+++ class.c (working copy)
@@ -1519,18 +1519,19 @@ make_method_value (tree mdecl)
{
/* Compute the `throws' information for the method. */
tree table = null_pointer_node;
- if (DECL_FUNCTION_THROWS (mdecl) != NULL_TREE)
+ if (DECL_FUNCTION_THROWS (mdecl) != NULL)
{
- int length = 1 + list_length (DECL_FUNCTION_THROWS (mdecl));
- tree iter, type, array;
+ int length = 1 + VEC_length (tree, DECL_FUNCTION_THROWS (mdecl));
+ tree t, type, array;
char buf[60];
+ unsigned ix;
table = tree_cons (NULL_TREE, table, NULL_TREE);
- for (iter = DECL_FUNCTION_THROWS (mdecl);
- iter != NULL_TREE;
- iter = TREE_CHAIN (iter))
+ for (ix = 0;
+ VEC_iterate (tree, DECL_FUNCTION_THROWS (mdecl), ix, t);
+ ix++)
{
- tree sig = DECL_NAME (TYPE_NAME (TREE_VALUE (iter)));
+ tree sig = DECL_NAME (TYPE_NAME (t));
tree utf8
= build_utf8_ref (unmangle_classname (IDENTIFIER_POINTER (sig),
IDENTIFIER_LENGTH (sig)));
Index: jcf-parse.c
===================================================================
--- jcf-parse.c (revision 159870)
+++ jcf-parse.c (working copy)
@@ -936,13 +936,14 @@ handle_signature_attribute (int member_i
#define HANDLE_EXCEPTIONS_ATTRIBUTE(COUNT) \
{ \
int n = COUNT; \
- tree list = DECL_FUNCTION_THROWS (current_method); \
+ VEC (tree,gc) *v = VEC_alloc (tree, gc, n); \
+ gcc_assert (DECL_FUNCTION_THROWS (current_method) == NULL); \
while (--n >= 0) \
{ \
tree thrown_class = get_class_constant (jcf, JCF_readu2 (jcf)); \
- list = tree_cons (NULL_TREE, thrown_class, list); \
+ VEC_quick_push (tree, v, thrown_class); \
} \
- DECL_FUNCTION_THROWS (current_method) = nreverse (list); \
+ DECL_FUNCTION_THROWS (current_method) = v; \
}
#define HANDLE_DEPRECATED_ATTRIBUTE() handle_deprecated ()
Index: ChangeLog
===================================================================
Index: java-tree.h
===================================================================
--- java-tree.h (revision 159870)
+++ java-tree.h (working copy)
@@ -776,7 +776,7 @@ struct GTY(()) lang_decl_func {
int max_stack;
int arg_slot_count;
source_location last_line; /* End line number for a function decl */
- tree throws_list; /* Exception specified by `throws' */
+ VEC(tree,gc) *throws_list; /* Exception specified by `throws' */
tree exc_obj; /* Decl holding the exception object. */
/* Class initialization test variables */