Skip to content

Commit

Permalink
Allow more than normal calltypes to specialize
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Feb 3, 2015
1 parent 05e122d commit 342b90a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/ir/instructions/CallInstr.java
Expand Up @@ -19,24 +19,24 @@ public class CallInstr extends CallBase implements ResultInstr {
protected Variable result;

public static CallInstr create(Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
return create(CallType.NORMAL, result, name, receiver, args, closure);
}

public static CallInstr create(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
if (!containsArgSplat(args)) {
boolean hasClosure = closure != null;

if (args.length == 0 && !hasClosure) {
return new ZeroOperandArgNoBlockCallInstr(result, name, receiver, args);
return new ZeroOperandArgNoBlockCallInstr(callType, result, name, receiver, args);
} else if (args.length == 1) {
if (hasClosure) return new OneOperandArgBlockCallInstr(result, name, receiver, args, closure);
if (isAllFixnums(args)) return new OneFixnumArgNoBlockCallInstr(result, name, receiver, args);
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(result, name, receiver, args);
if (hasClosure) return new OneOperandArgBlockCallInstr(callType, result, name, receiver, args, closure);
if (isAllFixnums(args)) return new OneFixnumArgNoBlockCallInstr(callType, result, name, receiver, args);
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(callType, result, name, receiver, args);

return new OneOperandArgNoBlockCallInstr(result, name, receiver, args);
return new OneOperandArgNoBlockCallInstr(callType, result, name, receiver, args);
}
}

return new CallInstr(CallType.NORMAL, result, name, receiver, args, closure);
}

public static CallInstr create(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
return new CallInstr(callType, result, name, receiver, args, closure);
}

Expand Down
Expand Up @@ -17,8 +17,8 @@
public class OneFixnumArgNoBlockCallInstr extends CallInstr {
private final long fixNum;

public OneFixnumArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1F, CallType.NORMAL, result, name, receiver, args, null);
public OneFixnumArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1F, callType, result, name, receiver, args, null);

assert args.length == 1;

Expand All @@ -27,7 +27,7 @@ public OneFixnumArgNoBlockCallInstr(Variable result, String name, Operand receiv

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

Expand Down
Expand Up @@ -17,8 +17,8 @@
public class OneFloatArgNoBlockCallInstr extends CallInstr {
private final double flote;

public OneFloatArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1D, CallType.NORMAL, result, name, receiver, args, null);
public OneFloatArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1D, callType, result, name, receiver, args, null);

assert args.length == 1;

Expand All @@ -27,8 +27,8 @@ public OneFloatArgNoBlockCallInstr(Variable result, String name, Operand receive

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

@Override
Expand Down
Expand Up @@ -14,13 +14,13 @@
import org.jruby.runtime.builtin.IRubyObject;

public class OneOperandArgBlockCallInstr extends CallInstr {
public OneOperandArgBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
super(Operation.CALL_1OB, CallType.NORMAL, result, name, receiver, args, closure);
public OneOperandArgBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
super(Operation.CALL_1OB, callType, result, name, receiver, args, closure);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneOperandArgBlockCallInstr(ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
return new OneOperandArgBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii));
}

Expand Down
Expand Up @@ -14,14 +14,14 @@
import org.jruby.runtime.builtin.IRubyObject;

public class OneOperandArgNoBlockCallInstr extends CallInstr {
public OneOperandArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1O, CallType.NORMAL, result, name, receiver, args, null);
public OneOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_1O, callType, result, name, receiver, args, null);
}

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

@Override
Expand Down
Expand Up @@ -14,13 +14,13 @@
import org.jruby.runtime.builtin.IRubyObject;

public class ZeroOperandArgNoBlockCallInstr extends CallInstr {
public ZeroOperandArgNoBlockCallInstr(Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_0O, CallType.NORMAL, result, name, receiver, args, null);
public ZeroOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args) {
super(Operation.CALL_0O, callType, result, name, receiver, args, null);
}

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

Expand Down

0 comments on commit 342b90a

Please sign in to comment.