Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d5d1f22f5a6c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 65416fbf4639
Choose a head ref
  • 4 commits
  • 15 files changed
  • 1 contributor

Commits on Sep 16, 2015

  1. Copy the full SHA
    e422866 View commit details
  2. Copy the full SHA
    881e24d View commit details
  3. [Truffle] Global cleanup of dispatch nodes.

    * Remove forced inlining of TruffleInterop,
      it should already be done by @coremethod.
    eregon committed Sep 16, 2015
    Copy the full SHA
    bc67d03 View commit details
  4. Copy the full SHA
    65416fb View commit details
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ public CachedBooleanDispatchNode(
this.falseMethod = falseMethod;

if (falseMethod != null) {
falseCallDirect = Truffle.getRuntime().createDirectCallNode(falseMethod.getCallTarget());
this.falseCallDirect = Truffle.getRuntime().createDirectCallNode(falseMethod.getCallTarget());

if (falseCallDirect.isCallTargetCloningAllowed() && falseMethod.getSharedMethodInfo().shouldAlwaysClone()) {
insert(falseCallDirect);
@@ -63,12 +63,12 @@ public CachedBooleanDispatchNode(
this.trueMethod = trueMethod;

if (trueMethod != null) {
trueCallDirect = Truffle.getRuntime().createDirectCallNode(trueMethod.getCallTarget());
this.trueCallDirect = Truffle.getRuntime().createDirectCallNode(trueMethod.getCallTarget());

if (trueCallDirect.isCallTargetCloningAllowed() && trueMethod.getSharedMethodInfo().shouldAlwaysClone()) {
insert(trueCallDirect);
trueCallDirect.cloneCallTarget();
}
if (trueCallDirect.isCallTargetCloningAllowed() && trueMethod.getSharedMethodInfo().shouldAlwaysClone()) {
insert(trueCallDirect);
trueCallDirect.cloneCallTarget();
}
}
}

Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
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.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;
@@ -40,22 +39,15 @@ public CachedBoxedDispatchNode(
DispatchAction dispatchAction) {
super(context, cachedName, next, dispatchAction);

assert RubyGuards.isRubyClass(expectedClass);

this.expectedShape = expectedShape;
this.unmodifiedAssumption = Layouts.MODULE.getFields(expectedClass).getUnmodifiedAssumption();
this.next = next;
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if (method != null) {
callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if ((callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone())
|| (method.getDeclaringModule() != null
&& Layouts.MODULE.getFields(method.getDeclaringModule()).getName().equals("TruffleInterop"))) {
insert(callNode);
callNode.cloneCallTarget();
}
if (callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone()) {
insert(callNode);
callNode.cloneCallTarget();
}
}

Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
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.RubyContext;
import org.jruby.truffle.runtime.array.ArrayUtils;
import org.jruby.truffle.runtime.layouts.Layouts;
@@ -41,12 +40,10 @@ public CachedBoxedMethodMissingDispatchNode(
DispatchAction dispatchAction) {
super(context, cachedName, next, dispatchAction);

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

callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

/*
* The way that #method_missing is used is usually as an indirection to call some other method, and
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
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.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

@@ -32,9 +31,9 @@ public CachedBoxedReturnMissingDispatchNode(
DynamicObject expectedClass,
DispatchAction dispatchAction) {
super(context, cachedName, next, dispatchAction);
assert RubyGuards.isRubyClass(expectedClass);

this.expectedShape = expectedShape;
unmodifiedAssumption = Layouts.MODULE.getFields(expectedClass).getUnmodifiedAssumption();
this.unmodifiedAssumption = Layouts.MODULE.getFields(expectedClass).getUnmodifiedAssumption();
this.next = next;
}

Original file line number Diff line number Diff line change
@@ -36,16 +36,13 @@ public CachedBoxedSymbolDispatchNode(
DispatchAction dispatchAction) {
super(context, cachedName, next, dispatchAction);

unmodifiedAssumption = Layouts.MODULE.getFields(context.getCoreLibrary().getSymbolClass()).getUnmodifiedAssumption();
this.unmodifiedAssumption = Layouts.MODULE.getFields(context.getCoreLibrary().getSymbolClass()).getUnmodifiedAssumption();
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if (method != null) {
callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if (callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone()) {
insert(callNode);
callNode.cloneCallTarget();
}
if (callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone()) {
insert(callNode);
callNode.cloneCallTarget();
}
}

Original file line number Diff line number Diff line change
@@ -44,9 +44,7 @@ public CachedForeignDispatchNode(RubyContext context, DispatchNode next, Object
} else {
this.nameForMessage = name;
}

initializeNodes(context, arity);

}

private void initializeNodes(RubyContext context, int arity) {
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ public final class CachedForeignGlobalDispatchNode extends CachedDispatchNode {

public CachedForeignGlobalDispatchNode(RubyContext context, DispatchNode next, Object cachedName, TruffleObject language, int numberOfArguments) {
super(context, cachedName, next, DispatchAction.CALL_METHOD);

this.cachedName = cachedName;
this.language = language;
this.numberOfArguments = numberOfArguments;
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.object.DynamicObject;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;
@@ -43,22 +42,15 @@ public CachedSingletonDispatchNode(
DispatchAction dispatchAction) {
super(context, cachedName, next, dispatchAction);

assert RubyGuards.isRubyClass(expectedClass);

this.expectedReceiver = expectedReceiver;
this.unmodifiedAssumption = Layouts.MODULE.getFields(expectedClass).getUnmodifiedAssumption();
this.next = next;
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if (method != null) {
callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if ((callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone())
|| (method.getDeclaringModule() != null
&& Layouts.MODULE.getFields(method.getDeclaringModule()).getName().equals("TruffleInterop"))) {
insert(callNode);
callNode.cloneCallTarget();
}
if (callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone()) {
insert(callNode);
callNode.cloneCallTarget();
}
}

@@ -123,11 +115,4 @@ public boolean couldOptimizeKeywordArguments() {
return false; //method.getSharedMethodInfo().getArity().getKeywordArguments() != null && next instanceof UnresolvedDispatchNode;
}

public InternalMethod getMethod() {
return method;
}

public Assumption getUnmodifiedAssumption() {
return unmodifiedAssumption;
}
}
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@
import com.oracle.truffle.api.object.DynamicObject;

import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;

public class CachedUnboxedDispatchNode extends CachedDispatchNode {
@@ -37,17 +36,15 @@ public CachedUnboxedDispatchNode(
InternalMethod method,
DispatchAction dispatchAction) {
super(context, cachedName, next, dispatchAction);

this.expectedClass = expectedClass;
this.unmodifiedAssumption = unmodifiedAssumption;
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if (method != null) {
callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

if (Layouts.MODULE.getFields(method.getDeclaringModule()).getName().equals("TruffleInterop")) {
insert(callNode);
callNode.cloneCallTarget();
}
if (callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone()) {
insert(callNode);
callNode.cloneCallTarget();
}
}

Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ public RespondToNode(RubyContext context, SourceSection sourceSection, RubyNode
super(context, sourceSection);
this.methodName = methodName;
this.child = child;
dispatch = new DoesRespondDispatchHeadNode(context, true, MissingBehavior.RETURN_MISSING, LexicalScope.NONE);
this.dispatch = new DoesRespondDispatchHeadNode(context, true, MissingBehavior.RETURN_MISSING, LexicalScope.NONE);
}

public boolean executeBoolean(VirtualFrame frame) {
Original file line number Diff line number Diff line change
@@ -94,9 +94,9 @@ public RubyCallNode(RubyContext context, SourceSection section, String methodNam
this.isSplatted = isSplatted;
this.isVCall = isVCall;

dispatchHead = DispatchHeadNodeFactory.createMethodCall(context, ignoreVisibility);
respondToMissing = DispatchHeadNodeFactory.createMethodCall(context, true, MissingBehavior.RETURN_MISSING);
respondToMissingCast = BooleanCastNodeGen.create(context, section, null);
this.dispatchHead = DispatchHeadNodeFactory.createMethodCall(context, ignoreVisibility);
this.respondToMissing = DispatchHeadNodeFactory.createMethodCall(context, true, MissingBehavior.RETURN_MISSING);
this.respondToMissingCast = BooleanCastNodeGen.create(context, section, null);

this.ignoreVisibility = ignoreVisibility;

@@ -105,7 +105,7 @@ public RubyCallNode(RubyContext context, SourceSection section, String methodNam
* so we just allocate a lot up-front. In a future version of Truffle
* @Children might not need to be final, which would fix this.
*/
keywordOptimizedArguments = new RubyNode[arguments.length + 32];
this.keywordOptimizedArguments = new RubyNode[arguments.length + 32];
}

@Override
Original file line number Diff line number Diff line change
@@ -42,12 +42,13 @@ public class UncachedDispatchNode extends DispatchNode {

public UncachedDispatchNode(RubyContext context, boolean ignoreVisibility, DispatchAction dispatchAction, MissingBehavior missingBehavior) {
super(context, dispatchAction);

this.ignoreVisibility = ignoreVisibility;
this.missingBehavior = missingBehavior;
indirectCallNode = Truffle.getRuntime().createIndirectCallNode();
toSymbolNode = ToSymbolNodeGen.create(context, null, null);
toJavaStringNode = ToJavaStringNodeGen.create(context, null, null);
metaClassNode = MetaClassNodeGen.create(context, null, null);
this.indirectCallNode = Truffle.getRuntime().createIndirectCallNode();
this.toSymbolNode = ToSymbolNodeGen.create(context, null, null);
this.toJavaStringNode = ToJavaStringNodeGen.create(context, null, null);
this.metaClassNode = MetaClassNodeGen.create(context, null, null);
}

@Override
@@ -98,9 +99,7 @@ public Object executeDispatch(

if (dispatchAction == DispatchAction.CALL_METHOD) {
final Object[] modifiedArgumentsObjects = new Object[1 + argumentsObjects.length];

modifiedArgumentsObjects[0] = toSymbolNode.executeRubySymbol(frame, name);

ArrayUtils.arraycopy(argumentsObjects, 0, modifiedArgumentsObjects, 1, argumentsObjects.length);

return call(frame, missingMethod, receiverObject, blockObject, modifiedArgumentsObjects);
Original file line number Diff line number Diff line change
@@ -126,31 +126,19 @@ private DispatchNode doUnboxedObject(
}

final String methodNameString = toString(methodName);

final InternalMethod method = lookup(callerClass, receiverObject, methodNameString, ignoreVisibility);

if (method == null) {
return createMethodMissingNode(first, methodName, receiverObject);
}

if (receiverObject instanceof Boolean) {
final Assumption falseUnmodifiedAssumption =
Layouts.MODULE.getFields(getContext().getCoreLibrary().getFalseClass()).getUnmodifiedAssumption();

final InternalMethod falseMethod =
lookup(callerClass, false, methodNameString,
ignoreVisibility);

final Assumption trueUnmodifiedAssumption =
Layouts.MODULE.getFields(getContext().getCoreLibrary().getTrueClass()).getUnmodifiedAssumption();
final Assumption falseUnmodifiedAssumption = Layouts.MODULE.getFields(getContext().getCoreLibrary().getFalseClass()).getUnmodifiedAssumption();
final InternalMethod falseMethod = lookup(callerClass, false, methodNameString, ignoreVisibility);

final InternalMethod trueMethod =
lookup(callerClass, true, methodNameString,
ignoreVisibility);

if ((falseMethod == null) && (trueMethod == null)) {
throw new UnsupportedOperationException();
}
final Assumption trueUnmodifiedAssumption = Layouts.MODULE.getFields(getContext().getCoreLibrary().getTrueClass()).getUnmodifiedAssumption();
final InternalMethod trueMethod = lookup(callerClass, true, methodNameString, ignoreVisibility);
assert falseMethod != null || trueMethod != null;

return new CachedBooleanDispatchNode(getContext(),
methodName, first,
Original file line number Diff line number Diff line change
@@ -11,7 +11,10 @@

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.methods.InternalMethod;
@@ -38,7 +41,9 @@ public MethodDefinitionNode(RubyContext context, SourceSection sourceSection, St
}

public InternalMethod executeMethod(VirtualFrame frame) {
return new InternalMethod(sharedMethodInfo, name, null, null, false, callTarget,
final DynamicObject dummyModule = getContext().getCoreLibrary().getObjectClass();
final Visibility dummyVisibility = Visibility.PUBLIC;
return new InternalMethod(sharedMethodInfo, name, dummyModule, dummyVisibility, false, callTarget,
frame.materialize() /* Currently used for visibility, will be fixed when we keep visibility in some better place */);
}

Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
package org.jruby.truffle.runtime.methods;

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
@@ -42,7 +41,7 @@ public class InternalMethod implements ObjectGraphNode {
public InternalMethod(SharedMethodInfo sharedMethodInfo, String name,
DynamicObject declaringModule, Visibility visibility, boolean undefined,
CallTarget callTarget, MaterializedFrame declarationFrame) {
assert declaringModule == null || RubyGuards.isRubyModule(declaringModule);
assert RubyGuards.isRubyModule(declaringModule);
this.sharedMethodInfo = sharedMethodInfo;
this.declaringModule = declaringModule;
this.name = name;