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

Commits on Sep 14, 2014

  1. Copy the full SHA
    dfa846c View commit details
  2. [Truffle] Don't try to convert exceptions that go all the way to the …

    …top level into Ruby backtraces.
    chrisseaton committed Sep 14, 2014
    Copy the full SHA
    8d82bd8 View commit details
  3. Copy the full SHA
    e11f4fd View commit details
  4. Copy the full SHA
    c43208d View commit details
  5. [Truffle] Disable by default passing loop counts through blocks - pre…

    …tty sure it's counterproductive.
    chrisseaton committed Sep 14, 2014
    Copy the full SHA
    d6e4392 View commit details

Commits on Sep 15, 2014

  1. Copy the full SHA
    f3254fc View commit details
15 changes: 11 additions & 4 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -203,12 +203,19 @@ public static void main(String[] args) {
} catch (RaiseException rj) {
System.exit(handleRaiseException(rj));
} catch (Throwable t) {
// print out as a nice Ruby backtrace
System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t));
while ((t = t.getCause()) != null) {
System.err.println("Caused by:");
// If a Truffle exception gets this far it's a hard failure - don't try and dress it up as a Ruby exception

if (main.config.getCompileMode() == RubyInstanceConfig.CompileMode.TRUFFLE) {
t.printStackTrace(System.err);
} else {
// print out as a nice Ruby backtrace
System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t));
while ((t = t.getCause()) != null) {
System.err.println("Caused by:");
System.err.println(ThreadContext.createRawBacktraceStringFromThrowable(t));
}
}

