This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ecj] Patch: FYI: fix side-effect-only computations
- From: Tom Tromey <tromey at redhat dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: 19 Jun 2006 12:03:58 -0600
- Subject: [ecj] Patch: FYI: fix side-effect-only computations
- Reply-to: tromey at redhat dot com
I'm checking this in on the gcj-eclipse branch.
I'm also testing it on the trunk; if it passes there I will be
checking it in on the trunk as well.
If we see bytecode like this:
13: checkcast #17=<Class CD>
16: pop
... we will end up not generating a call to _Jv_CheckCast. This
happens because the value ends up on the quick stack and is not put
into the tree for the method.
The fix is to flush the quick stack when pushing a value that has side
effects. This ensures that the expression will always be evaluated.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* expr.c (push_value): Flush quick stack if value has side
effects.
Index: expr.c
===================================================================
--- expr.c (revision 114451)
+++ expr.c (working copy)
@@ -301,6 +301,12 @@
TREE_CHAIN (node) = quick_stack;
quick_stack = node;
}
+ /* 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
+ the quick stack. */
+ if (TREE_SIDE_EFFECTS (value))
+ flush_quick_stack ();
}
/* Pop a type from the type stack.