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: 86106d738628
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cc46059a8c36
Choose a head ref
  • 5 commits
  • 11 files changed
  • 1 contributor

Commits on Oct 15, 2014

  1. [Truffle] Hide better ModuleChain and provide ancestor iterators.

    * So we have less comparisons with IncludedModule,
      clearer expectations on the capabilities of the receiver
      and avoid having to call getActualModule ourselves.
    eregon committed Oct 15, 2014
    Copy the full SHA
    b073f60 View commit details
  2. Copy the full SHA
    d7dc45c View commit details
  3. Copy the full SHA
    691427b View commit details
  4. Copy the full SHA
    068dbfd View commit details
  5. Copy the full SHA
    cc46059 View commit details
61 changes: 14 additions & 47 deletions core/src/main/java/org/jruby/truffle/nodes/core/ModuleNodes.java
Original file line number Diff line number Diff line change
@@ -51,33 +51,6 @@ public IsSubclassOfNode(IsSubclassOfNode prev) {
super(prev);
}

@Specialization
public Object isSubclassOf(VirtualFrame frame, RubyClass self, RubyClass other) {
notDesignedForCompilation();

if (self == other || ModuleOperations.includesModule(self, other)) {
return true;
}

for (ModuleChain c = self.getParentModule(); c != null; c = c.getParentModule()) {
if (c == other) {
return true;
}
}

if (ModuleOperations.includesModule(other, self)) {
return false;
}

for (ModuleChain c = other.getParentModule(); c != null; c = c.getParentModule()) {
if (c == self) {
return false;
}
}

return NilPlaceholder.INSTANCE;
}

