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

Commits on Oct 26, 2014

  1. [Truffle] Get rid of the copy of options stored in RubyContext.

    We used to copy some of the options into RubyContext where they can be
    final for the benefit of the PE, as using Option.load() requires a
    volatile read.
    chrisseaton committed Oct 26, 2014
    Copy the full SHA
    7cfbcfd View commit details
  2. [Truffle] Remove visibility asserts - a mess, and don't always make s…

    …ense in multi-language environment.
    chrisseaton committed Oct 26, 2014
    Copy the full SHA
    5257211 View commit details
  3. [Truffle] Change the generic dispatch node from caching to looking up…

    … every time.
    
    This node had lots of potential problems - invalidation wasn't checked,
    dead entries weren't removed, and the hash tables weren't synchronised.
    For now we'll just remove the caching, call it UncachedDispatchNode,
    and make it neverPartOfCompilation.
    chrisseaton committed Oct 26, 2014
    Copy the full SHA
    f72ddfa View commit details
  4. Copy the full SHA
    0e4dc82 View commit details
Showing with 320 additions and 654 deletions.
  1. +0 −30 core/src/main/java/org/jruby/lexer/yacc/TruffleSourcePosition.java
  2. +0 −67 core/src/main/java/org/jruby/lexer/yacc/TruffleSourcePositionFactory.java
  3. +2 −13 core/src/main/java/org/jruby/parser/Parser.java
  4. +4 −1 core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
  5. +0 −5 core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
  6. +6 −4 core/src/main/java/org/jruby/truffle/nodes/RubyRootNode.java
  7. +5 −2 core/src/main/java/org/jruby/truffle/nodes/core/ArrayAllocationSite.java
  8. +4 −1 core/src/main/java/org/jruby/truffle/nodes/core/ArrayBuilderNode.java
  9. +5 −7 core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  10. +17 −17 core/src/main/java/org/jruby/truffle/nodes/core/HashNodes.java
  11. +1 −2 core/src/main/java/org/jruby/truffle/nodes/core/YieldingArrayCoreMethodNode.java
  12. +1 −2 core/src/main/java/org/jruby/truffle/nodes/core/YieldingHashCoreMethodNode.java
  13. +3 −3 core/src/main/java/org/jruby/truffle/nodes/debug/RubyASTProber.java
  14. +10 −9 core/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchHeadNode.java
  15. +26 −2 core/src/main/java/org/jruby/truffle/nodes/dispatch/DispatchNode.java
  16. +0 −380 core/src/main/java/org/jruby/truffle/nodes/dispatch/GenericDispatchNode.java
  17. +206 −0 core/src/main/java/org/jruby/truffle/nodes/dispatch/UncachedDispatchNode.java
  18. +1 −1 core/src/main/java/org/jruby/truffle/nodes/dispatch/UnresolvedDispatchNode.java
  19. +2 −3 core/src/main/java/org/jruby/truffle/nodes/literal/HashLiteralNode.java
  20. +0 −10 core/src/main/java/org/jruby/truffle/nodes/literal/ObjectLiteralNode.java
  21. +3 −5 core/src/main/java/org/jruby/truffle/nodes/methods/ExceptionTranslatingNode.java
  22. +1 −4 core/src/main/java/org/jruby/truffle/nodes/yield/YieldDispatchHeadNode.java
  23. +5 −0 core/src/main/java/org/jruby/truffle/runtime/DebugOperations.java
  24. +1 −6 core/src/main/java/org/jruby/truffle/runtime/RubyArguments.java
  25. +1 −41 core/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  26. +0 −2 core/src/main/java/org/jruby/truffle/runtime/control/BreakException.java
  27. +0 −3 core/src/main/java/org/jruby/truffle/runtime/control/ContinuationReturnException.java
  28. +0 −2 core/src/main/java/org/jruby/truffle/runtime/control/NextException.java
  29. +0 −2 core/src/main/java/org/jruby/truffle/runtime/control/ReturnException.java
  30. +0 −4 core/src/main/java/org/jruby/truffle/runtime/control/ThrowException.java
  31. +1 −3 core/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  32. +3 −3 core/src/main/java/org/jruby/truffle/runtime/core/RubyArray.java
  33. +8 −6 core/src/main/java/org/jruby/truffle/runtime/core/RubyHash.java
  34. +0 −1 core/src/main/java/org/jruby/truffle/runtime/core/RubyModule.java
  35. +1 −0 core/src/main/java/org/jruby/truffle/runtime/core/RubyProc.java
  36. +2 −11 core/src/main/java/org/jruby/truffle/translator/Translator.java
  37. +1 −2 core/src/main/java/org/jruby/util/cli/Options.java
30 changes: 0 additions & 30 deletions core/src/main/java/org/jruby/lexer/yacc/TruffleSourcePosition.java

