[Soot-list] Locals vs Stack locations when writing class files

David Mohr dmohr at cs.unm.edu
Wed Sep 16 16:09:12 EDT 2009


On Wed, Sep 16, 2009 at 1:32 PM, Patrick Lam <plam at sable.mcgill.ca> wrote:
> David Mohr wrote:
>>
>> Hi,
>> I'm generating some code with soot using Jimple. For some computation,
>> I get intermediate values and I store them in Locals. When the Jimple
>> code gets translated into a class file, I end up with many true local
>> variables for my intermediate values, although I think they should
>> just live on the stack. Is there any way to influence what Jimple
>> Local variables become stack locations and which become local
>> variables in the byte code?
>
> Hi David,
>
> It shouldn't really matter, for a number of reasons.
>
> * Our CC2000 paper describes how we generate bytecode from Jimple. The
> default path is through Baf, and we do load/store optimizations to get code
> which looks similar to javac-generated code. Even if you add more Locals, it
> should not make a difference, and Soot should still generate reasonable
> code.
>
> * Most JVMs do a lot of optimization these days, so that the bytecode
> doesn't really influence what gets run on the machine. Also, there's a lot
> that goes on at the CPU level, so it's really hard to say what happens in
> the end.
>
> By "many", do you mean a few dozen or a few thousand? A few dozen shouldn't
> really make a difference.

With "many" I mean 4 out of 5 of the "temporary" locals I add in
Jimple also appear as locals in the byte code. You're of course right
about the JVM optimizations, so I think I'll just ignore this issue
for now unless I run into some kind of (performance) issue. Thanks for
the reference to the CC paper, I'll have a look.

~David


More information about the Soot-list mailing list