org.jikesrvm.compilers.opt.bc2ir
Class BC2IR

java.lang.Object
  extended by org.jikesrvm.compilers.opt.bc2ir.BC2IR
All Implemented Interfaces:
BytecodeConstants, ClassLoaderConstants, IRGenOptions, OptConstants, Operators, OSRConstants, SizeConstants

public final class BC2IR
extends Object
implements IRGenOptions, Operators, BytecodeConstants, ClassLoaderConstants, OptConstants, OSRConstants

This class translates from bytecode to HIR.

The only public entry point is BC2IR.generateHIR. generateHIR is passed an argument GenerationContext. The context is assumed to be "empty" but "initialized." Invoking generateHIR on a context results in it being "filled in" with the HIR for the method (and for any inlined methods) as specified by the state of the context.

The basic idea is to abstractly interpret the bytecode stream, translating it into a register-based IR along the way. At each program point BC2IR has an abstract stack and an abstract local variable array. Based on this, and on the bytecode, it can generate instructions. It also does a number of forward flow-sensitive dataflow analyses and optimistic optimizations in the process. There's lots of details in John Whaley's master thesis from MIT. However, one needs to be careful because this code has substantial diverged from the system described in his thesis. Some optimizations/features described in Johns's thesis are not implemented here. Some optimizations/features implemented here are not described in John's thesis. In particular this code takes a different approach to JSRs (inlining them), and has more advanced and effective implementation of the inlining transformation.

See Also:
IRGenOptions, GenerationContext, ConvertBCtoHIR

Nested Class Summary
private static class BC2IR.DummyStackSlot
          Dummy stack slot
 
Field Summary
private  Operand[] _localState
          Current state of local variables.
private  int bciAdjustment
          OSR field: TODO rework this mechanism!
private  BytecodeStream bcodes
          Bytecodes for the method being generated.
private  BBSet blocks
          The set of BasicBlockLEs we are generating
private  BasicBlockLE currentBBLE
          Current BBLE.
private  Operand currentGuard
           
(package private) static boolean DBG_SELECTED
           
private static boolean DBG_SELECTIVE
          Debugging with method_to_print.
static BC2IR.DummyStackSlot DUMMY
          Dummy slot.
private  boolean endOfBasicBlock
          Does basic block end here?
private  boolean fallThrough
          Do we fall through to the next basic block?
private  GenerationContext gc
          The generation context.
private  boolean inlinedSomething
          Was something inlined?
private  int instrIndex
          Bytecode index of current instruction.
private  Instruction lastInstr
          Last instruction generated (for ELIM_COPY_LOCALS)
private  Instruction lastOsrBarrier
          osr barrier needs type information of locals and stacks, it has to be created before a _callHelper.
private  boolean osrGuardedInline
           
private  int param1
          OSR: used for PSEUDO_InvokeStatic to recover the type info
private  int param2
          OSR: used for PSEUDO_InvokeStatic to recover the type info
private  int runoff
          Index of next basic block.
private  OperandStack stack
          Current simulated stack state.
 
Fields inherited from interface org.jikesrvm.compilers.opt.bc2ir.IRGenOptions
CF_CHECKCAST, CF_CHECKSTORE, CF_DOUBLECMP, CF_FLOATCMP, CF_INSTANCEOF, CF_INTIF, CF_INTIFCMP, CF_LONGCMP, CF_LOOKUPSWITCH, CF_REFIF, CF_REFIFCMP, CF_TABLESWITCH, CP_IN_LOCALS, DBG_ALL, DBG_BB, DBG_BBSET, DBG_BCPARSE, DBG_CF, DBG_CFG, DBG_ELIMCOPY, DBG_ELIMNULL, DBG_EX, DBG_FLATTEN, DBG_INLINE_JSR, DBG_INSTR, DBG_LOCAL, DBG_OPERAND_LATTICE, DBG_REGEN, DBG_STACK, DBG_TYPE, ELIM_COPY_LOCALS, LOCALS_ON_STACK, MAX_RETURN_ADDRESSES
 
