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

Commits on Feb 6, 2015

  1. Copy the full SHA
    ea403e8 View commit details
  2. [Truffle] Remove unused eval.

    * It also didn't care of setting proper visibility.
    eregon committed Feb 6, 2015
    Copy the full SHA
    8f770bc View commit details
  3. [Truffle] Make all class/module fields of CoreLibrary final.

    * Automatic check if field initialized before used.
    * CoreLibrary constructor need to not access RubyContext.getCoreLibrary().
    eregon committed Feb 6, 2015
    Copy the full SHA
    be3e5bf View commit details
Original file line number Diff line number Diff line change
@@ -103,9 +103,7 @@ public RubyContext(Ruby runtime) {

emptyShape = RubyBasicObject.LAYOUT.createShape(new RubyOperations(this));

// See note in CoreLibrary#initialize to see why we need to break this into two statements
coreLibrary = new CoreLibrary(this);
coreLibrary.initialize();

featureManager = new FeatureManager(this);
traceManager = new TraceManager();
@@ -198,11 +196,6 @@ public RubySymbol newSymbol(ByteList name) {
return symbolTable.getSymbol(name);
}

public Object eval(ByteList code, RubyNode currentNode) {
final Source source = Source.fromText(code, "(eval)");
return execute(this, source, code.getEncoding(), TranslatorDriver.ParserContext.TOP_LEVEL, coreLibrary.getMainObject(), null, currentNode, NodeWrapper.IDENTITY);
}

public Object instanceEval(ByteList code, Object self, RubyNode currentNode) {
final Source source = Source.fromText(code, "(eval)");
return execute(this, source, code.getEncoding(), TranslatorDriver.ParserContext.TOP_LEVEL, self, null, currentNode, new NodeWrapper() {
467 changes: 243 additions & 224 deletions truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -38,24 +38,24 @@ public class RubyClass extends RubyModule {
* This constructor supports initialization and solves boot-order problems and should not
* normally be used from outside this class.
*/
public static RubyClass createBootClass(RubyContext context, String name) {
return new RubyClass(context, null, null, name, false);
public static RubyClass createBootClass(RubyContext context, RubyClass classClass, String name) {
return new RubyClass(context, classClass, null, null, name, false);
}

public RubyClass(RubyContext context, RubyModule lexicalParent, RubyClass superclass, String name) {
this(context, lexicalParent, superclass, name, false);
this(context, superclass.getLogicalClass(), lexicalParent, superclass, name, false);
// Always create a class singleton class for normal classes for consistency.
ensureSingletonConsistency();
}

protected static RubyClass createSingletonClassOfObject(RubyContext context, RubyClass superclass, String name) {
// We also need to create the singleton class of a singleton class for proper lookup and consistency.
// See rb_singleton_class() documentation in MRI.
return new RubyClass(context, null, superclass, name, true).ensureSingletonConsistency();
return new RubyClass(context, superclass.getLogicalClass(), null, superclass, name, true).ensureSingletonConsistency();
}

protected RubyClass(RubyContext context, RubyModule lexicalParent, RubyClass superclass, String name, boolean isSingleton) {
super(context, context.getCoreLibrary().getClassClass(), lexicalParent, name, null);
protected RubyClass(RubyContext context, RubyClass classClass, RubyModule lexicalParent, RubyClass superclass, String name, boolean isSingleton) {
super(context, classClass, lexicalParent, name, null);
this.isSingleton = isSingleton;

if (superclass != null) {
@@ -108,7 +108,7 @@ private RubyClass createOneSingletonClass() {
}

metaClass = new RubyClass(getContext(),
null, singletonSuperclass, String.format("#<Class:%s>", getName()), true);
getLogicalClass(), null, singletonSuperclass, String.format("#<Class:%s>", getName()), true);

return metaClass;
}
@@ -164,7 +164,7 @@ public static class ClassAllocator implements Allocator {

@Override
public RubyBasicObject allocate(RubyContext context, RubyClass rubyClass, RubyNode currentNode) {
return new RubyClass(context, null, null, null, false);
return new RubyClass(context, context.getCoreLibrary().getClassClass(), null, null, null, false);
}

}
Original file line number Diff line number Diff line change
@@ -54,8 +54,8 @@ public static void storeAlias(String aliasName, RubyEncoding encoding) {
lookup.put(aliasName.toLowerCase(Locale.ENGLISH), encoding);
}

public static RubyEncoding newEncoding(RubyContext context, Encoding encoding, byte[] name, int p, int end, boolean dummy) {
return new RubyEncoding(context.getCoreLibrary().getEncodingClass(), encoding, new ByteList(name, p, end), dummy);
public static RubyEncoding newEncoding(RubyClass encodingClass, Encoding encoding, byte[] name, int p, int end, boolean dummy) {
return new RubyEncoding(encodingClass, encoding, new ByteList(name, p, end), dummy);
}

private RubyEncoding(RubyClass encodingClass, Encoding encoding, ByteList name, boolean dummy) {
Original file line number Diff line number Diff line change
@@ -106,10 +106,6 @@ public static void debugModuleChain(RubyModule module) {
*/
private final Set<RubyModule> lexicalDependents = Collections.newSetFromMap(new WeakHashMap<RubyModule, Boolean>());

public RubyModule(RubyContext context, RubyModule lexicalParent, String name) {
this(context, lexicalParent, name, null);
}

public RubyModule(RubyContext context, RubyModule lexicalParent, String name, RubyNode currentNode) {
this(context, context.getCoreLibrary().getModuleClass(), lexicalParent, name, currentNode);
}
@@ -129,7 +125,11 @@ protected void getAdoptedByLexicalParent(RubyModule lexicalParent, RubyNode curr
lexicalParent.setConstant(currentNode, name, this);
lexicalParent.addLexicalDependent(this);

if (lexicalParent != context.getCoreLibrary().getObjectClass()) {
// Tricky, we need to compare with the Object class, but we only have a Module at hand.
RubyClass classClass = lexicalParent.getLogicalClass();
RubyClass objectClass = classClass.getSuperClass().getSuperClass();

if (lexicalParent != objectClass) {
name = lexicalParent.getName() + "::" + name;
}
}
@@ -532,7 +532,7 @@ public static class ModuleAllocator implements Allocator {

@Override
public RubyBasicObject allocate(RubyContext context, RubyClass rubyClass, RubyNode currentNode) {
return new RubyModule(context, null, null);
return new RubyModule(context, null, null, currentNode);
}

}
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.runtime.subsystems.ObjectSpaceManager;
import org.jruby.util.cli.Options;

/**
* Represents the Ruby {@code Proc} class.