This file was deleted.

This file was deleted.

15 changes: 2 additions & 13 deletions core/src/main/java/org/jruby/parser/Parser.java
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.load.LoadServiceResourceInputStream;
import org.jruby.util.ByteList;
import org.jruby.util.cli.Options;

/**
* Serves as a simple facade for all the parsing magic.
@@ -75,7 +74,7 @@ public Node parse(String file, ByteList content, DynamicScope blockScope,
public Node parse(String file, byte[] content, DynamicScope blockScope,
ParserConfiguration configuration) {
RubyArray list = getLines(configuration, runtime, file);
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, getSourcePositionFactoryFactory());
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, new SimpleSourcePositionFactory.Factory());
return parse(file, lexerSource, blockScope, configuration);
}

@@ -86,7 +85,7 @@ public Node parse(String file, InputStream content, DynamicScope blockScope,
if (content instanceof LoadServiceResourceInputStream) {
return parse(file, ((LoadServiceResourceInputStream) content).getBytes(), blockScope, configuration);
} else {
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, getSourcePositionFactoryFactory());
LexerSource lexerSource = LexerSource.getSource(file, content, list, configuration, new SimpleSourcePositionFactory.Factory());
return parse(file, lexerSource, blockScope, configuration);
}
}
@@ -174,14 +173,4 @@ private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, Stri
return list;
}

// I'm really sorry, this is a factory factory factory method (CS)
private SourcePositionFactory.SourcePositionFactoryFactory getSourcePositionFactoryFactory() {
if (runtime.getInstanceConfig().getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE || Options.PARSER_ALWAYS_TRUFFLE_POSITIONS.load()) {
return new TruffleSourcePositionFactory.Factory();
} else {
return new SimpleSourcePositionFactory.Factory();
}
}


}
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/truffle/TruffleBridgeImpl.java
Original file line number Diff line number Diff line change
@@ -20,12 +20,14 @@
import org.jruby.truffle.nodes.RubyRootNode;
import org.jruby.truffle.nodes.core.*;
import org.jruby.truffle.nodes.methods.MethodDefinitionNode;
import org.jruby.truffle.runtime.DebugOperations;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.util.Supplier;
import org.jruby.truffle.translator.TranslatorDriver;
import org.jruby.util.cli.Options;

import java.io.IOException;
import java.nio.file.Files;
@@ -48,7 +50,7 @@ public TruffleBridgeImpl(org.jruby.Ruby runtime) {

@Override
public void init() {
if (RubyContext.PRINT_RUNTIME) {
if (Options.TRUFFLE_PRINT_RUNTIME.load()) {
runtime.getInstanceConfig().getError().println("jruby: using " + Truffle.getRuntime().getName());
}

@@ -154,6 +156,7 @@ public Object get() {

final RubyRootNode parsedRootNode = truffleContext.getTranslator().parse(truffleContext, source, parserContext, parentFrame, null);
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(parsedRootNode);

return callTarget.call(RubyArguments.pack(null, parentFrame, self, null, new Object[]{}));
}

5 changes: 0 additions & 5 deletions core/src/main/java/org/jruby/truffle/nodes/RubyCallNode.java
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.methods.*;
import org.jruby.truffle.runtime.util.ArrayUtils;
import org.jruby.truffle.runtime.LexicalScope;

import java.util.Arrays;

@@ -86,9 +85,6 @@ public Object execute(VirtualFrame frame) {
final Object[] argumentsObjects = executeArguments(frame);
final RubyProc blockObject = executeBlock(frame);

assert RubyContext.shouldObjectBeVisible(receiverObject);
assert RubyContext.shouldObjectsBeVisible(argumentsObjects);

return dispatchHead.call(frame, receiverObject, methodName, blockObject, argumentsObjects);
}

@@ -106,7 +102,6 @@ private Object[] executeArguments(VirtualFrame frame) {

for (int i = 0; i < arguments.length; i++) {
argumentsObjects[i] = arguments[i].execute(frame);
assert RubyContext.shouldObjectBeVisible(argumentsObjects[i]) : argumentsObjects[i].getClass();
}

if (isSplatted) {
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/truffle/nodes/RubyRootNode.java
Original file line number Diff line number Diff line change
@@ -13,15 +13,19 @@
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.nodes.*;
import org.jruby.truffle.runtime.DebugOperations;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.util.cli.Options;

/**
* The root node in an AST for a method. Unlike {@link RubyNode}, this has a single entry point,
* {@link #execute}, which Truffle knows about and can create a {@link CallTarget} from.
*/
public class RubyRootNode extends RootNode {

public static final boolean COMPILER_PASS_LOOPS_THROUGH_BLOCKS = Options.TRUFFLE_COMPILER_PASS_LOOPS_THROUGH_BLOCKS.load();

private final RubyContext context;
private final SharedMethodInfo sharedMethodInfo;
@Child protected RubyNode body;
@@ -42,9 +46,7 @@ public RubyRootNode cloneRubyRootNode() {

@Override
public Object execute(VirtualFrame frame) {
final Object result = body.execute(frame);
assert RubyContext.shouldObjectBeVisible(result) : getSourceSection();
return result;
return body.execute(frame);
}

@Override
@@ -60,7 +62,7 @@ public boolean isSplittable() {
public void reportLoopCountThroughBlocks(final int count) {
CompilerAsserts.neverPartOfCompilation();

if (RubyContext.COMPILER_PASS_LOOPS_THROUGH_BLOCKS) {
if (COMPILER_PASS_LOOPS_THROUGH_BLOCKS) {
Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {

@Override
Original file line number Diff line number Diff line change
@@ -13,22 +13,25 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.util.cli.Options;

public class ArrayAllocationSite {

public static final boolean ARRAYS_OPTIMISTIC_LONG = Options.TRUFFLE_ARRAYS_OPTIMISTIC_LONG.load();

@CompilerDirectives.CompilationFinal private boolean convertedIntToLong = false;
private final Assumption assumption = Truffle.getRuntime().createAssumption();

@CompilerDirectives.SlowPath
public void convertedIntToLong() {
if (RubyContext.ARRAYS_OPTIMISTIC_LONG) {
if (ARRAYS_OPTIMISTIC_LONG) {
convertedIntToLong = true;
assumption.invalidate();
}
}

public boolean hasConvertedIntToLong() {
if (RubyContext.ARRAYS_OPTIMISTIC_LONG) {
if (ARRAYS_OPTIMISTIC_LONG) {
assumption.isValid();
return convertedIntToLong;
} else {
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.util.ArrayUtils;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.util.cli.Options;

import java.util.Arrays;

@@ -24,6 +25,8 @@

public abstract class ArrayBuilderNode extends Node {

public static final int ARRAYS_UNINITIALIZED_SIZE = Options.TRUFFLE_ARRAYS_UNINITIALIZED_SIZE.load();

private final RubyContext context;

public ArrayBuilderNode(RubyContext context) {
@@ -60,7 +63,7 @@ public void resume(Object[] store) {
@Override
public Object start() {
CompilerDirectives.transferToInterpreter();
return new Object[RubyContext.ARRAYS_UNINITIALIZED_SIZE];
return new Object[ARRAYS_UNINITIALIZED_SIZE];
}

@Override
12 changes: 5 additions & 7 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -2930,8 +2930,6 @@ public Object selectObject(VirtualFrame frame, RubyArray array, RubyProc block)
// TODO(CS): cast to boolean?
notDesignedForCompilation();

assert RubyContext.shouldObjectBeVisible(value);
assert RubyContext.shouldObjectsBeVisible(new Object[]{value});
if (yieldBoolean(frame, block, new Object[]{value})) {
selectedStore = arrayBuilder.append(selectedStore, selectedSize, value);
selectedSize++;
@@ -3086,9 +3084,9 @@ public RubyArray sortVeryShortIntegerFixnum(VirtualFrame frame, RubyArray array)

// Selection sort - written very carefully to allow PE

for (int i = 0; i < RubyContext.ARRAYS_SMALL; i++) {
for (int i = 0; i < RubyArray.ARRAYS_SMALL; i++) {
if (i < size) {
for (int j = i + 1; j < RubyContext.ARRAYS_SMALL; j++) {
for (int j = i + 1; j < RubyArray.ARRAYS_SMALL; j++) {
if (j < size) {
if ((int) compareDispatchNode.call(frame, store[j], "<=>", null, store[i]) < 0) {
final int temp = store[j];
@@ -3122,9 +3120,9 @@ public RubyArray sortVeryShortLongFixnum(VirtualFrame frame, RubyArray array) {

// Selection sort - written very carefully to allow PE

for (int i = 0; i < RubyContext.ARRAYS_SMALL; i++) {
for (int i = 0; i < RubyArray.ARRAYS_SMALL; i++) {
if (i < size) {
for (int j = i + 1; j < RubyContext.ARRAYS_SMALL; j++) {
for (int j = i + 1; j < RubyArray.ARRAYS_SMALL; j++) {
if (j < size) {
if ((int) compareDispatchNode.call(frame, store[j], "<=>", null, store[i]) < 0) {
final long temp = store[j];
@@ -3205,7 +3203,7 @@ public int compare(Object a, Object b) {
}

protected static boolean isSmall(RubyArray array) {
return array.getSize() <= RubyContext.ARRAYS_SMALL;
return array.getSize() <= RubyArray.ARRAYS_SMALL;
}

}
Loading