@Override public Instr cloneForInlining(InlinerInfo ii) { Operand receiver = getReceiver(); if (this.implMethod == JRubyImplementationMethod.CHECK_ARITY) { Operand[] args = getCallArgs(); int required = ((Fixnum) args[0]).value.intValue(); int opt = ((Fixnum) args[1]).value.intValue(); int rest = ((Fixnum) args[2]).value.intValue(); int numArgs = ii.getArgsCount(); if ((numArgs < required) || ((rest == -1) && (numArgs > (required + opt)))) { // Argument error! Throw it at runtime return new JRubyImplCallInstr( null, JRubyImplementationMethod.RAISE_ARGUMENT_ERROR, null, new Operand[] {args[0], args[1], args[2], new Fixnum((long) numArgs)}); } else { return null; } } else { return new JRubyImplCallInstr( result == null ? null : ii.getRenamedVariable(result), this.implMethod, receiver == null ? null : receiver.cloneForInlining(ii), cloneCallArgs(ii), closure == null ? null : closure.cloneForInlining(ii)); } }
@Override public Object call(ThreadContext context, IRubyObject self, IRubyObject receiver, Object[] temp) { IRubyObject value1 = (IRubyObject) arg1.retrieve(context, self, temp); IRubyObject value2 = (IRubyObject) arg2.retrieve(context, self, temp); IRubyObject value3 = (IRubyObject) arg3.retrieve(context, self, temp); IRubyObject value4 = (IRubyObject) arg4.retrieve(context, self, temp); return callSite.call(context, self, receiver, value1, value2, value3, value4); }
@Override public Instr cloneForInlining(InlinerInfo ii) { return new ToAryInstr( (Variable) result.cloneForInlining(ii), array.cloneForInlining(ii), (BooleanLiteral) dontToAryArrays.cloneForInlining(ii)); }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { return new ModuleVersionGuardInstr( module, expectedVersion, candidateObj.cloneForInlining(ii), ii.getRenamedLabel(failurePathLabel)); }
@Override public Operand simplifyAndGetResult(Map<Operand, Operand> valueMap) { simplifyOperands(valueMap, false); if (!value.isConstant()) return null; return value == Nil.NIL || value == BooleanLiteral.FALSE ? BooleanLiteral.FALSE : BooleanLiteral.TRUE; }
@Override public Object interpret( ThreadContext context, IRubyObject self, IRubyObject[] args, Block block, Object exception, Object[] temp) { result.store(context, self, temp, methodHandle.retrieve(context, self, temp)); return null; }
@Override public Object interpret( ThreadContext context, IRubyObject self, IRubyObject[] args, Block block, Object exception, Object[] temp) { IRubyObject receiver = (IRubyObject) arg1.retrieve(context, self, temp); IRubyObject value = (IRubyObject) arg2.retrieve(context, self, temp); if (value == UndefinedValue.UNDEFINED) { result.store(context, self, temp, receiver); } else if (receiver instanceof RubyArray) { RubyArray testVals = (RubyArray) receiver; for (int i = 0, n = testVals.getLength(); i < n; i++) { IRubyObject excType = (IRubyObject) testVals.eltInternal(i); if (!(excType instanceof RubyModule)) { throw context .getRuntime() .newTypeError("class or module required for rescue clause. Found: " + excType); } IRubyObject eqqVal = excType.callMethod(context, "===", value); if (eqqVal.isTrue()) { result.store(context, self, temp, eqqVal); return null; } } result.store(context, self, temp, context.getRuntime().newBoolean(false)); } else { if (!(receiver instanceof RubyModule)) { throw context .getRuntime() .newTypeError("class or module required for rescue clause. Found: " + receiver); } result.store(context, self, temp, receiver.callMethod(context, "===", value)); } return null; }
@Override public Object interpret( ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) { Object receiver = array.retrieve(context, self, currDynScope, temp); // Don't call to_ary if we we have an array already and we are asked not to run to_ary on arrays if (dontToAryArrays.isTrue() && receiver instanceof RubyArray) { return receiver; } else { return RuntimeHelpers.aryToAry((IRubyObject) receiver); } }
@Override public Object interpret( ThreadContext context, IRubyObject self, IRubyObject[] args, Block block, Object exception, Object[] temp) { // ENEBO: This seems like a lot of extra work... result.store( context, self, temp, context .getRuntime() .newBoolean(((IRubyObject) value.retrieve(context, self, temp)).isTrue())); return null; }
@Override public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) { candidateObj = candidateObj.getSimplifiedOperand(valueMap, force); }
public Instr cloneForInlining(InlinerInfo ii) { return new RescueEQQInstr( ii.getRenamedVariable(result), arg1.cloneForInlining(ii), arg2.cloneForInlining(ii)); }
@Override public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) { arg1 = arg1.getSimplifiedOperand(valueMap, force); arg2 = arg2.getSimplifiedOperand(valueMap, force); }
public void setConstantValue(String constRef, Operand val) { if (val.isConstant()) _constMap.put(constRef, val); if (this instanceof IR_Module) ((IR_Module) this).getRootMethod().addInstr(new PUT_CONST_Instr(this, constRef, val)); }
@Override public Operand simplifyAndGetResult(Map<Operand, Operand> valueMap) { simplifyOperands(valueMap); Operand val = argument.getValue(valueMap); return val.fetchCompileTimeArrayElement(index, all); }
@Override public Instr cloneForInlining(InlinerInfo ii) { return new IsTrueInstr(ii.getRenamedVariable(result), value.cloneForInlining(ii)); }
@Override public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) { value = value.getSimplifiedOperand(valueMap, force); }
public Instr cloneForInlining(InlinerInfo ii) { return new MethodLookupInstr( ii.getRenamedVariable(result), (MethodHandle) methodHandle.cloneForInlining(ii)); }
public boolean versionMatches( ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) { IRubyObject receiver = (IRubyObject) candidateObj.retrieve(context, self, currDynScope, temp); // if (module.getGeneration() != expectedVersion) ... replace this instr with a direct jump return (receiver.getMetaClass().getGeneration() == expectedVersion); }
@Override public Operand simplifyAndGetResult(IRScope scope, Map<Operand, Operand> valueMap) { simplifyOperands(valueMap, false); return dontToAryArrays.isTrue() && (array.getValue(valueMap) instanceof Array) ? array : null; }