Fields inherited from interface org.jikesrvm.compilers.opt.ir.Operators
ADDR_2INT, ADDR_2INT_opcode, ADDR_2LONG, ADDR_2LONG_opcode, ADDRESS_CONSTANT, ADDRESS_CONSTANT_opcode, ADVISE_ESP, ADVISE_ESP_opcode, ARCH_INDEPENDENT_END_opcode, ARRAYLENGTH, ARRAYLENGTH_opcode, ATHROW, ATHROW_opcode, ATTEMPT_ADDR, ATTEMPT_ADDR_opcode, ATTEMPT_INT, ATTEMPT_INT_opcode, ATTEMPT_LONG, ATTEMPT_LONG_opcode, BBEND, BBEND_opcode, BOOLEAN_CMP_ADDR, BOOLEAN_CMP_ADDR_opcode, BOOLEAN_CMP_DOUBLE, BOOLEAN_CMP_DOUBLE_opcode, BOOLEAN_CMP_FLOAT, BOOLEAN_CMP_FLOAT_opcode, BOOLEAN_CMP_INT, BOOLEAN_CMP_INT_opcode, BOOLEAN_CMP_LONG, BOOLEAN_CMP_LONG_opcode, BOOLEAN_NOT, BOOLEAN_NOT_opcode, BOUNDS_CHECK, BOUNDS_CHECK_opcode, BRANCH_TARGET, BRANCH_TARGET_opcode, BYTE_ALOAD, BYTE_ALOAD_opcode, BYTE_ASTORE, BYTE_ASTORE_opcode, BYTE_LOAD, BYTE_LOAD_opcode, BYTE_STORE, BYTE_STORE_opcode, CALL, CALL_opcode, CALL_SAVE_VOLATILE, CALL_SAVE_VOLATILE_opcode, CHECKCAST, CHECKCAST_NOTNULL, CHECKCAST_NOTNULL_opcode, CHECKCAST_opcode, CHECKCAST_UNRESOLVED, CHECKCAST_UNRESOLVED_opcode, CLEAR_FLOATING_POINT_STATE, CLEAR_FLOATING_POINT_STATE_opcode, CMP_CMOV, CMP_CMOV_opcode, CMP_FCMOV, CMP_FCMOV_opcode, DOUBLE_2FLOAT, DOUBLE_2FLOAT_opcode, DOUBLE_2INT, DOUBLE_2INT_opcode, DOUBLE_2LONG, DOUBLE_2LONG_opcode, DOUBLE_ADD, DOUBLE_ADD_opcode, DOUBLE_ALOAD, DOUBLE_ALOAD_opcode, DOUBLE_AS_LONG_BITS, DOUBLE_AS_LONG_BITS_opcode, DOUBLE_ASTORE, DOUBLE_ASTORE_opcode, DOUBLE_CMPG, DOUBLE_CMPG_opcode, DOUBLE_CMPL, DOUBLE_CMPL_opcode, DOUBLE_COND_MOVE, DOUBLE_COND_MOVE_opcode, DOUBLE_DIV, DOUBLE_DIV_opcode, DOUBLE_IFCMP, DOUBLE_IFCMP_opcode, DOUBLE_LOAD, DOUBLE_LOAD_opcode, DOUBLE_MOVE, DOUBLE_MOVE_opcode, DOUBLE_MUL, DOUBLE_MUL_opcode, DOUBLE_NEG, DOUBLE_NEG_opcode, DOUBLE_REM, DOUBLE_REM_opcode, DOUBLE_SQRT, DOUBLE_SQRT_opcode, DOUBLE_STORE, DOUBLE_STORE_opcode, DOUBLE_SUB, DOUBLE_SUB_opcode, DUMMY_DEF, DUMMY_DEF_opcode, DUMMY_USE, DUMMY_USE_opcode, FCMP_CMOV, FCMP_CMOV_opcode, FCMP_FCMOV, FCMP_FCMOV_opcode, FENCE, FENCE_opcode, FLOAT_2DOUBLE, FLOAT_2DOUBLE_opcode, FLOAT_2INT, FLOAT_2INT_opcode, FLOAT_2LONG, FLOAT_2LONG_opcode, FLOAT_ADD, FLOAT_ADD_opcode, FLOAT_ALOAD, FLOAT_ALOAD_opcode, FLOAT_AS_INT_BITS, FLOAT_AS_INT_BITS_opcode, FLOAT_ASTORE, FLOAT_ASTORE_opcode, FLOAT_CMPG, FLOAT_CMPG_opcode, FLOAT_CMPL, FLOAT_CMPL_opcode, FLOAT_COND_MOVE, FLOAT_COND_MOVE_opcode, FLOAT_DIV, FLOAT_DIV_opcode, FLOAT_IFCMP, FLOAT_IFCMP_opcode, FLOAT_LOAD, FLOAT_LOAD_opcode, FLOAT_MOVE, FLOAT_MOVE_opcode, FLOAT_MUL, FLOAT_MUL_opcode, FLOAT_NEG, FLOAT_NEG_opcode, FLOAT_REM, FLOAT_REM_opcode, FLOAT_SQRT, FLOAT_SQRT_opcode, FLOAT_STORE, FLOAT_STORE_opcode, FLOAT_SUB, FLOAT_SUB_opcode, FP_ADD, FP_ADD_opcode, FP_DIV, FP_DIV_opcode, FP_MUL, FP_MUL_opcode, FP_NEG, FP_NEG_opcode, FP_REM, FP_REM_opcode, FP_SUB, FP_SUB_opcode, GET_ARRAY_ELEMENT_TIB_FROM_TIB, GET_ARRAY_ELEMENT_TIB_FROM_TIB_opcode, GET_CAUGHT_EXCEPTION, GET_CAUGHT_EXCEPTION_opcode, GET_CLASS_TIB, GET_CLASS_TIB_opcode, GET_CURRENT_PROCESSOR, GET_CURRENT_PROCESSOR_opcode, GET_DOES_IMPLEMENT_FROM_TIB, GET_DOES_IMPLEMENT_FROM_TIB_opcode, GET_OBJ_TIB, GET_OBJ_TIB_opcode, GET_SUPERCLASS_IDS_FROM_TIB, GET_SUPERCLASS_IDS_FROM_TIB_opcode, GET_TIME_BASE, GET_TIME_BASE_opcode, GET_TYPE_FROM_TIB, GET_TYPE_FROM_TIB_opcode, GETFIELD, GETFIELD_opcode, GETSTATIC, GETSTATIC_opcode, GOTO, GOTO_opcode, GUARD_COMBINE, GUARD_COMBINE_opcode, GUARD_COND_MOVE, GUARD_COND_MOVE_opcode, GUARD_MOVE, GUARD_MOVE_opcode, helper, IA32_ADC, IA32_ADC_opcode, IA32_ADD, IA32_ADD_opcode, IA32_ADDSD, IA32_ADDSD_opcode, IA32_ADDSS, IA32_ADDSS_opcode, IA32_AND, IA32_AND_opcode, IA32_ANDNPD, IA32_ANDNPD_opcode, IA32_ANDNPS, IA32_ANDNPS_opcode, IA32_ANDPD, IA32_ANDPD_opcode, IA32_ANDPS, IA32_ANDPS_opcode, IA32_BSWAP, IA32_BSWAP_opcode, IA32_BT, IA32_BT_opcode, IA32_BTC, IA32_BTC_opcode, IA32_BTR, IA32_BTR_opcode, IA32_BTS, IA32_BTS_opcode, IA32_CALL, IA32_CALL_opcode, IA32_CDO, IA32_CDO_opcode, IA32_CDQ, IA32_CDQ_opcode, IA32_CDQE, IA32_CDQE_opcode, IA32_CMOV, IA32_CMOV_opcode, IA32_CMP, IA32_CMP_opcode, IA32_CMPEQSD, IA32_CMPEQSD_opcode, IA32_CMPEQSS, IA32_CMPEQSS_opcode, IA32_CMPLESD, IA32_CMPLESD_opcode, IA32_CMPLESS, IA32_CMPLESS_opcode, IA32_CMPLTSD, IA32_CMPLTSD_opcode, IA32_CMPLTSS, IA32_CMPLTSS_opcode, IA32_CMPNESD, IA32_CMPNESD_opcode, IA32_CMPNESS, IA32_CMPNESS_opcode, IA32_CMPNLESD, IA32_CMPNLESD_opcode, IA32_CMPNLESS, IA32_CMPNLESS_opcode, IA32_CMPNLTSD, IA32_CMPNLTSD_opcode, IA32_CMPNLTSS, IA32_CMPNLTSS_opcode, IA32_CMPORDSD, IA32_CMPORDSD_opcode, IA32_CMPORDSS, IA32_CMPORDSS_opcode, IA32_CMPUNORDSD, IA32_CMPUNORDSD_opcode, IA32_CMPUNORDSS, IA32_CMPUNORDSS_opcode, IA32_CMPXCHG, IA32_CMPXCHG_opcode, IA32_CMPXCHG8B, IA32_CMPXCHG8B_opcode, IA32_CVTSD2SI, IA32_CVTSD2SI_opcode, IA32_CVTSD2SIQ, IA32_CVTSD2SIQ_opcode, IA32_CVTSD2SS, IA32_CVTSD2SS_opcode, IA32_CVTSI2SD, IA32_CVTSI2SD_opcode, IA32_CVTSI2SDQ, IA32_CVTSI2SDQ_opcode, IA32_CVTSI2SS, IA32_CVTSI2SS_opcode, IA32_CVTSS2SD, IA32_CVTSS2SD_opcode, IA32_CVTSS2SI, IA32_CVTSS2SI_opcode, IA32_CVTTSD2SI, IA32_CVTTSD2SI_opcode, IA32_CVTTSD2SIQ, IA32_CVTTSD2SIQ_opcode, IA32_CVTTSS2SI, IA32_CVTTSS2SI_opcode, IA32_DEC, IA32_DEC_opcode, IA32_DIV, IA32_DIV_opcode, IA32_DIVSD, IA32_DIVSD_opcode, IA32_DIVSS, IA32_DIVSS_opcode, IA32_FADD, IA32_FADD_opcode, IA32_FADDP, IA32_FADDP_opcode, IA32_FCHS, IA32_FCHS_opcode, IA32_FCLEAR, IA32_FCLEAR_opcode, IA32_FCMOV, IA32_FCMOV_opcode, IA32_FCOMI, IA32_FCOMI_opcode, IA32_FCOMIP, IA32_FCOMIP_opcode, IA32_FDIV, IA32_FDIV_opcode, IA32_FDIVP, IA32_FDIVP_opcode, IA32_FDIVR, IA32_FDIVR_opcode, IA32_FDIVRP, IA32_FDIVRP_opcode, IA32_FEXAM, IA32_FEXAM_opcode, IA32_FFREE, IA32_FFREE_opcode, IA32_FIADD, IA32_FIADD_opcode, IA32_FIDIV, IA32_FIDIV_opcode, IA32_FIDIVR, IA32_FIDIVR_opcode, IA32_FILD, IA32_FILD_opcode, IA32_FIMUL, IA32_FIMUL_opcode, IA32_FINIT, IA32_FINIT_opcode, IA32_FIST, IA32_FIST_opcode, IA32_FISTP, IA32_FISTP_opcode, IA32_FISUB, IA32_FISUB_opcode, IA32_FISUBR, IA32_FISUBR_opcode, IA32_FLD, IA32_FLD_opcode, IA32_FLD1, IA32_FLD1_opcode, IA32_FLDCW, IA32_FLDCW_opcode, IA32_FLDL2E, IA32_FLDL2E_opcode, IA32_FLDL2T, IA32_FLDL2T_opcode, IA32_FLDLG2, IA32_FLDLG2_opcode, IA32_FLDLN2, IA32_FLDLN2_opcode, IA32_FLDPI, IA32_FLDPI_opcode, IA32_FLDZ, IA32_FLDZ_opcode, IA32_FMOV, IA32_FMOV_ENDING_LIVE_RANGE, IA32_FMOV_ENDING_LIVE_RANGE_opcode, IA32_FMOV_opcode, IA32_FMUL, IA32_FMUL_opcode, IA32_FMULP, IA32_FMULP_opcode, IA32_FNINIT, IA32_FNINIT_opcode, IA32_FNSAVE, IA32_FNSAVE_opcode, IA32_FNSTCW, IA32_FNSTCW_opcode, IA32_FPREM, IA32_FPREM_opcode, IA32_FRSTOR, IA32_FRSTOR_opcode, IA32_FST, IA32_FST_opcode, IA32_FSTCW, IA32_FSTCW_opcode, IA32_FSTP, IA32_FSTP_opcode, IA32_FSUB, IA32_FSUB_opcode, IA32_FSUBP, IA32_FSUBP_opcode, IA32_FSUBR, IA32_FSUBR_opcode, IA32_FSUBRP, IA32_FSUBRP_opcode, IA32_FUCOMI, IA32_FUCOMI_opcode, IA32_FUCOMIP, IA32_FUCOMIP_opcode, IA32_FXCH, IA32_FXCH_opcode, IA32_IDIV, IA32_IDIV_opcode, IA32_IMUL1, IA32_IMUL1_opcode, IA32_IMUL2, IA32_IMUL2_opcode, IA32_INC, IA32_INC_opcode, IA32_INT, IA32_INT_opcode, IA32_JCC, IA32_JCC_opcode, IA32_JCC2, IA32_JCC2_opcode, IA32_JMP, IA32_JMP_opcode, IA32_LEA, IA32_LEA_opcode, IA32_LOCK, IA32_LOCK_CMPXCHG, IA32_LOCK_CMPXCHG_opcode, IA32_LOCK_CMPXCHG8B, IA32_LOCK_CMPXCHG8B_opcode, IA32_LOCK_opcode, IA32_METHODSTART, IA32_METHODSTART_opcode, IA32_MFENCE, IA32_MFENCE_opcode, IA32_MOV, IA32_MOV_opcode, IA32_MOVD, IA32_MOVD_opcode, IA32_MOVLPD, IA32_MOVLPD_opcode, IA32_MOVLPS, IA32_MOVLPS_opcode, IA32_MOVQ, IA32_MOVQ_opcode, IA32_MOVSD, IA32_MOVSD_opcode, IA32_MOVSS, IA32_MOVSS_opcode, IA32_MOVSX__B, IA32_MOVSX__B_opcode, IA32_MOVSX__W, IA32_MOVSX__W_opcode, IA32_MOVSXQ__B, IA32_MOVSXQ__B_opcode, IA32_MOVSXQ__W, IA32_MOVSXQ__W_opcode, IA32_MOVZX__B, IA32_MOVZX__B_opcode, IA32_MOVZX__W, IA32_MOVZX__W_opcode, IA32_MOVZXQ__B, IA32_MOVZXQ__B_opcode, IA32_MOVZXQ__W, IA32_MOVZXQ__W_opcode, IA32_MUL, IA32_MUL_opcode, IA32_MULSD, IA32_MULSD_opcode, IA32_MULSS, IA32_MULSS_opcode, IA32_NEG, IA32_NEG_opcode, IA32_NOT, IA32_NOT_opcode, IA32_OFFSET, IA32_OFFSET_opcode, IA32_OR, IA32_OR_opcode, IA32_ORPD, IA32_ORPD_opcode, IA32_ORPS, IA32_ORPS_opcode, IA32_PAUSE, IA32_PAUSE_opcode, IA32_POP, IA32_POP_opcode, IA32_PREFETCHNTA, IA32_PREFETCHNTA_opcode, IA32_PSLLQ, IA32_PSLLQ_opcode, IA32_PSRLQ, IA32_PSRLQ_opcode, IA32_PUSH, IA32_PUSH_opcode, IA32_RCL, IA32_RCL_opcode, IA32_RCR, IA32_RCR_opcode, IA32_RDTSC, IA32_RDTSC_opcode, IA32_RET, IA32_RET_opcode, IA32_ROL, IA32_ROL_opcode, IA32_ROR, IA32_ROR_opcode, IA32_SAL, IA32_SAL_opcode, IA32_SAR, IA32_SAR_opcode, IA32_SBB, IA32_SBB_opcode, IA32_SET__B, IA32_SET__B_opcode, IA32_SHL, IA32_SHL_opcode, IA32_SHLD, IA32_SHLD_opcode, IA32_SHR, IA32_SHR_opcode, IA32_SHRD, IA32_SHRD_opcode, IA32_SQRTSD, IA32_SQRTSD_opcode, IA32_SQRTSS, IA32_SQRTSS_opcode, IA32_SUB, IA32_SUB_opcode, IA32_SUBSD, IA32_SUBSD_opcode, IA32_SUBSS, IA32_SUBSS_opcode, IA32_SYSCALL, IA32_SYSCALL_opcode, IA32_TEST, IA32_TEST_opcode, IA32_TRAPIF, IA32_TRAPIF_opcode, IA32_UCOMISD, IA32_UCOMISD_opcode, IA32_UCOMISS, IA32_UCOMISS_opcode, IA32_XOR, IA32_XOR_opcode, IA32_XORPD, IA32_XORPD_opcode, IA32_XORPS, IA32_XORPS_opcode, IG_CLASS_TEST, IG_CLASS_TEST_opcode, IG_METHOD_TEST, IG_METHOD_TEST_opcode, IG_PATCH_POINT, IG_PATCH_POINT_opcode, INSTANCEOF, INSTANCEOF_NOTNULL, INSTANCEOF_NOTNULL_opcode, INSTANCEOF_opcode, INSTANCEOF_UNRESOLVED, INSTANCEOF_UNRESOLVED_opcode, INSTRUMENTED_EVENT_COUNTER, INSTRUMENTED_EVENT_COUNTER_opcode, INT_2ADDRSigExt, INT_2ADDRSigExt_opcode, INT_2ADDRZerExt, INT_2ADDRZerExt_opcode, INT_2BYTE, INT_2BYTE_opcode, INT_2DOUBLE, INT_2DOUBLE_opcode, INT_2FLOAT, INT_2FLOAT_opcode, INT_2FP, INT_2FP_opcode, INT_2LONG, INT_2LONG_opcode, INT_2SHORT, INT_2SHORT_opcode, INT_2USHORT, INT_2USHORT_opcode, INT_ADD, INT_ADD_opcode, INT_ALOAD, INT_ALOAD_opcode, INT_AND, INT_AND_opcode, INT_ASTORE, INT_ASTORE_opcode, INT_BITS_AS_FLOAT, INT_BITS_AS_FLOAT_opcode, INT_COND_MOVE, INT_COND_MOVE_opcode, INT_CONSTANT, INT_CONSTANT_opcode, INT_DIV, INT_DIV_opcode, INT_IFCMP, INT_IFCMP_opcode, INT_IFCMP2, INT_IFCMP2_opcode, INT_LOAD, INT_LOAD_opcode, INT_MOVE, INT_MOVE_opcode, INT_MUL, INT_MUL_opcode, INT_NEG, INT_NEG_opcode, INT_NOT, INT_NOT_opcode, INT_OR, INT_OR_opcode, INT_REM, INT_REM_opcode, INT_SHL, INT_SHL_opcode, INT_SHR, INT_SHR_opcode, INT_STORE, INT_STORE_opcode, INT_SUB, INT_SUB_opcode, INT_USHR, INT_USHR_opcode, INT_XOR, INT_XOR_opcode, INT_ZERO_CHECK, INT_ZERO_CHECK_opcode, IR_PROLOGUE, IR_PROLOGUE_opcode, LABEL, LABEL_opcode, LCMP_CMOV, LCMP_CMOV_opcode, LONG_2ADDR, LONG_2ADDR_opcode, LONG_2DOUBLE, LONG_2DOUBLE_opcode, LONG_2FLOAT, LONG_2FLOAT_opcode, LONG_2FP, LONG_2FP_opcode, LONG_2INT, LONG_2INT_opcode, LONG_ADD, LONG_ADD_opcode, LONG_ALOAD, LONG_ALOAD_opcode, LONG_AND, LONG_AND_opcode, LONG_ASTORE, LONG_ASTORE_opcode, LONG_BITS_AS_DOUBLE, LONG_BITS_AS_DOUBLE_opcode, LONG_CMP, LONG_CMP_opcode, LONG_COND_MOVE, LONG_COND_MOVE_opcode, LONG_CONSTANT, LONG_CONSTANT_opcode, LONG_DIV, LONG_DIV_opcode, LONG_IFCMP, LONG_IFCMP_opcode, LONG_LOAD, LONG_LOAD_opcode, LONG_MOVE, LONG_MOVE_opcode, LONG_MUL, LONG_MUL_opcode, LONG_NEG, LONG_NEG_opcode, LONG_NOT, LONG_NOT_opcode, LONG_OR, LONG_OR_opcode, LONG_REM, LONG_REM_opcode, LONG_SHL, LONG_SHL_opcode, LONG_SHR, LONG_SHR_opcode, LONG_STORE, LONG_STORE_opcode, LONG_SUB, LONG_SUB_opcode, LONG_USHR, LONG_USHR_opcode, LONG_XOR, LONG_XOR_opcode, LONG_ZERO_CHECK, LONG_ZERO_CHECK_opcode, LOOKUPSWITCH, LOOKUPSWITCH_opcode, LOWTABLESWITCH, LOWTABLESWITCH_opcode, MATERIALIZE_FP_CONSTANT, MATERIALIZE_FP_CONSTANT_opcode, MIR_END, MIR_END_opcode, MIR_LOWTABLESWITCH, MIR_LOWTABLESWITCH_opcode, MIR_START, MIR_START_opcode, MONITORENTER, MONITORENTER_opcode, MONITOREXIT, MONITOREXIT_opcode, MUST_IMPLEMENT_INTERFACE, MUST_IMPLEMENT_INTERFACE_opcode, NEW, NEW_opcode, NEW_UNRESOLVED, NEW_UNRESOLVED_opcode, NEWARRAY, NEWARRAY_opcode, NEWARRAY_UNRESOLVED, NEWARRAY_UNRESOLVED_opcode, NEWOBJMULTIARRAY, NEWOBJMULTIARRAY_opcode, NOP, NOP_opcode, NULL, NULL_CHECK, NULL_CHECK_opcode, NULL_opcode, OBJARRAY_STORE_CHECK, OBJARRAY_STORE_CHECK_NOTNULL, OBJARRAY_STORE_CHECK_NOTNULL_opcode, OBJARRAY_STORE_CHECK_opcode, OSR_BARRIER, OSR_BARRIER_opcode, OTHER_OPERAND, OTHER_OPERAND_opcode, PAUSE, PAUSE_opcode, PHI, PHI_opcode, PI, PI_opcode, PREFETCH, PREFETCH_opcode, PREPARE_ADDR, PREPARE_ADDR_opcode, PREPARE_INT, PREPARE_INT_opcode, PREPARE_LONG, PREPARE_LONG_opcode, PUTFIELD, PUTFIELD_opcode, PUTSTATIC, PUTSTATIC_opcode, READ_CEILING, READ_CEILING_opcode, REF_ADD, REF_ADD_opcode, REF_ALOAD, REF_ALOAD_opcode, REF_AND, REF_AND_opcode, REF_ASTORE, REF_ASTORE_opcode, REF_COND_MOVE, REF_COND_MOVE_opcode, REF_IFCMP, REF_IFCMP_opcode, REF_LOAD, REF_LOAD_opcode, REF_MOVE, REF_MOVE_opcode, REF_NEG, REF_NEG_opcode, REF_NOT, REF_NOT_opcode, REF_OR, REF_OR_opcode, REF_SHL, REF_SHL_opcode, REF_SHR, REF_SHR_opcode, REF_STORE, REF_STORE_opcode, REF_SUB, REF_SUB_opcode, REF_USHR, REF_USHR_opcode, REF_XOR, REF_XOR_opcode, REGISTER, REGISTER_opcode, REQUIRE_ESP, REQUIRE_ESP_opcode, RESOLVE, RESOLVE_MEMBER, RESOLVE_MEMBER_opcode, RESOLVE_opcode, RETURN, RETURN_opcode, ROUND_TO_ZERO, ROUND_TO_ZERO_opcode, SET_CAUGHT_EXCEPTION, SET_CAUGHT_EXCEPTION_opcode, SHORT_ALOAD, SHORT_ALOAD_opcode, SHORT_ASTORE, SHORT_ASTORE_opcode, SHORT_LOAD, SHORT_LOAD_opcode, SHORT_STORE, SHORT_STORE_opcode, SPLIT, SPLIT_opcode, SYSCALL, SYSCALL_opcode, TABLESWITCH, TABLESWITCH_opcode, TRAP, TRAP_IF, TRAP_IF_opcode, TRAP_opcode, UBYTE_ALOAD, UBYTE_ALOAD_opcode, UBYTE_LOAD, UBYTE_LOAD_opcode, UNINT_BEGIN, UNINT_BEGIN_opcode, UNINT_END, UNINT_END_opcode, USHORT_ALOAD, USHORT_ALOAD_opcode, USHORT_LOAD, USHORT_LOAD_opcode, WRITE_FLOOR, WRITE_FLOOR_opcode, YIELDPOINT_BACKEDGE, YIELDPOINT_BACKEDGE_opcode, YIELDPOINT_EPILOGUE, YIELDPOINT_EPILOGUE_opcode, YIELDPOINT_OSR, YIELDPOINT_OSR_opcode, YIELDPOINT_PROLOGUE, YIELDPOINT_PROLOGUE_opcode
 