System.exit(1);
}
}
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/truffle/nodes/RubyRootNode.java
Original file line number Diff line number Diff line change
@@ -64,6 +64,12 @@ public void reportLoopCountThroughBlocks(final int count) {

@Override
public Object visitFrame(FrameInstance frameInstance) {
// The call node for the top level is null and should be ignored

if (frameInstance.getCallNode() == null) {
return null;
}

final RootNode rootNode = frameInstance.getCallNode().getRootNode();

if (!(rootNode instanceof RubyRootNode)) {
Original file line number Diff line number Diff line change
@@ -422,13 +422,13 @@ private static String gets(RubyContext context) throws IOException {
final StringBuilder builder = new StringBuilder();

while (true) {
final char c = (char) context.getRuntime().getInstanceConfig().getInput().read();
final int c = context.getRuntime().getInstanceConfig().getInput().read();

if (c == '\r' || c == '\n') {
if (c == -1 || c == '\r' || c == '\n') {
break;
}

builder.append(c);
builder.append((char) c);
}

return builder.toString();
Original file line number Diff line number Diff line change
@@ -64,6 +64,25 @@ public NilPlaceholder dumpCallStack() {

}

@CoreMethod(names = "flush_stdout", isModuleMethod = true, needsSelf = false, maxArgs = 0)
public abstract static class FlushStdoutNode extends CoreMethodNode {

public FlushStdoutNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public FlushStdoutNode(PanicNode prev) {
super(prev);
}

@Specialization
public NilPlaceholder flush() {
getContext().getRuntime().getOut().flush();
return NilPlaceholder.INSTANCE;
}

}

@CoreMethod(names = "full_tree", isModuleMethod = true, needsSelf = false, maxArgs = 0)
public abstract static class FullTreeNode extends CoreMethodNode {

Original file line number Diff line number Diff line change
@@ -41,23 +41,23 @@ public ExceptionTranslatingNode(RubyContext context, SourceSection sourceSection
public Object execute(VirtualFrame frame) {
try {
return child.execute(frame);
} catch (ControlFlowException e) {
} catch (ControlFlowException exception) {
controlProfile.enter();
throw e;
} catch (RaiseException e) {
throw exception;
} catch (RaiseException exception) {
rethrowProfile.enter();
throw e;
} catch (TruffleFatalException e) {
throw e;
} catch (ArithmeticException e) {
throw exception;
} catch (TruffleFatalException exception) {
throw exception;
} catch (ArithmeticException exception) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(translate(e));
} catch (UnsupportedSpecializationException e) {
throw new RaiseException(translate(exception));
} catch (UnsupportedSpecializationException exception) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(translate(e));
} catch (Exception e) {
throw new RaiseException(translate(exception));
} catch (Throwable translate) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(translate(e));
throw new RaiseException(translate(translate));
}
}

@@ -114,25 +114,15 @@ private RubyBasicObject translate(UnsupportedSpecializationException exception)
}
}

builder.append(" - this is either a feature we haven't implemented for Truffle yet, or it might be disallowed in Ruby anyway");

return new RubyException(getContext().getCoreLibrary().getRubyTruffleErrorClass(), getContext().makeString(builder.toString()), RubyCallStack.getBacktrace(this));
return getContext().getCoreLibrary().internalError(builder.toString(), this);
}

public RubyBasicObject translate(Exception exception) {
public RubyBasicObject translate(Throwable throwable) {
if (RubyContext.EXCEPTIONS_PRINT_JAVA) {
exception.printStackTrace();
}

String message;

if (exception.getMessage() == null) {
message = exception.getClass().getSimpleName();
} else {
message = exception.getClass().getSimpleName() + ": " + exception.getMessage();
throwable.printStackTrace();
}

return new RubyException(getContext().getCoreLibrary().getRubyTruffleErrorClass(), getContext().makeString(message), RubyCallStack.getBacktrace(this));
return getContext().getCoreLibrary().internalError(throwable.getClass().getSimpleName(), this);
}

}
Original file line number Diff line number Diff line change
@@ -122,8 +122,13 @@ public static Backtrace getBacktrace(Node currentNode) {

@Override
public RubyMethod visitFrame(FrameInstance frameInstance) {
activations.add(new Activation(frameInstance.getCallNode(),
frameInstance.getFrame(FrameInstance.FrameAccess.MATERIALIZE, true).materialize()));
// Multiple top level methods (require) introduce null call nodes - ignore them

if (frameInstance.getCallNode() != null) {
activations.add(new Activation(frameInstance.getCallNode(),
frameInstance.getFrame(FrameInstance.FrameAccess.MATERIALIZE, true).materialize()));
}

return null;
}

Original file line number Diff line number Diff line change
@@ -318,10 +318,11 @@ public void initialize() {
}

public void initializeAfterMethodsAdded() {
// Just create a dummy object for $stdout - we can use Kernel#print
// Just create a dummy object for $stdout - we can use Kernel#print and a special method TruffleDebug#flush_stdout

final RubyBasicObject stdout = new RubyBasicObject(objectClass);
stdout.getSingletonClass(null).addMethod(null, stdout.getLookupNode().lookupMethod("print").withNewVisibility(Visibility.PUBLIC));
stdout.getSingletonClass(null).addMethod(null, truffleDebugModule.getLookupNode().lookupMethod("flush_stdout").withNewName("flush"));
globalVariablesObject.setInstanceVariable("$stdout", stdout);

objectClass.setConstant(null, "STDIN", new RubyBasicObject(objectClass));
@@ -506,6 +507,10 @@ public RubyBasicObject rangeError(String type, String value, String range, Node
return new RubyException(rangeErrorClass, context.makeString(String.format("%s %s out of range of %s", type, value, range)), RubyCallStack.getBacktrace(currentNode));
}

public RubyException internalError(String message, Node currentNode) {
return new RubyException(context.getCoreLibrary().getRubyTruffleErrorClass(), context.makeString("internal implementation error - " + message), RubyCallStack.getBacktrace(currentNode));
}

public RubyContext getContext() {
return context;
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ public class Options {
public static final Option<Boolean> TRUFFLE_ARRAYS_OPTIMISTIC_LONG = bool(TRUFFLE, "truffle.arrays.optimistic.long", true, "If we allocate an int[] for an Array and it has been converted to a long[], directly allocate a long[] next time.");
public static final Option<Integer> TRUFFLE_ARRAYS_SMALL = integer(TRUFFLE, "truffle.arrays.small", 3, "Maximum size of an Array to consider small for optimisations.");
public static final Option<Integer> TRUFFLE_HASHES_SMALL = integer(TRUFFLE, "truffle.hashes.small", 3, "Maximum size of a Hash to consider small for optimisations.");
public static final Option<Boolean> TRUFFLE_COMPILER_PASS_LOOPS_THROUGH_BLOCKS = bool(TRUFFLE, "truffle.compiler.pass_loops_through_blocks", true, "Pass loop counts through blocks to the method that is calling the block.");
public static final Option<Boolean> TRUFFLE_COMPILER_PASS_LOOPS_THROUGH_BLOCKS = bool(TRUFFLE, "truffle.compiler.pass_loops_through_blocks", false, "Pass loop counts through blocks to the method that is calling the block.");
public static final Option<Boolean> TRUFFLE_ALLOW_SIMPLE_SOURCE_SECTIONS = bool(TRUFFLE, "truffle.allow_simple_source_sections", false, "Allow simple source sections.");
public static final Option<Backtrace.Formatter> TRUFFLE_BACKTRACE_DISPLAY_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.display_format", Backtrace.Formatter.class, Backtrace.Formatter.MRI, "How to format backtraces displayed to the user.");
public static final Option<Backtrace.Formatter> TRUFFLE_BACKTRACE_DEBUG_FORMAT = enumeration(TRUFFLE, "truffle.backtrace.debug_format", Backtrace.Formatter.class, Backtrace.Formatter.DEBUG, "How to format backtraces displayed using TruffleDebug.dump_call_stack.");