Skip to content

Commit

Permalink
Showing 10 changed files with 42 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBooleanDispatchNode extends CachedDispatchNode {
public class CachedBooleanDispatchNode extends CachedDispatchNode {

private final Assumption falseUnmodifiedAssumption;
private final InternalMethod falseMethod;
@@ -90,21 +90,8 @@ public CachedBooleanDispatchNode(
}
}

public CachedBooleanDispatchNode(CachedBooleanDispatchNode prev) {
super(prev);
falseUnmodifiedAssumption = prev.falseUnmodifiedAssumption;
falseMethod = prev.falseMethod;
falseValue = prev.falseValue;
falseCallDirect = prev.falseCallDirect;
trueUnmodifiedAssumption = prev.trueUnmodifiedAssumption;
trueValue = prev.trueValue;
trueMethod = prev.trueMethod;
trueCallDirect = prev.trueCallDirect;
indirectCallNode = prev.indirectCallNode;
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {
public class CachedBoxedDispatchNode extends CachedDispatchNode {

private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;
@@ -92,18 +92,8 @@ public CachedBoxedDispatchNode(
}
}

public CachedBoxedDispatchNode(CachedBoxedDispatchNode prev) {
super(prev);
expectedClass = prev.expectedClass;
unmodifiedAssumption = prev.unmodifiedAssumption;
value = prev.value;
method = prev.method;
callNode = prev.callNode;
indirectCallNode = prev.indirectCallNode;
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.util.cli.Options;

public abstract class CachedBoxedMethodMissingDispatchNode extends CachedDispatchNode {
public class CachedBoxedMethodMissingDispatchNode extends CachedDispatchNode {

private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;
@@ -73,17 +73,8 @@ public CachedBoxedMethodMissingDispatchNode(
}
}

public CachedBoxedMethodMissingDispatchNode(CachedBoxedMethodMissingDispatchNode prev) {
super(prev);
expectedClass = prev.expectedClass;
unmodifiedAssumption = prev.unmodifiedAssumption;
method = prev.method;
callNode = prev.callNode;
indirectCallNode = prev.indirectCallNode;
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;

public abstract class CachedBoxedReturnMissingDispatchNode extends CachedDispatchNode {
public class CachedBoxedReturnMissingDispatchNode extends CachedDispatchNode {

private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;
@@ -39,14 +39,8 @@ public CachedBoxedReturnMissingDispatchNode(
this.next = next;
}

public CachedBoxedReturnMissingDispatchNode(CachedBoxedReturnMissingDispatchNode prev) {
super(prev);
expectedClass = prev.expectedClass;
unmodifiedAssumption = prev.unmodifiedAssumption;
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBoxedSymbolDispatchNode extends CachedDispatchNode {
public class CachedBoxedSymbolDispatchNode extends CachedDispatchNode {

private final Assumption unmodifiedAssumption;

@@ -61,17 +61,8 @@ public CachedBoxedSymbolDispatchNode(
}
}

public CachedBoxedSymbolDispatchNode(CachedBoxedSymbolDispatchNode prev) {
super(prev);
unmodifiedAssumption = prev.unmodifiedAssumption;
value = prev.value;
method = prev.method;
callNode = prev.callNode;
indirectCallNode = prev.indirectCallNode;
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedUnboxedDispatchNode extends CachedDispatchNode {
public class CachedUnboxedDispatchNode extends CachedDispatchNode {

private final Class<?> expectedClass;
private final Assumption unmodifiedAssumption;
@@ -59,18 +59,8 @@ public CachedUnboxedDispatchNode(
}
}

public CachedUnboxedDispatchNode(CachedUnboxedDispatchNode prev) {
super(prev);
expectedClass = prev.expectedClass;
unmodifiedAssumption = prev.unmodifiedAssumption;
value = prev.value;
method = prev.method;
callNode = prev.callNode;
indirectCallNode = prev.indirectCallNode;
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object methodName,
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ public DispatchAction getDispatchAction() {

public void forceUncached() {
adoptChildren();
first.replace(UncachedDispatchNodeFactory.create(context, ignoreVisibility, null, null, null, null, null));
first.replace(new UncachedDispatchNode(context, ignoreVisibility, dispatchAction));
}

}
Original file line number Diff line number Diff line change
@@ -26,11 +26,6 @@
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.InternalMethod;

@NodeChildren({
@NodeChild(value="receiver", type=Node.class),
@NodeChild(value="methodName", type=Node.class),
@NodeChild(value="blockObject", type=Node.class),
@NodeChild(value="arguments", type=Node.class)})
public abstract class DispatchNode extends RubyNode {

private final DispatchAction dispatchAction;
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class UncachedDispatchNode extends DispatchNode {
public class UncachedDispatchNode extends DispatchNode {

private final boolean ignoreVisibility;

@@ -47,8 +47,8 @@ public UncachedDispatchNode(RubyContext context, boolean ignoreVisibility, Dispa
toJavaStringNode = ToJavaStringNodeFactory.create(context, null, null);
}

@Specialization
public Object dispatch(
@Override
public Object executeDispatch(
VirtualFrame frame,
Object receiverObject,
Object name,
Original file line number Diff line number Diff line change
@@ -54,8 +54,7 @@ public Object executeDispatch(

if (depth == Options.TRUFFLE_DISPATCH_POLYMORPHIC_MAX.load()) {
return getHeadNode().getFirstDispatchNode()
.replace(UncachedDispatchNodeFactory.create(getContext(), ignoreVisibility, getDispatchAction(),
null, null, null, null))
.replace(new UncachedDispatchNode(getContext(), ignoreVisibility, getDispatchAction()))
.executeDispatch(frame, receiverObject,
methodName, blockObject, argumentsObjects);
}
@@ -128,21 +127,19 @@ private Object doUnboxedObject(
throw new UnsupportedOperationException();
}

final CachedBooleanDispatchNode newDispatch = CachedBooleanDispatchNodeFactory.create(getContext(),
final CachedBooleanDispatchNode newDispatch = new CachedBooleanDispatchNode(getContext(),
methodName, first,
falseUnmodifiedAssumption, null, falseMethod,
trueUnmodifiedAssumption, null, trueMethod, indirect, getDispatchAction(),
null, null, null, null);
trueUnmodifiedAssumption, null, trueMethod, indirect, getDispatchAction());

first.replace(newDispatch);

return newDispatch.executeDispatch(frame, receiverObject,
methodName, blockObject, argumentsObjects);
} else {
final CachedUnboxedDispatchNode newDispatch = CachedUnboxedDispatchNodeFactory.create(getContext(),
final CachedUnboxedDispatchNode newDispatch = new CachedUnboxedDispatchNode(getContext(),
methodName, first, receiverObject.getClass(),
getContext().getCoreLibrary().getLogicalClass(receiverObject).getUnmodifiedAssumption(), null, method, indirect, getDispatchAction(), null, null, null,
null);
getContext().getCoreLibrary().getLogicalClass(receiverObject).getUnmodifiedAssumption(), null, method, indirect, getDispatchAction());

first.replace(newDispatch);

@@ -177,11 +174,10 @@ private Object doRubyBasicObject(
final DispatchNode newDispatch;

if (receiverObject instanceof RubySymbol) {
newDispatch = CachedBoxedSymbolDispatchNodeFactory.create(getContext(), methodName, first, null, method, indirect, getDispatchAction(),
null, null, null, null);
newDispatch = new CachedBoxedSymbolDispatchNode(getContext(), methodName, first, null, method, indirect, getDispatchAction());
} else {
newDispatch = CachedBoxedDispatchNodeFactory.create(getContext(), methodName, first,
getContext().getCoreLibrary().getMetaClass(receiverObject), null, method, indirect, getDispatchAction(), null, null, null, null);
newDispatch = new CachedBoxedDispatchNode(getContext(), methodName, first,
getContext().getCoreLibrary().getMetaClass(receiverObject), null, method, indirect, getDispatchAction());
}

first.replace(newDispatch);
@@ -201,9 +197,9 @@ private Object doRubyBasicObject(

// The module, the "receiver" is an instance of its singleton class.
// But we want to check the module assumption, not its singleton class assumption.
final DispatchNode newDispatch = CachedBoxedDispatchNodeFactory.create(getContext(), methodName, first,
final DispatchNode newDispatch = new CachedBoxedDispatchNode(getContext(), methodName, first,
module.getSingletonClass(null), module.getUnmodifiedAssumption(), constant.getValue(),
null, indirect, getDispatchAction(), null, null, null, null);
null, indirect, getDispatchAction());

first.replace(newDispatch);
return newDispatch.executeDispatch(frame, receiverObject,
@@ -221,8 +217,8 @@ private DispatchNode createConstantMissingNode(

switch (missingBehavior) {
case RETURN_MISSING: {
return first.replace(CachedBoxedReturnMissingDispatchNodeFactory.create(getContext(), methodName, first,
receiverObject.getMetaClass(), indirect, getDispatchAction(), null, null, null, null));
return first.replace(new CachedBoxedReturnMissingDispatchNode(getContext(), methodName, first,
receiverObject.getMetaClass(), indirect, getDispatchAction()));
}

case CALL_CONST_MISSING: {
@@ -234,12 +230,11 @@ private DispatchNode createConstantMissingNode(
}

if (Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_UNCACHED.load()) {
return first.replace(UncachedDispatchNodeFactory.create(getContext(), ignoreVisibility,
null, null, null, null, null));
return first.replace(new UncachedDispatchNode(getContext(), ignoreVisibility, getDispatchAction()));
}

return first.replace(CachedBoxedMethodMissingDispatchNodeFactory.create(getContext(), methodName, first,
receiverObject.getMetaClass(), method, Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT.load(), getDispatchAction(), null, null, null, null));
return first.replace(new CachedBoxedMethodMissingDispatchNode(getContext(), methodName, first,
receiverObject.getMetaClass(), method, Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT.load(), getDispatchAction()));
}

default: {
@@ -255,8 +250,8 @@ private DispatchNode createMethodMissingNode(

switch (missingBehavior) {
case RETURN_MISSING: {
return first.replace(CachedBoxedReturnMissingDispatchNodeFactory.create(getContext(), methodName, first,
getContext().getCoreLibrary().getMetaClass(receiverObject), indirect, getDispatchAction(), null, null, null, null));
return first.replace(new CachedBoxedReturnMissingDispatchNode(getContext(), methodName, first,
getContext().getCoreLibrary().getMetaClass(receiverObject), indirect, getDispatchAction()));
}

case CALL_METHOD_MISSING: {
@@ -268,12 +263,11 @@ private DispatchNode createMethodMissingNode(
}

if (Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_UNCACHED.load()) {
return first.replace(UncachedDispatchNodeFactory.create(getContext(), ignoreVisibility, getDispatchAction(),
null, null, null, null));
return first.replace(new UncachedDispatchNode(getContext(), ignoreVisibility, getDispatchAction()));
}

return first.replace(CachedBoxedMethodMissingDispatchNodeFactory.create(getContext(), methodName, first,
getContext().getCoreLibrary().getMetaClass(receiverObject), method, Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT.load(), getDispatchAction(), null, null, null, null));
return first.replace(new CachedBoxedMethodMissingDispatchNode(getContext(), methodName, first,
getContext().getCoreLibrary().getMetaClass(receiverObject), method, Options.TRUFFLE_DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT.load(), getDispatchAction()));
}

default: {

2 comments on commit 99a2573

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What prompted this change?

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DSL wasn't really doing anything any more.

Originally we were filtering some types in the specialisation signature (which went in a commit before this one) but that meant we had to have a fallback case, which was cumbersome. It was also useful in some other interop work we are doing on a separate branch, but that now works a different way as well.

Please sign in to comment.