Fields inherited from interface org.jikesrvm.classloader.BytecodeConstants
JBC_aaload, JBC_aastore, JBC_aconst_null, JBC_aload, JBC_aload_0, JBC_aload_1, JBC_aload_2, JBC_aload_3, JBC_anewarray, JBC_areturn, JBC_arraylength, JBC_astore, JBC_astore_0, JBC_astore_1, JBC_astore_2, JBC_astore_3, JBC_athrow, JBC_baload, JBC_bastore, JBC_bipush, JBC_caload, JBC_castore, JBC_checkcast, JBC_d2f, JBC_d2i, JBC_d2l, JBC_dadd, JBC_daload, JBC_dastore, JBC_dcmpg, JBC_dcmpl, JBC_dconst_0, JBC_dconst_1, JBC_ddiv, JBC_dload, JBC_dload_0, JBC_dload_1, JBC_dload_2, JBC_dload_3, JBC_dmul, JBC_dneg, JBC_drem, JBC_dreturn, JBC_dstore, JBC_dstore_0, JBC_dstore_1, JBC_dstore_2, JBC_dstore_3, JBC_dsub, JBC_dup, JBC_dup_x1, JBC_dup_x2, JBC_dup2, JBC_dup2_x1, JBC_dup2_x2, JBC_f2d, JBC_f2i, JBC_f2l, JBC_fadd, JBC_faload, JBC_fastore, JBC_fcmpg, JBC_fcmpl, JBC_fconst_0, JBC_fconst_1, JBC_fconst_2, JBC_fdiv, JBC_fload, JBC_fload_0, JBC_fload_1, JBC_fload_2, JBC_fload_3, JBC_fmul, JBC_fneg, JBC_frem, JBC_freturn, JBC_fstore, JBC_fstore_0, JBC_fstore_1, JBC_fstore_2, JBC_fstore_3, JBC_fsub, JBC_getfield, JBC_getstatic, JBC_goto, JBC_goto_w, JBC_i2d, JBC_i2f, JBC_i2l, JBC_iadd, JBC_iaload, JBC_iand, JBC_iastore, JBC_iconst_0, JBC_iconst_1, JBC_iconst_2, JBC_iconst_3, JBC_iconst_4, JBC_iconst_5, JBC_iconst_m1, JBC_idiv, JBC_if_acmpeq, JBC_if_acmpne, JBC_if_icmpeq, JBC_if_icmpge, JBC_if_icmpgt, JBC_if_icmple, JBC_if_icmplt, JBC_if_icmpne, JBC_ifeq, JBC_ifge, JBC_ifgt, JBC_ifle, JBC_iflt, JBC_ifne, JBC_ifnonnull, JBC_ifnull, JBC_iinc, JBC_iload, JBC_iload_0, JBC_iload_1, JBC_iload_2, JBC_iload_3, JBC_impdep1, JBC_impdep2, JBC_imul, JBC_ineg, JBC_instanceof, JBC_int2byte, JBC_int2char, JBC_int2short, JBC_invokeinterface, JBC_invokespecial, JBC_invokestatic, JBC_invokevirtual, JBC_ior, JBC_irem, JBC_ireturn, JBC_ishl, JBC_ishr, JBC_istore, JBC_istore_0, JBC_istore_1, JBC_istore_2, JBC_istore_3, JBC_isub, JBC_iushr, JBC_ixor, JBC_jsr, JBC_jsr_w, JBC_l2d, JBC_l2f, JBC_l2i, JBC_ladd, JBC_laload, JBC_land, JBC_lastore, JBC_lcmp, JBC_lconst_0, JBC_lconst_1, JBC_ldc, JBC_ldc_w, JBC_ldc2_w, JBC_ldiv, JBC_length, JBC_lload, JBC_lload_0, JBC_lload_1, JBC_lload_2, JBC_lload_3, JBC_lmul, JBC_lneg, JBC_lookupswitch, JBC_lor, JBC_lrem, JBC_lreturn, JBC_lshl, JBC_lshr, JBC_lstore, JBC_lstore_0, JBC_lstore_1, JBC_lstore_2, JBC_lstore_3, JBC_lsub, JBC_lushr, JBC_lxor, JBC_monitorenter, JBC_monitorexit, JBC_multianewarray, JBC_name, JBC_new, JBC_newarray, JBC_nop, JBC_pop, JBC_pop2, JBC_putfield, JBC_putstatic, JBC_ret, JBC_return, JBC_saload, JBC_sastore, JBC_sipush, JBC_swap, JBC_tableswitch, JBC_wide, JBC_xxxunusedxxx
 
