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

Commits on Nov 7, 2016

  1. Copy the full SHA
    13156c2 View commit details
  2. Copy the full SHA
    9df290f View commit details
  3. Copy the full SHA
    2092a66 View commit details
  4. [Truffle] Rename Truffle::Boot.run_jruby_root to Truffle::Boot.main.

    * Since it is the entry point in user Ruby code.
    eregon committed Nov 7, 2016
    Copy the full SHA
    52f208f View commit details
4 changes: 2 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ public JRubyTruffleImpl(RubyInstanceConfig instanceConfig) {
engine = PolyglotEngine.newBuilder()
.globalSymbol(JRubyTruffleInterface.RUNTIME_SYMBOL, new InstanceConfigWrapper(instanceConfig))
.build();
context = (RubyContext) engine.eval(loadSource("Truffle::Boot.context", "context")).get();
context = engine.eval(loadSource("Truffle::Boot.context", "context")).as(RubyContext.class);
}

@Override
@@ -42,7 +42,7 @@ public int execute(String path) {

context.setOriginalInputFile(path);

return engine.eval(loadSource("Truffle::Boot.run_jruby_root", "run_jruby_root")).as(Integer.class);
return engine.eval(loadSource("Truffle::Boot.main", "main")).as(Integer.class);
}

@Override
8 changes: 4 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -290,7 +290,7 @@ public class CoreLibrary {
private final Map<Errno, DynamicObject> errnoClasses = new HashMap<>();

@CompilationFinal private InternalMethod basicObjectSendMethod;
@CompilationFinal private InternalMethod truffleBootRunJRubyRootMethod;
@CompilationFinal private InternalMethod truffleBootMainMethod;

@CompilationFinal private GlobalVariableStorage loadPathStorage;
@CompilationFinal private GlobalVariableStorage loadedFeaturesStorage;
@@ -817,7 +817,7 @@ public void addCoreMethods(PrimitiveManager primitiveManager) {
coreMethodNodeManager.allMethodInstalled();

basicObjectSendMethod = getMethod(basicObjectClass, "__send__");
truffleBootRunJRubyRootMethod = getMethod(node.getSingletonClass(truffleBootModule), "run_jruby_root");
truffleBootMainMethod = getMethod(node.getSingletonClass(truffleBootModule), "main");
}

private InternalMethod getMethod(DynamicObject module, String name) {
@@ -1518,8 +1518,8 @@ public boolean isSend(InternalMethod method) {
return callTarget == basicObjectSendMethod.getCallTarget();
}

public boolean isRunJRubyRootMethod(SharedMethodInfo info) {
return info == truffleBootRunJRubyRootMethod.getSharedMethodInfo();
public boolean isTruffleBootMainMethod(SharedMethodInfo info) {
return info == truffleBootMainMethod.getSharedMethodInfo();
}

public DynamicObjectFactory getIntRangeFactory() {
Original file line number Diff line number Diff line change
@@ -103,30 +103,15 @@ protected static long randInt(org.jruby.util.Random r, long limit) {
public static abstract class RandomizerGenSeedPrimitiveNode extends PrimitiveArrayArgumentsNode {

// Single instance of Random per host VM

private static Random random;
private static final Random RANDOM = new SecureRandom();

@TruffleBoundary
@Specialization
public DynamicObject randomizerGenSeed(DynamicObject randomizerClass) {
final BigInteger seed = RubyRandom.randomSeedBigInteger(getRandom());
final BigInteger seed = RubyRandom.randomSeedBigInteger(RANDOM);
return createBignum(seed);
}

private Random getRandom() {
if (random == null) {
// We don't care about racing to create this

try {
random = new SecureRandom();
} catch (Throwable t) {
// TODO CS 5-Nov-16 should we warn about this?
random = new Random();
}
}

return random;
}
}

@Primitive(name = "randomizer_bytes", lowerFixnum = 1)
Original file line number Diff line number Diff line change
@@ -225,10 +225,10 @@ private boolean ignoreFrame(FrameInstance frameInstance) {

final RootNode rootNode = callNode.getRootNode();

// Ignore the call to Truffle::Boot.run_jruby_root
// Ignore the call to Truffle::Boot.main
if (rootNode instanceof RubyRootNode) {
SharedMethodInfo sharedMethodInfo = ((RubyRootNode) rootNode).getSharedMethodInfo();
if (context.getCoreLibrary().isRunJRubyRootMethod(sharedMethodInfo)) {
if (context.getCoreLibrary().isTruffleBootMainMethod(sharedMethodInfo)) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -80,11 +80,11 @@ public RubyContext context() {
}
}

@CoreMethod(names = "run_jruby_root", onSingleton = true)
public abstract static class RunJRubyRootNode extends CoreMethodArrayArgumentsNode {
@CoreMethod(names = "main", onSingleton = true)
public abstract static class MainNode extends CoreMethodArrayArgumentsNode {

@Specialization
public Object runJRubyRootNode(VirtualFrame frame, @Cached("create()") IndirectCallNode callNode) {
public Object main(VirtualFrame frame, @Cached("create()") IndirectCallNode callNode) {
final String arg0 = getContext().getInstanceConfig().displayedFileName();

coreLibrary().getGlobalVariables().put("$0", StringOperations.createString(