/** * Create a new exception handler BBLE (and exception handler basic block) for the specified * bytecode index and exception type. * * @param loc bytecode index * @param position inline sequence * @param eType exception type * @param temps the register pool to allocate exceptionObject from * @param exprStackSize max size of expression stack * @param cfg ControlFlowGraph into which the block will eventually be inserted */ HandlerBlockLE( int loc, InlineSequence position, TypeOperand eType, GenericRegisterPool temps, int exprStackSize, ControlFlowGraph cfg) { super(loc); entryBlock = new ExceptionHandlerBasicBlock(SYNTH_CATCH_BCI, position, eType, cfg); block = new BasicBlock(loc, position, cfg); // NOTE: We intentionally use throwable rather than eType to avoid // having the complexity of having to regenerate the handler when a // new type of caught exception is added. Since we shouldn't care about // the performance of code in exception handling blocks, this // should be the right tradeoff. exceptionObject = temps.makeTemp(TypeReference.JavaLangThrowable); BC2IR.setGuardForRegOp(exceptionObject, new TrueGuardOperand()); // know not null high = loc; // Set up expression stack on entry to have the caught exception operand. stackState = new OperandStack(exprStackSize); stackState.push(exceptionObject); setStackKnown(); // entry block contains instructions to transfer the caught // exception object to exceptionObject. Instruction s = Nullary.create(GET_CAUGHT_EXCEPTION, exceptionObject.copyD2D()); entryBlock.appendInstruction(s); s.bcIndex = SYNTH_CATCH_BCI; entryBlock.insertOut(block); }
/** * Given a value number, return the temporary register allocated for that value number. Create one * if necessary. * * @param heapType a TypeReference or RVMField identifying the array SSA heap type * @param valueNumber * @param registers a mapping from value number to temporary register * @param pool register pool to allocate new temporaries from * @param type the type to store in the new register */ static Register findOrCreateRegister( Object heapType, int valueNumber, HashMap<UseRecord, Register> registers, GenericRegisterPool pool, TypeReference type) { UseRecord key = new UseRecord(heapType, valueNumber); Register result = registers.get(key); if (result == null) { // create a new temp and insert it in the mapping result = pool.makeTemp(type).getRegister(); registers.put(key, result); } return result; }