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]

Re: Non-call exceptions versus cse


Richard Henderson writes:
 > On Tue, Nov 19, 2002 at 04:21:29PM +0000, Andrew Haley wrote:
 > > Consider this code fragment:
 > > 
 > > int nn = 0;
 > > try
 > > {
 > >     int tmp = foo->bar;
 > >     nn = tmp;
 > > }
 > > ...
 > > 
 > > When using non-call exceptions, this may not be changed to
 > > 
 > > int nn = 0;
 > > try
 > > {
 > >     nn = foo->bar;
 > > }
 > 
 > Huh?
 > 
 > I don't see that these two are going to be any different at all.
 > The value must be loaded from foo->bar before it can be stored 
 > in nn.  This is true even if you have mem->mem moves, since the
 > source might cause a normal page fault as well.
 > 
 > Please explain the problem you're actaully seeing in more detail.

I already did when we met in person.

>From what I remember, you said that flow would work correctly in this
case iff the value read from memory were first copied to a temporary,
and that's what I'm trying to do.

This is the Java code that is not compiled correctly:

    boolean ok = false;
    int nn = 0;

[ ... ]

    ok = false;
    try
      {
	int[] x = (int[])null;
	nn = x[0];
      }
    catch (NullPointerException _)
      {
	ok = true;
      }

    if (!ok || nn != 0)
      throw new RuntimeException("test failed:3");

The problem is that nn is assigned to a register for the period
between the assignment in the try block and the test after the catch.
That register is not initialized before it is set.

Andrew.


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