Ejemplo n.º 1
0
  public Operand[] cloneCallArgs(InlinerInfo ii) {
    int i = 0;
    Operand[] clonedArgs = new Operand[arguments.length];

    for (Operand a : arguments) {
      clonedArgs[i++] = a.cloneForInlining(ii);
    }

    return clonedArgs;
  }
Ejemplo n.º 2
0
  @Override
  public void simplifyOperands(Map<Operand, Operand> valueMap, boolean force) {
    // FIXME: receiver should never be null (checkArity seems to be one culprit)
    if (receiver != null) receiver = receiver.getSimplifiedOperand(valueMap, force);
    methAddr = (MethAddr) methAddr.getSimplifiedOperand(valueMap, force);
    for (int i = 0; i < arguments.length; i++) {
      arguments[i] = arguments[i].getSimplifiedOperand(valueMap, force);
    }

    // Recompute containsArgSplat flag
    containsArgSplat = containsArgSplat(arguments);

    if (closure != null) closure = closure.getSimplifiedOperand(valueMap, force);
    flagsComputed = false; // Forces recomputation of flags

    // recompute whenever instr operands change! (can this really change though?)
    callSite = getCallSiteFor(callType, methAddr);
  }
Ejemplo n.º 3
0
  public Block prepareBlock(
      ThreadContext context,
      IRubyObject self,
      StaticScope currScope,
      DynamicScope currDynScope,
      Object[] temp) {
    if (closure == null) return Block.NULL_BLOCK;

    return IRRuntimeHelpers.getBlockFromObject(
        context, closure.retrieve(context, self, currScope, currDynScope, temp));
  }
Ejemplo n.º 4
0
  protected IRubyObject[] prepareArgumentsComplex(
      ThreadContext context,
      IRubyObject self,
      Operand[] args,
      StaticScope currScope,
      DynamicScope currDynScope,
      Object[] temp) {
    // SSS: For regular calls, IR builder never introduces splats except as the first argument
    // But when zsuper is converted to SuperInstr with known args, splats can appear anywhere
    // in the list.  So, this looping handles both these scenarios, although if we wanted to
    // optimize for CallInstr which has splats only in the first position, we could do that.
    List<IRubyObject> argList = new ArrayList<IRubyObject>();
    for (Operand arg : args) {
      IRubyObject rArg = (IRubyObject) arg.retrieve(context, self, currScope, currDynScope, temp);
      if (arg instanceof Splat) {
        argList.addAll(Arrays.asList(((RubyArray) rArg).toJavaArray()));
      } else {
        argList.add(rArg);
      }
    }

    return argList.toArray(new IRubyObject[argList.size()]);
  }
Ejemplo n.º 5
0
  @Override
  public Object interpret(
      ThreadContext context,
      StaticScope currScope,
      DynamicScope dynamicScope,
      IRubyObject self,
      Object[] temp) {
    IRubyObject object =
        (IRubyObject) receiver.retrieve(context, self, currScope, dynamicScope, temp);
    IRubyObject[] values =
        prepareArguments(context, self, arguments, currScope, dynamicScope, temp);
    Block preparedBlock = prepareBlock(context, self, currScope, dynamicScope, temp);

    return callSite.call(context, self, object, values, preparedBlock);
  }