This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gcjx] Patch: FYI: fix 'for' lowering
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: 12 Feb 2005 20:54:42 -0700
- Subject: [gcjx] Patch: FYI: fix 'for' lowering
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcjx branch.
Inexplicably, we didn't wrap the body of a 'for' loop in a LOOP_EXPR.
Also, this adds a NOP_EXPR that is needed when finding the vtable in a
class that isn't Object. However, this is just temporary; I'm told it
is better to generate a series of COMPONENT_REFs for the nameless
superclass fields until we get up to the Object "field", rather than
simply applying a cast to the pointer.
Tom
#
# patch "gcc/gcc/java/ChangeLog"
# from [35289bee2f06c4edb8cf706f38989eda28165595]
# to [548275cfa618229aef6a40b44a708d2428503ab3]
#
# patch "gcc/gcc/java/abi.cc"
# from [343372377857f3120cb8485137d5b4ddd4ad9e13]
# to [0c8cecca21a803bf53970ee8d02223a92460ea00]
#
# patch "gcc/gcc/java/tree.cc"
# from [37e70463907e099df2c599ac8228aa5ba5ef1fae]
# to [e5a2ad74e4ddc38ee6982ce7e0fbc189cec9fa58]
#
--- gcc/gcc/java/ChangeLog
+++ gcc/gcc/java/ChangeLog
@@ -1,3 +1,10 @@
+2005-02-09 Tom Tromey <tromey@redhat.com>
+
+ * tree.cc (visit_for): Wrap body in a LOOP_EXPR.
+
+ * abi.cc (build_method_call): Wrap object in NOP_EXPR before
+ finding "vtable" field.
+
2005-02-08 Tom Tromey <tromey@redhat.com>
* tree.cc (visit_for): Use LABEL_EXPRs as statements. Set
--- gcc/gcc/java/abi.cc
+++ gcc/gcc/java/abi.cc
@@ -94,7 +94,8 @@
obj = builtins->check_reference (obj);
// Find the vtable by looking for the 'vtable' field.
- tree dtable = build1 (INDIRECT_REF, type_object, obj);
+ tree dtable = build1 (INDIRECT_REF, type_object,
+ build1 (NOP_EXPR, type_object_ptr, obj));
dtable = build3 (COMPONENT_REF, type_dtable_ptr,
dtable,
builtins->find_decl (type_object, "vtable"),
--- gcc/gcc/java/tree.cc
+++ gcc/gcc/java/tree.cc
@@ -556,35 +556,44 @@
save_tree saver (current_block, make_node (BLOCK));
BLOCK_SUPERCONTEXT (current_block) = saver.get ();
- tree body_tree = alloc_stmt_list ();
- tree_stmt_iterator out = tsi_start (body_tree);
+ tree result = alloc_stmt_list ();
+ tree_stmt_iterator result_out = tsi_start (result);
if (init)
{
init->visit (this);
- tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
+ tsi_link_after (&result_out, current, TSI_CONTINUE_LINKING);
}
+
+ // The body of the loop, including the condition and the update.
+ tree body_tree = alloc_stmt_list ();
+ tree_stmt_iterator body_out = tsi_start (body_tree);
if (cond)
{
cond->visit (this);
- tsi_link_after (&out, build1 (EXIT_EXPR, void_type_node,
- build1 (TRUTH_NOT_EXPR,
- type_jboolean,
- current)),
+ tsi_link_after (&body_out, build1 (EXIT_EXPR, void_type_node,
+ build1 (TRUTH_NOT_EXPR,
+ type_jboolean,
+ current)),
TSI_CONTINUE_LINKING);
}
body->visit (this);
- tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
+ tsi_link_after (&body_out, current, TSI_CONTINUE_LINKING);
- tsi_link_after (&out, build1 (LABEL_EXPR, void_type_node, update_tree),
+ tsi_link_after (&body_out, build1 (LABEL_EXPR, void_type_node, update_tree),
TSI_CONTINUE_LINKING);
if (update)
{
update->visit (this);
- tsi_link_after (&out, current, TSI_CONTINUE_LINKING);
+ tsi_link_after (&body_out, current, TSI_CONTINUE_LINKING);
}
- tsi_link_after (&out, build1 (LABEL_EXPR, void_type_node, done_tree),
+ // Now wrap the body in a loop and link it into the outer statement
+ // list.
+ body_tree = build1 (LOOP_EXPR, void_type_node, body_tree);
+ tsi_link_after (&result_out, body_tree, TSI_CONTINUE_LINKING);
+
+ tsi_link_after (&result_out, build1 (LABEL_EXPR, void_type_node, done_tree),
TSI_CONTINUE_LINKING);
current = build3 (BIND_EXPR, void_type_node,