Fields inherited from interface org.jikesrvm.compilers.opt.driver.OptConstants
EPILOGUE_BCI, EPILOGUE_BLOCK_BCI, EXTANT_ANALYSIS_BCI, INSTRUMENTATION_BCI, MAYBE, METHOD_COUNTER_BCI, NO, OSR_PROLOGUE, PROLOGUE_BCI, PROLOGUE_BLOCK_BCI, RECTIFY_BCI, RUNTIME_SERVICES_BCI, SSA_SYNTH_BCI, SYNCHRONIZED_MONITORENTER_BCI, SYNCHRONIZED_MONITOREXIT_BCI, SYNTH_CATCH_BCI, SYNTH_LOOP_VERSIONING_BCI, UNKNOWN_BCI, YES
 
Fields inherited from interface org.jikesrvm.osr.OSRConstants
ACONST, BCI_MASK, BCI_SHIFT, CLEANREFS, DOUBLE, FLOAT, GETREFAT, HIGH_64BIT, ICONST, IEI_MASK, IEI_SHIFT, INT, INVALID_BCI, INVALID_IEI, KIND_MASK, KIND_SHIFT, LCONST, LOCAL, LONG, NEXT_BIT, NO_OSR_ENTRY, NUM_MASK, NUM_SHIFT, OFFSET_MASK, OFFSET_SHIFT, OSRI_MASK, OSRI_SHIFT, PHYREG, PSEUDO_CheckCast, PSEUDO_InvokeCompiledMethod, PSEUDO_InvokeStatic, PSEUDO_LoadDoubleConst, PSEUDO_LoadFloatConst, PSEUDO_LoadIntConst, PSEUDO_LoadLongConst, PSEUDO_LoadRetAddrConst, PSEUDO_LoadWordConst, PSEUDO_ParamInitEnd, REF, RET_ADDR, ReturnAddressTypeCode, SPILL, STACK, TCODE_MASK, TCODE_SHIFT, VTYPE_MASK, VTYPE_SHIFT, WORD, WordTypeCode
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Fields inherited from interface org.jikesrvm.classloader.ClassLoaderConstants
ACC_ABSTRACT, ACC_ANNOTATION, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VOLATILE, APPLICABLE_TO_CLASSES, APPLICABLE_TO_FIELDS, APPLICABLE_TO_METHODS, ArrayTypeCode, BooleanTypeCode, BRIDGE, ByteTypeCode, CharTypeCode, CLASS_INITIALIZED, CLASS_INITIALIZER_FAILED, CLASS_INITIALIZING, CLASS_INSTANTIATED, CLASS_LOADED, CLASS_RESOLVED, CLASS_VACANT, ClassTypeCode, CP_CLASS, CP_DOUBLE, CP_FLOAT, CP_INT, CP_LONG, CP_MEMBER, CP_STRING, CP_UTF, DoubleTypeCode, FloatTypeCode, IntTypeCode, LongTypeCode, ShortTypeCode, TAG_DOUBLE, TAG_FIELDREF, TAG_FLOAT, TAG_INT, TAG_INTERFACE_METHODREF, TAG_LONG, TAG_MEMBERNAME_AND_DESCRIPTOR, TAG_METHODREF, TAG_STRING, TAG_TYPEREF, TAG_UNUSED, TAG_UTF, VARARGS, VoidTypeCode
 
