This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[JAVA] Convert java/expr.c from build to buildN
- From: Roger Sayle <roger at eyesopen dot com>
- To: java-patches at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 4 Jul 2004 19:45:21 -0600 (MDT)
- Subject: [JAVA] Convert java/expr.c from build to buildN
The following patch transitions the java front-end's expr.c from
calling "build" to using the new prefered "buildN" interfaces.
expr.c is by far the largest caller of "build", and this patch
starts the process of converting the java/ subdirectory.
There are no functional changes with this patch.
The following patch has been tested on i686-pc-linux-gnu, with a full
"make bootstrap", including java, and regression tested with a top-level
"make -k check" with no new failures.
Ok for mainline?
2004-07-04 Roger Sayle <roger@eyesopen.com>
* expr.c (java_truthvalue_conversion, flush_quick_stack,
java_stack_swap, java_stack_dup, build_java_athrow, build_java_jsr,
build_java_ret, build_java_throw_out_of_bounds_exception,
build_java_array_length_access, java_check_reference,
build_java_arrayaccess, build_java_arraystore_check, build_newarray,
build_anewarray, expand_java_multianewarray, expand_java_arraystore,
expand_java_arrayload, build_java_monitor, expand_java_return,
expand_load_internal, expand_java_NEW, build_get_class,
build_instanceof, expand_java_CHECKCAST, expand_iinc,
build_java_soft_divmod, build_java_binop, build_field_ref,
expand_compare, expand_java_goto, expand_java_switch,
expand_java_add_case, build_class_init, build_known_method_ref,
invoke_build_dtable, build_invokevirtual, build_invokeinterface,
expand_invoke, build_jni_stub, expand_java_field_op,
java_expand_expr, expand_byte_code, STORE_INTERNAL,
force_evaluation_order, emit_init_test_initialization): Convert
calls to "build" into calls to the prefered "buildN" functions.
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/expr.c,v
retrieving revision 1.195
diff -c -3 -p -r1.195 expr.c
*** expr.c 27 Jun 2004 18:16:47 -0000 1.195
--- expr.c 4 Jul 2004 21:50:10 -0000
*************** java_truthvalue_conversion (tree expr)
*** 188,196 ****
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
! return fold (build (COND_EXPR, boolean_type_node, TREE_OPERAND (expr, 0),
! java_truthvalue_conversion (TREE_OPERAND (expr, 1)),
! java_truthvalue_conversion (TREE_OPERAND (expr, 2))));
case NOP_EXPR:
/* If this is widening the argument, we can ignore it. */
--- 188,197 ----
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
! return fold
! (build3 (COND_EXPR, boolean_type_node, TREE_OPERAND (expr, 0),
! java_truthvalue_conversion (TREE_OPERAND (expr, 1)),
! java_truthvalue_conversion (TREE_OPERAND (expr, 2))));
case NOP_EXPR:
/* If this is widening the argument, we can ignore it. */
*************** java_truthvalue_conversion (tree expr)
*** 200,206 ****
/* fall through to default */
default:
! return fold (build (NE_EXPR, boolean_type_node, expr, boolean_false_node));
}
}
--- 201,208 ----
/* fall through to default */
default:
! return fold (build2 (NE_EXPR, boolean_type_node,
! expr, boolean_false_node));
}
}
*************** flush_quick_stack (void)
*** 239,245 ****
decl = find_stack_slot (stack_index, type);
if (decl != node)
! java_add_stmt (build (MODIFY_EXPR, TREE_TYPE (node), decl, node));
stack_index += 1 + TYPE_IS_WIDE (type);
}
}
--- 241,247 ----
decl = find_stack_slot (stack_index, type);
if (decl != node)
! java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (node), decl, node));
stack_index += 1 + TYPE_IS_WIDE (type);
}
}
*************** java_stack_swap (void)
*** 513,525 ****
decl2 = find_stack_slot (stack_pointer - 2, type2);
temp = build_decl (VAR_DECL, NULL_TREE, type1);
java_add_local_var (temp);
! java_add_stmt (build (MODIFY_EXPR, type1, temp, decl1));
! java_add_stmt (build (MODIFY_EXPR, type2,
! find_stack_slot (stack_pointer - 1, type2),
! decl2));
! java_add_stmt (build (MODIFY_EXPR, type1,
! find_stack_slot (stack_pointer - 2, type1),
! temp));
stack_type_map[stack_pointer - 1] = type2;
stack_type_map[stack_pointer - 2] = type1;
}
--- 515,527 ----
decl2 = find_stack_slot (stack_pointer - 2, type2);
temp = build_decl (VAR_DECL, NULL_TREE, type1);
java_add_local_var (temp);
! java_add_stmt (build2 (MODIFY_EXPR, type1, temp, decl1));
! java_add_stmt (build2 (MODIFY_EXPR, type2,
! find_stack_slot (stack_pointer - 1, type2),
! decl2));
! java_add_stmt (build2 (MODIFY_EXPR, type1,
! find_stack_slot (stack_pointer - 2, type1),
! temp));
stack_type_map[stack_pointer - 1] = type2;
stack_type_map[stack_pointer - 2] = type1;
}
*************** java_stack_dup (int size, int offset)
*** 565,571 ****
tree dst_decl = find_stack_slot (dst_index, type);
java_add_stmt
! (build (MODIFY_EXPR, TREE_TYPE (dst_decl), dst_decl, src_decl));
stack_type_map[dst_index] = type;
}
}
--- 567,573 ----
tree dst_decl = find_stack_slot (dst_index, type);
java_add_stmt
! (build2 (MODIFY_EXPR, TREE_TYPE (dst_decl), dst_decl, src_decl));
stack_type_map[dst_index] = type;
}
}
*************** build_java_athrow (tree node)
*** 579,589 ****
{
tree call;
! call = build (CALL_EXPR,
! void_type_node,
! build_address_of (throw_node),
! build_tree_list (NULL_TREE, node),
! NULL_TREE);
TREE_SIDE_EFFECTS (call) = 1;
java_add_stmt (call);
java_stack_pop (stack_pointer);
--- 581,591 ----
{
tree call;
! call = build3 (CALL_EXPR,
! void_type_node,
! build_address_of (throw_node),
! build_tree_list (NULL_TREE, node),
! NULL_TREE);
TREE_SIDE_EFFECTS (call) = 1;
java_add_stmt (call);
java_stack_pop (stack_pointer);
*************** build_java_jsr (int target_pc, int retur
*** 599,605 ****
tree ret_label = fold (build1 (ADDR_EXPR, return_address_type_node, ret));
push_value (ret_label);
flush_quick_stack ();
! java_add_stmt (build (GOTO_EXPR, void_type_node, where));
/* Do not need to emit the label here. We noted the existance of the
label as a jump target in note_instructions; we'll emit the label
--- 601,607 ----
tree ret_label = fold (build1 (ADDR_EXPR, return_address_type_node, ret));
push_value (ret_label);
flush_quick_stack ();
! java_add_stmt (build1 (GOTO_EXPR, void_type_node, where));
/* Do not need to emit the label here. We noted the existance of the
label as a jump target in note_instructions; we'll emit the label
*************** build_java_jsr (int target_pc, int retur
*** 609,615 ****
static void
build_java_ret (tree location)
{
! java_add_stmt (build (GOTO_EXPR, void_type_node, location));
}
/* Implementation of operations on array: new, load, store, length */
--- 611,617 ----
static void
build_java_ret (tree location)
{
! java_add_stmt (build1 (GOTO_EXPR, void_type_node, location));
}
/* Implementation of operations on array: new, load, store, length */
*************** encode_newarray_type (tree type)
*** 662,670 ****
static tree
build_java_throw_out_of_bounds_exception (tree index)
{
! tree node = build (CALL_EXPR, int_type_node,
! build_address_of (soft_badarrayindex_node),
! build_tree_list (NULL_TREE, index), NULL_TREE);
TREE_SIDE_EFFECTS (node) = 1; /* Allows expansion within ANDIF */
return (node);
}
--- 664,672 ----
static tree
build_java_throw_out_of_bounds_exception (tree index)
{
! tree node = build3 (CALL_EXPR, int_type_node,
! build_address_of (soft_badarrayindex_node),
! build_tree_list (NULL_TREE, index), NULL_TREE);
TREE_SIDE_EFFECTS (node) = 1; /* Allows expansion within ANDIF */
return (node);
}
*************** build_java_array_length_access (tree nod
*** 684,692 ****
of type ptr_type_node at this point is `aconst_null; arraylength'
or something equivalent. */
if (type == ptr_type_node)
! return build (CALL_EXPR, int_type_node,
! build_address_of (soft_nullpointer_node),
! NULL_TREE, NULL_TREE);
if (!is_array_type_p (type))
abort ();
--- 686,694 ----
of type ptr_type_node at this point is `aconst_null; arraylength'
or something equivalent. */
if (type == ptr_type_node)
! return build3 (CALL_EXPR, int_type_node,
! build_address_of (soft_nullpointer_node),
! NULL_TREE, NULL_TREE);
if (!is_array_type_p (type))
abort ();
*************** build_java_array_length_access (tree nod
*** 695,705 ****
if (length >= 0)
return build_int_2 (length, 0);
! node = build (COMPONENT_REF, int_type_node,
! build_java_indirect_ref (array_type, node,
! flag_check_references),
! lookup_field (&array_type, get_identifier ("length")),
! NULL_TREE);
IS_ARRAY_LENGTH_ACCESS (node) = 1;
return node;
}
--- 697,707 ----
if (length >= 0)
return build_int_2 (length, 0);
! node = build3 (COMPONENT_REF, int_type_node,
! build_java_indirect_ref (array_type, node,
! flag_check_references),
! lookup_field (&array_type, get_identifier ("length")),
! NULL_TREE);
IS_ARRAY_LENGTH_ACCESS (node) = 1;
return node;
}
*************** java_check_reference (tree expr, int che
*** 714,725 ****
if (!flag_syntax_only && check)
{
expr = save_expr (expr);
! expr = build (COND_EXPR, TREE_TYPE (expr),
! build (EQ_EXPR, boolean_type_node, expr, null_pointer_node),
! build (CALL_EXPR, void_type_node,
! build_address_of (soft_nullpointer_node),
! NULL_TREE, NULL_TREE),
! expr);
}
return expr;
--- 716,728 ----
if (!flag_syntax_only && check)
{
expr = save_expr (expr);
! expr = build3 (COND_EXPR, TREE_TYPE (expr),
! build2 (EQ_EXPR, boolean_type_node,
! expr, null_pointer_node),
! build3 (CALL_EXPR, void_type_node,
! build_address_of (soft_nullpointer_node),
! NULL_TREE, NULL_TREE),
! expr);
}
return expr;
*************** build_java_arrayaccess (tree array, tree
*** 759,771 ****
tree test;
tree len = build_java_array_length_access (array);
TREE_TYPE (len) = unsigned_int_type_node;
! test = fold (build (GE_EXPR, boolean_type_node,
! convert (unsigned_int_type_node, index),
! len));
if (! integer_zerop (test))
{
! throw = build (TRUTH_ANDIF_EXPR, int_type_node, test,
! build_java_throw_out_of_bounds_exception (index));
/* allows expansion within COMPOUND */
TREE_SIDE_EFFECTS( throw ) = 1;
}
--- 762,774 ----
tree test;
tree len = build_java_array_length_access (array);
TREE_TYPE (len) = unsigned_int_type_node;
! test = fold (build2 (GE_EXPR, boolean_type_node,
! convert (unsigned_int_type_node, index),
! len));
if (! integer_zerop (test))
{
! throw = build2 (TRUTH_ANDIF_EXPR, int_type_node, test,
! build_java_throw_out_of_bounds_exception (index));
/* allows expansion within COMPOUND */
TREE_SIDE_EFFECTS( throw ) = 1;
}
*************** build_java_arrayaccess (tree array, tree
*** 774,789 ****
/* If checking bounds, wrap the index expr with a COMPOUND_EXPR in order
to have the bounds check evaluated first. */
if (throw != NULL_TREE)
! index = build (COMPOUND_EXPR, int_type_node, throw, index);
data_field = lookup_field (&array_type, get_identifier ("data"));
! ref = build (COMPONENT_REF, TREE_TYPE (data_field),
! build_java_indirect_ref (array_type, array,
! flag_check_references),
! data_field, NULL_TREE);
! node = build (ARRAY_REF, type, ref, index, NULL_TREE, NULL_TREE);
return node;
}
--- 777,792 ----
/* If checking bounds, wrap the index expr with a COMPOUND_EXPR in order
to have the bounds check evaluated first. */
if (throw != NULL_TREE)
! index = build2 (COMPOUND_EXPR, int_type_node, throw, index);
data_field = lookup_field (&array_type, get_identifier ("data"));
! ref = build3 (COMPONENT_REF, TREE_TYPE (data_field),
! build_java_indirect_ref (array_type, array,
! flag_check_references),
! data_field, NULL_TREE);
! node = build4 (ARRAY_REF, type, ref, index, NULL_TREE, NULL_TREE);
return node;
}
*************** build_java_arraystore_check (tree array,
*** 845,855 ****
}
/* Build an invocation of _Jv_CheckArrayStore */
! check = build (CALL_EXPR, void_type_node,
! build_address_of (soft_checkarraystore_node),
! tree_cons (NULL_TREE, array,
! build_tree_list (NULL_TREE, object)),
! NULL_TREE);
TREE_SIDE_EFFECTS (check) = 1;
return check;
--- 848,858 ----
}
/* Build an invocation of _Jv_CheckArrayStore */
! check = build3 (CALL_EXPR, void_type_node,
! build_address_of (soft_checkarraystore_node),
! tree_cons (NULL_TREE, array,
! build_tree_list (NULL_TREE, object)),
! NULL_TREE);
TREE_SIDE_EFFECTS (check) = 1;
return check;
*************** build_newarray (int atype_value, tree le
*** 908,919 ****
else
type_arg = build_class_ref (prim_type);
! return build (CALL_EXPR, promote_type (type),
! build_address_of (soft_newarray_node),
! tree_cons (NULL_TREE,
! type_arg,
! build_tree_list (NULL_TREE, length)),
! NULL_TREE);
}
/* Generates anewarray from a given CLASS_TYPE. Gets from the stack the size
--- 911,922 ----
else
type_arg = build_class_ref (prim_type);
! return build3 (CALL_EXPR, promote_type (type),
! build_address_of (soft_newarray_node),
! tree_cons (NULL_TREE,
! type_arg,
! build_tree_list (NULL_TREE, length)),
! NULL_TREE);
}
/* Generates anewarray from a given CLASS_TYPE. Gets from the stack the size
*************** build_anewarray (tree class_type, tree l
*** 927,939 ****
host_integerp (length, 0)
? tree_low_cst (length, 0) : -1);
! return build (CALL_EXPR, promote_type (type),
! build_address_of (soft_anewarray_node),
! tree_cons (NULL_TREE, length,
! tree_cons (NULL_TREE, build_class_ref (class_type),
! build_tree_list (NULL_TREE,
! null_pointer_node))),
! NULL_TREE);
}
/* Return a node the evaluates 'new TYPE[LENGTH]'. */
--- 930,942 ----
host_integerp (length, 0)
? tree_low_cst (length, 0) : -1);
! return build3 (CALL_EXPR, promote_type (type),
! build_address_of (soft_anewarray_node),
! tree_cons (NULL_TREE, length,
! tree_cons (NULL_TREE, build_class_ref (class_type),
! build_tree_list (NULL_TREE,
! null_pointer_node))),
! NULL_TREE);
}
/* Return a node the evaluates 'new TYPE[LENGTH]'. */
*************** expand_java_multianewarray (tree class_t
*** 960,972 ****
for( i = 0; i < ndim; i++ )
args = tree_cons (NULL_TREE, pop_value (int_type_node), args);
! push_value (build (CALL_EXPR,
! promote_type (class_type),
! build_address_of (soft_multianewarray_node),
! tree_cons (NULL_TREE, build_class_ref (class_type),
! tree_cons (NULL_TREE,
! build_int_2 (ndim, 0), args )),
! NULL_TREE));
}
/* ARRAY[INDEX] <- RHS. build_java_check_indexed_type makes sure that
--- 963,975 ----
for( i = 0; i < ndim; i++ )
args = tree_cons (NULL_TREE, pop_value (int_type_node), args);
! push_value (build3 (CALL_EXPR,
! promote_type (class_type),
! build_address_of (soft_multianewarray_node),
! tree_cons (NULL_TREE, build_class_ref (class_type),
! tree_cons (NULL_TREE,
! build_int_2 (ndim, 0), args)),
! NULL_TREE));
}
/* ARRAY[INDEX] <- RHS. build_java_check_indexed_type makes sure that
*************** expand_java_arraystore (tree rhs_type_no
*** 1002,1008 ****
}
array = build_java_arrayaccess (array, rhs_type_node, index);
! java_add_stmt (build (MODIFY_EXPR, TREE_TYPE (array), array, rhs_node));
}
/* Expand the evaluation of ARRAY[INDEX]. build_java_check_indexed_type makes
--- 1005,1011 ----
}
array = build_java_arrayaccess (array, rhs_type_node, index);
! java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (array), array, rhs_node));
}
/* Expand the evaluation of ARRAY[INDEX]. build_java_check_indexed_type makes
*************** expand_java_arrayload (tree lhs_type_nod
*** 1026,1034 ****
/* The only way we could get a node of type ptr_type_node at this
point is `aconst_null; arraylength' or something equivalent, so
unconditionally throw NullPointerException. */
! load_node = build (CALL_EXPR, lhs_type_node,
! build_address_of (soft_nullpointer_node),
! NULL_TREE, NULL_TREE);
else
{
lhs_type_node = build_java_check_indexed_type (array_node, lhs_type_node);
--- 1029,1037 ----
/* The only way we could get a node of type ptr_type_node at this
point is `aconst_null; arraylength' or something equivalent, so
unconditionally throw NullPointerException. */
! load_node = build3 (CALL_EXPR, lhs_type_node,
! build_address_of (soft_nullpointer_node),
! NULL_TREE, NULL_TREE);
else
{
lhs_type_node = build_java_check_indexed_type (array_node, lhs_type_node);
*************** expand_java_array_length (void)
*** 1059,1069 ****
static tree
build_java_monitor (tree call, tree object)
{
! return (build (CALL_EXPR,
void_type_node,
build_address_of (call),
build_tree_list (NULL_TREE, object),
! NULL_TREE));
}
/* Emit code for one of the PUSHC instructions. */
--- 1062,1072 ----
static tree
build_java_monitor (tree call, tree object)
{
! return build3 (CALL_EXPR,
void_type_node,
build_address_of (call),
build_tree_list (NULL_TREE, object),
! NULL_TREE);
}
/* Emit code for one of the PUSHC instructions. */
*************** static void
*** 1095,1106 ****
expand_java_return (tree type)
{
if (type == void_type_node)
! java_add_stmt (build (RETURN_EXPR, void_type_node, NULL));
else
{
tree retval = pop_value (type);
tree res = DECL_RESULT (current_function_decl);
! retval = build (MODIFY_EXPR, TREE_TYPE (res), res, retval);
/* Handle the situation where the native integer type is smaller
than the JVM integer. It can happen for many cross compilers.
--- 1098,1109 ----
expand_java_return (tree type)
{
if (type == void_type_node)
! java_add_stmt (build1 (RETURN_EXPR, void_type_node, NULL));
else
{
tree retval = pop_value (type);
tree res = DECL_RESULT (current_function_decl);
! retval = build2 (MODIFY_EXPR, TREE_TYPE (res), res, retval);
/* Handle the situation where the native integer type is smaller
than the JVM integer. It can happen for many cross compilers.
*************** expand_java_return (tree type)
*** 1112,1118 ****
retval = build1(NOP_EXPR, TREE_TYPE(res), retval);
TREE_SIDE_EFFECTS (retval) = 1;
! java_add_stmt (build (RETURN_EXPR, TREE_TYPE (retval), retval));
}
}
--- 1115,1121 ----
retval = build1(NOP_EXPR, TREE_TYPE(res), retval);
TREE_SIDE_EFFECTS (retval) = 1;
! java_add_stmt (build1 (RETURN_EXPR, TREE_TYPE (retval), retval));
}
}
*************** expand_load_internal (int index, tree ty
*** 1130,1136 ****
Hopefully this all gets optimized out. */
copy = build_decl (VAR_DECL, NULL_TREE, type);
java_add_local_var (copy);
! java_add_stmt (build (MODIFY_EXPR, TREE_TYPE (var), copy, var));
push_value (copy);
}
--- 1133,1139 ----
Hopefully this all gets optimized out. */
copy = build_decl (VAR_DECL, NULL_TREE, type);
java_add_local_var (copy);
! java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (var), copy, var));
push_value (copy);
}
*************** expand_java_NEW (tree type)
*** 1163,1172 ****
if (! CLASS_LOADED_P (type))
load_class (type, 1);
safe_layout_class (type);
! push_value (build (CALL_EXPR, promote_type (type),
! build_address_of (alloc_node),
! build_tree_list (NULL_TREE, build_class_ref (type)),
! NULL_TREE));
}
/* This returns an expression which will extract the class of an
--- 1166,1175 ----
if (! CLASS_LOADED_P (type))
load_class (type, 1);
safe_layout_class (type);
! push_value (build3 (CALL_EXPR, promote_type (type),
! build_address_of (alloc_node),
! build_tree_list (NULL_TREE, build_class_ref (type)),
! NULL_TREE));
}
/* This returns an expression which will extract the class of an
*************** build_get_class (tree value)
*** 1178,1190 ****
tree class_field = lookup_field (&dtable_type, get_identifier ("class"));
tree vtable_field = lookup_field (&object_type_node,
get_identifier ("vtable"));
! return build (COMPONENT_REF, class_ptr_type,
! build1 (INDIRECT_REF, dtable_type,
! build (COMPONENT_REF, dtable_ptr_type,
! build_java_indirect_ref (object_type_node, value,
! flag_check_references),
! vtable_field, NULL_TREE)),
! class_field, NULL_TREE);
}
/* This builds the tree representation of the `instanceof' operator.
--- 1181,1193 ----
tree class_field = lookup_field (&dtable_type, get_identifier ("class"));
tree vtable_field = lookup_field (&object_type_node,
get_identifier ("vtable"));
! tree tmp = build3 (COMPONENT_REF, dtable_ptr_type,
! build_java_indirect_ref (object_type_node, value,
! flag_check_references),
! vtable_field, NULL_TREE);
! return build3 (COMPONENT_REF, class_ptr_type,
! build1 (INDIRECT_REF, dtable_type, tmp),
! class_field, NULL_TREE);
}
/* This builds the tree representation of the `instanceof' operator.
*************** build_instanceof (tree value, tree type)
*** 1216,1222 ****
/* Anything except `null' is an instance of Object. Likewise,
if the object is known to be an instance of the class, then
we only need to check for `null'. */
! expr = build (NE_EXPR, itype, value, null_pointer_node);
}
else if (! TYPE_ARRAY_P (type)
&& ! TYPE_ARRAY_P (valtype)
--- 1219,1225 ----
/* Anything except `null' is an instance of Object. Likewise,
if the object is known to be an instance of the class, then
we only need to check for `null'. */
! expr = build2 (NE_EXPR, itype, value, null_pointer_node);
}
else if (! TYPE_ARRAY_P (type)
&& ! TYPE_ARRAY_P (valtype)
*************** build_instanceof (tree value, tree type)
*** 1234,1255 ****
else if (DECL_P (klass) && CLASS_FINAL (klass))
{
tree save = save_expr (value);
! expr = build (COND_EXPR, itype,
! build (NE_EXPR, boolean_type_node,
! save, null_pointer_node),
! build (EQ_EXPR, itype,
! build_get_class (save),
! build_class_ref (type)),
! boolean_false_node);
}
else
{
! expr = build (CALL_EXPR, itype,
! build_address_of (soft_instanceof_node),
! tree_cons (NULL_TREE, value,
! build_tree_list (NULL_TREE,
! build_class_ref (type))),
! NULL_TREE);
}
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (value);
return expr;
--- 1237,1258 ----
else if (DECL_P (klass) && CLASS_FINAL (klass))
{
tree save = save_expr (value);
! expr = build3 (COND_EXPR, itype,
! build2 (NE_EXPR, boolean_type_node,
! save, null_pointer_node),
! build2 (EQ_EXPR, itype,
! build_get_class (save),
! build_class_ref (type)),
! boolean_false_node);
}
else
{
! expr = build3 (CALL_EXPR, itype,
! build_address_of (soft_instanceof_node),
! tree_cons (NULL_TREE, value,
! build_tree_list (NULL_TREE,
! build_class_ref (type))),
! NULL_TREE);
}
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (value);
return expr;
*************** static void
*** 1267,1292 ****
expand_java_CHECKCAST (tree type)
{
tree value = pop_value (ptr_type_node);
! value = build (CALL_EXPR, promote_type (type),
! build_address_of (soft_checkcast_node),
! tree_cons (NULL_TREE, build_class_ref (type),
! build_tree_list (NULL_TREE, value)),
! NULL_TREE);
push_value (value);
}
static void
expand_iinc (unsigned int local_var_index, int ival, int pc)
{
! tree local_var, res;
! tree constant_value;
! flush_quick_stack ();
! local_var = find_local_variable (local_var_index, int_type_node, pc);
! constant_value = build_int_2 (ival, ival < 0 ? -1 : 0);
! res = fold (build (PLUS_EXPR, int_type_node, local_var, constant_value));
! java_add_stmt (build (MODIFY_EXPR, TREE_TYPE (local_var), local_var, res));
! update_aliases (local_var, local_var_index);
}
--- 1270,1295 ----
expand_java_CHECKCAST (tree type)
{
tree value = pop_value (ptr_type_node);
! value = build3 (CALL_EXPR, promote_type (type),
! build_address_of (soft_checkcast_node),
! tree_cons (NULL_TREE, build_class_ref (type),
! build_tree_list (NULL_TREE, value)),
! NULL_TREE);
push_value (value);
}
static void
expand_iinc (unsigned int local_var_index, int ival, int pc)
{
! tree local_var, res;
! tree constant_value;
! flush_quick_stack ();
! local_var = find_local_variable (local_var_index, int_type_node, pc);
! constant_value = build_int_2 (ival, ival < 0 ? -1 : 0);
! res = fold (build2 (PLUS_EXPR, int_type_node, local_var, constant_value));
! java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (local_var), local_var, res));
! update_aliases (local_var, local_var_index);
}
*************** build_java_soft_divmod (enum tree_code o
*** 1329,1339 ****
if (! call)
abort ();
! call = build (CALL_EXPR, type,
! build_address_of (call),
! tree_cons (NULL_TREE, arg1,
! build_tree_list (NULL_TREE, arg2)),
! NULL_TREE);
return call;
}
--- 1332,1342 ----
if (! call)
abort ();
! call = build3 (CALL_EXPR, type,
! build_address_of (call),
! tree_cons (NULL_TREE, arg1,
! build_tree_list (NULL_TREE, arg2)),
! NULL_TREE);
return call;
}
*************** build_java_binop (enum tree_code op, tre
*** 1354,1389 ****
case LSHIFT_EXPR:
case RSHIFT_EXPR:
mask = build_int_2 (TYPE_PRECISION (TREE_TYPE (arg1)) - 1, 0);
! arg2 = fold (build (BIT_AND_EXPR, int_type_node, arg2, mask));
break;
case COMPARE_L_EXPR: /* arg1 > arg2 ? 1 : arg1 == arg2 ? 0 : -1 */
case COMPARE_G_EXPR: /* arg1 < arg2 ? -1 : arg1 == arg2 ? 0 : 1 */
arg1 = save_expr (arg1); arg2 = save_expr (arg2);
{
! tree ifexp1 = fold ( build (op == COMPARE_L_EXPR ? GT_EXPR : LT_EXPR,
boolean_type_node, arg1, arg2));
! tree ifexp2 = fold ( build (EQ_EXPR, boolean_type_node, arg1, arg2));
! tree second_compare = fold (build (COND_EXPR, int_type_node,
! ifexp2, integer_zero_node,
! op == COMPARE_L_EXPR
! ? integer_minus_one_node
! : integer_one_node));
! return fold (build (COND_EXPR, int_type_node, ifexp1,
! op == COMPARE_L_EXPR ? integer_one_node
! : integer_minus_one_node,
! second_compare));
}
case COMPARE_EXPR:
arg1 = save_expr (arg1); arg2 = save_expr (arg2);
{
! tree ifexp1 = fold ( build (LT_EXPR, boolean_type_node, arg1, arg2));
! tree ifexp2 = fold ( build (GT_EXPR, boolean_type_node, arg1, arg2));
! tree second_compare = fold ( build (COND_EXPR, int_type_node,
ifexp2, integer_one_node,
integer_zero_node));
! return fold (build (COND_EXPR, int_type_node,
! ifexp1, integer_minus_one_node, second_compare));
}
case TRUNC_DIV_EXPR:
case TRUNC_MOD_EXPR:
--- 1357,1392 ----
case LSHIFT_EXPR:
case RSHIFT_EXPR:
mask = build_int_2 (TYPE_PRECISION (TREE_TYPE (arg1)) - 1, 0);
! arg2 = fold (build2 (BIT_AND_EXPR, int_type_node, arg2, mask));
break;
case COMPARE_L_EXPR: /* arg1 > arg2 ? 1 : arg1 == arg2 ? 0 : -1 */
case COMPARE_G_EXPR: /* arg1 < arg2 ? -1 : arg1 == arg2 ? 0 : 1 */
arg1 = save_expr (arg1); arg2 = save_expr (arg2);
{
! tree ifexp1 = fold (build2 (op == COMPARE_L_EXPR ? GT_EXPR : LT_EXPR,
boolean_type_node, arg1, arg2));
! tree ifexp2 = fold (build2 (EQ_EXPR, boolean_type_node, arg1, arg2));
! tree second_compare = fold (build3 (COND_EXPR, int_type_node,
! ifexp2, integer_zero_node,
! op == COMPARE_L_EXPR
! ? integer_minus_one_node
! : integer_one_node));
! return fold (build3 (COND_EXPR, int_type_node, ifexp1,
! op == COMPARE_L_EXPR ? integer_one_node
! : integer_minus_one_node,
! second_compare));
}
case COMPARE_EXPR:
arg1 = save_expr (arg1); arg2 = save_expr (arg2);
{
! tree ifexp1 = fold (build2 (LT_EXPR, boolean_type_node, arg1, arg2));
! tree ifexp2 = fold (build2 (GT_EXPR, boolean_type_node, arg1, arg2));
! tree second_compare = fold (build3 (COND_EXPR, int_type_node,
ifexp2, integer_one_node,
integer_zero_node));
! return fold (build3 (COND_EXPR, int_type_node,
! ifexp1, integer_minus_one_node, second_compare));
}
case TRUNC_DIV_EXPR:
case TRUNC_MOD_EXPR:
*************** build_java_binop (enum tree_code op, tre
*** 1396,1406 ****
arg1 = convert (double_type_node, arg1);
arg2 = convert (double_type_node, arg2);
}
! call = build (CALL_EXPR, double_type_node,
! build_address_of (soft_fmod_node),
! tree_cons (NULL_TREE, arg1,
! build_tree_list (NULL_TREE, arg2)),
! NULL_TREE);
if (type != double_type_node)
call = convert (type, call);
return call;
--- 1399,1409 ----
arg1 = convert (double_type_node, arg1);
arg2 = convert (double_type_node, arg2);
}
! call = build3 (CALL_EXPR, double_type_node,
! build_address_of (soft_fmod_node),
! tree_cons (NULL_TREE, arg1,
! build_tree_list (NULL_TREE, arg2)),
! NULL_TREE);
if (type != double_type_node)
call = convert (type, call);
return call;
*************** build_java_binop (enum tree_code op, tre
*** 1414,1420 ****
break;
default: ;
}
! return fold (build (op, type, arg1, arg2));
}
static void
--- 1417,1423 ----
break;
default: ;
}
! return fold (build2 (op, type, arg1, arg2));
}
static void
*************** build_field_ref (tree self_value, tree s
*** 1538,1560 ****
(field_decl, &TYPE_OTABLE_METHODS (output_class)),
0);
tree field_offset
! = build (ARRAY_REF, integer_type_node,
! TYPE_OTABLE_DECL (output_class), otable_index,
! NULL_TREE, NULL_TREE);
tree address;
field_offset = fold (convert (sizetype, field_offset));
address
! = fold (build (PLUS_EXPR,
! build_pointer_type (TREE_TYPE (field_decl)),
! self_value, field_offset));
return fold (build1 (INDIRECT_REF, TREE_TYPE (field_decl), address));
}
self_value = build_java_indirect_ref (TREE_TYPE (TREE_TYPE (self_value)),
self_value, check);
! return fold (build (COMPONENT_REF, TREE_TYPE (field_decl),
! self_value, field_decl, NULL_TREE));
}
}
--- 1541,1563 ----
(field_decl, &TYPE_OTABLE_METHODS (output_class)),
0);
tree field_offset
! = build4 (ARRAY_REF, integer_type_node,
! TYPE_OTABLE_DECL (output_class), otable_index,
! NULL_TREE, NULL_TREE);
tree address;
field_offset = fold (convert (sizetype, field_offset));
address
! = fold (build2 (PLUS_EXPR,
! build_pointer_type (TREE_TYPE (field_decl)),
! self_value, field_offset));
return fold (build1 (INDIRECT_REF, TREE_TYPE (field_decl), address));
}
self_value = build_java_indirect_ref (TREE_TYPE (TREE_TYPE (self_value)),
self_value, check);
! return fold (build3 (COMPONENT_REF, TREE_TYPE (field_decl),
! self_value, field_decl, NULL_TREE));
}
}
*************** expand_compare (enum tree_code condition
*** 1618,1628 ****
int target_pc)
{
tree target = lookup_label (target_pc);
! tree cond = fold (build (condition, boolean_type_node, value1, value2));
java_add_stmt
! (build (COND_EXPR, void_type_node, java_truthvalue_conversion (cond),
! build (GOTO_EXPR, void_type_node, target),
! build_java_empty_stmt ()));
}
/* Emit code for a TEST-type opcode. */
--- 1621,1631 ----
int target_pc)
{
tree target = lookup_label (target_pc);
! tree cond = fold (build2 (condition, boolean_type_node, value1, value2));
java_add_stmt
! (build3 (COND_EXPR, void_type_node, java_truthvalue_conversion (cond),
! build1 (GOTO_EXPR, void_type_node, target),
! build_java_empty_stmt ()));
}
/* Emit code for a TEST-type opcode. */
*************** expand_java_goto (int target_pc)
*** 1656,1662 ****
{
tree target_label = lookup_label (target_pc);
flush_quick_stack ();
! java_add_stmt (build (GOTO_EXPR, void_type_node, target_label));
}
static tree
--- 1659,1665 ----
{
tree target_label = lookup_label (target_pc);
flush_quick_stack ();
! java_add_stmt (build1 (GOTO_EXPR, void_type_node, target_label));
}
static tree
*************** expand_java_switch (tree selector, int d
*** 1665,1679 ****
tree switch_expr, x;
flush_quick_stack ();
! switch_expr = build (SWITCH_EXPR, TREE_TYPE (selector), selector,
! NULL_TREE, NULL_TREE);
java_add_stmt (switch_expr);
! x = build (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE,
! create_artificial_label ());
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
! x = build (GOTO_EXPR, void_type_node, lookup_label (default_pc));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
return switch_expr;
--- 1668,1682 ----
tree switch_expr, x;
flush_quick_stack ();
! switch_expr = build3 (SWITCH_EXPR, TREE_TYPE (selector), selector,
! NULL_TREE, NULL_TREE);
java_add_stmt (switch_expr);
! x = build3 (CASE_LABEL_EXPR, void_type_node, NULL_TREE, NULL_TREE,
! create_artificial_label ());
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
! x = build1 (GOTO_EXPR, void_type_node, lookup_label (default_pc));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
return switch_expr;
*************** expand_java_add_case (tree switch_expr,
*** 1687,1697 ****
value = build_int_2 (match, match < 0 ? -1 : 0);
TREE_TYPE (value) = TREE_TYPE (switch_expr);
! x = build (CASE_LABEL_EXPR, void_type_node, value, NULL_TREE,
! create_artificial_label ());
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
! x = build (GOTO_EXPR, void_type_node, lookup_label (target_pc));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
}
--- 1690,1700 ----
value = build_int_2 (match, match < 0 ? -1 : 0);
TREE_TYPE (value) = TREE_TYPE (switch_expr);
! x = build3 (CASE_LABEL_EXPR, void_type_node, value, NULL_TREE,
! create_artificial_label ());
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
! x = build1 (GOTO_EXPR, void_type_node, lookup_label (target_pc));
append_to_statement_list (x, &SWITCH_BODY (switch_expr));
}
*************** build_class_init (tree clas, tree expr)
*** 1757,1766 ****
if (always_initialize_class_p)
{
! init = build (CALL_EXPR, void_type_node,
! build_address_of (soft_initclass_node),
! build_tree_list (NULL_TREE, build_class_ref (clas)),
! NULL_TREE);
TREE_SIDE_EFFECTS (init) = 1;
}
else
--- 1760,1769 ----
if (always_initialize_class_p)
{
! init = build3 (CALL_EXPR, void_type_node,
! build_address_of (soft_initclass_node),
! build_tree_list (NULL_TREE, build_class_ref (clas)),
! NULL_TREE);
TREE_SIDE_EFFECTS (init) = 1;
}
else
*************** build_class_init (tree clas, tree expr)
*** 1788,1812 ****
DECL_IGNORED_P (*init_test_decl) = 1;
}
! init = build (CALL_EXPR, void_type_node,
! build_address_of (soft_initclass_node),
! build_tree_list (NULL_TREE, build_class_ref (clas)),
! NULL_TREE);
TREE_SIDE_EFFECTS (init) = 1;
! init = build (COND_EXPR, void_type_node,
! build (EQ_EXPR, boolean_type_node,
! *init_test_decl, boolean_false_node),
! init, integer_zero_node);
TREE_SIDE_EFFECTS (init) = 1;
! init = build (COMPOUND_EXPR, TREE_TYPE (expr), init,
! build (MODIFY_EXPR, boolean_type_node,
! *init_test_decl, boolean_true_node));
TREE_SIDE_EFFECTS (init) = 1;
}
if (expr != NULL_TREE)
{
! expr = build (COMPOUND_EXPR, TREE_TYPE (expr), init, expr);
TREE_SIDE_EFFECTS (expr) = 1;
return expr;
}
--- 1791,1815 ----
DECL_IGNORED_P (*init_test_decl) = 1;
}
! init = build3 (CALL_EXPR, void_type_node,
! build_address_of (soft_initclass_node),
! build_tree_list (NULL_TREE, build_class_ref (clas)),
! NULL_TREE);
TREE_SIDE_EFFECTS (init) = 1;
! init = build3 (COND_EXPR, void_type_node,
! build2 (EQ_EXPR, boolean_type_node,
! *init_test_decl, boolean_false_node),
! init, integer_zero_node);
TREE_SIDE_EFFECTS (init) = 1;
! init = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init,
! build2 (MODIFY_EXPR, boolean_type_node,
! *init_test_decl, boolean_true_node));
TREE_SIDE_EFFECTS (init) = 1;
}
if (expr != NULL_TREE)
{
! expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), init, expr);
TREE_SIDE_EFFECTS (expr) = 1;
return expr;
}
*************** build_known_method_ref (tree method, tre
*** 1833,1841 ****
tree table_index
= build_int_2 (get_symbol_table_index
(method, &TYPE_ATABLE_METHODS (output_class)), 0);
! func = build (ARRAY_REF, method_ptr_type_node,
! TYPE_ATABLE_DECL (output_class), table_index,
! NULL_TREE, NULL_TREE);
}
func = convert (method_ptr_type_node, func);
}
--- 1836,1844 ----
tree table_index
= build_int_2 (get_symbol_table_index
(method, &TYPE_ATABLE_METHODS (output_class)), 0);
! func = build4 (ARRAY_REF, method_ptr_type_node,
! TYPE_ATABLE_DECL (output_class), table_index,
! NULL_TREE, NULL_TREE);
}
func = convert (method_ptr_type_node, func);
}
*************** build_known_method_ref (tree method, tre
*** 1861,1868 ****
ncode_ident = get_identifier ("ncode");
if (methods_ident == NULL_TREE)
methods_ident = get_identifier ("methods");
! ref = build (COMPONENT_REF, method_ptr_type_node, ref,
! lookup_field (&class_type_node, methods_ident), NULL_TREE);
for (meth = TYPE_METHODS (self_type);
; meth = TREE_CHAIN (meth))
{
--- 1864,1872 ----
ncode_ident = get_identifier ("ncode");
if (methods_ident == NULL_TREE)
methods_ident = get_identifier ("methods");
! ref = build3 (COMPONENT_REF, method_ptr_type_node, ref,
! lookup_field (&class_type_node, methods_ident),
! NULL_TREE);
for (meth = TYPE_METHODS (self_type);
; meth = TREE_CHAIN (meth))
{
*************** build_known_method_ref (tree method, tre
*** 1874,1885 ****
method_index++;
}
method_index *= int_size_in_bytes (method_type_node);
! ref = fold (build (PLUS_EXPR, method_ptr_type_node,
! ref, build_int_2 (method_index, 0)));
ref = build1 (INDIRECT_REF, method_type_node, ref);
! func = build (COMPONENT_REF, nativecode_ptr_type_node,
! ref, lookup_field (&method_type_node, ncode_ident),
! NULL_TREE);
}
return func;
}
--- 1878,1889 ----
method_index++;
}
method_index *= int_size_in_bytes (method_type_node);
! ref = fold (build2 (PLUS_EXPR, method_ptr_type_node,
! ref, build_int_2 (method_index, 0)));
ref = build1 (INDIRECT_REF, method_type_node, ref);
! func = build3 (COMPONENT_REF, nativecode_ptr_type_node,
! ref, lookup_field (&method_type_node, ncode_ident),
! NULL_TREE);
}
return func;
}
*************** invoke_build_dtable (int is_invoke_inter
*** 1902,1909 ****
dtable_ident = get_identifier ("vtable");
dtable = build_java_indirect_ref (object_type_node, objectref,
flag_check_references);
! dtable = build (COMPONENT_REF, dtable_ptr_type, dtable,
! lookup_field (&object_type_node, dtable_ident), NULL_TREE);
return dtable;
}
--- 1906,1913 ----
dtable_ident = get_identifier ("vtable");
dtable = build_java_indirect_ref (object_type_node, objectref,
flag_check_references);
! dtable = build3 (COMPONENT_REF, dtable_ptr_type, dtable,
! lookup_field (&object_type_node, dtable_ident), NULL_TREE);
return dtable;
}
*************** build_invokevirtual (tree dtable, tree m
*** 1957,1965 ****
otable_index
= build_int_2 (get_symbol_table_index
(method, &TYPE_OTABLE_METHODS (output_class)), 0);
! method_index = build (ARRAY_REF, integer_type_node,
! TYPE_OTABLE_DECL (output_class),
! otable_index, NULL_TREE, NULL_TREE);
}
else
{
--- 1961,1969 ----
otable_index
= build_int_2 (get_symbol_table_index
(method, &TYPE_OTABLE_METHODS (output_class)), 0);
! method_index = build4 (ARRAY_REF, integer_type_node,
! TYPE_OTABLE_DECL (output_class),
! otable_index, NULL_TREE, NULL_TREE);
}
else
{
*************** build_invokevirtual (tree dtable, tree m
*** 1975,1982 ****
size_int (TARGET_VTABLE_USES_DESCRIPTORS));
}
! func = fold (build (PLUS_EXPR, nativecode_ptr_ptr_type_node, dtable,
! convert (nativecode_ptr_ptr_type_node, method_index)));
if (TARGET_VTABLE_USES_DESCRIPTORS)
func = build1 (NOP_EXPR, nativecode_ptr_type_node, func);
--- 1979,1986 ----
size_int (TARGET_VTABLE_USES_DESCRIPTORS));
}
! func = fold (build2 (PLUS_EXPR, nativecode_ptr_ptr_type_node, dtable,
! convert (nativecode_ptr_ptr_type_node, method_index)));
if (TARGET_VTABLE_USES_DESCRIPTORS)
func = build1 (NOP_EXPR, nativecode_ptr_type_node, func);
*************** build_invokeinterface (tree dtable, tree
*** 2004,2011 ****
dtable = build_java_indirect_ref (dtable_type, dtable,
flag_check_references);
! dtable = build (COMPONENT_REF, class_ptr_type, dtable,
! lookup_field (&dtable_type, class_ident), NULL_TREE);
interface = DECL_CONTEXT (method);
if (! CLASS_INTERFACE (TYPE_NAME (interface)))
--- 2008,2015 ----
dtable = build_java_indirect_ref (dtable_type, dtable,
flag_check_references);
! dtable = build3 (COMPONENT_REF, class_ptr_type, dtable,
! lookup_field (&dtable_type, class_ident), NULL_TREE);
interface = DECL_CONTEXT (method);
if (! CLASS_INTERFACE (TYPE_NAME (interface)))
*************** build_invokeinterface (tree dtable, tree
*** 2017,2025 ****
otable_index
= build_int_2 (get_symbol_table_index
(method, &TYPE_OTABLE_METHODS (output_class)), 0);
! idx = build (ARRAY_REF, integer_type_node,
! TYPE_OTABLE_DECL (output_class), otable_index,
! NULL_TREE, NULL_TREE);
}
else
idx = build_int_2 (get_interface_method_index (method, interface), 0);
--- 2021,2029 ----
otable_index
= build_int_2 (get_symbol_table_index
(method, &TYPE_OTABLE_METHODS (output_class)), 0);
! idx = build4 (ARRAY_REF, integer_type_node,
! TYPE_OTABLE_DECL (output_class), otable_index,
! NULL_TREE, NULL_TREE);
}
else
idx = build_int_2 (get_interface_method_index (method, interface), 0);
*************** build_invokeinterface (tree dtable, tree
*** 2028,2036 ****
tree_cons (NULL_TREE, build_class_ref (interface),
build_tree_list (NULL_TREE, idx)));
! return build (CALL_EXPR, ptr_type_node,
! build_address_of (soft_lookupinterfacemethod_node),
! lookup_arg, NULL_TREE);
}
/* Expand one of the invoke_* opcodes.
--- 2032,2040 ----
tree_cons (NULL_TREE, build_class_ref (interface),
build_tree_list (NULL_TREE, idx)));
! return build3 (CALL_EXPR, ptr_type_node,
! build_address_of (soft_lookupinterfacemethod_node),
! lookup_arg, NULL_TREE);
}
/* Expand one of the invoke_* opcodes.
*************** expand_invoke (int opcode, int method_re
*** 2151,2163 ****
else
func = build1 (NOP_EXPR, build_pointer_type (method_type), func);
! call = build (CALL_EXPR, TREE_TYPE (method_type), func, arg_list, NULL_TREE);
TREE_SIDE_EFFECTS (call) = 1;
call = check_for_builtin (method, call);
if (check != NULL_TREE)
{
! call = build (COMPOUND_EXPR, TREE_TYPE (call), check, call);
TREE_SIDE_EFFECTS (call) = 1;
}
--- 2155,2168 ----
else
func = build1 (NOP_EXPR, build_pointer_type (method_type), func);
! call = build3 (CALL_EXPR, TREE_TYPE (method_type),
! func, arg_list, NULL_TREE);
TREE_SIDE_EFFECTS (call) = 1;
call = check_for_builtin (method, call);
if (check != NULL_TREE)
{
! call = build2 (COMPOUND_EXPR, TREE_TYPE (call), check, call);
TREE_SIDE_EFFECTS (call) = 1;
}
*************** build_jni_stub (tree method)
*** 2232,2242 ****
TREE_TYPE (block) = TREE_TYPE (TREE_TYPE (method));
/* Compute the local `env' by calling _Jv_GetJNIEnvNewFrame. */
! body = build (MODIFY_EXPR, ptr_type_node, env_var,
! build (CALL_EXPR, ptr_type_node,
! build_address_of (soft_getjnienvnewframe_node),
! build_tree_list (NULL_TREE, klass),
! NULL_TREE));
CAN_COMPLETE_NORMALLY (body) = 1;
/* All the arguments to this method become arguments to the
--- 2237,2247 ----
TREE_TYPE (block) = TREE_TYPE (TREE_TYPE (method));
/* Compute the local `env' by calling _Jv_GetJNIEnvNewFrame. */
! body = build2 (MODIFY_EXPR, ptr_type_node, env_var,
! build3 (CALL_EXPR, ptr_type_node,
! build_address_of (soft_getjnienvnewframe_node),
! build_tree_list (NULL_TREE, klass),
! NULL_TREE));
CAN_COMPLETE_NORMALLY (body) = 1;
/* All the arguments to this method become arguments to the
*************** build_jni_stub (tree method)
*** 2295,2334 ****
jni_func_type = build_pointer_type (tem);
! jnifunc = build (COND_EXPR, ptr_type_node,
! meth_var, meth_var,
! build (MODIFY_EXPR, ptr_type_node,
! meth_var,
! build (CALL_EXPR, ptr_type_node,
! build_address_of (soft_lookupjnimethod_node),
! lookup_arg, NULL_TREE)));
/* Now we make the actual JNI call via the resulting function
pointer. */
! call = build (CALL_EXPR, TREE_TYPE (TREE_TYPE (method)),
! build1 (NOP_EXPR, jni_func_type, jnifunc),
! args, NULL_TREE);
/* If the JNI call returned a result, capture it here. If we had to
unwrap JNI object results, we would do that here. */
if (res_var != NULL_TREE)
! call = build (MODIFY_EXPR, TREE_TYPE (TREE_TYPE (method)),
! res_var, call);
TREE_SIDE_EFFECTS (call) = 1;
CAN_COMPLETE_NORMALLY (call) = 1;
! body = build (COMPOUND_EXPR, void_type_node, body, call);
TREE_SIDE_EFFECTS (body) = 1;
/* Now free the environment we allocated. */
! call = build (CALL_EXPR, ptr_type_node,
! build_address_of (soft_jnipopsystemframe_node),
! build_tree_list (NULL_TREE, env_var),
! NULL_TREE);
TREE_SIDE_EFFECTS (call) = 1;
CAN_COMPLETE_NORMALLY (call) = 1;
! body = build (COMPOUND_EXPR, void_type_node, body, call);
TREE_SIDE_EFFECTS (body) = 1;
/* Finally, do the return. */
--- 2300,2339 ----
jni_func_type = build_pointer_type (tem);
! jnifunc = build3 (COND_EXPR, ptr_type_node,
! meth_var, meth_var,
! build2 (MODIFY_EXPR, ptr_type_node, meth_var,
! build3 (CALL_EXPR, ptr_type_node,
! build_address_of
! (soft_lookupjnimethod_node),
! lookup_arg, NULL_TREE)));
/* Now we make the actual JNI call via the resulting function
pointer. */
! call = build3 (CALL_EXPR, TREE_TYPE (TREE_TYPE (method)),
! build1 (NOP_EXPR, jni_func_type, jnifunc),
! args, NULL_TREE);
/* If the JNI call returned a result, capture it here. If we had to
unwrap JNI object results, we would do that here. */
if (res_var != NULL_TREE)
! call = build2 (MODIFY_EXPR, TREE_TYPE (TREE_TYPE (method)),
! res_var, call);
TREE_SIDE_EFFECTS (call) = 1;
CAN_COMPLETE_NORMALLY (call) = 1;
! body = build2 (COMPOUND_EXPR, void_type_node, body, call);
TREE_SIDE_EFFECTS (body) = 1;
/* Now free the environment we allocated. */
! call = build3 (CALL_EXPR, ptr_type_node,
! build_address_of (soft_jnipopsystemframe_node),
! build_tree_list (NULL_TREE, env_var),
! NULL_TREE);
TREE_SIDE_EFFECTS (call) = 1;
CAN_COMPLETE_NORMALLY (call) = 1;
! body = build2 (COMPOUND_EXPR, void_type_node, body, call);
TREE_SIDE_EFFECTS (body) = 1;
/* Finally, do the return. */
*************** build_jni_stub (tree method)
*** 2345,2360 ****
drt = TREE_TYPE (DECL_RESULT (method));
if (drt != TREE_TYPE (res_var))
res_var = build1 (CONVERT_EXPR, drt, res_var);
! res_var = build (MODIFY_EXPR, drt, DECL_RESULT (method), res_var);
TREE_SIDE_EFFECTS (res_var) = 1;
}
! body = build (COMPOUND_EXPR, void_type_node, body,
! build1 (RETURN_EXPR, res_type, res_var));
TREE_SIDE_EFFECTS (body) = 1;
! bind = build (BIND_EXPR, void_type_node, BLOCK_VARS (block),
! body, block);
return bind;
}
--- 2350,2365 ----
drt = TREE_TYPE (DECL_RESULT (method));
if (drt != TREE_TYPE (res_var))
res_var = build1 (CONVERT_EXPR, drt, res_var);
! res_var = build2 (MODIFY_EXPR, drt, DECL_RESULT (method), res_var);
TREE_SIDE_EFFECTS (res_var) = 1;
}
! body = build2 (COMPOUND_EXPR, void_type_node, body,
! build1 (RETURN_EXPR, res_type, res_var));
TREE_SIDE_EFFECTS (body) = 1;
! bind = build3 (BIND_EXPR, void_type_node, BLOCK_VARS (block),
! body, block);
return bind;
}
*************** expand_java_field_op (int is_static, int
*** 2436,2443 ****
field_decl, field_decl);
}
}
! java_add_stmt (build (MODIFY_EXPR,
! TREE_TYPE (field_ref), field_ref, new_value));
}
else
push_value (field_ref);
--- 2441,2448 ----
field_decl, field_decl);
}
}
! java_add_stmt (build2 (MODIFY_EXPR, TREE_TYPE (field_ref),
! field_ref, new_value));
}
else
push_value (field_ref);
*************** java_expand_expr (tree exp, rtx target,
*** 2584,2593 ****
TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (init_decl)) = 1;
init = init_decl;
}
! expand_assignment (build (COMPONENT_REF, TREE_TYPE (data_fld),
! build_java_indirect_ref (array_type,
! array_decl, flag_check_references),
! data_fld, NULL_TREE),
init, 0);
return tmp;
}
--- 2589,2599 ----
TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (init_decl)) = 1;
init = init_decl;
}
! expand_assignment (build3 (COMPONENT_REF, TREE_TYPE (data_fld),
! build_java_indirect_ref
! (array_type, array_decl,
! flag_check_references),
! data_fld, NULL_TREE),
init, 0);
return tmp;
}
*************** expand_byte_code (JCF *jcf, tree method)
*** 2878,2884 ****
tree label = lookup_label (PC);
flush_quick_stack ();
if ((instruction_bits [PC] & BCODE_TARGET) != 0)
! java_add_stmt (build (LABEL_EXPR, void_type_node, label));
if (LABEL_VERIFIED (label) || PC == 0)
load_type_state (label);
}
--- 2884,2890 ----
tree label = lookup_label (PC);
flush_quick_stack ();
if ((instruction_bits [PC] & BCODE_TARGET) != 0)
! java_add_stmt (build1 (LABEL_EXPR, void_type_node, label));
if (LABEL_VERIFIED (label) || PC == 0)
load_type_state (label);
}
*************** process_jvm_instruction (int PC, const u
*** 3167,3173 ****
type = TREE_TYPE (value); \
decl = find_local_variable (index, type, oldpc); \
set_local_type (index, type); \
! java_add_stmt (build (MODIFY_EXPR, type, decl, value)); \
update_aliases (decl, index); \
}
--- 3173,3179 ----
type = TREE_TYPE (value); \
decl = find_local_variable (index, type, oldpc); \
set_local_type (index, type); \
! java_add_stmt (build2 (MODIFY_EXPR, type, decl, value)); \
update_aliases (decl, index); \
}
*************** force_evaluation_order (tree node)
*** 3427,3433 ****
{
tree saved = save_expr (force_evaluation_order (TREE_VALUE (arg)));
cmp = (cmp == NULL_TREE ? saved :
! build (COMPOUND_EXPR, void_type_node, cmp, saved));
TREE_VALUE (arg) = saved;
}
--- 3433,3439 ----
{
tree saved = save_expr (force_evaluation_order (TREE_VALUE (arg)));
cmp = (cmp == NULL_TREE ? saved :
! build2 (COMPOUND_EXPR, void_type_node, cmp, saved));
TREE_VALUE (arg) = saved;
}
*************** force_evaluation_order (tree node)
*** 3436,3442 ****
if (cmp)
{
! cmp = build (COMPOUND_EXPR, TREE_TYPE (node), cmp, node);
if (TREE_TYPE (cmp) != void_type_node)
cmp = save_expr (cmp);
CAN_COMPLETE_NORMALLY (cmp) = CAN_COMPLETE_NORMALLY (node);
--- 3442,3448 ----
if (cmp)
{
! cmp = build2 (COMPOUND_EXPR, TREE_TYPE (node), cmp, node);
if (TREE_TYPE (cmp) != void_type_node)
cmp = save_expr (cmp);
CAN_COMPLETE_NORMALLY (cmp) = CAN_COMPLETE_NORMALLY (node);
*************** emit_init_test_initialization (void **en
*** 3467,3482 ****
initialized. This makes things a bit faster if the class is
already initialized, which should be the common case. */
else
! rhs = build (GE_EXPR, boolean_type_node,
! build (COMPONENT_REF, byte_type_node,
! build1 (INDIRECT_REF, class_type_node, klass),
! lookup_field (&class_type_node,
! get_identifier ("state")),
! NULL_TREE),
! build_int_2 (JV_STATE_DONE, 0));
! expand_expr_stmt (build (MODIFY_EXPR, boolean_type_node,
! ite->value, rhs));
return true;
}
--- 3473,3488 ----
initialized. This makes things a bit faster if the class is
already initialized, which should be the common case. */
else
! rhs = build2 (GE_EXPR, boolean_type_node,
! build3 (COMPONENT_REF, byte_type_node,
! build1 (INDIRECT_REF, class_type_node, klass),
! lookup_field (&class_type_node,
! get_identifier ("state")),
! NULL_TREE),
! build_int_2 (JV_STATE_DONE, 0));
! expand_expr_stmt (build2 (MODIFY_EXPR, boolean_type_node,
! ite->value, rhs));
return true;
}
Roger
--
Roger Sayle, E-mail: roger@eyesopen.com
OpenEye Scientific Software, WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833