aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/expr.c
diff options
context:
space:
mode:
authorNathan Froyd <froydnj@codesourcery.com>2010-05-24 14:46:54 +0000
committerNathan Froyd <froydnj@gcc.gnu.org>2010-05-24 14:46:54 +0000
commit00f93defed4254cb9303f0a085f0c5b22d164283 (patch)
tree9134fd216e7da2fde6943f343736f7193b111a22 /gcc/java/expr.c
parent1db0429a13b229a2a2ad43ca895786871f0b4834 (diff)
downloadgcc-00f93defed4254cb9303f0a085f0c5b22d164283.zip
gcc-00f93defed4254cb9303f0a085f0c5b22d164283.tar.gz
gcc-00f93defed4254cb9303f0a085f0c5b22d164283.tar.bz2
expr.c (quick_stack): Change type to a VEC.
* expr.c (quick_stack): Change type to a VEC. Update comment. (tree_list_free_list): Delete. (flush_quick_stack): Update for quick_stack type change. (push_value): Likewise. (pop_value): Likewise. From-SVN: r159782
Diffstat (limited to 'gcc/java/expr.c')
-rw-r--r--gcc/java/expr.c63
1 files changed, 18 insertions, 45 deletions
diff --git a/gcc/java/expr.c b/gcc/java/expr.c
index 2cce0ee..0f3cf1a 100644
--- a/gcc/java/expr.c
+++ b/gcc/java/expr.c
@@ -90,8 +90,8 @@ tree dtable_ident = NULL_TREE;
int always_initialize_class_p = 0;
/* We store the stack state in two places:
- Within a basic block, we use the quick_stack, which is a
- pushdown list (TREE_LISTs) of expression nodes.
+ Within a basic block, we use the quick_stack, which is a VEC of expression
+ nodes.
This is the top part of the stack; below that we use find_stack_slot.
At the end of a basic block, the quick_stack must be flushed
to the stack slot array (as handled by find_stack_slot).
@@ -116,10 +116,7 @@ int always_initialize_class_p = 0;
So dup cannot just add an extra element to the quick_stack, but iadd can.
*/
-static GTY(()) tree quick_stack;
-
-/* A free-list of unused permanent TREE_LIST nodes. */
-static GTY((deletable)) tree tree_list_free_list;
+static GTY(()) VEC(tree,gc) *quick_stack;
/* The physical memory page size used in this computer. See
build_field_ref(). */
@@ -215,33 +212,24 @@ static void
flush_quick_stack (void)
{
int stack_index = stack_pointer;
- tree prev, cur, next;
+ unsigned ix;
+ tree t;
- /* First reverse the quick_stack, and count the number of slots it has. */
- for (cur = quick_stack, prev = NULL_TREE; cur != NULL_TREE; cur = next)
- {
- next = TREE_CHAIN (cur);
- TREE_CHAIN (cur) = prev;
- prev = cur;
- stack_index -= 1 + TYPE_IS_WIDE (TREE_TYPE (TREE_VALUE (cur)));
- }
- quick_stack = prev;
+ /* Count the number of slots the quick stack is holding. */
+ for (ix = 0; VEC_iterate(tree, quick_stack, ix, t); ix++)
+ stack_index -= 1 + TYPE_IS_WIDE (TREE_TYPE (t));
- while (quick_stack != NULL_TREE)
+ for (ix = 0; VEC_iterate(tree, quick_stack, ix, t); ix++)
{
- tree decl;
- tree node = quick_stack, type;
- quick_stack = TREE_CHAIN (node);
- TREE_CHAIN (node) = tree_list_free_list;
- tree_list_free_list = node;
- node = TREE_VALUE (node);
- type = TREE_TYPE (node);
+ tree decl, type = TREE_TYPE (t);
decl = find_stack_slot (stack_index, type);
- if (decl != node)
- java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (node), decl, node));
+ if (decl != t)
+ java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (t), decl, t));
stack_index += 1 + TYPE_IS_WIDE (type);
}
+
+ VEC_truncate (tree, quick_stack, 0);
}
/* Push TYPE on the type stack.
@@ -282,16 +270,8 @@ push_value (tree value)
value = convert (type, value);
}
push_type (type);
- if (tree_list_free_list == NULL_TREE)
- quick_stack = tree_cons (NULL_TREE, value, quick_stack);
- else
- {
- tree node = tree_list_free_list;
- tree_list_free_list = TREE_CHAIN (tree_list_free_list);
- TREE_VALUE (node) = value;
- TREE_CHAIN (node) = quick_stack;
- quick_stack = node;
- }
+ VEC_safe_push (tree, gc, quick_stack, value);
+
/* If the value has a side effect, then we need to evaluate it
whether or not the result is used. If the value ends up on the
quick stack and is then popped, this won't happen -- so we flush
@@ -604,15 +584,8 @@ static tree
pop_value (tree type)
{
type = pop_type (type);
- if (quick_stack)
- {
- tree node = quick_stack;
- quick_stack = TREE_CHAIN (quick_stack);
- TREE_CHAIN (node) = tree_list_free_list;
- tree_list_free_list = node;
- node = TREE_VALUE (node);
- return node;
- }
+ if (VEC_length (tree, quick_stack) != 0)
+ return VEC_pop (tree, quick_stack);
else
return find_stack_slot (stack_pointer, promote_type (type));
}