Constructor Summary
private BC2IR()
           
private BC2IR(GenerationContext context)
          Construct the BC2IR object for the generation context.
 
Method Summary
 Instruction _aloadHelper(Operator operator, Operand ref, Operand index, TypeReference type)
           
private  Instruction _binaryDualHelper(Operator operator, Operand op1, Operand op2, TypeReference type)
           
private  Instruction _binaryHelper(Operator operator, Operand op1, Operand op2, TypeReference type)
           
private  Instruction _callHelper(MethodReference meth, MethodOperand methOp)
          Pop method parameters off the expression stack.
private  Instruction _createOsrBarrier()
           
private  Instruction _gotoHelper(int offset)
           
private  Instruction _guardedBinaryDualHelper(Operator operator, Operand op1, Operand op2, Operand guard, TypeReference type)
           
private  Instruction _guardedBinaryHelper(Operator operator, Operand op1, Operand op2, Operand guard, TypeReference type)
           
private  Instruction _intIfCmpHelper(ConditionOperand cond)
           
private  Instruction _intIfHelper(ConditionOperand cond)
           
private  Instruction _jsrHelper(int offset)
           
private  Operand _loadLocalForOSR(Operand op)
          make a temporary register, and create a move instruction
private  Instruction _moveDualHelper(Operator operator, Operand val, TypeReference type)
           
private  Instruction _moveHelper(Operator operator, Operand val, TypeReference type)
           
static Instruction _osrHelper(Instruction barrier)
          Creates an OSR point instruction with its dependent OsrBarrier which provides type and variable information.
private  Operand _prepareDoubleConstant(Operand op)
          special process for long/double constants
private  Operand _prepareLongConstant(Operand op)
          special process for long/double constants
private  Instruction _refIfCmpHelper(ConditionOperand cond)
           
private  Instruction _refIfNullHelper(ConditionOperand cond)
           
private  Instruction _retHelper(int var)
           
private  void _returnHelper(Operator operator, Operand val)
           
private  Instruction _unaryDualHelper(Operator operator, Operand val, TypeReference type)
           
private  Instruction _unaryHelper(Operator operator, Operand val, TypeReference type)
           
 void appendInstruction(Instruction s)
          Append an instruction to the current basic block.
private  void assertIsAssignable(TypeReference parentType, TypeReference childType)
          Assert that the given child type is a subclass of the given parent type.
 void assertIsType(Operand op, TypeReference type)
          Assert that the given operand is of the given type, or of a subclass of the given type.
 void clearCurrentGuard()
           