@Specialization
public Object isSubclassOf(VirtualFrame frame, RubyModule self, RubyModule other) {
notDesignedForCompilation();
@@ -182,8 +155,8 @@ public RubyArray ancestors(RubyModule self) {
notDesignedForCompilation();

final List<RubyModule> ancestors = new ArrayList<>();
for (ModuleChain module = self; module != null; module = module.getParentModule()) {
ancestors.add(module.getActualModule());
for (RubyModule module : self.ancestors()) {
ancestors.add(module);
}

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), ancestors.toArray(new Object[ancestors.size()]));
@@ -817,17 +790,15 @@ public NestingNode(NestingNode prev) {
public RubyArray nesting() {
notDesignedForCompilation();

final List<ModuleChain> modules = new ArrayList<>();
final List<RubyModule> modules = new ArrayList<>();

ModuleChain module = RubyCallStack.getCallingMethod().getDeclaringModule();
RubyModule module = RubyCallStack.getCallingMethod().getDeclaringModule();
RubyClass object = getContext().getCoreLibrary().getObjectClass();

while (module != null && module != object) {
if (module instanceof RubyModule) {
modules.add(module);
}

module = module.getLexicalParentModule();
for (RubyModule englobing : module.lexicalAncestors()) {
if (englobing == object)
break;
modules.add(englobing);
}

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), modules.toArray(new Object[modules.size()]));
@@ -974,11 +945,10 @@ public RubyArray privateInstanceMethods(RubyModule module, boolean includeAncest

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

if (includeAncestors) {
ModuleChain parent = module.getParentModule();
while(parent != null){
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
parent = parent.getParentModule();
}
}
for (RubyMethod method : methods) {
@@ -1014,10 +984,8 @@ public RubyArray publicInstanceMethods(RubyModule module, boolean includeAncesto
final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
final List<RubyMethod> methods = new ArrayList<>(module.getMethods().values());
if (includeAncestors) {
ModuleChain parent = module.getParentModule();
while(parent != null){
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
parent = parent.getParentModule();
}
}
for (RubyMethod method : methods) {
@@ -1052,15 +1020,14 @@ public RubyArray instanceMethods(RubyModule module, UndefinedPlaceholder argumen
public RubyArray instanceMethods(RubyModule module, boolean includeAncestors) {
notDesignedForCompilation();

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
final List<RubyMethod> methods = new ArrayList<>(module.getMethods().values());
if (includeAncestors) {
ModuleChain parent = module.getParentModule();
while(parent != null){
for (RubyModule parent : module.parentAncestors()) {
methods.addAll(parent.getMethods().values());
parent = parent.getParentModule();
}
}

final RubyArray array = new RubyArray(getContext().getCoreLibrary().getArrayClass());
for (RubyMethod method : methods) {
if (method.getVisibility() != Visibility.PRIVATE){
RubySymbol m = getContext().newSymbol(method.getName());
Original file line number Diff line number Diff line change
@@ -18,17 +18,17 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.jruby.truffle.runtime.ModuleChain;
import org.jruby.truffle.runtime.NilPlaceholder;
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.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;

public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {

private final ModuleChain expectedClass;
private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;

private final Object value;
@@ -37,7 +37,7 @@ public abstract class CachedBoxedDispatchNode extends CachedDispatchNode {
@Child protected DirectCallNode callNode;

public CachedBoxedDispatchNode(RubyContext context, Object cachedName, DispatchNode next,
ModuleChain expectedClass, Object value, RubyMethod method) {
RubyClass expectedClass, Object value, RubyMethod method) {
super(context, cachedName, next);

this.expectedClass = expectedClass;
Original file line number Diff line number Diff line change
@@ -18,25 +18,25 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.jruby.truffle.runtime.ModuleChain;
import org.jruby.truffle.runtime.NilPlaceholder;
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.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.util.cli.Options;

public abstract class CachedBoxedMethodMissingDispatchNode extends CachedDispatchNode {

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

@Child protected DirectCallNode callNode;

public CachedBoxedMethodMissingDispatchNode(RubyContext context, Object cachedName, DispatchNode next,
ModuleChain expectedClass, RubyMethod method) {
RubyClass expectedClass, RubyMethod method) {
super(context, cachedName, next);

this.expectedClass = expectedClass;
Original file line number Diff line number Diff line change
@@ -16,19 +16,19 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import org.jruby.truffle.runtime.ModuleChain;
import org.jruby.truffle.runtime.NilPlaceholder;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyProc;

public abstract class CachedBoxedReturnMissingDispatchNode extends CachedDispatchNode {

private final ModuleChain expectedClass;
private final RubyClass expectedClass;
private final Assumption unmodifiedAssumption;

public CachedBoxedReturnMissingDispatchNode(RubyContext context, Object cachedName, DispatchNode next,
ModuleChain expectedClass) {
RubyClass expectedClass) {
super(context, cachedName, next);
assert expectedClass != null;
this.expectedClass = expectedClass;
Original file line number Diff line number Diff line change
@@ -17,15 +17,11 @@
import com.oracle.truffle.api.Truffle;
import org.jruby.common.IRubyWarnings;
import org.jruby.truffle.nodes.cast.BoxingNode;
import org.jruby.truffle.runtime.ModuleChain;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyConstant;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.util.cli.Options;

@@ -287,21 +283,21 @@ public Object dispatch(
}

@CompilerDirectives.SlowPath
public ConstantCacheEntry lookupInConstantCache(ModuleChain metaClass, Object methodName) {
public ConstantCacheEntry lookupInConstantCache(RubyClass metaClass, Object methodName) {
return constantCache.get(new MethodCacheKey(metaClass, methodName));
}

@CompilerDirectives.SlowPath
public MethodCacheEntry lookupInCache(ModuleChain metaClass, Object methodName) {
public MethodCacheEntry lookupInCache(RubyClass metaClass, Object methodName) {
return methodCache.get(new MethodCacheKey(metaClass, methodName));
}

private static class MethodCacheKey {

private final ModuleChain metaClass;
private final RubyClass metaClass;
private final Object methodName;

private MethodCacheKey(ModuleChain metaClass, Object methodName) {
private MethodCacheKey(RubyClass metaClass, Object methodName) {
this.metaClass = metaClass;
this.methodName = methodName;
}
86 changes: 0 additions & 86 deletions core/src/main/java/org/jruby/truffle/runtime/IncludedModule.java

This file was deleted.

44 changes: 0 additions & 44 deletions core/src/main/java/org/jruby/truffle/runtime/ModuleChain.java

This file was deleted.

Loading