public Label clone() { Label newL = new Label(prefix, id); newL.setTargetPC(getTargetPC()); // Strictly not necessary, but, copy everything over return newL; }
protected Label getRenamedLabelSimple(Label l) { // In ensure-block-clone mode, no cloning of labels not already pre-renamed and initialized // FIXME: IRScope.java:prepareInstructionsForInterpretation/Compilation assumes that // multiple labels with the same name are identical java objects. So, reuse the object here. return isEnsureBlock ? l : l.clone(); }
public boolean isGlobalEnsureBlockLabel() { return this.equals(GLOBAL_ENSURE_BLOCK_LABEL); }
private Instr[] prepareBuildInstructions(List<Instr> instructions) { int length = instructions.size(); Instr[] linearizedInstrArray = instructions.toArray(new Instr[length]); for (int ipc = 0; ipc < length; ipc++) { Instr i = linearizedInstrArray[ipc]; if (i instanceof LabelInstr) ((LabelInstr) i).getLabel().setTargetPC(ipc + 1); } Stack<Integer> markers = new Stack(); rescueIPCs = new int[length]; int rpc = -1; for (int ipc = 0; ipc < length; ipc++) { Instr i = linearizedInstrArray[ipc]; if (i instanceof ExceptionRegionStartMarkerInstr) { rpc = ((ExceptionRegionStartMarkerInstr) i).getFirstRescueBlockLabel().getTargetPC(); markers.push(rpc); } else if (i instanceof ExceptionRegionEndMarkerInstr) { markers.pop(); rpc = markers.isEmpty() ? -1 : markers.peek().intValue(); } rescueIPCs[ipc] = rpc; } return linearizedInstrArray; }
@Override public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc) { Object result = operand.retrieve(context, self, currScope, currDynScope, temp); if (!(result instanceof RubyFixnum)) { // not a fixnum, fall back on old case logic return rubyCase.getTargetPC(); } int value = ((RubyFixnum) result).getIntValue(); int index = Arrays.binarySearch(jumps, value); if (index < 0) { return elseTarget.getTargetPC(); } return targets[index].getTargetPC(); }
public Label clone() { return new Label(label); }
private void setupLabelPCs(HashMap<Label, Integer> labelIPCMap) { for (BasicBlock b: linearizedBBList) { Label l = b.getLabel(); l.setTargetPC(labelIPCMap.get(l)); } }
if (geb == null) { Variable exc = cfgScope.createTemporaryVariable(); geb = new BasicBlock(cfg, Label.getGlobalEnsureBlockLabel()); geb.addInstr(new ReceiveJRubyExceptionInstr(exc)); // JRuby implementation exception handling geb.addInstr(new ThrowExceptionInstr(exc));
private BasicBlock createBB(Label label, Stack<ExceptionRegion> nestedExceptionRegions) { BasicBlock basicBlock = new BasicBlock(this, label); addBasicBlock(basicBlock); if (label.isGlobalEnsureBlockLabel()) { globalEnsureBB = basicBlock; } if (!nestedExceptionRegions.empty()) nestedExceptionRegions.peek().addBB(basicBlock); return basicBlock; }
public void Label(Label label) { print(label.toString()); } public void LocalVariable(LocalVariable localvariable) { print(localvariable.getName()); }
case HASH: return Hash.decode(this); case IR_EXCEPTION: return IRException.decode(this); case LABEL: return Label.decode(this); case LOCAL_VARIABLE: return LocalVariable.decode(this); case NIL: return manager.getNil();
@Override public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc) { Object result = operand.retrieve(context, self, currScope, currDynScope, temp); if (!(result instanceof RubyFixnum)) { // not a fixnum, fall back on old case logic return rubyCase.getTargetPC(); } int value = ((RubyFixnum) result).getIntValue(); int index = Arrays.binarySearch(jumps, value); if (index < 0) { return elseTarget.getTargetPC(); } return targets[index].getTargetPC(); }
private Instr[] prepareBuildInstructions(List<Instr> instructions) { int length = instructions.size(); Instr[] linearizedInstrArray = instructions.toArray(new Instr[length]); for (int ipc = 0; ipc < length; ipc++) { Instr i = linearizedInstrArray[ipc]; if (i instanceof LabelInstr) ((LabelInstr) i).getLabel().setTargetPC(ipc + 1); } Stack<Integer> markers = new Stack(); rescueIPCs = new int[length]; int rpc = -1; for (int ipc = 0; ipc < length; ipc++) { Instr i = linearizedInstrArray[ipc]; if (i instanceof ExceptionRegionStartMarkerInstr) { rpc = ((ExceptionRegionStartMarkerInstr) i).getFirstRescueBlockLabel().getTargetPC(); markers.push(rpc); } else if (i instanceof ExceptionRegionEndMarkerInstr) { markers.pop(); rpc = markers.isEmpty() ? -1 : markers.peek().intValue(); } rescueIPCs[ipc] = rpc; } return linearizedInstrArray; }
public Label clone() { return new Label(label); }
private void setupLabelPCs(HashMap<Label, Integer> labelIPCMap) { for (BasicBlock b: linearizedBBList) { Label l = b.getLabel(); l.setTargetPC(labelIPCMap.get(l)); } }
if (geb == null) { Variable exc = cfgScope.createTemporaryVariable(); geb = new BasicBlock(cfg, Label.getGlobalEnsureBlockLabel()); geb.addInstr(new ReceiveJRubyExceptionInstr(exc)); // JRuby implementation exception handling geb.addInstr(new ThrowExceptionInstr(exc));
private BasicBlock createBB(Label label, Stack<ExceptionRegion> nestedExceptionRegions) { BasicBlock basicBlock = new BasicBlock(this, label); addBasicBlock(basicBlock); if (label.isGlobalEnsureBlockLabel()) { globalEnsureBB = basicBlock; } if (!nestedExceptionRegions.empty()) nestedExceptionRegions.peek().addBB(basicBlock); return basicBlock; }
public void Label(Label label) { print(label.toString()); } public void LocalVariable(LocalVariable localvariable) { print(localvariable.getName()); }
case HASH: return Hash.decode(this); case IR_EXCEPTION: return IRException.decode(this); case LABEL: return Label.decode(this); case LOCAL_VARIABLE: return LocalVariable.decode(this); case NIL: return manager.getNil();
@Override public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) { return ((Label)getJumpTarget().retrieve(context, self, currDynScope, temp)).getTargetPC(); }