Skip to content

Commit

Permalink
Showing 6 changed files with 55 additions and 25 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/ir/targets/Bootstrap.java
Original file line number Diff line number Diff line change
@@ -48,8 +48,8 @@

public class Bootstrap {
public final static String BOOTSTRAP_BARE_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class);
public final static String BOOTSTRAP_LONG_STRING_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, long.class, String.class, int.class);
public final static String BOOTSTRAP_DOUBLE_STRING_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, double.class, String.class, int.class);
public final static String BOOTSTRAP_LONG_STRING_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, long.class, int.class, String.class, int.class);
public final static String BOOTSTRAP_DOUBLE_STRING_INT_SIG = sig(CallSite.class, Lookup.class, String.class, MethodType.class, double.class, int.class, String.class, int.class);
public static final Class[] REIFIED_OBJECT_CLASSES = {
RubyObjectVar0.class,
RubyObjectVar1.class,
Original file line number Diff line number Diff line change
@@ -384,7 +384,7 @@ public org.objectweb.asm.Label newLabel() {
*
* @param name name of the method to invoke
*/
public abstract void invokeOtherOneFixnum(String file, int line, String name, long fixnum);
public abstract void invokeOtherOneFixnum(String file, int line, String name, long fixnum, CallType callType);

/**
* Invoke a float-receiving method on an object other than self.
@@ -393,7 +393,7 @@ public org.objectweb.asm.Label newLabel() {
*
* @param name name of the method to invoke
*/
public abstract void invokeOtherOneFloat(String file, int line, String name, double flote);
public abstract void invokeOtherOneFloat(String file, int line, String name, double flote, CallType callType);


/**
20 changes: 16 additions & 4 deletions core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter6.java
Original file line number Diff line number Diff line change
@@ -532,11 +532,17 @@ public static void buildArrayFromLocals(SkinnyMethodAdapter adapter2, int base,
}
}

public void invokeOtherOneFixnum(String file, int line, String name, long fixnum) {
public void invokeOtherOneFixnum(String file, int line, String name, long fixnum, CallType callType) {
if (!MethodIndex.hasFastFixnumOps(name)) {
pushFixnum(fixnum);
invokeOther(file, line, name, 1, false, false);
if (callType == CallType.NORMAL) {
invokeOther(file, line, name, 1, false, false);
} else {
invokeSelf(file, line, name, 1, false, callType, false);
}
return;
}

SkinnyMethodAdapter adapter2;
String incomingSig = sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT));
String outgoingSig = sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, long.class));
@@ -582,11 +588,17 @@ public void invokeOtherOneFixnum(String file, int line, String name, long fixnum
adapter.invokestatic(getClassData().clsName, methodName, incomingSig);
}

public void invokeOtherOneFloat(String file, int line, String name, double flote) {
public void invokeOtherOneFloat(String file, int line, String name, double flote, CallType callType) {
if (!MethodIndex.hasFastFloatOps(name)) {
pushFloat(flote);
invokeOther(file, line, name, 1, false, false);
if (callType == CallType.NORMAL) {
invokeOther(file, line, name, 1, false, false);
} else {
invokeSelf(file, line, name, 1, false, callType, false);
}
return;
}

SkinnyMethodAdapter adapter2;
String incomingSig = sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT));
String outgoingSig = sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, double.class));
27 changes: 25 additions & 2 deletions core/src/main/java/org/jruby/ir/targets/IRBytecodeAdapter7.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.MethodIndex;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
@@ -151,26 +152,48 @@ public void invokeArrayDeref() {
adapter.invokedynamic("aref", sig(JVM.OBJECT, params(ThreadContext.class, JVM.OBJECT, JVM.OBJECT, JVM.OBJECT, 1)), ArrayDerefInvokeSite.BOOTSTRAP);
}

public void invokeOtherOneFixnum(String file, int line, String name, long fixnum) {
public void invokeOtherOneFixnum(String file, int line, String name, long fixnum, CallType callType) {
if (!MethodIndex.hasFastFixnumOps(name)) {
pushFixnum(fixnum);
if (callType == CallType.NORMAL) {
invokeOther(file, line, name, 1, false, false);
} else {
invokeSelf(file, line, name, 1, false, callType, false);
}
return;
}

String signature = sig(IRubyObject.class, params(ThreadContext.class, IRubyObject.class, IRubyObject.class));

adapter.invokedynamic(
"fixnumOperator:" + JavaNameMangler.mangleMethodName(name),
signature,
Bootstrap.getFixnumOperatorHandle(),
fixnum,
callType.ordinal(),
"",
0);
}

public void invokeOtherOneFloat(String file, int line, String name, double flote) {
public void invokeOtherOneFloat(String file, int line, String name, double flote, CallType callType) {
if (!MethodIndex.hasFastFloatOps(name)) {
pushFloat(flote);
if (callType == CallType.NORMAL) {
invokeOther(file, line, name, 1, false, false);
} else {
invokeSelf(file, line, name, 1, false, callType, false);
}
return;
}

String signature = sig(IRubyObject.class, params(ThreadContext.class, IRubyObject.class, IRubyObject.class));

adapter.invokedynamic(
"floatOperator:" + JavaNameMangler.mangleMethodName(name),
signature,
Bootstrap.getFloatOperatorHandle(),
flote,
callType.ordinal(),
"",
0);
}
13 changes: 4 additions & 9 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -989,11 +989,10 @@ public void BuildSplatInstr(BuildSplatInstr instr) {

@Override
public void CallInstr(CallInstr callInstr) {
if (callInstr instanceof OneFixnumArgNoBlockCallInstr && MethodIndex.getFastFixnumOpsMethod(callInstr.getName()) != null) {
if (callInstr instanceof OneFixnumArgNoBlockCallInstr) {
oneFixnumArgNoBlockCallInstr((OneFixnumArgNoBlockCallInstr) callInstr);
return;
} else if (callInstr instanceof OneFloatArgNoBlockCallInstr &&
MethodIndex.getFastFloatOpsMethod(callInstr.getName()) != null) {
} else if (callInstr instanceof OneFloatArgNoBlockCallInstr) {
oneFloatArgNoBlockCallInstr((OneFloatArgNoBlockCallInstr) callInstr);
return;
}
@@ -1527,7 +1526,7 @@ public void oneFixnumArgNoBlockCallInstr(OneFixnumArgNoBlockCallInstr oneFixnumA

visit(receiver);

m.invokeOtherOneFixnum(file, lastLine, name, fixnum);
m.invokeOtherOneFixnum(file, lastLine, name, fixnum, oneFixnumArgNoBlockCallInstr.getCallType());

if (result != null) {
jvmStoreLocal(result);
@@ -1538,10 +1537,6 @@ public void oneFixnumArgNoBlockCallInstr(OneFixnumArgNoBlockCallInstr oneFixnumA
}

public void oneFloatArgNoBlockCallInstr(OneFloatArgNoBlockCallInstr oneFloatArgNoBlockCallInstr) {
if (MethodIndex.getFastFloatOpsMethod(oneFloatArgNoBlockCallInstr.getName()) == null) {
CallInstr(oneFloatArgNoBlockCallInstr);
return;
}
IRBytecodeAdapter m = jvmMethod();
String name = oneFloatArgNoBlockCallInstr.getName();
double flote = oneFloatArgNoBlockCallInstr.getFloatArg();
@@ -1556,7 +1551,7 @@ public void oneFloatArgNoBlockCallInstr(OneFloatArgNoBlockCallInstr oneFloatArgN

visit(receiver);

m.invokeOtherOneFloat(file, lastLine, name, flote);
m.invokeOtherOneFloat(file, lastLine, name, flote, oneFloatArgNoBlockCallInstr.getCallType());

if (result != null) {
jvmStoreLocal(result);
Original file line number Diff line number Diff line change
@@ -51,10 +51,10 @@
public class MathLinker {
private static final Logger LOG = LoggerFactory.getLogger(MathLinker.class);

public static CallSite fixnumOperatorBootstrap(Lookup lookup, String name, MethodType type, long value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
public static CallSite fixnumOperatorBootstrap(Lookup lookup, String name, MethodType type, long value, int callType, String file, int line) throws NoSuchMethodException, IllegalAccessException {
String[] names = name.split(":");
String operator = JavaNameMangler.demangleMethodName(names[1]);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, true);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.values()[callType], file, line, operator, true);

MethodHandle target = lookup.findStatic(MathLinker.class, "fixnumOperator",
methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, long.class));
@@ -64,10 +64,10 @@ public static CallSite fixnumOperatorBootstrap(Lookup lookup, String name, Metho
return site;
}

public static CallSite fixnumBooleanBootstrap(Lookup lookup, String name, MethodType type, long value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
public static CallSite fixnumBooleanBootstrap(Lookup lookup, String name, MethodType type, long value, int callType, String file, int line) throws NoSuchMethodException, IllegalAccessException {
String[] names = name.split(":");
String operator = JavaNameMangler.demangleMethodName(names[1]);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, true);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.values()[callType], file, line, operator, true);

MethodHandle target = lookup.findStatic(MathLinker.class, "fixnumBoolean",
methodType(boolean.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, long.class));
@@ -77,10 +77,10 @@ public static CallSite fixnumBooleanBootstrap(Lookup lookup, String name, Method
return site;
}

public static CallSite floatOperatorBootstrap(Lookup lookup, String name, MethodType type, double value, String file, int line) throws NoSuchMethodException, IllegalAccessException {
public static CallSite floatOperatorBootstrap(Lookup lookup, String name, MethodType type, double value, int callType, String file, int line) throws NoSuchMethodException, IllegalAccessException {
String[] names = name.split(":");
String operator = JavaNameMangler.demangleMethodName(names[1]);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.NORMAL, file, line, operator, true);
JRubyCallSite site = new JRubyCallSite(lookup, type, CallType.values()[callType], file, line, operator, true);

MethodHandle target = lookup.findStatic(MathLinker.class, "floatOperator",
methodType(IRubyObject.class, ThreadContext.class, IRubyObject.class, IRubyObject.class, JRubyCallSite.class, double.class));

0 comments on commit 07cdf83

Please sign in to comment.