[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: incoherent stack height



On Mon, Sep 20, 2004 at 09:19:07AM -0500, Uwe Dolinsky wrote:
> Hi,
> 
> The method in question:
> 
> static void refer()
> {
>      for (int i=0;i<8;i++)
>      {}
> }
> 
> has the following baf output:
> 
>  push 0
>  store.i i0
>  load.i i0
>  push 8
>  ifcmpge.i return
>  inc.i i0 1
>  goto load.i i0
>  return
> 
> When I insert a dup before the store and delete the subsequent load (which should
> result in the same stack layout) I get:
> 
>    push 0
>    dup1.i
>    store.i i0
>    push 8
>    ifcmpge.i return
>    inc.i i0 1
>    goto push 8
>    return
> 
> which I output right after the modification. Then soot complains:
> 
> Exception in thread "main" java.lang.RuntimeException: incoherent stack height a
> t block merge point Block 1:
> [preds: 0 2 ] [succs: 2 3 ]
> push 8;
> ifcmpge.i return;
> Block 2:
> [preds: 1 ] [succs: 1 ]
> inc.i i0 1;
> goto push 8;
> 
> computed blockHeight == 0 recorded blockHeight = 1
>         at soot.baf.JasminClass.calculateStackHeight(JasminClass.java:1799)
>         at soot.baf.JasminClass.calculateStackHeight(JasminClass.java:1804)
> 
> It compiles fine when I leave the original load instruction in the code together
> with the newly inserted dup.
> 
> What am I doing wrong?

On the path from the beginning of the method, the dup/store may well be
equivalent to the original store/load. However, on the other path, which 
goes from the goto (second-last instruction), you've removed a load
without replacing it with anything. Without having the code to play
with, this is all just speculation, but I would expect that that's the
problem.

Ondrej

> I'm using revision 1792.
> 
> Thanks
> Uwe
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm
>