Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jruby.ir.instructions;
  
 
 /*
  * args field: [self, receiver, *args]
  */
 public class CallInstr extends CallBase implements ResultInstr {
     protected Variable result;
 
     public static CallInstr create(Variable resultMethAddr methAddrOperand receiverOperand[] argsOperand closure) {
         return new CallInstr(.resultmethAddrreceiverargsclosure);
     }
 
     public static CallInstr create(CallType callTypeVariable resultMethAddr methAddrOperand receiverOperand[] argsOperand closure) {
         return new CallInstr(callTyperesultmethAddrreceiverargsclosure);
     }
 
 
     public CallInstr(CallType callTypeVariable resultMethAddr methAddrOperand receiverOperand[] argsOperand closure) {
         this(.callTyperesultmethAddrreceiverargsclosure);
     }
 
     protected CallInstr(Operation opCallType callTypeVariable resultMethAddr methAddrOperand receiverOperand[] argsOperand closure) {
         super(opcallTypemethAddrreceiverargsclosure);
 
         assert result != null;
 
         this. = result;
     }
 
     public CallInstr(Operation opCallInstr ordinary) {
         this(opordinary.getCallType(), ordinary.getResult(),
                 ordinary.getMethodAddr(), ordinary.getReceiver(), ordinary.getCallArgs(),
                 ordinary.getClosureArg(null));
     }
 
     public Variable getResult() {
         return ;
     }
 
     public void updateResult(Variable v) {
         this. = v;
     }
 
     @Override
     public CallBase specializeForInterpretation() {
         Operand[] callArgs = getCallArgs();
         if (hasClosure() || containsSplat(callArgs)) return this;
 
         switch (callArgs.length) {
             case 0:
                 return new ZeroOperandArgNoBlockCallInstr(this);
             case 1:
                 if (isAllFixnums()) return new OneFixnumArgNoBlockCallInstr(this);
 
                 return new OneOperandArgNoBlockCallInstr(this);
         }
         return this;
     }
 
     public Instr discardResult() {
     }
 
     @Override
     public Instr cloneForInlining(InlinerInfo ii) {
         return new CallInstr(getCallType(), ii.getRenamedVariable(),
                 (MethAddrgetMethodAddr().cloneForInlining(ii),
                 .cloneForInlining(ii), cloneCallArgs(ii),
                  == null ? null : .cloneForInlining(ii));
     }
 
     @Override
     public String toString() {
         return (hasUnusedResult() ? "[DEAD-RESULT]" : "") +  + " = " + super.toString();
     }
 
     @Override
     public void visit(IRVisitor visitor) {
         visitor.CallInstr(this);
     }
 
 /* FIXME: Dead code which I think should be a special instr (enebo)
         Object ma = methAddr.retrieve(interp, context, self);
         if (ma instanceof MethodHandle) return interpretMethodHandle(interp, context, self, (MethodHandle) ma, args);
          */

    
ENEBO: Dead code for now... public Label interpret_with_inline(InterpreterContext interp) { Object ma = methAddr.retrieve(interp); IRubyObject[] args = prepareArguments(getCallArgs(), interp); Object resultValue; if (ma instanceof MethodHandle) { MethodHandle mh = (MethodHandle)ma; assert mh.getMethodNameOperand() == getReceiver(); DynamicMethod m = mh.getResolvedMethod(); String mn = mh.getResolvedMethodName(); IRubyObject ro = mh.getReceiverObj(); if (m.isUndefined()) { resultValue = Helpers.callMethodMissing(interp.getContext(), ro, m.getVisibility(), mn, CallType.FUNCTIONAL, args, prepareBlock(interp)); } else { ThreadContext tc = interp.getContext(); RubyClass rc = ro.getMetaClass(); if (profile == null) { profile = new HashMap<DynamicMethod, Integer>(); } Integer count = profile.get(m); if (count == null) { count = new Integer(1); } else { count = new Integer(count + 1); if ((count > 50) && (m instanceof InterpretedIRMethod) && (profile.size() == 1)) { IRMethod inlineableMethod = ((InterpretedIRMethod)m).method; profile.remove(m); // remove it because the interpreter might ignore this hint throw new org.jruby.ir.interpreter.InlineMethodHint(inlineableMethod); } } profile.put(m, count); resultValue = m.call(tc, ro, rc, mn, args, prepareBlock(interp)); } } else { IRubyObject object = (IRubyObject) getReceiver().retrieve(interp); String name = ma.toString(); // SSS FIXME: If this is not a ruby string or a symbol, then this is an error in the source code! resultValue = object.callMethod(interp.getContext(), name, args, prepareBlock(interp)); } getResult().store(interp, resultValue); return null; } private Label interpretMethodHandle(InterpreterContext interp, ThreadContext context, IRubyObject self, MethodHandle mh, IRubyObject[] args) { assert mh.getMethodNameOperand() == getReceiver(); IRubyObject resultValue; DynamicMethod m = mh.getResolvedMethod(); String mn = mh.getResolvedMethodName(); IRubyObject ro = mh.getReceiverObj(); if (m.isUndefined()) { resultValue = Helpers.callMethodMissing(context, ro, m.getVisibility(), mn, CallType.FUNCTIONAL, args, prepareBlock(interp, context, self)); } else { resultValue = m.call(context, ro, ro.getMetaClass(), mn, args, prepareBlock(interp, context, self)); } getResult().store(interp, context, self, resultValue); return null;
New to GrepCode? Check out our FAQ X