Skip to content

Commit

Permalink
New specialized instr 2 operand call. Roughly half of gem list
Browse files Browse the repository at this point in the history
scopes which make it to full build are 2 operand calls (which
is pretty surprising).  This also took a chunk out of red black
tree in interp mode.
enebo committed Jun 9, 2016
1 parent 4c4d6c7 commit 9111d5e
Showing 4 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/Operation.java
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ public enum Operation {
CALL_1F(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
CALL_1D(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
CALL_1O(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
CALL_2O(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
CALL_1OB(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
CALL_0O(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
NORESULT_CALL_1O(OpFlags.f_has_side_effect | OpFlags.f_is_call | OpFlags.f_can_raise_exception),
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CallInstr.java
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.jruby.ir.instructions.specialized.OneFloatArgNoBlockCallInstr;
import org.jruby.ir.instructions.specialized.OneOperandArgBlockCallInstr;
import org.jruby.ir.instructions.specialized.OneOperandArgNoBlockCallInstr;
import org.jruby.ir.instructions.specialized.TwoOperandArgNoBlockCallInstr;
import org.jruby.ir.instructions.specialized.ZeroOperandArgNoBlockCallInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
@@ -40,6 +41,8 @@ public static CallInstr create(IRScope scope, CallType callType, Variable result
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);

return new OneOperandArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);
} else if (args.length == 2 && !hasClosure) {
return new TwoOperandArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.jruby.ir.instructions.specialized;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.CallInstr;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.CallType;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

/**
* Created by enebo on 6/8/16.
*/
public class TwoOperandArgNoBlockCallInstr extends CallInstr {
public TwoOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
this(Operation.CALL_1O, callType, result, name, receiver, args, isPotentiallyRefined);
/*
this(Operation.CALL_2O, callType, result, name, receiver, args, isPotentiallyRefined);
*/
}

public TwoOperandArgNoBlockCallInstr(Operation op, CallType callType, Variable result, String name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
super(op, callType, result, name, receiver, args, null, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new TwoOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined());
}

public Operand getArg2() {
return operands[2];
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
IRubyObject object = (IRubyObject) getReceiver().retrieve(context, self, currScope, dynamicScope, temp);
IRubyObject arg1 = (IRubyObject) getArg1().retrieve(context, self, currScope, dynamicScope, temp);
IRubyObject arg2 = (IRubyObject) getArg2().retrieve(context, self, currScope, dynamicScope, temp);
return getCallSite().call(context, self, object, arg1, arg2);
}
}
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import org.jruby.ir.instructions.specialized.OneOperandArgBlockCallInstr;
import org.jruby.ir.instructions.specialized.OneOperandArgNoBlockCallInstr;
import org.jruby.ir.instructions.specialized.OneOperandArgNoBlockNoResultCallInstr;
import org.jruby.ir.instructions.specialized.TwoOperandArgNoBlockCallInstr;
import org.jruby.ir.instructions.specialized.ZeroOperandArgNoBlockCallInstr;
import org.jruby.ir.operands.Bignum;
import org.jruby.ir.operands.Fixnum;
@@ -314,6 +315,15 @@ protected static void processCall(ThreadContext context, Instr instr, Operation
setResult(temp, currDynScope, call.getResult(), result);
break;
}
case CALL_2O: {
TwoOperandArgNoBlockCallInstr call = (TwoOperandArgNoBlockCallInstr)instr;
IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, currScope, temp);
IRubyObject o1 = (IRubyObject)call.getArg1().retrieve(context, self, currScope, currDynScope, temp);
IRubyObject o2 = (IRubyObject)call.getArg2().retrieve(context, self, currScope, currDynScope, temp);
result = call.getCallSite().call(context, self, r, o1, o2);
setResult(temp, currDynScope, call.getResult(), result);
break;
}
case CALL_1OB: {
OneOperandArgBlockCallInstr call = (OneOperandArgBlockCallInstr)instr;
IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, currScope, temp);

0 comments on commit 9111d5e

Please sign in to comment.