private  boolean couldCauseClassLoading(TypeReference typeRef)
           
private  void db(String val)
          Print a debug string to the sysWrite stream
private  Instruction do_aload(int index)
          Simulate a load from a given local variable of a reference.
private  Instruction do_astore(int index)
          Simulate a store into a given local variable of an object ref.
 boolean do_BoundsCheck(Operand ref, Operand index)
          Generate a boundscheck instruction for the given operand and index.
private  boolean do_CheckStore(Operand ref, Operand elem, TypeReference elemType)
          Generate a storecheck for the given array and elem
private  Instruction do_dload(int index)
          Simulate a load from a given local variable of a double.
private  Instruction do_fload(int index)
          Simulate a load from a given local variable of a float.
private  Instruction do_iinc(int index, int amount)
          Simulate the incrementing of a given int local variable.
private  Instruction do_iload(int index)
          Simulate a load from a given local variable of an int.
private  boolean do_IntZeroCheck(Operand div)
          Generate a check for 0 for the given operand
private  Instruction do_lload(int index)
          Simulate a load from a given local variable of a long.
private  boolean do_LongZeroCheck(Operand div)
          Generate a check for 0 for the given operand
 boolean do_NullCheck(Operand ref)
          Generate a null-check instruction for the given operand.
private  Instruction do_store(int index, Operand op1)
          Simulate a store into a given local variable of an int/long/double/float Returns generated instruction (or null if no instruction generated.)
private  void finish(GenerationContext context)
           
 Instruction generateAnewarray(TypeReference arrayTypeRef, TypeReference elementTypeRef)
           
private  void generateFrom(int fromIndex)
          Generate instructions for a basic block.
private  void generateHIR()
          Main generation loop.
static void generateHIR(GenerationContext context)
          Generate HIR as specified by the argument GenerationContext.
private  BranchOperand generateTarget(int offset)
           
 TypeReference getArrayTypeOf(Operand op)
          Return the data type of the given operand, assuming that the operand is an array reference.
 Operand getConstantOperand(int index)
          Fetch the value of the next operand, a constant, from the bytecode stream.
 Operand getCurrentGuard()
           
static Operand getGuard(Operand op)
           
private  Operand getLocal(int i)
          Gets the specified local variable.
private  Operand getLocalDual(int i)
          Gets the specified local variable (long, double).
private  BasicBlockLE getOrCreateBlock(int target)
          Get or create a block at the specified target.
private  BasicBlockLE getOrCreateBlock(int target, BasicBlockLE from, OperandStack simStack, Operand[] simLocals)
          Get or create a block at the specified target.
private  TypeReference getRefTypeOf(Operand op)
          Return the data type of the given operand, assuming that the operand is a reference.
static boolean hasGuard(RegisterOperand rop)
           
static boolean hasLessConservativeGuard(RegisterOperand rop1, RegisterOperand rop2)
           
static boolean isNonNull(Operand op)
           
private  LocationOperand makeInstanceFieldRef(FieldReference f)
           
private  LocationOperand makeStaticFieldRef(FieldReference f)
          Make a field reference operand referring to the given field with the given type.
private  TypeOperand makeTypeOperand(RVMType type)
          Make a type operand that refers to the given type.
private  TypeOperand makeTypeOperand(TypeReference type)
          Make a type operand that refers to the given type.
(package private)  void markBBUnsafeForScheduling()
          HACK: Mark current basic block unsafe for scheduling.
 void markGuardlessNonNull(RegisterOperand rop)
           
private  boolean maybeInlineMethod(InlineDecision inlDec, Instruction callSite)
          Attempt to inline a method.
(package private)  Operand pop()
          Pop an operand from the stack.
(package private)  Operand pop(TypeReference type)
          Pop an operand of the given type from the stack.
 Operand popAddress()
          Pop a ref operand from the stack.
(package private)  Operand popDouble()
          Pop a double operand from the stack.
(package private)  void popDummy()
          Pop a dummy operand from the stack.
(package private)  Operand popFloat()
          Pop a float operand from the stack.
 Operand popInt()
          Pop an int operand from the stack.
(package private)  Operand popLong()
          Pop a long operand from the stack.
 Operand popRef()
          Pop a ref operand from the stack.
private  Operand popShiftInt(boolean longShift)
          Pop an int from the stack to be used in a shift.
private  String printBlocks()
          Return a string representation of the current basic block set.
 void push(Operand r)
          Push a single width operand (int, float, ref, ...) on the simulated stack.
(package private)  void push(Operand r, TypeReference type)
          Push an operand of the specified type on the simulated stack.
private  Instruction pushCopy(Operand op1)
          Push a copy of the given operand onto simulated stack.
private  Instruction pushCopy(Operand op1, int b1)
          Push a copy of the given operand onto simulated stack.
(package private)  void pushDual(Operand r)
          Push a double width operand (long, double) on the simulated stack.
private  BasicBlock rectifyStateWithArithmeticExceptionHandler()
           
private  BasicBlock rectifyStateWithArithmeticExceptionHandler(boolean linkToExitIfUncaught)
           
private  BasicBlock rectifyStateWithArrayBoundsExceptionHandler()
           
private  BasicBlock rectifyStateWithArrayBoundsExceptionHandler(boolean linkToExitIfUncaught)
           
private  BasicBlock rectifyStateWithArrayStoreExceptionHandler()
           
private  BasicBlock rectifyStateWithArrayStoreExceptionHandler(boolean linkToExitIfUncaught)
           
private  BasicBlock rectifyStateWithErrorHandler()
           
private  BasicBlock rectifyStateWithErrorHandler(boolean linkToExitIfUncaught)
           
 BasicBlock rectifyStateWithExceptionHandler(TypeReference exceptionType)
           
private  BasicBlock rectifyStateWithExceptionHandler(TypeReference exceptionType, boolean linkToExitIfUncaught)
           
 void rectifyStateWithExceptionHandlers()
           
private  void rectifyStateWithExceptionHandlers(boolean linkToExitIfUncaught)
           
private  BasicBlock rectifyStateWithNullPtrExceptionHandler()
           
private  BasicBlock rectifyStateWithNullPtrExceptionHandler(boolean linkToExitIfUncaught)
           
private  void replaceLocalsOnStack(int index, TypeReference type)
          Replaces copies of local <#index,type> with newly-generated temporaries, and generates the necessary move instructions.
private  void setCurrentGuard(Operand guard)
           
static void setGuard(RegisterOperand rop, Operand guard)
           
private  void setLocal(int i, Operand op)
          Set the specified local variable
private  void setLocalDual(int i, Operand op)
          Set the specified local variable
private  InlineDecision shouldInline(Instruction call, boolean isExtant, int realBCI)
          Should we inline a call site?
