#include "config.h"
#include "system.h"
#include "coretypes.h"
-#include "tm.h"
#include "tree.h"
-#include "real.h"
-#include "rtl.h"
#include "flags.h"
-#include "expr.h"
#include "java-tree.h"
#include "javaop.h"
#include "java-opcodes.h"
#include "jcf.h"
#include "java-except.h"
#include "parse.h"
+#include "diagnostic-core.h"
#include "toplev.h"
-#include "except.h"
-#include "tm_p.h"
#include "ggc.h"
#include "tree-iterator.h"
-#include "gimple.h"
#include "target.h"
static void flush_quick_stack (void);
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).
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(). */
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.
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
if (*as_pp)
return;
- *as_pp = ggc_alloc (sizeof (type_assertion));
+ *as_pp = ggc_alloc_type_assertion ();
**(type_assertion **)as_pp = as;
}
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));
}
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;
char buf[32];
if (pc > highest_label_pc_this_method)
highest_label_pc_this_method = pc;
- ASM_GENERATE_INTERNAL_LABEL(buf, "LJpc=", start_label_pc_this_method + pc);
+ targetm.asm_out.generate_internal_label (buf, "LJpc=",
+ start_label_pc_this_method + pc);
name = get_identifier (buf);
if (IDENTIFIER_LOCAL_VALUE (name))
return IDENTIFIER_LOCAL_VALUE (name);
{
static int l_number = 0;
char buff [32];
- ASM_GENERATE_INTERNAL_LABEL(buff, "LJv", l_number);
+ targetm.asm_out.generate_internal_label (buff, "LJv", l_number);
l_number++;
return get_identifier (buff);
}
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);
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;
reused. */
int
-get_symbol_table_index (tree t, tree special, tree *symbol_table)
+get_symbol_table_index (tree t, tree special,
+ VEC(method_entry,gc) **symbol_table)
{
- int i = 1;
- tree method_list;
+ method_entry *e;
+ unsigned i;
- if (*symbol_table == NULL_TREE)
- {
- *symbol_table = build_tree_list (special, t);
- return 1;
- }
-
- method_list = *symbol_table;
-
- while (1)
- {
- tree value = TREE_VALUE (method_list);
- tree purpose = TREE_PURPOSE (method_list);
- if (value == t && purpose == special)
- return i;
- i++;
- if (TREE_CHAIN (method_list) == NULL_TREE)
- break;
- else
- method_list = TREE_CHAIN (method_list);
- }
+ FOR_EACH_VEC_ELT (method_entry, *symbol_table, i, e)
+ if (t == e->method && special == e->special)
+ goto done;
+
+ e = VEC_safe_push (method_entry, gc, *symbol_table, NULL);
+ e->method = t;
+ e->special = special;
- TREE_CHAIN (method_list) = build_tree_list (special, t);
- return i;
+ done:
+ return i + 1;
}
tree
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);
/* 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
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)