Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
@@ -29,7 +31,7 @@ public class CachedBoxedMethodMissingDispatchNode extends CachedDispatchNode {
private static final boolean DISPATCH_METHODMISSING_ALWAYS_CLONED = Options.TRUFFLE_DISPATCH_METHODMISSING_ALWAYS_CLONED.load();
private static final boolean DISPATCH_METHODMISSING_ALWAYS_INLINED = Options.TRUFFLE_DISPATCH_METHODMISSING_ALWAYS_INLINED.load();

private final DynamicObject expectedClass;
private final Shape expectedShape;
private final Assumption unmodifiedAssumption;
private final InternalMethod method;

@@ -40,14 +42,15 @@ public CachedBoxedMethodMissingDispatchNode(
RubyContext context,
Object cachedName,
DispatchNode next,
Shape expectedShape,
DynamicObject expectedClass,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);

assert RubyGuards.isRubyClass(expectedClass);
this.expectedClass = expectedClass;
this.expectedShape = expectedShape;
unmodifiedAssumption = Layouts.MODULE.getFields(expectedClass).getUnmodifiedAssumption();
this.method = method;

@@ -79,7 +82,7 @@ public CachedBoxedMethodMissingDispatchNode(
protected boolean guard(Object methodName, Object receiver) {
return guardName(methodName) &&
(receiver instanceof DynamicObject) &&
Layouts.BASIC_OBJECT.getMetaClass(((DynamicObject) receiver)) == expectedClass;
((DynamicObject) receiver).getShape() == expectedShape;
}

@Override
Original file line number Diff line number Diff line change
@@ -17,10 +17,12 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.interop.messages.Argument;
import com.oracle.truffle.interop.messages.Read;
import com.oracle.truffle.interop.messages.Receiver;
import com.oracle.truffle.interop.node.ForeignObjectAccessNode;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.objects.SingletonClassNode;
import org.jruby.truffle.runtime.RubyArguments;
@@ -251,7 +253,10 @@ private DispatchNode createMethodMissingNode(
return new UncachedDispatchNode(getContext(), ignoreVisibility, getDispatchAction(), missingBehavior);
}

return new CachedBoxedMethodMissingDispatchNode(getContext(), methodName, first,
// TODO (eregon, 26 Aug. 2015): should handle primitive types as well
final Shape shape = (receiverObject instanceof DynamicObject) ? ((DynamicObject) receiverObject).getShape() : null;

return new CachedBoxedMethodMissingDispatchNode(getContext(), methodName, first, shape,
getContext().getCoreLibrary().getMetaClass(receiverObject), method, DISPATCH_METAPROGRAMMING_ALWAYS_INDIRECT, getDispatchAction());
}

0 comments on commit 67f445b

Please sign in to comment.