private  void start(GenerationContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUMMY

public static final BC2IR.DummyStackSlot DUMMY
Dummy slot. Used to deal with the fact the longs/doubles take two words of stack space/local space to represent. This field needs to be accessed by several of the IR classes, but is not intended to be referenced by general client code.


gc

private GenerationContext gc
The generation context.


bcodes

private BytecodeStream bcodes
Bytecodes for the method being generated.


blocks

private BBSet blocks
The set of BasicBlockLEs we are generating


instrIndex

private int instrIndex
Bytecode index of current instruction.


osrGuardedInline

private boolean osrGuardedInline

bciAdjustment

private int bciAdjustment
OSR field: TODO rework this mechanism! adjustment of bcIndex of instructions because of specialized bytecode.


lastInstr

private Instruction lastInstr
Last instruction generated (for ELIM_COPY_LOCALS)


endOfBasicBlock

private boolean endOfBasicBlock
Does basic block end here?


fallThrough

private boolean fallThrough
Do we fall through to the next basic block?


currentBBLE

private BasicBlockLE currentBBLE
Current BBLE.


stack

private OperandStack stack
Current simulated stack state.


_localState

private Operand[] _localState
Current state of local variables.


runoff

private int runoff
Index of next basic block.


currentGuard

private Operand currentGuard

inlinedSomething

private boolean inlinedSomething
Was something inlined?


param1

private int param1
OSR: used for PSEUDO_InvokeStatic to recover the type info


param2

private int param2
OSR: used for PSEUDO_InvokeStatic to recover the type info


lastOsrBarrier

private Instruction lastOsrBarrier
osr barrier needs type information of locals and stacks, it has to be created before a _callHelper. only when the call site is going to be inlined, the instruction is inserted before the call site.


DBG_SELECTIVE

private static final boolean DBG_SELECTIVE
Debugging with method_to_print. Switch following 2 to both be non-final. Set DBG_SELECTIVE to true DBG_SELECTED will then be true when the method matches. You must also uncomment the assignment to DBG_SELECTIVE in start

See Also:
Constant Field Values

DBG_SELECTED

static final boolean DBG_SELECTED
See Also:
Constant Field Values
Constructor Detail

BC2IR

private BC2IR()

BC2IR

private BC2IR(GenerationContext context)
Construct the BC2IR object for the generation context. After the constructor completes, we're ready to start generating HIR from bytecode 0 of context.method.

Parameters:
context - the context to generate HIR into
Method Detail

generateHIR

public static void generateHIR(GenerationContext context)
Generate HIR as specified by the argument GenerationContext. As a result of calling this method, the cfg field of the generation context is populated with basic blocks and instructions. Additionally, other fields of the generation context will be modified to summarize what happened during IR generation.

This is the only external entry point to BC2IR.

Note: most clients should be calling methods in ConvertBCtoHIR or in Inliner rather than invoking BC2IR.generateHIR directly.

Parameters:
context - the generation context

start

private void start(GenerationContext context)

finish

private void finish(GenerationContext context)

generateHIR

private void generateHIR()
Main generation loop.


generateAnewarray

public Instruction generateAnewarray(TypeReference arrayTypeRef,
                                     TypeReference elementTypeRef)

generateFrom

private void generateFrom(int fromIndex)
Generate instructions for a basic block. May discover other basic blocks that need to be generated along the way.

Parameters:
fromIndex - bytecode index to start from

_unaryHelper

private Instruction _unaryHelper(Operator operator,
                                 Operand val,
                                 TypeReference type)

_unaryDualHelper

private Instruction _unaryDualHelper(Operator operator,
                                     Operand val,
                                     TypeReference type)

_binaryHelper

private Instruction _binaryHelper(Operator operator,
                                  Operand op1,
                                  Operand op2,
                                  TypeReference type)

_guardedBinaryHelper

private Instruction _guardedBinaryHelper(Operator operator,
                                         Operand op1,
                                         Operand op2,
                                         Operand guard,
                                         TypeReference type)

_binaryDualHelper

private Instruction _binaryDualHelper(Operator operator,
                                      Operand op1,
                                      Operand op2,
                                      TypeReference type)

_guardedBinaryDualHelper

private Instruction _guardedBinaryDualHelper(Operator operator,
                                             Operand op1,
                                             Operand op2,
                                             Operand guard,
                                             TypeReference type)

_moveHelper

private Instruction _moveHelper(Operator operator,
                                Operand val,
                                TypeReference type)

_moveDualHelper

private Instruction _moveDualHelper(Operator operator,
                                    Operand val,
                                    TypeReference type)

_aloadHelper

public Instruction _aloadHelper(Operator operator,
                                Operand ref,
                                Operand index,
                                TypeReference type)

_callHelper

private Instruction _callHelper(MethodReference meth,
                                MethodOperand methOp)
Pop method parameters off the expression stack. If a non-void return, then create a result operand and push it on the stack. Create the call instruction and initialize all its operands.


_returnHelper

private void _returnHelper(Operator operator,
                           Operand val)

appendInstruction

public void appendInstruction(Instruction s)
Append an instruction to the current basic block.

Parameters:
s - instruction to append

markBBUnsafeForScheduling

void markBBUnsafeForScheduling()
HACK: Mark current basic block unsafe for scheduling. TODO: remove when we've got UNINT_BEGIN/END working correctly.


makeStaticFieldRef

private LocationOperand makeStaticFieldRef(FieldReference f)
Make a field reference operand referring to the given field with the given type.

Parameters:
f - desired field

makeInstanceFieldRef

private LocationOperand makeInstanceFieldRef(FieldReference f)

makeTypeOperand

private TypeOperand makeTypeOperand(TypeReference type)
Make a type operand that refers to the given type.

Parameters:
type - desired type

makeTypeOperand

private TypeOperand makeTypeOperand(RVMType type)
Make a type operand that refers to the given type.

Parameters:
type - desired type

couldCauseClassLoading

private boolean couldCauseClassLoading(TypeReference typeRef)

getConstantOperand

public Operand getConstantOperand(int index)
Fetch the value of the next operand, a constant, from the bytecode stream.

Returns:
the value of a literal constant from the bytecode stream, encoding as a constant IR operand

do_iload

private Instruction do_iload(int index)
Simulate a load from a given local variable of an int. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

do_fload

private Instruction do_fload(int index)
Simulate a load from a given local variable of a float. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

do_aload

private Instruction do_aload(int index)
Simulate a load from a given local variable of a reference. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

do_lload

private Instruction do_lload(int index)
Simulate a load from a given local variable of a long. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

do_dload

private Instruction do_dload(int index)
Simulate a load from a given local variable of a double. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

do_iinc

private Instruction do_iinc(int index,
                            int amount)
Simulate the incrementing of a given int local variable. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number
amount - amount to increment by

do_store

private Instruction do_store(int index,
                             Operand op1)
Simulate a store into a given local variable of an int/long/double/float Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

do_astore

private Instruction do_astore(int index)
Simulate a store into a given local variable of an object ref. Returns generated instruction (or null if no instruction generated.)

Parameters:
index - local variable number

push

public void push(Operand r)
Push a single width operand (int, float, ref, ...) on the simulated stack.

Parameters:
r - operand to push

pushDual

void pushDual(Operand r)
Push a double width operand (long, double) on the simulated stack.

Parameters:
r - operand to push

push

void push(Operand r,
          TypeReference type)
Push an operand of the specified type on the simulated stack.

Parameters:
r - operand to push
type - data type of operand

pushCopy

private Instruction pushCopy(Operand op1,
                             int b1)
Push a copy of the given operand onto simulated stack.

Parameters:
op1 - operand to push
b1 - bytecode index to associate with the pushed operand

pushCopy

private Instruction pushCopy(Operand op1)
Push a copy of the given operand onto simulated stack.

Parameters:
op1 - operand to push

pop

Operand pop()
Pop an operand from the stack. No type checking is performed.


popInt

public Operand popInt()
Pop an int operand from the stack.


popFloat

Operand popFloat()
Pop a float operand from the stack.


popRef

public Operand popRef()
Pop a ref operand from the stack.


popAddress

public Operand popAddress()
Pop a ref operand from the stack.


popLong

Operand popLong()
Pop a long operand from the stack.


popDouble

Operand popDouble()
Pop a double operand from the stack.


popDummy

void popDummy()
Pop a dummy operand from the stack.


pop

Operand pop(TypeReference type)
Pop an operand of the given type from the stack.


popShiftInt

private Operand popShiftInt(boolean longShift)
Pop an int from the stack to be used in a shift. A shift only uses the bottom 5 or 6 bits of an int so the upper bits must be masked to conform with the semantics of xx_SHx. NB the opt compiler shift operators allow that (x << 16) << 16 == x << 32, which isn't true in the bytecode

Parameters:
longShift - is this a shift of a long
Returns:
the operand containing the amount to shift by

_jsrHelper

private Instruction _jsrHelper(int offset)

_retHelper

private Instruction _retHelper(int var)

getArrayTypeOf

public TypeReference getArrayTypeOf(Operand op)
Return the data type of the given operand, assuming that the operand is an array reference. (and not a null constant.)

Parameters:
op - operand to get type of

getRefTypeOf

private TypeReference getRefTypeOf(Operand op)
Return the data type of the given operand, assuming that the operand is a reference. (and not a null constant.)

Parameters:
op - operand to get type of

assertIsType

public void assertIsType(Operand op,
                         TypeReference type)
Assert that the given operand is of the given type, or of a subclass of the given type.

Parameters:
op - operand to check
type - expected type of operand

assertIsAssignable

private void assertIsAssignable(TypeReference parentType,
                                TypeReference childType)
Assert that the given child type is a subclass of the given parent type.

Parameters:
parentType - parent type
childType - child type

db

private void db(String val)
Print a debug string to the sysWrite stream

Parameters:
val - string to print

printBlocks

private String printBlocks()
Return a string representation of the current basic block set.


isNonNull

public static boolean isNonNull(Operand op)

hasGuard

public static boolean hasGuard(RegisterOperand rop)

hasLessConservativeGuard

public static boolean hasLessConservativeGuard(RegisterOperand rop1,
                                               RegisterOperand rop2)

markGuardlessNonNull

public void markGuardlessNonNull(RegisterOperand rop)

getGuard

public static Operand getGuard(Operand op)

setGuard

public static void setGuard(RegisterOperand rop,
                            Operand guard)

setCurrentGuard

private void setCurrentGuard(Operand guard)

clearCurrentGuard

public void clearCurrentGuard()

getCurrentGuard

public Operand getCurrentGuard()

do_NullCheck

public boolean do_NullCheck(Operand ref)
Generate a null-check instruction for the given operand.

Returns:
true if an unconditional throw is generated, false otherwise

do_BoundsCheck

public boolean do_BoundsCheck(Operand ref,
                              Operand index)
Generate a boundscheck instruction for the given operand and index.

Returns:
true if an unconditional throw is generated, false otherwise

do_IntZeroCheck

private boolean do_IntZeroCheck(Operand div)
Generate a check for 0 for the given operand

Returns:
true if an unconditional trap is generated, false otherwise

do_LongZeroCheck

private boolean do_LongZeroCheck(Operand div)
Generate a check for 0 for the given operand

Returns:
true if an unconditional trap is generated, false otherwise

do_CheckStore

private boolean do_CheckStore(Operand ref,
                              Operand elem,
                              TypeReference elemType)
Generate a storecheck for the given array and elem

Parameters:
ref - the array reference
elem - the element to be written to the array
elemType - the type of the array references elements
Returns:
true if an unconditional throw is generated, false otherwise

getOrCreateBlock

private BasicBlockLE getOrCreateBlock(int target)
Get or create a block at the specified target. Rectifies current state with target state. Instructions to rectify state are appended to currentBBLE. If the target is between bcodes.index() and runoff, runoff is updated to be target.

Parameters:
target - target index

getOrCreateBlock

private BasicBlockLE getOrCreateBlock(int target,
                                      BasicBlockLE from,
                                      OperandStack simStack,
                                      Operand[] simLocals)
Get or create a block at the specified target. If simStack is non-null, rectifies stack state with target stack state. If simLocals is non-null, rectifies local state with target local state. Any instructions needed to rectify stack/local state are appended to from. If the target is between bcodes.index() and runoff, runoff is updated to be target.

Parameters:
target - target index
from - the block from which control is being transfered and to which stack rectification instructions are added.
simStack - stack state to rectify, or null
simLocals - local state to rectify, or null

generateTarget

private BranchOperand generateTarget(int offset)

_gotoHelper

private Instruction _gotoHelper(int offset)

_intIfHelper

private Instruction _intIfHelper(ConditionOperand cond)

_intIfCmpHelper

private Instruction _intIfCmpHelper(ConditionOperand cond)

_refIfNullHelper

private Instruction _refIfNullHelper(ConditionOperand cond)

_refIfCmpHelper

private Instruction _refIfCmpHelper(ConditionOperand cond)

replaceLocalsOnStack

private void replaceLocalsOnStack(int index,
                                  TypeReference type)
Replaces copies of local <#index,type> with newly-generated temporaries, and generates the necessary move instructions.

Parameters:
index - the local's index
type - the local's type

rectifyStateWithNullPtrExceptionHandler

private BasicBlock rectifyStateWithNullPtrExceptionHandler()

rectifyStateWithArrayBoundsExceptionHandler

private BasicBlock rectifyStateWithArrayBoundsExceptionHandler()

rectifyStateWithArithmeticExceptionHandler

private BasicBlock rectifyStateWithArithmeticExceptionHandler()

rectifyStateWithArrayStoreExceptionHandler

private BasicBlock rectifyStateWithArrayStoreExceptionHandler()

rectifyStateWithErrorHandler

private BasicBlock rectifyStateWithErrorHandler()

rectifyStateWithExceptionHandlers

public void rectifyStateWithExceptionHandlers()

rectifyStateWithExceptionHandler

public BasicBlock rectifyStateWithExceptionHandler(TypeReference exceptionType)

rectifyStateWithNullPtrExceptionHandler

private BasicBlock rectifyStateWithNullPtrExceptionHandler(boolean linkToExitIfUncaught)

rectifyStateWithArrayBoundsExceptionHandler

private BasicBlock rectifyStateWithArrayBoundsExceptionHandler(boolean linkToExitIfUncaught)

rectifyStateWithArithmeticExceptionHandler

private BasicBlock rectifyStateWithArithmeticExceptionHandler(boolean linkToExitIfUncaught)

rectifyStateWithArrayStoreExceptionHandler

private BasicBlock rectifyStateWithArrayStoreExceptionHandler(boolean linkToExitIfUncaught)

rectifyStateWithErrorHandler

private BasicBlock rectifyStateWithErrorHandler(boolean linkToExitIfUncaught)

rectifyStateWithExceptionHandler

private BasicBlock rectifyStateWithExceptionHandler(TypeReference exceptionType,
                                                    boolean linkToExitIfUncaught)

rectifyStateWithExceptionHandlers

private void rectifyStateWithExceptionHandlers(boolean linkToExitIfUncaught)

shouldInline

private InlineDecision shouldInline(Instruction call,
                                    boolean isExtant,
                                    int realBCI)
Should we inline a call site?

Parameters:
call - the call instruction being considered for inlining
isExtant - is the receiver of a virtual method an extant object?
realBCI - the real bytecode index of the call instruction, not adjusted because of OSR

maybeInlineMethod

private boolean maybeInlineMethod(InlineDecision inlDec,
                                  Instruction callSite)
Attempt to inline a method. This may fail.

Parameters:
inlDec - the inline decision for this call site
callSite - the call instruction we are attempting to inline
Returns:
true if inlining succeeded, false otherwise

_createOsrBarrier

private Instruction _createOsrBarrier()

_prepareLongConstant

private Operand _prepareLongConstant(Operand op)
special process for long/double constants


_prepareDoubleConstant

private Operand _prepareDoubleConstant(Operand op)
special process for long/double constants


_loadLocalForOSR

private Operand _loadLocalForOSR(Operand op)
make a temporary register, and create a move instruction

Parameters:
op - the local variable.
Returns:
operand marked as use.

_osrHelper

public static Instruction _osrHelper(Instruction barrier)
Creates an OSR point instruction with its dependent OsrBarrier which provides type and variable information. The OsrPoint instruction is going to be refilled immediately after BC2IR, before any other optimizations.


getLocal

private Operand getLocal(int i)
Gets the specified local variable. This can return an RegisterOperand which refers to the given local, or some other kind of operand (if the local variable is assumed to contain a particular value.)

Parameters:
i - local variable number

getLocalDual

private Operand getLocalDual(int i)
Gets the specified local variable (long, double). This can return an RegisterOperand which refers to the given local, or some other kind of operand (if the local variable is assumed to contain a given value.)

Parameters:
i - local variable number

setLocal

private void setLocal(int i,
                      Operand op)
Set the specified local variable

Parameters:
i - local variable number
op - Operand to store in the local

setLocalDual

private void setLocalDual(int i,
                          Operand op)
Set the specified local variable

Parameters:
i - local variable number
op - Operand to store in the local