[Soot-list] Fwd: Jimple Code for comparing floats
Chandan Rupakheti
rupakhcr at clarkson.edu
Mon Jul 27 19:44:53 EDT 2009
---------- Forwarded message ----------
From: Chandan Rupakheti <rupakhcr at clarkson.edu>
Date: Mon, Jul 27, 2009 at 7:41 PM
Subject: Re: [Soot-list] Jimple Code for comparing floats
To: Patrick Lam <plam at sable.mcgill.ca>
Hello Pat,
The byte code for the equals method is as follows:
// access flags 1
public equals(Ljava/lang/Object;)Z
L0
LINENUMBER 7 L0
ALOAD 1
INSTANCEOF test/Test
IFNE L1
L2
LINENUMBER 8 L2
ICONST_0
IRETURN
L1
LINENUMBER 9 L1
ALOAD 1
CHECKCAST test/Test
ASTORE 2
L3
LINENUMBER 10 L3
ALOAD 0
GETFIELD test/Test.field : F
ALOAD 2
GETFIELD test/Test.field : F
FCMPL // Compare the two
floats loaded in the stack by taking them off. If equal push 0 to the stack
...
IFNE L4
ICONST_1
IRETURN
L4
ICONST_0
IRETURN
L5
LOCALVARIABLE this Ltest/Test; L0 L5 0
LOCALVARIABLE o Ljava/lang/Object; L0 L5 1
LOCALVARIABLE that Ltest/Test; L3 L5 2
MAXSTACK = 2
MAXLOCALS = 3
I believe, I did not understand the functionality of cmpl operator in
jimple. Assuming that it is trying to perform similar functionality as FCMPL
of bytecode, it completely make sense now. If the two floats are equal then
the result of cmpl will be zero and the generated jimple code makes perfect
sense now.
I am sorry for impatiently posting in the list without doing some
preliminary research myself. I tried to look at the source code of CmplExpr
/ JCmplExpr but could find any source documentation so could not think of
any other way to resolve the issue.
Thanks,
Chandan
On Mon, Jul 27, 2009 at 6:17 PM, Patrick Lam <plam at sable.mcgill.ca> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Chandan Rupakheti wrote:
> > Hello,
> >
> > I am little surprised on why soot chose to generate jimple using
> > CmplExpr for EqExpr when comparing floats. I have following code:
>
> I'd be surprised if Soot is changing the bytecode. Have you checked the
> original bytecode (using javap, for instance?)
>
> pat
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkpuJ5QACgkQNTVxnNGEyOiOOgCfeWGoT6gzUSpm2QRwYbN62yed
> WQ0AoIBqa/Z3k3O3uVVdomS4rjl2mTxq
> =Hi1E
> -----END PGP SIGNATURE-----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090727/73e80626/attachment.html
More information about the Soot-list
mailing list