Search in sources :

Example 1 with LoadRetAddrConst

use of org.jikesrvm.osr.bytecodes.LoadRetAddrConst in project JikesRVM by JikesRVM.

the class ExecutionState method generateBinaries.

/**
 * Generating binary code from pseudo code, the size and the code
 * list are padded and well calculated.
 *
 * @param bhead the first pseude bytecode (must be a NOP)
 * @param bsize the size of the bytecode
 * @return generated bytecodes
 */
private static byte[] generateBinaries(PseudoBytecode bhead, int bsize) {
    /* patch the LoalAddrConst instruction, and generate codes. */
    byte[] codes = new byte[bsize];
    /* skip the first NOP */
    PseudoBytecode bcode = bhead.next;
    int pos = 0;
    while (bcode != null) {
        int size = bcode.getSize();
        if (bcode instanceof LoadRetAddrConst) {
            LoadRetAddrConst laddr = (LoadRetAddrConst) bcode;
            /* CAUTION: path relative offset only. */
            laddr.patch(laddr.getOffset() + bsize);
        }
        if (VM.TraceOnStackReplacement)
            VM.sysWriteln(pos + " : " + bcode.toString());
        System.arraycopy(bcode.getBytes(), 0, codes, pos, size);
        pos += size;
        bcode = bcode.next;
    }
    return codes;
}
Also used : PseudoBytecode(org.jikesrvm.osr.bytecodes.PseudoBytecode) LoadRetAddrConst(org.jikesrvm.osr.bytecodes.LoadRetAddrConst)

Aggregations

LoadRetAddrConst (org.jikesrvm.osr.bytecodes.LoadRetAddrConst)1 PseudoBytecode (org.jikesrvm.osr.bytecodes.PseudoBytecode)1