This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ecj] Patch: FYI: fix side-effect-only computations


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]