use of org.jikesrvm.classloader.FieldReference in project JikesRVM by JikesRVM.
the class TemplateCompilerFramework method genCode.
/**
* Main code generation loop.
*
* @return generated machine code
*/
protected final MachineCode genCode() {
AbstractAssembler asm = getAssembler();
AbstractLister lister = getLister();
emit_prologue();
while (bcodes.hasMoreBytecodes()) {
biStart = bcodes.index();
bytecodeMap[biStart] = asm.getMachineCodeIndex();
asm.resolveForwardReferences(biStart);
starting_bytecode();
int code = bcodes.nextInstruction();
switch(code) {
case JBC_nop:
{
if (shouldPrint)
lister.noteBytecode(biStart, "nop");
break;
}
case JBC_aconst_null:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aconst_null");
emit_aconst_null();
break;
}
case JBC_iconst_m1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_m1");
emit_iconst(-1);
break;
}
case JBC_iconst_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_0");
emit_iconst(0);
break;
}
case JBC_iconst_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_1");
emit_iconst(1);
break;
}
case JBC_iconst_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_2");
emit_iconst(2);
break;
}
case JBC_iconst_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_3");
emit_iconst(3);
break;
}
case JBC_iconst_4:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_4");
emit_iconst(4);
break;
}
case JBC_iconst_5:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iconst_5");
emit_iconst(5);
break;
}
case JBC_lconst_0:
{
// floating-point 0 is long 0
if (shouldPrint)
lister.noteBytecode(biStart, "lconst_0");
emit_lconst(0);
break;
}
case JBC_lconst_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lconst_1");
emit_lconst(1);
break;
}
case JBC_fconst_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fconst_0");
emit_fconst_0();
break;
}
case JBC_fconst_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fconst_1");
emit_fconst_1();
break;
}
case JBC_fconst_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fconst_2");
emit_fconst_2();
break;
}
case JBC_dconst_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dconst_0");
emit_dconst_0();
break;
}
case JBC_dconst_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dconst_1");
emit_dconst_1();
break;
}
case JBC_bipush:
{
int val = bcodes.getByteValue();
if (shouldPrint)
lister.noteBytecode(biStart, "bipush", val);
emit_iconst(val);
break;
}
case JBC_sipush:
{
int val = bcodes.getShortValue();
if (shouldPrint)
lister.noteBytecode(biStart, "sipush", val);
emit_iconst(val);
break;
}
case JBC_ldc:
{
int index = bcodes.getConstantIndex();
if (shouldPrint)
lister.noteBytecode(biStart, "ldc", index);
Offset offset = klass.getLiteralOffset(index);
byte type = klass.getLiteralDescription(index);
emit_ldc(offset, type);
break;
}
case JBC_ldc_w:
{
int index = bcodes.getWideConstantIndex();
if (shouldPrint)
lister.noteBytecode(biStart, "ldc_w", index);
Offset offset = klass.getLiteralOffset(index);
byte type = klass.getLiteralDescription(index);
emit_ldc(offset, type);
break;
}
case JBC_ldc2_w:
{
int index = bcodes.getWideConstantIndex();
if (shouldPrint)
lister.noteBytecode(biStart, "ldc2_w", index);
Offset offset = klass.getLiteralOffset(index);
byte type = klass.getLiteralDescription(index);
emit_ldc2(offset, type);
break;
}
case JBC_iload:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "iload", index);
emit_iload(index);
break;
}
case JBC_lload:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "lload", index);
emit_lload(index);
break;
}
case JBC_fload:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "fload", index);
emit_fload(index);
break;
}
case JBC_dload:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "dload", index);
emit_dload(index);
break;
}
case JBC_aload:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "aload", index);
emit_aload(index);
break;
}
case JBC_iload_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iload_0");
emit_iload(0);
break;
}
case JBC_iload_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iload_1");
emit_iload(1);
break;
}
case JBC_iload_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iload_2");
emit_iload(2);
break;
}
case JBC_iload_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iload_3");
emit_iload(3);
break;
}
case JBC_lload_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lload_0");
emit_lload(0);
break;
}
case JBC_lload_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lload_1");
emit_lload(1);
break;
}
case JBC_lload_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lload_2");
emit_lload(2);
break;
}
case JBC_lload_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lload_3");
emit_lload(3);
break;
}
case JBC_fload_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fload_0");
emit_fload(0);
break;
}
case JBC_fload_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fload_1");
emit_fload(1);
break;
}
case JBC_fload_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fload_2");
emit_fload(2);
break;
}
case JBC_fload_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fload_3");
emit_fload(3);
break;
}
case JBC_dload_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dload_0");
emit_dload(0);
break;
}
case JBC_dload_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dload_1");
emit_dload(1);
break;
}
case JBC_dload_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dload_2");
emit_dload(2);
break;
}
case JBC_dload_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dload_3");
emit_dload(3);
break;
}
case JBC_aload_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aload_0");
emit_aload(0);
break;
}
case JBC_aload_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aload_1");
emit_aload(1);
break;
}
case JBC_aload_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aload_2");
emit_aload(2);
break;
}
case JBC_aload_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aload_3");
emit_aload(3);
break;
}
case JBC_iaload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iaload");
emit_iaload();
break;
}
case JBC_laload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "laload");
emit_laload();
break;
}
case JBC_faload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "faload");
emit_faload();
break;
}
case JBC_daload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "daload");
emit_daload();
break;
}
case JBC_aaload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aaload");
emit_aaload();
break;
}
case JBC_baload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "baload");
emit_baload();
break;
}
case JBC_caload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "caload");
emit_caload();
break;
}
case JBC_saload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "saload");
emit_saload();
break;
}
case JBC_istore:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "istore", index);
emit_istore(index);
break;
}
case JBC_lstore:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "lstore", index);
emit_lstore(index);
break;
}
case JBC_fstore:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "fstore", index);
emit_fstore(index);
break;
}
case JBC_dstore:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "dstore", index);
emit_dstore(index);
break;
}
case JBC_astore:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "astore", index);
emit_astore(index);
break;
}
case JBC_istore_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "istore_0");
emit_istore(0);
break;
}
case JBC_istore_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "istore_1");
emit_istore(1);
break;
}
case JBC_istore_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "istore_2");
emit_istore(2);
break;
}
case JBC_istore_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "istore_3");
emit_istore(3);
break;
}
case JBC_lstore_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lstore_0");
emit_lstore(0);
break;
}
case JBC_lstore_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lstore_1");
emit_lstore(1);
break;
}
case JBC_lstore_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lstore_2");
emit_lstore(2);
break;
}
case JBC_lstore_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lstore_3");
emit_lstore(3);
break;
}
case JBC_fstore_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fstore_0");
emit_fstore(0);
break;
}
case JBC_fstore_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fstore_1");
emit_fstore(1);
break;
}
case JBC_fstore_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fstore_2");
emit_fstore(2);
break;
}
case JBC_fstore_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fstore_3");
emit_fstore(3);
break;
}
case JBC_dstore_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dstore_0");
emit_dstore(0);
break;
}
case JBC_dstore_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dstore_1");
emit_dstore(1);
break;
}
case JBC_dstore_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dstore_2");
emit_dstore(2);
break;
}
case JBC_dstore_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dstore_3");
emit_dstore(3);
break;
}
case JBC_astore_0:
{
if (shouldPrint)
lister.noteBytecode(biStart, "astore_0");
emit_astore(0);
break;
}
case JBC_astore_1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "astore_1");
emit_astore(1);
break;
}
case JBC_astore_2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "astore_2");
emit_astore(2);
break;
}
case JBC_astore_3:
{
if (shouldPrint)
lister.noteBytecode(biStart, "astore_3");
emit_astore(3);
break;
}
case JBC_iastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iastore");
emit_iastore();
break;
}
case JBC_lastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lastore");
emit_lastore();
break;
}
case JBC_fastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fastore");
emit_fastore();
break;
}
case JBC_dastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dastore");
emit_dastore();
break;
}
case JBC_aastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "aastore");
// ArrayStoreException}
if (VM.VerifyUnint && isUninterruptible && doesCheckStore)
forbiddenBytecode("aastore", bcodes.index());
emit_aastore();
break;
}
case JBC_bastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "bastore");
emit_bastore();
break;
}
case JBC_castore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "castore");
emit_castore();
break;
}
case JBC_sastore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "sastore");
emit_sastore();
break;
}
case JBC_pop:
{
if (shouldPrint)
lister.noteBytecode(biStart, "pop");
emit_pop();
break;
}
case JBC_pop2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "pop2");
emit_pop2();
break;
}
case JBC_dup:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dup");
emit_dup();
break;
}
case JBC_dup_x1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dup_x1");
emit_dup_x1();
break;
}
case JBC_dup_x2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dup_x2");
emit_dup_x2();
break;
}
case JBC_dup2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dup2");
emit_dup2();
break;
}
case JBC_dup2_x1:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dup2_x1");
emit_dup2_x1();
break;
}
case JBC_dup2_x2:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dup2_x2");
emit_dup2_x2();
break;
}
case JBC_swap:
{
if (shouldPrint)
lister.noteBytecode(biStart, "swap");
emit_swap();
break;
}
case JBC_iadd:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iadd");
emit_iadd();
break;
}
case JBC_ladd:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ladd");
emit_ladd();
break;
}
case JBC_fadd:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fadd");
emit_fadd();
break;
}
case JBC_dadd:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dadd");
emit_dadd();
break;
}
case JBC_isub:
{
if (shouldPrint)
lister.noteBytecode(biStart, "isub");
emit_isub();
break;
}
case JBC_lsub:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lsub");
emit_lsub();
break;
}
case JBC_fsub:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fsub");
emit_fsub();
break;
}
case JBC_dsub:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dsub");
emit_dsub();
break;
}
case JBC_imul:
{
if (shouldPrint)
lister.noteBytecode(biStart, "imul");
emit_imul();
break;
}
case JBC_lmul:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lmul");
emit_lmul();
break;
}
case JBC_fmul:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fmul");
emit_fmul();
break;
}
case JBC_dmul:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dmul");
emit_dmul();
break;
}
case JBC_idiv:
{
if (shouldPrint)
lister.noteBytecode(biStart, "idiv");
emit_idiv();
break;
}
case JBC_ldiv:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ldiv");
emit_ldiv();
break;
}
case JBC_fdiv:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fdiv");
emit_fdiv();
break;
}
case JBC_ddiv:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ddiv");
emit_ddiv();
break;
}
case JBC_irem:
{
if (shouldPrint)
lister.noteBytecode(biStart, "irem");
emit_irem();
break;
}
case JBC_lrem:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lrem");
emit_lrem();
break;
}
case JBC_frem:
{
if (shouldPrint)
lister.noteBytecode(biStart, "frem");
emit_frem();
break;
}
case JBC_drem:
{
if (shouldPrint)
lister.noteBytecode(biStart, "drem");
emit_drem();
break;
}
case JBC_ineg:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ineg");
emit_ineg();
break;
}
case JBC_lneg:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lneg");
emit_lneg();
break;
}
case JBC_fneg:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fneg");
emit_fneg();
break;
}
case JBC_dneg:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dneg");
emit_dneg();
break;
}
case JBC_ishl:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ishl");
emit_ishl();
break;
}
case JBC_lshl:
{
// l >> n
if (shouldPrint)
lister.noteBytecode(biStart, "lshl");
emit_lshl();
break;
}
case JBC_ishr:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ishr");
emit_ishr();
break;
}
case JBC_lshr:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lshr");
emit_lshr();
break;
}
case JBC_iushr:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iushr");
emit_iushr();
break;
}
case JBC_lushr:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lushr");
emit_lushr();
break;
}
case JBC_iand:
{
if (shouldPrint)
lister.noteBytecode(biStart, "iand");
emit_iand();
break;
}
case JBC_land:
{
if (shouldPrint)
lister.noteBytecode(biStart, "land");
emit_land();
break;
}
case JBC_ior:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ior");
emit_ior();
break;
}
case JBC_lor:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lor");
emit_lor();
break;
}
case JBC_ixor:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ixor");
emit_ixor();
break;
}
case JBC_lxor:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lxor");
emit_lxor();
break;
}
case JBC_iinc:
{
int index = bcodes.getLocalNumber();
int val = bcodes.getIncrement();
if (shouldPrint)
lister.noteBytecode(biStart, "iinc", index, val);
emit_iinc(index, val);
break;
}
case JBC_i2l:
{
if (shouldPrint)
lister.noteBytecode(biStart, "i2l");
emit_i2l();
break;
}
case JBC_i2f:
{
if (shouldPrint)
lister.noteBytecode(biStart, "i2f");
emit_i2f();
break;
}
case JBC_i2d:
{
if (shouldPrint)
lister.noteBytecode(biStart, "i2d");
emit_i2d();
break;
}
case JBC_l2i:
{
if (shouldPrint)
lister.noteBytecode(biStart, "l2i");
emit_l2i();
break;
}
case JBC_l2f:
{
if (shouldPrint)
lister.noteBytecode(biStart, "l2f");
emit_l2f();
break;
}
case JBC_l2d:
{
if (shouldPrint)
lister.noteBytecode(biStart, "l2d");
emit_l2d();
break;
}
case JBC_f2i:
{
if (shouldPrint)
lister.noteBytecode(biStart, "f2i");
emit_f2i();
break;
}
case JBC_f2l:
{
if (shouldPrint)
lister.noteBytecode(biStart, "f2l");
emit_f2l();
break;
}
case JBC_f2d:
{
if (shouldPrint)
lister.noteBytecode(biStart, "f2d");
emit_f2d();
break;
}
case JBC_d2i:
{
if (shouldPrint)
lister.noteBytecode(biStart, "d2i");
emit_d2i();
break;
}
case JBC_d2l:
{
if (shouldPrint)
lister.noteBytecode(biStart, "d2l");
emit_d2l();
break;
}
case JBC_d2f:
{
if (shouldPrint)
lister.noteBytecode(biStart, "d2f");
emit_d2f();
break;
}
case JBC_int2byte:
{
if (shouldPrint)
lister.noteBytecode(biStart, "i2b");
emit_i2b();
break;
}
case JBC_int2char:
{
if (shouldPrint)
lister.noteBytecode(biStart, "i2c");
emit_i2c();
break;
}
case JBC_int2short:
{
if (shouldPrint)
lister.noteBytecode(biStart, "i2s");
emit_i2s();
break;
}
case JBC_lcmp:
{
// a ? b
if (shouldPrint)
lister.noteBytecode(biStart, "lcmp");
emit_lcmp();
break;
}
case JBC_fcmpl:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fcmpl");
emit_DFcmpGL(true, false);
break;
}
case JBC_fcmpg:
{
if (shouldPrint)
lister.noteBytecode(biStart, "fcmpg");
emit_DFcmpGL(true, true);
break;
}
case JBC_dcmpl:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dcmpl");
emit_DFcmpGL(false, false);
break;
}
case JBC_dcmpg:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dcmpg");
emit_DFcmpGL(false, true);
break;
}
case JBC_ifeq:
{
do_if(biStart, BranchCondition.EQ);
break;
}
case JBC_ifne:
{
do_if(biStart, BranchCondition.NE);
break;
}
case JBC_iflt:
{
do_if(biStart, BranchCondition.LT);
break;
}
case JBC_ifge:
{
do_if(biStart, BranchCondition.GE);
break;
}
case JBC_ifgt:
{
do_if(biStart, BranchCondition.GT);
break;
}
case JBC_ifle:
{
do_if(biStart, BranchCondition.LE);
break;
}
case JBC_if_icmpeq:
{
do_if_icmp(biStart, BranchCondition.EQ);
break;
}
case JBC_if_icmpne:
{
do_if_icmp(biStart, BranchCondition.NE);
break;
}
case JBC_if_icmplt:
{
do_if_icmp(biStart, BranchCondition.LT);
break;
}
case JBC_if_icmpge:
{
do_if_icmp(biStart, BranchCondition.GE);
break;
}
case JBC_if_icmpgt:
{
do_if_icmp(biStart, BranchCondition.GT);
break;
}
case JBC_if_icmple:
{
do_if_icmp(biStart, BranchCondition.LE);
break;
}
case JBC_if_acmpeq:
{
int offset = bcodes.getBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "if_acmpeq", offset, bTarget);
if (offset <= 0)
emit_threadSwitchTest(RVMThread.BACKEDGE);
emit_if_acmpeq(bTarget);
break;
}
case JBC_if_acmpne:
{
int offset = bcodes.getBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "if_acmpne", offset, bTarget);
if (offset <= 0)
emit_threadSwitchTest(RVMThread.BACKEDGE);
emit_if_acmpne(bTarget);
break;
}
case JBC_goto:
{
int offset = bcodes.getBranchOffset();
// bi has been bumped by 3 already
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "goto", offset, bTarget);
if (offset <= 0)
emit_threadSwitchTest(RVMThread.BACKEDGE);
emit_goto(bTarget);
break;
}
case JBC_jsr:
{
int offset = bcodes.getBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "jsr", offset, bTarget);
emit_jsr(bTarget);
break;
}
case JBC_ret:
{
int index = bcodes.getLocalNumber();
if (shouldPrint)
lister.noteBytecode(biStart, "ret ", index);
emit_ret(index);
break;
}
case JBC_tableswitch:
{
bcodes.alignSwitch();
int defaultval = bcodes.getDefaultSwitchOffset();
int low = bcodes.getLowSwitchValue();
int high = bcodes.getHighSwitchValue();
if (shouldPrint)
lister.noteTableswitchBytecode(biStart, low, high, defaultval);
emit_tableswitch(defaultval, low, high);
break;
}
case JBC_lookupswitch:
{
bcodes.alignSwitch();
int defaultval = bcodes.getDefaultSwitchOffset();
int npairs = bcodes.getSwitchLength();
if (shouldPrint)
lister.noteLookupswitchBytecode(biStart, npairs, defaultval);
emit_lookupswitch(defaultval, npairs);
break;
}
case JBC_ireturn:
{
if (shouldPrint)
lister.noteBytecode(biStart, "ireturn");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
emit_ireturn();
break;
}
case JBC_lreturn:
{
if (shouldPrint)
lister.noteBytecode(biStart, "lreturn");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
emit_lreturn();
break;
}
case JBC_freturn:
{
if (shouldPrint)
lister.noteBytecode(biStart, "freturn");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
emit_freturn();
break;
}
case JBC_dreturn:
{
if (shouldPrint)
lister.noteBytecode(biStart, "dreturn");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
emit_dreturn();
break;
}
case JBC_areturn:
{
if (shouldPrint)
lister.noteBytecode(biStart, "areturn");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
emit_areturn();
break;
}
case JBC_return:
{
if (shouldPrint)
lister.noteBytecode(biStart, "return");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
emit_return();
break;
}
case JBC_getstatic:
{
FieldReference fieldRef = bcodes.getFieldReference();
if (shouldPrint)
lister.noteBytecode(biStart, "getstatic", fieldRef);
if (fieldRef.needsDynamicLink(method)) {
// interruptions
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("unresolved getstatic ", fieldRef, bcodes.index());
emit_unresolved_getstatic(fieldRef);
} else {
emit_resolved_getstatic(fieldRef);
}
break;
}
case JBC_putstatic:
{
FieldReference fieldRef = bcodes.getFieldReference();
if (shouldPrint)
lister.noteBytecode(biStart, "putstatic", fieldRef);
if (fieldRef.needsDynamicLink(method)) {
// interruptions
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("unresolved putstatic ", fieldRef, bcodes.index());
emit_unresolved_putstatic(fieldRef);
} else {
emit_resolved_putstatic(fieldRef);
}
break;
}
case JBC_getfield:
{
FieldReference fieldRef = bcodes.getFieldReference();
if (shouldPrint)
lister.noteBytecode(biStart, "getfield", fieldRef);
if (fieldRef.needsDynamicLink(method)) {
// interruptions
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("unresolved getfield ", fieldRef, bcodes.index());
emit_unresolved_getfield(fieldRef);
} else {
emit_resolved_getfield(fieldRef);
}
break;
}
case JBC_putfield:
{
FieldReference fieldRef = bcodes.getFieldReference();
if (shouldPrint)
lister.noteBytecode(biStart, "putfield", fieldRef);
if (fieldRef.needsDynamicLink(method)) {
// interruptions
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("unresolved putfield ", fieldRef, bcodes.index());
emit_unresolved_putfield(fieldRef);
} else {
emit_resolved_putfield(fieldRef);
}
break;
}
case JBC_invokevirtual:
{
ForwardReference xx = null;
if (biStart == this.pendingIdx) {
// goto X
ForwardReference x = emit_pending_goto(0);
// pendingIdx: (target of pending goto in prologue)
this.pendingRef.resolve(asm);
CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
if (VM.VerifyAssertions)
VM._assert(cm.isSpecialForOSR());
// invoke_cmid
emit_invoke_compiledmethod(cm);
// goto XX
xx = emit_pending_goto(0);
// X:
x.resolve(asm);
}
MethodReference methodRef = bcodes.getMethodReference();
if (shouldPrint)
lister.noteBytecode(biStart, "invokevirtual", methodRef);
if (methodRef.getType().isMagicType()) {
if (emit_Magic(methodRef)) {
break;
}
}
if (methodRef.isMiranda()) {
/* Special case of abstract interface method should generate
* an invokeinterface, despite the compiler claiming it should
* be invokevirtual.
*/
if (shouldPrint)
lister.noteBytecode(biStart, "invokeinterface", methodRef);
// causes runtime checks that can be interrupted
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("invokeinterface ", methodRef, bcodes.index());
emit_invokeinterface(methodRef);
} else {
if (methodRef.needsDynamicLink(method)) {
// cause interruptions
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("unresolved invokevirtual ", methodRef, bcodes.index());
emit_unresolved_invokevirtual(methodRef);
} else {
if (VM.VerifyUnint && !isInterruptible)
checkTarget(methodRef.peekResolvedMethod(), bcodes.index());
emit_resolved_invokevirtual(methodRef);
}
}
if (xx != null) {
// XX:
xx.resolve(asm);
}
break;
}
case JBC_invokespecial:
{
ForwardReference xx = null;
if (biStart == this.pendingIdx) {
// goto X
ForwardReference x = emit_pending_goto(0);
// pendingIdx: (target of pending goto in prologue)
this.pendingRef.resolve(asm);
CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
if (VM.VerifyAssertions)
VM._assert(cm.isSpecialForOSR());
// invoke_cmid
emit_invoke_compiledmethod(cm);
// goto XX
xx = emit_pending_goto(0);
// X:
x.resolve(asm);
}
MethodReference methodRef = bcodes.getMethodReference();
if (shouldPrint)
lister.noteBytecode(biStart, "invokespecial", methodRef);
RVMMethod target = methodRef.resolveInvokeSpecial();
if (target != null) {
if (VM.VerifyUnint && !isInterruptible)
checkTarget(target, bcodes.index());
emit_resolved_invokespecial(methodRef, target);
} else {
emit_unresolved_invokespecial(methodRef);
}
if (xx != null) {
// XX:
xx.resolve(asm);
}
break;
}
case JBC_invokestatic:
{
ForwardReference xx = null;
if (biStart == this.pendingIdx) {
// goto X
ForwardReference x = emit_pending_goto(0);
// pendingIdx: (target of pending goto in prologue)
this.pendingRef.resolve(asm);
CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
if (VM.VerifyAssertions)
VM._assert(cm.isSpecialForOSR());
// invoke_cmid
emit_invoke_compiledmethod(cm);
// goto XX
xx = emit_pending_goto(0);
// X:
x.resolve(asm);
}
MethodReference methodRef = bcodes.getMethodReference();
if (shouldPrint)
lister.noteBytecode(biStart, "invokestatic", methodRef);
if (methodRef.isMagic()) {
if (emit_Magic(methodRef)) {
break;
}
}
if (methodRef.needsDynamicLink(method)) {
// cause interruptions
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("unresolved invokestatic ", methodRef, bcodes.index());
emit_unresolved_invokestatic(methodRef);
} else {
if (VM.VerifyUnint && !isInterruptible)
checkTarget(methodRef.peekResolvedMethod(), bcodes.index());
emit_resolved_invokestatic(methodRef);
}
if (xx != null) {
// XX:
xx.resolve(asm);
}
break;
}
case JBC_invokeinterface:
{
ForwardReference xx = null;
if (biStart == this.pendingIdx) {
// goto X
ForwardReference x = emit_pending_goto(0);
// pendingIdx: (target of pending goto in prologue)
this.pendingRef.resolve(asm);
CompiledMethod cm = CompiledMethods.getCompiledMethod(this.pendingCMID);
if (VM.VerifyAssertions)
VM._assert(cm.isSpecialForOSR());
// invoke_cmid
emit_invoke_compiledmethod(cm);
// goto XX
xx = emit_pending_goto(0);
// X:
x.resolve(asm);
}
MethodReference methodRef = bcodes.getMethodReference();
bcodes.alignInvokeInterface();
if (shouldPrint)
lister.noteBytecode(biStart, "invokeinterface", methodRef);
// causes runtime checks that can be interrupted
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("invokeinterface ", methodRef, bcodes.index());
emit_invokeinterface(methodRef);
if (xx != null) {
// XX:
xx.resolve(asm);
}
break;
}
case JBC_invokedynamic:
{
if (shouldPrint)
lister.noteBytecode(biStart, "unused");
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
break;
}
case JBC_new:
{
TypeReference typeRef = bcodes.getTypeReference();
if (shouldPrint)
lister.noteBytecode(biStart, "new", typeRef);
// that are interruptible
if (VM.VerifyUnint && isUninterruptible)
forbiddenBytecode("new ", typeRef, bcodes.index());
RVMType type = typeRef.peekType();
if (type != null && (type.isInitialized() || type.isInBootImage())) {
emit_resolved_new(type.asClass());
} else {
if (VM.VerifyUnint && isUnpreemptible)
forbiddenBytecode("unresolved new ", typeRef, bcodes.index());
emit_unresolved_new(typeRef);
}
break;
}
case JBC_newarray:
{
int atype = bcodes.getArrayElementType();
RVMArray array = RVMArray.getPrimitiveArrayType(atype);
if (VM.VerifyAssertions) {
boolean resolved = array.isResolved();
if (!resolved) {
String msg = "Found reference to unresolved array type " + array + " while compiling newarray bytecode in method " + method;
VM._assert(VM.NOT_REACHED, msg);
}
}
// that are interruptible
if (shouldPrint)
lister.noteBytecode(biStart, "newarray", array.getTypeRef());
if (VM.VerifyUnint && isUninterruptible)
forbiddenBytecode("newarray ", array, bcodes.index());
emit_resolved_newarray(array);
break;
}
case JBC_anewarray:
{
TypeReference elementTypeRef = bcodes.getTypeReference();
TypeReference arrayRef = elementTypeRef.getArrayTypeForElementType();
if (shouldPrint)
lister.noteBytecode(biStart, "anewarray new", arrayRef);
// that are interruptible
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("anewarray ", arrayRef, bcodes.index());
if (VM.VerifyAssertions && elementTypeRef.isUnboxedType()) {
String msg = "During compilation of " + method + " found an anewarray of " + elementTypeRef + "\n" + "You must use the 'create' function to create an array of this type";
VM._assert(VM.NOT_REACHED, msg);
}
RVMArray array = (RVMArray) arrayRef.peekType();
if (RVMType.JavaLangObjectType.isInstantiated()) {
// We need Object to be instantiated because we are going to mine it's TIB to get entries for array methods...
if (array == null || !(array.isInitialized() || array.isInBootImage())) {
RVMType elementType = elementTypeRef.peekType();
if (elementType != null && (elementType.isInitialized() || elementType.isInBootImage())) {
if (array == null) {
array = (RVMArray) arrayRef.resolve();
}
array.resolve();
array.instantiate();
}
}
}
if (array != null && (array.isInitialized() || array.isInBootImage())) {
emit_resolved_newarray(array);
} else {
emit_unresolved_newarray(arrayRef);
}
break;
}
case JBC_arraylength:
{
if (shouldPrint)
lister.noteBytecode(biStart, "arraylength");
emit_arraylength();
break;
}
case JBC_athrow:
{
if (shouldPrint)
lister.noteBytecode(biStart, "athrow");
if (VM.UseEpilogueYieldPoints)
emit_threadSwitchTest(RVMThread.EPILOGUE);
// that are interruptible
if (VM.VerifyUnint && isUninterruptible)
forbiddenBytecode("athrow", bcodes.index());
emit_athrow();
break;
}
case JBC_checkcast:
{
TypeReference typeRef = bcodes.getTypeReference();
if (shouldPrint)
lister.noteBytecode(biStart, "checkcast", typeRef);
RVMType type = typeRef.peekType();
if (type != null) {
if (type.isClassType()) {
RVMClass cType = type.asClass();
if (cType.isFinal()) {
emit_checkcast_final(cType);
break;
} else if (cType.isResolved()) {
if (cType.isInterface()) {
emit_checkcast_resolvedInterface(cType);
} else {
emit_checkcast_resolvedClass(cType);
}
break;
}
// else fall through to emit_checkcast
} else if (type.isArrayType()) {
RVMType elemType = type.asArray().getElementType();
if (elemType.isPrimitiveType() || elemType.isUnboxedType() || (elemType.isClassType() && elemType.asClass().isFinal())) {
emit_checkcast_final(type);
break;
}
// else fall through to emit_checkcast
} else {
// checkcast to a primitive. Must be a word type.
if (VM.VerifyAssertions)
VM._assert(type.getTypeRef().isUnboxedType());
break;
}
}
// that executes via interruptible code
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("checkcast ", typeRef, bcodes.index());
emit_checkcast(typeRef);
break;
}
case JBC_instanceof:
{
TypeReference typeRef = bcodes.getTypeReference();
if (shouldPrint)
lister.noteBytecode(biStart, "instanceof", typeRef);
RVMType type = typeRef.peekType();
if (type != null) {
if (type.isClassType()) {
RVMClass cType = type.asClass();
if (cType.isFinal()) {
emit_instanceof_final(type);
break;
} else if (cType.isResolved()) {
if (cType.isInterface()) {
emit_instanceof_resolvedInterface(cType);
} else {
emit_instanceof_resolvedClass(cType);
}
break;
}
} else if (type.isArrayType()) {
RVMType elemType = type.asArray().getElementType();
if (elemType.isPrimitiveType() || elemType.isUnboxedType() || (elemType.isClassType() && elemType.asClass().isFinal())) {
emit_instanceof_final(type);
break;
}
}
}
// for its implementation
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("instanceof ", typeRef, bcodes.index());
emit_instanceof(typeRef);
break;
}
case JBC_monitorenter:
{
if (shouldPrint)
lister.noteBytecode(biStart, "monitorenter");
// for its implementation
if (VM.VerifyUnint && isUninterruptible)
forbiddenBytecode("monitorenter", bcodes.index());
emit_monitorenter();
break;
}
case JBC_monitorexit:
{
if (shouldPrint)
lister.noteBytecode(biStart, "monitorexit");
// for its implementation
if (VM.VerifyUnint && isUninterruptible)
forbiddenBytecode("monitorexit", bcodes.index());
emit_monitorexit();
break;
}
case JBC_wide:
{
int widecode = bcodes.getWideOpcode();
int index = bcodes.getWideLocalNumber();
switch(widecode) {
case JBC_iload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide iload", index);
emit_iload(index);
break;
}
case JBC_lload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide lload", index);
emit_lload(index);
break;
}
case JBC_fload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide fload", index);
emit_fload(index);
break;
}
case JBC_dload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide dload", index);
emit_dload(index);
break;
}
case JBC_aload:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide aload", index);
emit_aload(index);
break;
}
case JBC_istore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide istore", index);
emit_istore(index);
break;
}
case JBC_lstore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide lstore", index);
emit_lstore(index);
break;
}
case JBC_fstore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide fstore", index);
emit_fstore(index);
break;
}
case JBC_dstore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide dstore", index);
emit_dstore(index);
break;
}
case JBC_astore:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide astore", index);
emit_astore(index);
break;
}
case JBC_iinc:
{
int val = bcodes.getWideIncrement();
if (shouldPrint)
lister.noteBytecode(biStart, "wide inc", index, val);
emit_iinc(index, val);
break;
}
case JBC_ret:
{
if (shouldPrint)
lister.noteBytecode(biStart, "wide ret", index);
emit_ret(index);
break;
}
default:
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
break;
}
case JBC_multianewarray:
{
TypeReference typeRef = bcodes.getTypeReference();
int dimensions = bcodes.getArrayDimension();
if (shouldPrint)
lister.noteBytecode(biStart, "multianewarray", typeRef);
// that are interruptible
if (VM.VerifyUnint && !isInterruptible)
forbiddenBytecode("multianewarray", bcodes.index());
emit_multianewarray(typeRef, dimensions);
break;
}
case JBC_ifnull:
{
int offset = bcodes.getBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "ifnull", offset, bTarget);
if (offset <= 0)
emit_threadSwitchTest(RVMThread.BACKEDGE);
emit_ifnull(bTarget);
break;
}
case JBC_ifnonnull:
{
int offset = bcodes.getBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "ifnonnull", offset, bTarget);
if (offset <= 0)
emit_threadSwitchTest(RVMThread.BACKEDGE);
emit_ifnonnull(bTarget);
break;
}
case JBC_goto_w:
{
int offset = bcodes.getWideBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "goto_w", offset, bTarget);
if (offset <= 0)
emit_threadSwitchTest(RVMThread.BACKEDGE);
emit_goto(bTarget);
break;
}
case JBC_jsr_w:
{
int offset = bcodes.getWideBranchOffset();
int bTarget = biStart + offset;
if (shouldPrint)
lister.noteBranchBytecode(biStart, "jsr_w", offset, bTarget);
emit_jsr(bTarget);
break;
}
/* CAUTION: cannot use JBC_impdep1, which is 0xfffffffe (signed),
* this is not consistent with OPT compiler.
*/
case JBC_impdep1:
/* --- pseudo bytecode --- */
{
if (VM.BuildForAdaptiveSystem) {
int pseudo_opcode = bcodes.nextPseudoInstruction();
// pseudo instruction
switch(pseudo_opcode) {
case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadIntConst:
{
int value = bcodes.readIntConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_int", value);
Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateIntSizeLiteral(value));
emit_ldc(offset, CP_INT);
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadLongConst:
{
// fetch8BytesUnsigned();
long value = bcodes.readLongConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_long", value);
Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateLongSizeLiteral(value));
emit_ldc2(offset, CP_LONG);
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadWordConst:
{
if (VM.BuildFor32Addr) {
int value = bcodes.readIntConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_word " + Integer.toHexString(value));
Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateIntSizeLiteral(value));
emit_ldc(offset, CP_INT);
} else {
long value = bcodes.readLongConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_word " + Long.toHexString(value));
Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateLongSizeLiteral(value));
emit_ldc2(offset, CP_LONG);
// dirty hack
emit_l2i();
}
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadFloatConst:
{
// fetch4BytesSigned();
int ibits = bcodes.readIntConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_float", ibits);
Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateIntSizeLiteral(ibits));
emit_ldc(offset, CP_FLOAT);
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadDoubleConst:
{
// fetch8BytesUnsigned();
long lbits = bcodes.readLongConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_double", lbits);
Offset offset = Offset.fromIntSignExtend(Statics.findOrCreateLongSizeLiteral(lbits));
emit_ldc2(offset, CP_DOUBLE);
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_LoadRetAddrConst:
{
// fetch4BytesSigned();
int bcIndex = bcodes.readIntConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_load_retaddr", bcIndex);
// for bytecode to get future bytecode's address
// we register it and patch it later.
emit_loadretaddrconst(bcIndex);
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_InvokeStatic:
{
// fetch4BytesSigned();
int targetidx = bcodes.readIntConst();
RVMMethod methodRef = InvokeStatic.targetMethod(targetidx);
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_invokestatic", methodRef);
emit_resolved_invokestatic(methodRef.getMemberRef().asMethodReference());
break;
}
/*
case org.jikesrvm.osr.OSRConstants.PSEUDO_CheckCast: {
if (shouldPrint) lister.noteBytecode(biStart, "pseudo_checkcast");
// fetch 4 byte type id
int tid = bcodes.readIntConst(); // fetch4BytesSigned();
// do nothing now
break;
}
*/
case org.jikesrvm.osr.OSRConstants.PSEUDO_InvokeCompiledMethod:
{
// fetch4BytesSigned(); // callee's cmid
int cmid = bcodes.readIntConst();
int origIdx = // fetch4BytesSigned(); // orginal bytecode index of this call (for build gc map)
bcodes.readIntConst();
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_invoke_cmid", cmid);
this.pendingCMID = cmid;
this.pendingIdx = origIdx + this.method.getOsrPrologueLength();
this.pendingRef = emit_pending_goto(this.pendingIdx);
/*
CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
if (VM.VerifyAssertions) VM._assert(cm.isSpecialForOSR());
emit_invoke_compiledmethod(cm);
*/
break;
}
case org.jikesrvm.osr.OSRConstants.PSEUDO_ParamInitEnd:
{
if (shouldPrint)
lister.noteBytecode(biStart, "pseudo_paraminitend");
// now we can inserted stack overflow check,
emit_deferred_prologue();
break;
}
default:
if (VM.TraceOnStackReplacement) {
VM.sysWriteln("Unexpected PSEUDO code " + Services.intAsHexString(pseudo_opcode));
}
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
break;
}
} else {
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
break;
}
default:
VM.sysWriteln("BaselineCompilerImpl: unexpected bytecode: " + Services.getHexString(code, false));
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
ending_bytecode();
}
bytecodeMap[bcodes.length()] = asm.getMachineCodeIndex();
ending_method();
return new MachineCode(getAssembler().getMachineCodes(), bytecodeMap);
}
use of org.jikesrvm.classloader.FieldReference in project JikesRVM by JikesRVM.
the class ObjectReplacer method scalarReplace.
/**
* Replace a given use of a object with its scalar equivalent
*
* @param use the use to replace
* @param scalars an array of scalar register operands to replace
* the object's fields with
* @param fields the object's fields
* @param visited the registers that were already seen
*/
private void scalarReplace(RegisterOperand use, RegisterOperand[] scalars, ArrayList<RVMField> fields, Set<Register> visited) {
Instruction inst = use.instruction;
try {
switch(inst.getOpcode()) {
case PUTFIELD_opcode:
{
FieldReference fr = PutField.getLocation(inst).getFieldRef();
if (VM.VerifyAssertions)
VM._assert(fr.isResolved());
RVMField f = fr.peekResolvedField();
int index = fields.indexOf(f);
TypeReference type = scalars[index].getType();
Operator moveOp = IRTools.getMoveOp(type);
Instruction i = Move.create(moveOp, scalars[index].copyRO(), PutField.getClearValue(inst));
inst.insertBefore(i);
DefUse.removeInstructionAndUpdateDU(inst);
DefUse.updateDUForNewInstruction(i);
}
break;
case GETFIELD_opcode:
{
FieldReference fr = GetField.getLocation(inst).getFieldRef();
if (VM.VerifyAssertions)
VM._assert(fr.isResolved());
RVMField f = fr.peekResolvedField();
int index = fields.indexOf(f);
TypeReference type = scalars[index].getType();
Operator moveOp = IRTools.getMoveOp(type);
Instruction i = Move.create(moveOp, GetField.getClearResult(inst), scalars[index].copyRO());
inst.insertBefore(i);
DefUse.removeInstructionAndUpdateDU(inst);
DefUse.updateDUForNewInstruction(i);
}
break;
case MONITORENTER_opcode:
inst.insertBefore(Empty.create(READ_CEILING));
DefUse.removeInstructionAndUpdateDU(inst);
break;
case MONITOREXIT_opcode:
inst.insertBefore(Empty.create(WRITE_FLOOR));
DefUse.removeInstructionAndUpdateDU(inst);
break;
case CALL_opcode:
case NULL_CHECK_opcode:
// (SJF) TODO: Why wasn't this caught by BC2IR for
// java.lang.Double.<init> (Ljava/lang/String;)V ?
DefUse.removeInstructionAndUpdateDU(inst);
break;
case CHECKCAST_opcode:
case CHECKCAST_NOTNULL_opcode:
case CHECKCAST_UNRESOLVED_opcode:
{
// We cannot handle removing the checkcast if the result of the
// checkcast test is unknown
TypeReference lhsType = TypeCheck.getType(inst).getTypeRef();
if (ClassLoaderProxy.includesType(lhsType, klass.getTypeRef()) == YES) {
if (visited == null) {
visited = new HashSet<Register>();
}
Register copy = TypeCheck.getResult(inst).getRegister();
if (!visited.contains(copy)) {
visited.add(copy);
transform2(copy, inst, scalars, fields, visited);
// NB will remove inst
} else {
DefUse.removeInstructionAndUpdateDU(inst);
}
} else {
Instruction i2 = Trap.create(TRAP, null, TrapCodeOperand.CheckCast());
DefUse.replaceInstructionAndUpdateDU(inst, i2);
}
}
break;
case INSTANCEOF_opcode:
case INSTANCEOF_NOTNULL_opcode:
case INSTANCEOF_UNRESOLVED_opcode:
{
// We cannot handle removing the instanceof if the result of the
// instanceof test is unknown
TypeReference lhsType = InstanceOf.getType(inst).getTypeRef();
Instruction i2;
if (ClassLoaderProxy.includesType(lhsType, klass.getTypeRef()) == YES) {
i2 = Move.create(INT_MOVE, InstanceOf.getClearResult(inst), IC(1));
} else {
i2 = Move.create(INT_MOVE, InstanceOf.getClearResult(inst), IC(0));
}
DefUse.replaceInstructionAndUpdateDU(inst, i2);
}
break;
case GET_OBJ_TIB_opcode:
{
Instruction i2 = Move.create(REF_MOVE, GuardedUnary.getClearResult(inst), new TIBConstantOperand(klass));
DefUse.replaceInstructionAndUpdateDU(inst, i2);
}
break;
case REF_MOVE_opcode:
{
if (visited == null) {
visited = new HashSet<Register>();
}
Register copy = Move.getResult(use.instruction).getRegister();
if (!visited.contains(copy)) {
visited.add(copy);
transform2(copy, inst, scalars, fields, visited);
// NB will remove inst
} else {
DefUse.removeInstructionAndUpdateDU(inst);
}
}
break;
default:
throw new OptimizingCompilerException("ObjectReplacer: unexpected use " + inst);
}
} catch (Exception e) {
OptimizingCompilerException oe = new OptimizingCompilerException("Error handling use (" + use + ") of: " + inst);
oe.initCause(e);
throw oe;
}
}
use of org.jikesrvm.classloader.FieldReference in project JikesRVM by JikesRVM.
the class SSADictionary method getStaticHelper.
/**
* Record the effects of a getstatic instruction on the heap array
* SSA form. Register the heap variables that this instruction uses and
* defs. Note that if inserting uphi functions, a getstatic defs a new
* heap variable name.
*
* @param s the getstatic instruction
* @param b the basic block containing s
*/
private void getStaticHelper(Instruction s, BasicBlock b) {
LocationOperand locOp = GetStatic.getLocation(s);
FieldReference field = locOp.getFieldRef();
registerUse(s, field);
if (uphi) {
registerDef(s, b, field);
}
}
use of org.jikesrvm.classloader.FieldReference in project JikesRVM by JikesRVM.
the class SSADictionary method putStaticHelper.
/**
* Record the effects of a putstatic instruction on the heap array
* SSA form. Register the heap variables that this instruction uses and
* defs.
*
* @param s the putstatic instruction
* @param b the basic block containing s
*/
private void putStaticHelper(Instruction s, BasicBlock b) {
LocationOperand locOp = PutStatic.getLocation(s);
FieldReference field = locOp.getFieldRef();
registerUse(s, field);
registerDef(s, b, field);
}
use of org.jikesrvm.classloader.FieldReference in project JikesRVM by JikesRVM.
the class ExpandRuntimeServices method perform.
/**
* Given an HIR, expand operators that are implemented as calls to
* runtime service methods. This method should be called as one of the
* first steps in lowering HIR into LIR.
*
* @param ir The HIR to expand
*/
@Override
public void perform(IR ir) {
// resync generation context -- yuck...
ir.getGc().resync();
for (Instruction inst = ir.firstInstructionInCodeOrder(); inst != null; inst = next) {
next = inst.nextInstructionInCodeOrder();
int opcode = inst.getOpcode();
switch(opcode) {
case NEW_opcode:
{
TypeOperand Type = New.getClearType(inst);
RVMClass cls = (RVMClass) Type.getVMType();
IntConstantOperand hasFinalizer = IRTools.IC(cls.hasFinalizer() ? 1 : 0);
RVMMethod callSite = inst.position().getMethod();
IntConstantOperand allocator = IRTools.IC(MemoryManager.pickAllocator(cls, callSite));
IntConstantOperand align = IRTools.IC(ObjectModel.getAlignment(cls));
IntConstantOperand offset = IRTools.IC(ObjectModel.getOffsetForAlignment(cls, false));
Operand tib = ConvertToLowLevelIR.getTIB(inst, ir, Type);
if (VM.BuildForIA32 && VM.runningVM) {
// shield BC2IR from address constants
RegisterOperand tmp = ir.regpool.makeTemp(TypeReference.TIB);
inst.insertBefore(Move.create(REF_MOVE, tmp, tib));
tib = tmp.copyRO();
}
IntConstantOperand site = IRTools.IC(MemoryManager.getAllocationSite(true));
RVMMethod target = Entrypoints.resolvedNewScalarMethod;
Call.mutate7(inst, CALL, New.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), IRTools.IC(cls.getInstanceSize()), tib, hasFinalizer, allocator, align, offset, site);
next = inst.prevInstructionInCodeOrder();
if (ir.options.H2L_INLINE_NEW) {
if (inst.getBasicBlock().getInfrequent())
container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst, ir);
}
}
}
break;
case NEW_UNRESOLVED_opcode:
{
int typeRefId = New.getType(inst).getTypeRef().getId();
RVMMethod target = Entrypoints.unresolvedNewScalarMethod;
IntConstantOperand site = IRTools.IC(MemoryManager.getAllocationSite(true));
Call.mutate2(inst, CALL, New.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), IRTools.IC(typeRefId), site);
}
break;
case NEWARRAY_opcode:
{
TypeOperand Array = NewArray.getClearType(inst);
RVMArray array = (RVMArray) Array.getVMType();
Operand numberElements = NewArray.getClearSize(inst);
boolean inline = numberElements instanceof IntConstantOperand;
Operand width = IRTools.IC(array.getLogElementSize());
Operand headerSize = IRTools.IC(ObjectModel.computeArrayHeaderSize(array));
RVMMethod callSite = inst.position().getMethod();
IntConstantOperand allocator = IRTools.IC(MemoryManager.pickAllocator(array, callSite));
IntConstantOperand align = IRTools.IC(ObjectModel.getAlignment(array));
IntConstantOperand offset = IRTools.IC(ObjectModel.getOffsetForAlignment(array, false));
Operand tib = ConvertToLowLevelIR.getTIB(inst, ir, Array);
if (VM.BuildForIA32 && VM.runningVM) {
// shield BC2IR from address constants
RegisterOperand tmp = ir.regpool.makeTemp(TypeReference.TIB);
inst.insertBefore(Move.create(REF_MOVE, tmp, tib));
tib = tmp.copyRO();
}
IntConstantOperand site = IRTools.IC(MemoryManager.getAllocationSite(true));
RVMMethod target = Entrypoints.resolvedNewArrayMethod;
Call.mutate8(inst, CALL, NewArray.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), numberElements, width, headerSize, tib, allocator, align, offset, site);
next = inst.prevInstructionInCodeOrder();
if (inline && ir.options.H2L_INLINE_NEW) {
if (inst.getBasicBlock().getInfrequent())
container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst, ir);
}
}
}
break;
case NEWARRAY_UNRESOLVED_opcode:
{
int typeRefId = NewArray.getType(inst).getTypeRef().getId();
Operand numberElements = NewArray.getClearSize(inst);
RVMMethod target = Entrypoints.unresolvedNewArrayMethod;
IntConstantOperand site = IRTools.IC(MemoryManager.getAllocationSite(true));
Call.mutate3(inst, CALL, NewArray.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), numberElements, IRTools.IC(typeRefId), site);
}
break;
case NEWOBJMULTIARRAY_opcode:
{
int dimensions = Multianewarray.getNumberOfDimensions(inst);
RVMMethod callSite = inst.position().getMethod();
int typeRefId = Multianewarray.getType(inst).getTypeRef().getId();
if (dimensions == 2) {
RVMMethod target = Entrypoints.optNew2DArrayMethod;
Call.mutate4(inst, CALL, Multianewarray.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), IRTools.IC(callSite.getId()), Multianewarray.getClearDimension(inst, 0), Multianewarray.getClearDimension(inst, 1), IRTools.IC(typeRefId));
} else {
// Step 1: Create an int array to hold the dimensions.
TypeOperand dimArrayType = new TypeOperand(RVMArray.IntArray);
RegisterOperand dimArray = ir.regpool.makeTemp(TypeReference.IntArray);
dimArray.setPreciseType();
next = NewArray.create(NEWARRAY, dimArray, dimArrayType, new IntConstantOperand(dimensions));
inst.insertBefore(next);
// Step 2: Assign the dimension values to dimArray
for (int i = 0; i < dimensions; i++) {
LocationOperand loc = new LocationOperand(TypeReference.Int);
inst.insertBefore(AStore.create(INT_ASTORE, Multianewarray.getClearDimension(inst, i), dimArray.copyD2U(), IRTools.IC(i), loc, IRTools.TG()));
}
// Step 3. Plant call to OptLinker.newArrayArray
RVMMethod target = Entrypoints.optNewArrayArrayMethod;
Call.mutate3(inst, CALL, Multianewarray.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), IRTools.IC(callSite.getId()), dimArray.copyD2U(), IRTools.IC(typeRefId));
}
}
break;
case ATHROW_opcode:
{
RVMMethod target = Entrypoints.athrowMethod;
MethodOperand methodOp = MethodOperand.STATIC(target);
// Record the fact that this is a non-returning call.
methodOp.setIsNonReturningCall(true);
Call.mutate1(inst, CALL, null, IRTools.AC(target.getOffset()), methodOp, Athrow.getClearValue(inst));
}
break;
case MONITORENTER_opcode:
{
Operand ref = MonitorOp.getClearRef(inst);
RVMType refType = ref.getType().peekType();
if (refType != null && !refType.getThinLockOffset().isMax()) {
RVMMethod target = Entrypoints.inlineLockMethod;
Call.mutate2(inst, CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), MonitorOp.getClearGuard(inst), ref, IRTools.AC(refType.getThinLockOffset()));
next = inst.prevInstructionInCodeOrder();
if (inst.getBasicBlock().getInfrequent())
container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst, ir);
}
} else {
RVMMethod target = Entrypoints.lockMethod;
Call.mutate1(inst, CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), MonitorOp.getClearGuard(inst), ref);
}
}
break;
case MONITOREXIT_opcode:
{
Operand ref = MonitorOp.getClearRef(inst);
RVMType refType = ref.getType().peekType();
if (refType != null && !refType.getThinLockOffset().isMax()) {
RVMMethod target = Entrypoints.inlineUnlockMethod;
Call.mutate2(inst, CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), MonitorOp.getClearGuard(inst), ref, IRTools.AC(refType.getThinLockOffset()));
next = inst.prevInstructionInCodeOrder();
if (inst.getBasicBlock().getInfrequent())
container.counter1++;
container.counter2++;
if (!ir.options.FREQ_FOCUS_EFFORT || !inst.getBasicBlock().getInfrequent()) {
inline(inst, ir);
}
} else {
RVMMethod target = Entrypoints.unlockMethod;
Call.mutate1(inst, CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), MonitorOp.getClearGuard(inst), ref);
}
}
break;
case REF_ASTORE_opcode:
{
if (NEEDS_OBJECT_ASTORE_BARRIER) {
RVMMethod target = Entrypoints.objectArrayWriteBarrierMethod;
Instruction wb = Call.create3(CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), AStore.getClearGuard(inst), AStore.getArray(inst).copy(), AStore.getIndex(inst).copy(), AStore.getValue(inst).copy());
replaceInstructionWithBarrier(inst, wb);
if (ir.options.H2L_INLINE_WRITE_BARRIER) {
inline(wb, ir, true);
}
}
}
break;
case BYTE_ASTORE_opcode:
{
if (NEEDS_BYTE_ASTORE_BARRIER) {
primitiveArrayStoreHelper(Entrypoints.byteArrayWriteBarrierMethod, inst, ir);
}
}
break;
case DOUBLE_ASTORE_opcode:
{
if (NEEDS_DOUBLE_ASTORE_BARRIER) {
primitiveArrayStoreHelper(Entrypoints.doubleArrayWriteBarrierMethod, inst, ir);
}
}
break;
case FLOAT_ASTORE_opcode:
{
if (NEEDS_FLOAT_ASTORE_BARRIER) {
primitiveArrayStoreHelper(Entrypoints.floatArrayWriteBarrierMethod, inst, ir);
}
}
break;
case INT_ASTORE_opcode:
{
if (NEEDS_INT_ASTORE_BARRIER) {
primitiveArrayStoreHelper(Entrypoints.intArrayWriteBarrierMethod, inst, ir);
}
}
break;
case LONG_ASTORE_opcode:
{
if (NEEDS_LONG_ASTORE_BARRIER) {
primitiveArrayStoreHelper(Entrypoints.longArrayWriteBarrierMethod, inst, ir);
}
}
break;
case SHORT_ASTORE_opcode:
{
TypeReference type = AStore.getLocation(inst).getElementType();
if (NEEDS_SHORT_ASTORE_BARRIER && type.isShortType()) {
primitiveArrayStoreHelper(Entrypoints.shortArrayWriteBarrierMethod, inst, ir);
} else if (NEEDS_CHAR_ASTORE_BARRIER) {
if (VM.VerifyAssertions)
VM._assert(type.isCharType());
primitiveArrayStoreHelper(Entrypoints.charArrayWriteBarrierMethod, inst, ir);
}
}
break;
case REF_ALOAD_opcode:
{
if (NEEDS_OBJECT_ALOAD_BARRIER) {
RVMMethod target = Entrypoints.objectArrayReadBarrierMethod;
Instruction rb = Call.create2(CALL, ALoad.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), ALoad.getClearGuard(inst), ALoad.getArray(inst).copy(), ALoad.getIndex(inst).copy());
replaceInstructionWithBarrier(inst, rb);
inline(rb, ir, true);
}
}
break;
case PUTFIELD_opcode:
{
if (NEEDS_OBJECT_PUTFIELD_BARRIER) {
LocationOperand loc = PutField.getLocation(inst);
FieldReference fieldRef = loc.getFieldRef();
if (!fieldRef.getFieldContentsType().isPrimitiveType()) {
// reference PUTFIELD
RVMField field = fieldRef.peekResolvedField();
if (field == null || !field.isUntraced()) {
RVMMethod target = Entrypoints.objectFieldWriteBarrierMethod;
Instruction wb = Call.create4(CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), PutField.getClearGuard(inst), PutField.getRef(inst).copy(), PutField.getValue(inst).copy(), PutField.getOffset(inst).copy(), IRTools.IC(fieldRef.getId()));
replaceInstructionWithBarrier(inst, wb);
if (ir.options.H2L_INLINE_WRITE_BARRIER) {
inline(wb, ir, true);
}
}
} else {
// primitive PUTFIELD
if (NEEDS_BOOLEAN_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isBooleanType()) {
primitiveObjectFieldStoreHelper(Entrypoints.booleanFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_BYTE_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isByteType()) {
primitiveObjectFieldStoreHelper(Entrypoints.byteFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_CHAR_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isCharType()) {
primitiveObjectFieldStoreHelper(Entrypoints.charFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_DOUBLE_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isDoubleType()) {
primitiveObjectFieldStoreHelper(Entrypoints.doubleFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_FLOAT_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isFloatType()) {
primitiveObjectFieldStoreHelper(Entrypoints.floatFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_INT_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isIntType()) {
primitiveObjectFieldStoreHelper(Entrypoints.intFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_LONG_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isLongType()) {
primitiveObjectFieldStoreHelper(Entrypoints.longFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_SHORT_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isShortType()) {
primitiveObjectFieldStoreHelper(Entrypoints.shortFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_WORD_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isWordType()) {
primitiveObjectFieldStoreHelper(Entrypoints.wordFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_ADDRESS_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isAddressType()) {
primitiveObjectFieldStoreHelper(Entrypoints.addressFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_EXTENT_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isExtentType()) {
primitiveObjectFieldStoreHelper(Entrypoints.extentFieldWriteBarrierMethod, inst, ir, fieldRef);
} else if (NEEDS_OFFSET_PUTFIELD_BARRIER && fieldRef.getFieldContentsType().isOffsetType()) {
primitiveObjectFieldStoreHelper(Entrypoints.offsetFieldWriteBarrierMethod, inst, ir, fieldRef);
}
}
}
}
break;
case GETFIELD_opcode:
{
if (NEEDS_OBJECT_GETFIELD_BARRIER) {
LocationOperand loc = GetField.getLocation(inst);
FieldReference fieldRef = loc.getFieldRef();
if (GetField.getResult(inst).getType().isReferenceType()) {
RVMField field = fieldRef.peekResolvedField();
if (field == null || !field.isUntraced()) {
RVMMethod target = Entrypoints.objectFieldReadBarrierMethod;
Instruction rb = Call.create3(CALL, GetField.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), GetField.getClearGuard(inst), GetField.getRef(inst).copy(), GetField.getOffset(inst).copy(), IRTools.IC(fieldRef.getId()));
replaceInstructionWithBarrier(inst, rb);
inline(rb, ir, true);
}
}
}
}
break;
case PUTSTATIC_opcode:
{
if (NEEDS_OBJECT_PUTSTATIC_BARRIER) {
LocationOperand loc = PutStatic.getLocation(inst);
FieldReference field = loc.getFieldRef();
if (!field.getFieldContentsType().isPrimitiveType()) {
RVMMethod target = Entrypoints.objectStaticWriteBarrierMethod;
Instruction wb = Call.create3(CALL, null, IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), PutStatic.getValue(inst).copy(), PutStatic.getOffset(inst).copy(), IRTools.IC(field.getId()));
replaceInstructionWithBarrier(inst, wb);
if (ir.options.H2L_INLINE_WRITE_BARRIER) {
inline(wb, ir, true);
}
}
}
}
break;
case GETSTATIC_opcode:
{
if (NEEDS_OBJECT_GETSTATIC_BARRIER) {
LocationOperand loc = GetStatic.getLocation(inst);
FieldReference field = loc.getFieldRef();
if (!field.getFieldContentsType().isPrimitiveType()) {
RVMMethod target = Entrypoints.objectStaticReadBarrierMethod;
Instruction rb = Call.create2(CALL, GetStatic.getClearResult(inst), IRTools.AC(target.getOffset()), MethodOperand.STATIC(target), GetStatic.getOffset(inst).copy(), IRTools.IC(field.getId()));
replaceInstructionWithBarrier(inst, rb);
inline(rb, ir, true);
}
}
}
break;
default:
break;
}
}
// If we actually inlined anything, clean up the mess
if (didSomething) {
if (branchOpts == null) {
branchOpts = new BranchOptimizations(-1, true, true);
}
branchOpts.perform(ir, true);
if (_os == null) {
_os = new Simple(1, false, false, false, false);
}
_os.perform(ir);
}
// signal that we do not intend to use the gc in other phases anymore.
ir.getGc().close();
}
Aggregations