Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#91 Bytecode instructions not preserved

open
nobody
decompiler (49)
5
2007-01-12
2007-01-12
Trevor Harmon
No

After JODE completes its analysis, all of the bytecode instructions it has read from the class files are discarded. This is a problem for building tools on top of JODE that need the bytecode data, such as WCET analyzers.

The attached patch fixes that problem, based on advice from Jochen. See: http://sourceforge.net/forum/message.php?msg_id=4050121

The patch simply modifies StructuredBlock.java so that it holds a list of bytecode instructions corresponding to the block. It also modifies Opcodes.java so that when blocks are created, a handle to the bytecode instruction is passed to it. This required changing several subclasses of StructuredBlock to take in an instruction parameter. Finally, the StrucutredBlock.moveDefinitions function was implemented to copy the instructions so that they are preserved during transformations.

(The moveDefinitions function should probably be renamed copyBytecode or something so that it better reflects the purpose of the function. But I left that alone for now.)

Discussion

  • Trevor Harmon
    Trevor Harmon
    2007-01-26

    Logged In: YES
    user_id=720008
    Originator: YES

    I've done some more testing on this, and it works for everything except loop conditions. In the original patch, the moveDefinitions method copies bytecode instructions from "from.getSubBlocks()[0]", but if "from" is a ConditionalBlock, apparently it should instead copy from "from" directly. (I'm not sure why; perhaps there is a bug in the moveDefinitions calls in FlowBlock?)

    In any case, here's a revised implementation of moveDefinitions that works for ConditionalBlocks and all other types of StructuredBlocks:

    // Special-case handling of ConditionalBlocks (bug in FlowBlock?)
    if ( !(from instanceof ConditionalBlock) )
    {
    from = from.getSubBlocks()[0];
    }

    // Copy all instructions from "from" to the beginning of this block's instruction list
    bytecodeInstructions.addAll(0, from.bytecodeInstructions);