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

Re: inserting instructions with Baf



Navindra Umanee wrote:
Chris Pickett <chris.pickett@mail.mcgill.ca> wrote:
  
I can get it to work in Jimple, except that sometimes there are 
intervening bytecodes:

INVOKESTATIC
possible intervening bytecodes
INVOKE<X>
    

Correct me if I'm wrong, but these intervening bytecodes are needed to
load operands on the stack before making the function call.

  
No, you're right.  I didn't explain fully.  I want the intervening bytecodes that push the operands for the INVOKE<X> onto the stack to come _before_ the INVOKESTATIC.  The INVOKESTATIC calls an empty void method, so it can appear anywhere in the bytecode without affecting things.  However, at run-time I replace the INVOKESTATIC with my own non-Java instruction, and it needs to be right before the INVOKE<X>, after all its operands are already on the stack.

  
I tried using Baf, since it works at the instruction level, but I can't 
seem to get a (Patching)Chain of Units that can be cast to Inst ... it 
only works for Stmt.  Another alternative would be some trick in Jimple 
that always put the INVOKESTATIC right before the INVOKE<X>, but I can't 
think of a way to do it.
    

This works fine for me and results in no intervening bytecodes.  

Make sure you are adding the transformation to a proper Baf phase, not
to "jtp" which is specific to Jimple.  I added it to "bop" which I then
enabled from the command line with "-p bop on".
  

Thanks, that was what I was looking for.

Cheers,
Chris