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

Commits on Jun 8, 2016

  1. Copy the full SHA
    cba8d93 View commit details
  2. [Truffle] Fix visibility to respond_to? when at the top level and in …

    …the first required file.
    chrisseaton committed Jun 8, 2016
    Copy the full SHA
    4071392 View commit details
  3. Copy the full SHA
    fa866cf View commit details
  4. Copy the full SHA
    6344c26 View commit details
  5. Copy the full SHA
    5be7e53 View commit details
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -239,6 +239,7 @@ public class Options {
public static final Option<Boolean> TRUFFLE_PROFILER = bool(TRUFFLE, "truffle.profiler", false, "Run the Truffle profiler.");

public static final Option<String> TRUFFLE_CORE_LOAD_PATH = string(TRUFFLE, "truffle.core.load_path", "truffle:/jruby-truffle", "Location to load the Truffle core library from.");
public static final Option<Boolean> TRUFFLE_CORE_PARALLEL_LOAD = bool(TRUFFLE, "truffle.core.parallel_load", true, "Load the Truffle core library in parallel.");

public static final Option<Integer> TRUFFLE_ARRAY_UNINITIALIZED_SIZE = integer(TRUFFLE, "truffle.array.uninitialized_size", 32, "How large an Array to allocate when we have no other information to go on.");
public static final Option<Integer> TRUFFLE_ARRAY_SMALL = integer(TRUFFLE, "truffle.array.small", 3, "Maximum size of an Array to consider small for optimisations.");

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -9,10 +9,8 @@
*/
package org.jruby.truffle.builtins;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.core.ObjectNodesFactory;
import org.jruby.truffle.core.VMPrimitiveNodesFactory;
import org.jruby.truffle.core.array.ArrayNodesFactory;
@@ -37,23 +35,22 @@
import org.jruby.truffle.core.thread.ThreadNodesFactory;
import org.jruby.truffle.core.time.TimeNodesFactory;
import org.jruby.truffle.extra.ffi.PointerPrimitiveNodesFactory;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
* Manages the available Rubinius primitive calls.
*/
public class PrimitiveManager {

private final ConcurrentMap<String, PrimitiveConstructor> primitives = new ConcurrentHashMap<String, PrimitiveConstructor>();
private final Map<String, PrimitiveNodeConstructor> primitives = new ConcurrentHashMap<>();

public PrimitiveConstructor getPrimitive(String name) {
final PrimitiveConstructor constructor = primitives.get(name);
public PrimitiveNodeConstructor getPrimitive(String name) {
final PrimitiveNodeConstructor constructor = primitives.get(name);

if (constructor == null) {
return primitives.get(UndefinedPrimitiveNodes.NAME);
@@ -100,10 +97,4 @@ public void addAnnotatedPrimitives() {
}
}
}

@TruffleBoundary
public void installPrimitive(String name, DynamicObject method) {
assert RubyGuards.isRubyMethod(method);
primitives.put(name, new PrimitiveCallConstructor(method));
}
}
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import java.util.ArrayList;
import java.util.List;

public class PrimitiveNodeConstructor implements PrimitiveConstructor {
public class PrimitiveNodeConstructor {

private final Primitive annotation;
private final NodeFactory<? extends RubyNode> factory;
@@ -33,12 +33,10 @@ public PrimitiveNodeConstructor(Primitive annotation, NodeFactory<? extends Ruby
this.factory = factory;
}

@Override
public int getPrimitiveArity() {
return factory.getExecutionSignature().size();
}

@Override
public RubyNode createCallPrimitiveNode(RubyContext context, SourceSection sourceSection, ReturnID returnID) {
int argumentsCount = getPrimitiveArity();
final List<RubyNode> arguments = new ArrayList<>(argumentsCount);
129 changes: 124 additions & 5 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -120,6 +120,9 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;

public class CoreLibrary {

@@ -904,13 +907,38 @@ public void initializeAfterBasicMethodsAdded() {

try {
Main.printTruffleTimeMetric("before-load-core");

state = State.LOADING_RUBY_CORE;

final Future<RubyRootNode>[] coreFileFutures = new Future[coreFiles.length];

try {
final RubyRootNode rootNode = context.getCodeLoader().parse(context.getSourceCache().getSource(getCoreLoadPath() + "/core.rb"), UTF8Encoding.INSTANCE, ParserContext.TOP_LEVEL, null, true, node);
final CodeLoader.DeferredCall deferredCall = context.getCodeLoader().prepareExecute(ParserContext.TOP_LEVEL, DeclarationContext.TOP_LEVEL, rootNode, null, context.getCoreLibrary().getMainObject());
deferredCall.callWithoutCallNode();
} catch (IOException e) {
for (int n = 0; n < coreFiles.length; n++) {
final int finalN = n;

coreFileFutures[n] = ForkJoinPool.commonPool().submit(() ->
context.getCodeLoader().parse(
context.getSourceCache().getSource(getCoreLoadPath() + coreFiles[finalN]),
UTF8Encoding.INSTANCE, ParserContext.TOP_LEVEL, null, true, node)
);

if (!context.getOptions().CORE_PARALLEL_LOAD) {
coreFileFutures[n].get();
}
}

for (int n = 0; n < coreFiles.length; n++) {
final RubyRootNode rootNode = coreFileFutures[n].get();

final CodeLoader.DeferredCall deferredCall = context.getCodeLoader().prepareExecute(
ParserContext.TOP_LEVEL,
DeclarationContext.TOP_LEVEL,
rootNode,
null,
context.getCoreLibrary().getMainObject());

deferredCall.callWithoutCallNode();
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}

@@ -938,6 +966,7 @@ public void initializePostBoot() {

try {
Main.printTruffleTimeMetric("before-post-boot");

try {
final RubyRootNode rootNode = context.getCodeLoader().parse(context.getSourceCache().getSource(getCoreLoadPath() + "/core/post-boot.rb"), UTF8Encoding.INSTANCE, ParserContext.TOP_LEVEL, null, true, node);
final CodeLoader.DeferredCall deferredCall = context.getCodeLoader().prepareExecute(ParserContext.TOP_LEVEL, DeclarationContext.TOP_LEVEL, rootNode, null, context.getCoreLibrary().getMainObject());
@@ -1378,4 +1407,94 @@ public DynamicObjectFactory getHandleFactory() {
return handleFactory;
}

private static final String[] coreFiles = {
"/core/pre.rb",
"/core/tuple.rb",
"/core/lookuptable.rb",
"/core/basic_object.rb",
"/core/mirror.rb",
"/core/bignum.rb",
"/core/channel.rb",
"/core/character.rb",
"/core/configuration.rb",
"/core/false.rb",
"/core/gc.rb",
"/core/nil.rb",
"/core/rubinius.rb",
"/core/stat.rb",
"/core/string.rb",
"/core/thread.rb",
"/core/true.rb",
"/core/type.rb",
"/core/weakref.rb",
"/core/library.rb",
"/core/truffle/ffi/ffi.rb",
"/core/truffle/ffi/pointer.rb",
"/core/truffle/ffi/ffi_file.rb",
"/core/truffle/ffi/ffi_struct.rb",
"/core/io.rb",
"/core/immediate.rb",
"/core/string_mirror.rb",
"/core/module.rb",
"/core/proc.rb",
"/core/enumerable_helper.rb",
"/core/enumerable.rb",
"/core/enumerator.rb",
"/core/argf.rb",
"/core/exception.rb",
"/core/undefined.rb",
"/core/hash.rb",
"/core/array.rb",
"/core/kernel.rb",
"/core/identity_map.rb",
"/core/comparable.rb",
"/core/numeric_mirror.rb",
"/core/numeric.rb",
"/core/truffle/ctype.rb",
"/core/integer.rb",
"/core/fixnum.rb",
"/core/lru_cache.rb",
"/core/regexp.rb",
"/core/encoding.rb",
"/core/env.rb",
"/core/errno.rb",
"/core/file.rb",
"/core/dir.rb",
"/core/dir_glob.rb",
"/core/file_test.rb",
"/core/float.rb",
"/core/marshal.rb",
"/core/object_space.rb",
"/core/range_mirror.rb",
"/core/range.rb",
"/core/struct.rb",
"/core/tms.rb",
"/core/process.rb",
"/core/process_mirror.rb",
"/core/random.rb",
"/core/signal.rb",
"/core/splitter.rb",
"/core/symbol.rb",
"/core/mutex.rb",
"/core/throw_catch.rb",
"/core/time.rb",
"/core/rational.rb",
"/core/rationalizer.rb",
"/core/complex.rb",
"/core/complexifier.rb",
"/core/class.rb",
"/core/binding.rb",
"/core/math.rb",
"/core/method.rb",
"/core/unbound_method.rb",
"/core/shims.rb",
"/core/truffle/attachments.rb",
"/core/truffle/debug.rb",
"/core/truffle/cext.rb",
"/core/truffle/interop.rb",
"/core/rbconfig.rb",
"/core/main.rb",
"/core/post.rb"
};

}
2 changes: 2 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/language/Options.java
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import static org.jruby.util.cli.Options.TRUFFLE_CONSTANT_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_CORE_ALWAYS_CLONE;
import static org.jruby.util.cli.Options.TRUFFLE_CORE_LOAD_PATH;
import static org.jruby.util.cli.Options.TRUFFLE_CORE_PARALLEL_LOAD;
import static org.jruby.util.cli.Options.TRUFFLE_COVERAGE_GLOBAL;
import static org.jruby.util.cli.Options.TRUFFLE_DISPATCH_CACHE;
import static org.jruby.util.cli.Options.TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE;
@@ -90,6 +91,7 @@ public class Options {
// Resources

public final String CORE_LOAD_PATH = TRUFFLE_CORE_LOAD_PATH.load();
public final boolean CORE_PARALLEL_LOAD = TRUFFLE_CORE_PARALLEL_LOAD.load();

// Data structures

Original file line number Diff line number Diff line change
@@ -76,17 +76,6 @@ public DynamicObject jrubyHomeDirectoryProtocol() {

}

@CoreMethod(names = "install_rubinius_primitive", isModuleFunction = true, required = 1)
public abstract static class InstallRubiniusPrimitiveNode extends CoreMethodArrayArgumentsNode {

@Specialization(guards = "isRubyMethod(rubyMethod)")
public Object installRubiniusPrimitive(DynamicObject rubyMethod) {
String name = Layouts.METHOD.getMethod(rubyMethod).getName();
getContext().getPrimitiveManager().installPrimitive(name, rubyMethod);
return nil();
}
}

@CoreMethod(names = "context", onSingleton = true)
public abstract static class ContextNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -152,8 +152,14 @@ private DispatchNode doDynamicObject(
if (ignoreVisibility) {
callerClass = null;
} else if (getDispatchAction() == DispatchAction.RESPOND_TO_METHOD) {
final Frame callerFrame = getContext().getCallStack().getCallerFrameIgnoringSend().getFrame(FrameInstance.FrameAccess.READ_ONLY, true);
callerClass = coreLibrary().getMetaClass(RubyArguments.getSelf(callerFrame));
final FrameInstance instance = getContext().getCallStack().getCallerFrameIgnoringSend();

if (instance == null) {
callerClass = coreLibrary().getMetaClass(coreLibrary().getMainObject());
} else {
final Frame callerFrame = instance.getFrame(FrameInstance.FrameAccess.READ_ONLY, true);
callerClass = coreLibrary().getMetaClass(RubyArguments.getSelf(callerFrame));
}
} else {
callerClass = coreLibrary().getMetaClass(RubyArguments.getSelf(frame));
}
Loading