Skip to content

Commit

Permalink
Showing 24 changed files with 131 additions and 149 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.util.ArrayUtils;

public class RubyCallNode extends RubyNode {
@@ -193,7 +193,7 @@ public Object isDefined(VirtualFrame frame) {

// TODO(CS): this lookup should be cached

final RubyMethod method = ModuleOperations.lookupMethod(context.getCoreLibrary().getMetaClass(receiverObject), methodName);
final InternalMethod method = ModuleOperations.lookupMethod(context.getCoreLibrary().getMetaClass(receiverObject), methodName);

final Object self = RubyArguments.getSelf(frame.getArguments());

Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public class LambdaNode extends RubyNode {

@@ -32,7 +32,7 @@ public LambdaNode(RubyContext context, SourceSection sourceSection, RubyNode def
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

final RubyMethod method = (RubyMethod) definition.execute(frame);
final InternalMethod method = (InternalMethod) definition.execute(frame);

// TODO(CS): not sure we're closing over the correct state here

Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.Arity;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.runtime.util.ArrayUtils;

@@ -118,7 +118,7 @@ private static void addMethod(RubyModule module, RubyRootNode rootNode, List<Str
coreMethodNode.setName(name);
}

final RubyMethod method = new RubyMethod(rootNodeCopy.getSharedMethodInfo(), name, module, visibility, false,
final InternalMethod method = new InternalMethod(rootNodeCopy.getSharedMethodInfo(), name, module, visibility, false,
Truffle.getRuntime().createCallTarget(rootNodeCopy), null);

module.addMethod(null, method.withVisibility(visibility).withNewName(name));
18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.hash.HashOperations;
import org.jruby.truffle.runtime.hash.KeyValue;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.util.ByteList;
import org.jruby.util.cli.Options;

@@ -1338,15 +1338,15 @@ public RubyArray methods(RubyBasicObject self, boolean includeInherited) {

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

Map<String, RubyMethod> methods;
Map<String, InternalMethod> methods;

if (includeInherited) {
methods = ModuleOperations.getAllMethods(self.getMetaClass());
} else {
methods = self.getMetaClass().getMethods();
}

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() == Visibility.PUBLIC || method.getVisibility() == Visibility.PROTECTED) {
array.slowPush(self.getContext().newSymbol(method.getName()));
}
@@ -1450,15 +1450,15 @@ public RubyArray private_methods(RubyBasicObject self, boolean includeInherited)

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

Map<String, RubyMethod> methods;
Map<String, InternalMethod> methods;

if (includeInherited) {
methods = ModuleOperations.getAllMethods(self.getMetaClass());
} else {
methods = self.getMetaClass().getMethods();
}

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() == Visibility.PRIVATE) {
array.slowPush(self.getContext().newSymbol(method.getName()));
}
@@ -1518,9 +1518,9 @@ public RubyArray methods(RubyBasicObject self, UndefinedPlaceholder includeInher

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

final Map<String, RubyMethod> methods = self.getMetaClass().getMethods();
final Map<String, InternalMethod> methods = self.getMetaClass().getMethods();

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() == Visibility.PUBLIC) {
array.slowPush(self.getContext().newSymbol(method.getName()));
}
@@ -1846,15 +1846,15 @@ public RubyArray singletonMethods(RubyBasicObject self, boolean includeInherited

final RubyArray array = new RubyArray(self.getContext().getCoreLibrary().getArrayClass());

final Collection<RubyMethod> methods;
final Collection<InternalMethod> methods;

if (includeInherited) {
methods = ModuleOperations.getAllMethods(self.getSingletonClass(this)).values();
} else {
methods = self.getSingletonClass(this).getMethods().values();
}

for (RubyMethod method : methods) {
for (InternalMethod method : methods) {
array.slowPush(RubySymbol.newSymbol(self.getContext(), method.getName()));
}

32 changes: 16 additions & 16 deletions core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Original file line number Diff line number Diff line change
@@ -37,8 +37,8 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.methods.Arity;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.translator.NodeWrapper;
import org.jruby.truffle.translator.TranslatorDriver;
@@ -282,7 +282,7 @@ public static void attrReader(RubyNode currentNode, RubyContext context, SourceS
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, null, indicativeName, false, null, false);
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final RubyMethod method = new RubyMethod(sharedMethodInfo, name, module, Visibility.PUBLIC, false, callTarget, null);
final InternalMethod method = new InternalMethod(sharedMethodInfo, name, module, Visibility.PUBLIC, false, callTarget, null);
module.addMethod(currentNode, method);
}
}
@@ -335,7 +335,7 @@ public static void attrWriter(RubyNode currentNode, RubyContext context, SourceS
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, null, indicativeName, false, null, false);
final RubyRootNode rootNode = new RubyRootNode(context, sourceSection, null, sharedMethodInfo, block);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final RubyMethod method = new RubyMethod(sharedMethodInfo, name + "=", module, Visibility.PUBLIC, false, callTarget, null);
final InternalMethod method = new InternalMethod(sharedMethodInfo, name + "=", module, Visibility.PUBLIC, false, callTarget, null);
module.addMethod(currentNode, method);
}
}
@@ -764,7 +764,7 @@ private void defineMethod(RubyModule module, RubySymbol name, RubyProc proc) {
notDesignedForCompilation();

final CallTarget modifiedCallTarget = proc.getCallTargetForMethods();
final RubyMethod modifiedMethod = new RubyMethod(proc.getSharedMethodInfo(), name.toString(), module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());
final InternalMethod modifiedMethod = new InternalMethod(proc.getSharedMethodInfo(), name.toString(), module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());
module.addMethod(this, modifiedMethod);
}

@@ -1070,7 +1070,7 @@ public RubyModule publicClassMethod(RubyModule module, Object... args) {
throw new UnsupportedOperationException();
}

final RubyMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);
final InternalMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());
@@ -1131,7 +1131,7 @@ public RubyModule privateClassMethod(RubyModule module, Object... args) {
throw new UnsupportedOperationException();
}

final RubyMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);
final InternalMethod method = ModuleOperations.lookupMethod(moduleSingleton, methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());
@@ -1165,14 +1165,14 @@ public RubyArray privateInstanceMethods(RubyModule module, boolean includeAncest
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
final List<RubyMethod> methods = new ArrayList<>(module.getMethods().values());
final List<InternalMethod> methods = new ArrayList<>(module.getMethods().values());

if (includeAncestors) {
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
}
}
for (RubyMethod method : methods) {
for (InternalMethod method : methods) {
if (method.getVisibility() == Visibility.PRIVATE){
RubySymbol m = getContext().newSymbol(method.getName());
array.slowPush(m);
@@ -1203,13 +1203,13 @@ public RubyArray publicInstanceMethods(RubyModule module, boolean includeAncesto
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
final List<RubyMethod> methods = new ArrayList<>(module.getMethods().values());
final List<InternalMethod> methods = new ArrayList<>(module.getMethods().values());
if (includeAncestors) {
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
}
}
for (RubyMethod method : methods) {
for (InternalMethod method : methods) {
if (method.getVisibility() == Visibility.PUBLIC){
RubySymbol m = getContext().newSymbol(method.getName());
array.slowPush(m);
@@ -1241,7 +1241,7 @@ public RubyArray instanceMethods(RubyModule module, UndefinedPlaceholder argumen
public RubyArray instanceMethods(RubyModule module, boolean includeAncestors) {
notDesignedForCompilation();

Map<String, RubyMethod> methods;
Map<String, InternalMethod> methods;

if (includeAncestors) {
methods = ModuleOperations.getAllMethods(module);
@@ -1250,7 +1250,7 @@ public RubyArray instanceMethods(RubyModule module, boolean includeAncestors) {
}

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getVisibility() != Visibility.PRIVATE && !method.isUndefined()) {
// TODO(CS): shoudln't be using this
array.slowPush(getContext().newSymbol(method.getName()));
@@ -1402,7 +1402,7 @@ public UndefMethodNode(UndefMethodNode prev) {
public RubyModule undefMethod(RubyClass rubyClass, RubyString name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), rubyClass.toString(), this));
}
@@ -1414,7 +1414,7 @@ public RubyModule undefMethod(RubyClass rubyClass, RubyString name) {
public RubyModule undefMethod(RubyClass rubyClass, RubySymbol name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(rubyClass, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), rubyClass.toString(), this));
}
@@ -1426,7 +1426,7 @@ public RubyModule undefMethod(RubyClass rubyClass, RubySymbol name) {
public RubyModule undefMethod(RubyModule module, RubyString name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(module, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(module, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), module.toString(), this));
}
@@ -1438,7 +1438,7 @@ public RubyModule undefMethod(RubyModule module, RubyString name) {
public RubyModule undefMethod(RubyModule module, RubySymbol name) {
notDesignedForCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(module, name.toString());
final InternalMethod method = ModuleOperations.lookupMethod(module, name.toString());
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name.toString(), module.toString(), this));
}
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
@@ -22,19 +21,19 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBooleanDispatchNode extends CachedDispatchNode {

private final Assumption falseUnmodifiedAssumption;
private final RubyMethod falseMethod;
private final InternalMethod falseMethod;
private final BranchProfile falseProfile = BranchProfile.create();

private final Object falseValue;
@Child private DirectCallNode falseCallDirect;

private final Assumption trueUnmodifiedAssumption;
private final RubyMethod trueMethod;
private final InternalMethod trueMethod;
private final BranchProfile trueProfile = BranchProfile.create();

private final Object trueValue;
@@ -48,10 +47,10 @@ public CachedBooleanDispatchNode(
DispatchNode next,
Assumption falseUnmodifiedAssumption,
Object falseValue,
RubyMethod falseMethod,
InternalMethod falseMethod,
Assumption trueUnmodifiedAssumption,
Object trueValue,
RubyMethod trueMethod,
InternalMethod trueMethod,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
@@ -24,7 +23,7 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {

@@ -33,7 +32,7 @@ public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {

private final Object value;

private final RubyMethod method;
private final InternalMethod method;
@Child private DirectCallNode callNode;
@Child private IndirectCallNode indirectCallNode;

@@ -43,7 +42,7 @@ public CachedBoxedDispatchNode(
DispatchNode next,
RubyClass expectedClass,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
this(
@@ -68,7 +67,7 @@ public CachedBoxedDispatchNode(
RubyClass expectedClass,
Assumption unmodifiedAssumption,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
@@ -23,14 +22,14 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.util.cli.Options;

public abstract class CachedBoxedMethodMissingDispatchNode extends CachedDispatchNode {

private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;
private final RubyMethod method;
private final InternalMethod method;

@Child private DirectCallNode callNode;
@Child private IndirectCallNode indirectCallNode;
@@ -40,7 +39,7 @@ public CachedBoxedMethodMissingDispatchNode(
Object cachedName,
DispatchNode next,
RubyClass expectedClass,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Original file line number Diff line number Diff line change
@@ -12,26 +12,24 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedBoxedSymbolDispatchNode extends CachedDispatchNode {

private final Assumption unmodifiedAssumption;

private final Object value;

private final RubyMethod method;
private final InternalMethod method;
@Child private DirectCallNode callNode;
@Child private IndirectCallNode indirectCallNode;

@@ -40,7 +38,7 @@ public CachedBoxedSymbolDispatchNode(
Object cachedName,
DispatchNode next,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
@@ -22,7 +21,7 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class CachedUnboxedDispatchNode extends CachedDispatchNode {

@@ -31,7 +30,7 @@ public abstract class CachedUnboxedDispatchNode extends CachedDispatchNode {

private final Object value;

private final RubyMethod method;
private final InternalMethod method;
@Child private DirectCallNode callNode;
@Child private IndirectCallNode indirectCallNode;

@@ -42,7 +41,7 @@ public CachedUnboxedDispatchNode(
Class<?> expectedClass,
Assumption unmodifiedAssumption,
Object value,
RubyMethod method,
InternalMethod method,
boolean indirect,
DispatchAction dispatchAction) {
super(context, cachedName, next, indirect, dispatchAction);
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

@NodeChildren({
@NodeChild(value="receiver", type=Node.class),
@@ -77,12 +77,12 @@ protected RubyConstant lookupConstant(
}

@CompilerDirectives.TruffleBoundary
protected RubyMethod lookup(
protected InternalMethod lookup(
RubyClass callerClass,
Object receiver,
String name,
boolean ignoreVisibility) {
RubyMethod method = ModuleOperations.lookupMethod(getContext().getCoreLibrary().getMetaClass(receiver), name);
InternalMethod method = ModuleOperations.lookupMethod(getContext().getCoreLibrary().getMetaClass(receiver), name);

// If no method was found, use #method_missing

Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class UncachedDispatchNode extends DispatchNode {

@@ -68,7 +68,7 @@ public Object dispatch(

final RubyClass callerClass = ignoreVisibility ? null : getContext().getCoreLibrary().getMetaClass(RubyArguments.getSelf(frame.getArguments()));

final RubyMethod missingMethod = lookup(callerClass, receiverObject, "const_missing", ignoreVisibility);
final InternalMethod missingMethod = lookup(callerClass, receiverObject, "const_missing", ignoreVisibility);

if (missingMethod == null) {
CompilerDirectives.transferToInterpreter();
@@ -88,7 +88,7 @@ public Object dispatch(
} else {
final RubyClass callerClass = ignoreVisibility ? null : getContext().getCoreLibrary().getMetaClass(RubyArguments.getSelf(frame.getArguments()));

final RubyMethod method = lookup(callerClass, receiverObject, toJavaStringNode.executeJavaString(frame, name),
final InternalMethod method = lookup(callerClass, receiverObject, toJavaStringNode.executeJavaString(frame, name),
ignoreVisibility);

if (method != null) {
@@ -111,7 +111,7 @@ public Object dispatch(

methodMissingProfile.enter();

final RubyMethod missingMethod = lookup(callerClass, receiverObject, "method_missing", true);
final InternalMethod missingMethod = lookup(callerClass, receiverObject, "method_missing", true);

if (missingMethod == null) {
if (dispatchAction == DispatchAction.RESPOND_TO_METHOD) {
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.RubyModule;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.util.cli.Options;

public final class UnresolvedDispatchNode extends DispatchNode {
@@ -101,7 +101,7 @@ private Object doUnboxedObject(
}

if (dispatchAction == DispatchAction.CALL_METHOD || dispatchAction == DispatchAction.RESPOND_TO_METHOD) {
final RubyMethod method = lookup(callerClass, receiverObject, methodName.toString(), ignoreVisibility);
final InternalMethod method = lookup(callerClass, receiverObject, methodName.toString(), ignoreVisibility);

if (method == null) {
final DispatchNode newDispatch = createMethodMissingNode(methodName, receiverObject);
@@ -113,14 +113,14 @@ private Object doUnboxedObject(
final Assumption falseUnmodifiedAssumption =
getContext().getCoreLibrary().getFalseClass().getUnmodifiedAssumption();

final RubyMethod falseMethod =
final InternalMethod falseMethod =
lookup(callerClass, false, methodName.toString(),
ignoreVisibility);

final Assumption trueUnmodifiedAssumption =
getContext().getCoreLibrary().getTrueClass().getUnmodifiedAssumption();

final RubyMethod trueMethod =
final InternalMethod trueMethod =
lookup(callerClass, true, methodName.toString(),
ignoreVisibility);

@@ -166,7 +166,7 @@ private Object doRubyBasicObject(
final RubyClass callerClass = ignoreVisibility ? null : getContext().getCoreLibrary().getMetaClass(RubyArguments.getSelf(frame.getArguments()));

if (dispatchAction == DispatchAction.CALL_METHOD || dispatchAction == DispatchAction.RESPOND_TO_METHOD) {
final RubyMethod method = lookup(callerClass, receiverObject, methodName.toString(), ignoreVisibility);
final InternalMethod method = lookup(callerClass, receiverObject, methodName.toString(), ignoreVisibility);

if (method == null) {
final DispatchNode newDispatch = createMethodMissingNode(methodName, receiverObject);
@@ -226,7 +226,7 @@ private DispatchNode createConstantMissingNode(
}

case CALL_CONST_MISSING: {
final RubyMethod method = lookup(callerClass, receiverObject, "const_missing", ignoreVisibility);
final InternalMethod method = lookup(callerClass, receiverObject, "const_missing", ignoreVisibility);

if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().runtimeError(
@@ -260,7 +260,7 @@ private DispatchNode createMethodMissingNode(
}

case CALL_METHOD_MISSING: {
final RubyMethod method = lookup(null, receiverObject, "method_missing", true);
final InternalMethod method = lookup(null, receiverObject, "method_missing", true);

if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().runtimeError(
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public class AddMethodNode extends RubyNode {

@@ -43,7 +43,7 @@ public RubySymbol execute(VirtualFrame frame) {

final Object receiverObject = receiver.execute(frame);

final RubyMethod methodObject = (RubyMethod) methodNode.execute(frame);
final InternalMethod methodObject = (InternalMethod) methodNode.execute(frame);

RubyModule module;

@@ -54,7 +54,7 @@ public RubySymbol execute(VirtualFrame frame) {
}

final Visibility visibility = getVisibility(frame, methodObject.getName());
final RubyMethod method = methodObject.withDeclaringModule(module).withVisibility(visibility);
final InternalMethod method = methodObject.withDeclaringModule(module).withVisibility(visibility);

if (method.getVisibility() == Visibility.MODULE_FUNCTION) {
module.addMethod(this, method.withVisibility(Visibility.PRIVATE));
Original file line number Diff line number Diff line change
@@ -10,25 +10,13 @@
package org.jruby.truffle.nodes.methods;

import com.oracle.truffle.api.CallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstance.FrameAccess;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.frame.FrameSlot;
import com.oracle.truffle.api.frame.FrameSlotTypeException;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.runtime.Visibility;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;

/**
@@ -53,7 +41,7 @@ public MethodDefinitionNode(RubyContext context, SourceSection sourceSection, St
this.callTarget = callTarget;
}

public RubyMethod executeMethod(VirtualFrame frame) {
public InternalMethod executeMethod(VirtualFrame frame) {
notDesignedForCompilation();

final MaterializedFrame declarationFrame;
@@ -67,10 +55,10 @@ public RubyMethod executeMethod(VirtualFrame frame) {
return executeMethod(frame, declarationFrame);
}

public RubyMethod executeMethod(VirtualFrame frame, MaterializedFrame declarationFrame) {
public InternalMethod executeMethod(VirtualFrame frame, MaterializedFrame declarationFrame) {
notDesignedForCompilation();

return new RubyMethod(sharedMethodInfo, name, null, null, false, callTarget, declarationFrame);
return new InternalMethod(sharedMethodInfo, name, null, null, false, callTarget, declarationFrame);
}

@Override
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

/**
* Open a module and execute a method in it - probably to define new methods.
@@ -49,7 +49,7 @@ public Object execute(VirtualFrame frame) {
lexicalScope.setLiveModule(module);
lexicalScope.getParent().getLiveModule().addLexicalDependent(module);

final RubyMethod definition = definitionMethod.executeMethod(frame).withDeclaringModule(module);
final InternalMethod definition = definitionMethod.executeMethod(frame).withDeclaringModule(module);
return callModuleDefinitionNode.call(frame, definition.getCallTarget(), RubyArguments.pack(definition, definition.getDeclarationFrame(), module, null, new Object[]{}));
}

Original file line number Diff line number Diff line change
@@ -27,14 +27,14 @@
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

public abstract class AbstractGeneralSuperCallNode extends RubyNode {

@Child protected DirectCallNode callNode;

@CompilerDirectives.CompilationFinal protected Assumption unmodifiedAssumption;
@CompilerDirectives.CompilationFinal protected RubyMethod method;
@CompilerDirectives.CompilationFinal protected InternalMethod method;

public AbstractGeneralSuperCallNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -51,11 +51,11 @@ protected void lookup(VirtualFrame frame) {
final FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
MethodLike methodLike = RubyCallStack.getMethod(currentFrame);

while (!(methodLike instanceof RubyMethod)) {
while (!(methodLike instanceof InternalMethod)) {
methodLike = ((RubyProc) methodLike).getMethod();
}

final String name = ((RubyMethod) methodLike).getName();
final String name = ((InternalMethod) methodLike).getName();

// TODO: this is wrong, we need the lexically enclosing method (or define_method)'s module
final RubyModule declaringModule = RubyCallStack.getCurrentDeclaringModule();
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import com.oracle.truffle.api.nodes.NodeUtil;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

import java.util.ArrayList;
import java.util.List;
@@ -40,7 +40,7 @@ public static String inspect(RubyContext context, Object object) {
public static Object send(RubyContext context, Object object, String methodName, RubyProc block, Object... arguments) {
CompilerAsserts.neverPartOfCompilation();

final RubyMethod method = ModuleOperations.lookupMethod(context.getCoreLibrary().getMetaClass(object), methodName);
final InternalMethod method = ModuleOperations.lookupMethod(context.getCoreLibrary().getMetaClass(object), methodName);

if (method == null) {
return null;
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;

import java.util.HashMap;
import java.util.Map;
@@ -126,17 +126,17 @@ public static RubyConstant lookupConstant(RubyContext context, LexicalScope lexi
return null;
}

public static Map<String, RubyMethod> getAllMethods(RubyModule module) {
public static Map<String, InternalMethod> getAllMethods(RubyModule module) {
CompilerAsserts.neverPartOfCompilation();

final Map<String, RubyMethod> methods = new HashMap<>();
final Map<String, InternalMethod> methods = new HashMap<>();

// Look in the current module
methods.putAll(module.getMethods());

// Look in ancestors
for (RubyModule ancestor : module.parentAncestors()) {
for (Map.Entry<String, RubyMethod> method : ancestor.getMethods().entrySet()) {
for (Map.Entry<String, InternalMethod> method : ancestor.getMethods().entrySet()) {
if (!methods.containsKey(method.getKey())) {
methods.put(method.getKey(), method.getValue());
}
@@ -146,10 +146,10 @@ public static Map<String, RubyMethod> getAllMethods(RubyModule module) {
return methods;
}

public static RubyMethod lookupMethod(RubyModule module, String name) {
public static InternalMethod lookupMethod(RubyModule module, String name) {
CompilerAsserts.neverPartOfCompilation();

RubyMethod method;
InternalMethod method;

// Look in the current module
method = module.getMethods().get(name);
@@ -172,15 +172,15 @@ public static RubyMethod lookupMethod(RubyModule module, String name) {
return null;
}

public static RubyMethod lookupSuperMethod(RubyModule declaringModule, String name, RubyClass objectMetaClass) {
public static InternalMethod lookupSuperMethod(RubyModule declaringModule, String name, RubyClass objectMetaClass) {
CompilerAsserts.neverPartOfCompilation();

boolean foundDeclaringModule = false;
for (RubyModule module : objectMetaClass.ancestors()) {
if (module == declaringModule) {
foundDeclaringModule = true;
} else if (foundDeclaringModule) {
RubyMethod method = module.getMethods().get(name);
InternalMethod method = module.getMethods().get(name);

if (method != null) {
return method;
32 changes: 16 additions & 16 deletions core/src/main/java/org/jruby/truffle/runtime/RubyCallStack.java
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@
import org.jruby.truffle.runtime.backtrace.Activation;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.util.Memo;
import org.jruby.util.cli.Options;

@@ -34,24 +34,24 @@ public static RubyModule getCurrentDeclaringModule() {
return method.getDeclaringModule();
}

public static RubyMethod getCurrentMethod() {
public static InternalMethod getCurrentMethod() {
CompilerAsserts.neverPartOfCompilation();

final FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
final MethodLike method = getMethod(currentFrame);

if (method instanceof RubyMethod) {
return (RubyMethod) method;
if (method instanceof InternalMethod) {
return (InternalMethod) method;
}

return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<RubyMethod>() {
return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<InternalMethod>() {

@Override
public RubyMethod visitFrame(FrameInstance frameInstance) {
public InternalMethod visitFrame(FrameInstance frameInstance) {
final MethodLike maybeMethod = getMethod(frameInstance);

if (maybeMethod instanceof RubyMethod) {
return (RubyMethod) maybeMethod;
if (maybeMethod instanceof InternalMethod) {
return (InternalMethod) maybeMethod;
} else {
return null;
}
@@ -60,7 +60,7 @@ public RubyMethod visitFrame(FrameInstance frameInstance) {
});
}

public static RubyMethod getCallingMethod() {
public static InternalMethod getCallingMethod() {
CompilerAsserts.neverPartOfCompilation();

final Memo<Boolean> seenCurrent = new Memo<Boolean>();
@@ -71,19 +71,19 @@ public static RubyMethod getCallingMethod() {

method = getMethod(currentFrame);

if (method instanceof RubyMethod) {
if (method instanceof InternalMethod) {
seenCurrent.set(true);
}

return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<RubyMethod>() {
return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<InternalMethod>() {

@Override
public RubyMethod visitFrame(FrameInstance frameInstance) {
public InternalMethod visitFrame(FrameInstance frameInstance) {
final MethodLike maybeMethod = getMethod(frameInstance);

if (maybeMethod instanceof RubyMethod) {
if (maybeMethod instanceof InternalMethod) {
if (seenCurrent.get()) {
return (RubyMethod) maybeMethod;
return (InternalMethod) maybeMethod;
} else {
seenCurrent.set(true);
return null;
@@ -122,10 +122,10 @@ public static Backtrace getBacktrace(Node currentNode) {
activations.add(new Activation(currentNode, Truffle.getRuntime().getCurrentFrame().getFrame(FrameInstance.FrameAccess.MATERIALIZE, true).materialize()));
}

Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<RubyMethod>() {
Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<InternalMethod>() {

@Override
public RubyMethod visitFrame(FrameInstance frameInstance) {
public InternalMethod visitFrame(FrameInstance frameInstance) {
// Multiple top level methods (require) introduce null call nodes - ignore them

if (frameInstance.getCallNode() != null) {
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.TruffleFatalException;
import org.jruby.truffle.runtime.core.RubyException;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.RubyMethod;

import java.util.ArrayList;
import java.util.List;
@@ -54,13 +54,13 @@ private static void formatActivation(RubyContext context, Activation activation,
final MethodLike method = RubyArguments.getMethod(arguments);
lines.add(String.format(" method = %s", method));

if (method instanceof RubyMethod) {
final RubyMethod rubyMethod = (RubyMethod) method;
if (method instanceof InternalMethod) {
final InternalMethod internalMethod = (InternalMethod) method;

if (rubyMethod.getDeclaringModule() == null) {
if (internalMethod.getDeclaringModule() == null) {
lines.add(String.format(" declaring module = null"));
} else {
lines.add(String.format(" declaring module = %s", rubyMethod.getDeclaringModule().getName()));
lines.add(String.format(" declaring module = %s", internalMethod.getDeclaringModule().getName()));
}
}

22 changes: 11 additions & 11 deletions core/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
import org.jruby.truffle.nodes.objects.Allocator;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.subsystems.ObjectSpaceManager;

import java.util.*;
@@ -88,7 +88,7 @@ public static void debugModuleChain(RubyModule module) {
private LexicalScope lexicalScope;
private String name;

private final Map<String, RubyMethod> methods = new HashMap<>();
private final Map<String, InternalMethod> methods = new HashMap<>();
private final Map<String, RubyConstant> constants = new HashMap<>();
private final Map<String, Object> classVariables = new HashMap<>();

@@ -210,7 +210,7 @@ public void removeClassVariable(RubyNode currentNode, String variableName) {
classVariables.remove(variableName);
}

public void addMethod(RubyNode currentNode, RubyMethod method) {
public void addMethod(RubyNode currentNode, InternalMethod method) {
RubyNode.notDesignedForCompilation();

assert method != null;
@@ -232,15 +232,15 @@ public void removeMethod(RubyNode currentNode, String methodName) {

public void undefMethod(RubyNode currentNode, String methodName) {
RubyNode.notDesignedForCompilation();
final RubyMethod method = ModuleOperations.lookupMethod(this, methodName);
final InternalMethod method = ModuleOperations.lookupMethod(this, methodName);
if (method == null) {
throw new UnsupportedOperationException();
} else {
undefMethod(currentNode, method);
}
}

public void undefMethod(RubyNode currentNode, RubyMethod method) {
public void undefMethod(RubyNode currentNode, InternalMethod method) {
RubyNode.notDesignedForCompilation();
addMethod(currentNode, method.undefined());
}
@@ -249,8 +249,8 @@ public void undefMethod(RubyNode currentNode, RubyMethod method) {
* Also searches on Object for modules.
* Used for alias_method, visibility changes, etc.
*/
private RubyMethod deepMethodSearch(String name) {
RubyMethod method = ModuleOperations.lookupMethod(this, name);
private InternalMethod deepMethodSearch(String name) {
InternalMethod method = ModuleOperations.lookupMethod(this, name);

// Also search on Object if we are a Module. JRuby calls it deepMethodSearch().
if (method == null && isOnlyAModule()) { // TODO: handle undefined methods
@@ -263,7 +263,7 @@ private RubyMethod deepMethodSearch(String name) {
public void alias(RubyNode currentNode, String newName, String oldName) {
RubyNode.notDesignedForCompilation();

RubyMethod method = deepMethodSearch(oldName);
InternalMethod method = deepMethodSearch(oldName);

if (method == null) {
CompilerDirectives.transferToInterpreter();
@@ -388,7 +388,7 @@ public void visibilityMethod(RubyNode currentNode, Object[] arguments, Visibilit
throw new UnsupportedOperationException();
}

final RubyMethod method = deepMethodSearch(methodName);
final InternalMethod method = deepMethodSearch(methodName);

if (method == null) {
throw new RuntimeException("Couldn't find method " + arg.toString());
@@ -414,7 +414,7 @@ public Map<String, RubyConstant> getConstants() {
return constants;
}

public Map<String, RubyMethod> getMethods() {
public Map<String, InternalMethod> getMethods() {
return methods;
}

@@ -430,7 +430,7 @@ public void visitObjectGraphChildren(ObjectSpaceManager.ObjectGraphVisitor visit
}
}

for (RubyMethod method : methods.values()) {
for (InternalMethod method : methods.values()) {
if (method.getDeclarationFrame() != null) {
getContext().getObjectSpaceManager().visitFrame(method.getDeclarationFrame(), visitor);
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
* Any kind of Ruby method - so normal methods in classes and modules, but also blocks, procs,
* lambdas and native methods written in Java.
*/
public class RubyMethod implements MethodLike {
public class InternalMethod implements MethodLike {

private final SharedMethodInfo sharedMethodInfo;
private final String name;
@@ -33,9 +33,9 @@ public class RubyMethod implements MethodLike {
private final CallTarget callTarget;
private final MaterializedFrame declarationFrame;

public RubyMethod(SharedMethodInfo sharedMethodInfo, String name,
RubyModule declaringModule, Visibility visibility, boolean undefined,
CallTarget callTarget, MaterializedFrame declarationFrame) {
public InternalMethod(SharedMethodInfo sharedMethodInfo, String name,
RubyModule declaringModule, Visibility visibility, boolean undefined,
CallTarget callTarget, MaterializedFrame declarationFrame) {
this.sharedMethodInfo = sharedMethodInfo;
this.declaringModule = declaringModule;
this.name = name;
@@ -72,28 +72,28 @@ public CallTarget getCallTarget(){
return callTarget;
}

public RubyMethod withDeclaringModule(RubyModule newDeclaringModule) {
public InternalMethod withDeclaringModule(RubyModule newDeclaringModule) {
if (newDeclaringModule == declaringModule) {
return this;
} else {
return new RubyMethod(sharedMethodInfo, name, newDeclaringModule, visibility, undefined, callTarget, declarationFrame);
return new InternalMethod(sharedMethodInfo, name, newDeclaringModule, visibility, undefined, callTarget, declarationFrame);
}
}

public RubyMethod withNewName(String newName) {
return new RubyMethod(sharedMethodInfo, newName, declaringModule, visibility, undefined, callTarget, declarationFrame);
public InternalMethod withNewName(String newName) {
return new InternalMethod(sharedMethodInfo, newName, declaringModule, visibility, undefined, callTarget, declarationFrame);
}

public RubyMethod withVisibility(Visibility newVisibility) {
public InternalMethod withVisibility(Visibility newVisibility) {
if (newVisibility == visibility) {
return this;
} else {
return new RubyMethod(sharedMethodInfo, name, declaringModule, newVisibility, undefined, callTarget, declarationFrame);
return new InternalMethod(sharedMethodInfo, name, declaringModule, newVisibility, undefined, callTarget, declarationFrame);
}
}

public RubyMethod undefined() {
return new RubyMethod(sharedMethodInfo, name, declaringModule, visibility, true, callTarget, declarationFrame);
public InternalMethod undefined() {
return new InternalMethod(sharedMethodInfo, name, declaringModule, visibility, true, callTarget, declarationFrame);
}

public boolean isVisibleTo(Node currentNode, RubyClass callerClass) {
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
import org.jruby.truffle.runtime.LexicalScope;

/**
* {@link RubyMethod} objects are copied as properties such as visibility are changed. {@link SharedMethodInfo} stores
* {@link InternalMethod} objects are copied as properties such as visibility are changed. {@link SharedMethodInfo} stores
* the state that does not change, such as where the method was defined.
*/
public class SharedMethodInfo {

0 comments on commit 90620c5

Please sign in to comment.