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

Commits on Oct 30, 2014

  1. Copy the full SHA
    c11a07d View commit details
  2. 3
    Copy the full SHA
    894e802 View commit details
41 changes: 1 addition & 40 deletions core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
Original file line number Diff line number Diff line change
@@ -10,19 +10,14 @@
package org.jruby.truffle.nodes;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import org.jruby.truffle.nodes.dispatch.Dispatch;
import org.jruby.truffle.nodes.yield.YieldDispatchNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.*;
import org.jruby.truffle.runtime.core.*;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyHash;
@@ -219,38 +214,4 @@ public static void notDesignedForCompilation() {
CompilerAsserts.neverPartOfCompilation();
}

private static void panic(RubyContext context, RubyNode currentNode, String message) {
CompilerDirectives.transferToInterpreter();

System.err.println("PANIC");

if (message != null) {
System.err.println(message);
}

for (String line : Backtrace.PANIC_FORMATTER.format(context, null, RubyCallStack.getBacktrace(currentNode))) {
System.err.println(line);
}

new Exception().printStackTrace();

System.exit(1);
}

public void panic(String format, Object... args) {
panic(String.format(format, args));
}

public void panic(String message) {
panic(getContext(), this, message);
}

public void panic() {
panic(getContext(), this, null);
}

public static void panic(RubyContext context) {
panic(context, null, null);
}

}
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ public PanicNode(PanicNode prev) {

@Specialization
public RubyNilClass doPanic() {
panic();
DebugOperations.panic(getContext(), this, null);
return getContext().getCoreLibrary().getNilObject();
}

Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.DebugOperations;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.control.ThreadExitException;
@@ -123,7 +124,7 @@ public RubyBasicObject translate(Throwable throwable) {
}

if (Options.TRUFFLE_PANIC_ON_JAVA_ASSERT.load() && throwable instanceof AssertionError) {
panic(throwable.toString());
DebugOperations.panic(getContext(), this, throwable.toString());
}

return getContext().getCoreLibrary().internalError(throwable.getClass().getSimpleName(), this);
96 changes: 96 additions & 0 deletions core/src/main/java/org/jruby/truffle/runtime/DebugOperations.java
Original file line number Diff line number Diff line change
@@ -10,12 +10,23 @@
package org.jruby.truffle.runtime;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.nodes.RootNode;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.dispatch.*;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyNilClass;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.RubyMethod;

import java.math.BigInteger;
import java.util.List;

public abstract class DebugOperations {

@@ -46,4 +57,89 @@ public static Object send(RubyContext context, Object object, String methodName,
RubyArguments.pack(method, method.getDeclarationFrame(), rubyObject, block, arguments));
}

public static void panic(RubyContext context, Node currentNode, String message) {
CompilerDirectives.transferToInterpreter();

System.err.println("=========================== JRuby+Truffle Debug Report ========================");

if (message != null) {
System.err.println();
System.err.println("Stopped because: " + message);
}

System.err.println();
System.err.println(" =========================== Ruby Bracktrace =========================== ");
System.err.println();

try {
for (String line : Backtrace.PANIC_FORMATTER.format(context, null, RubyCallStack.getBacktrace(currentNode))) {
System.err.println(line);
}
} catch (Throwable e) {
e.printStackTrace();
}

System.err.println();
System.err.println(" ========================== AST Backtrace ========================== ");
System.err.println();

try {
printASTBacktrace(currentNode);
} catch (Throwable e) {
e.printStackTrace();
}

System.err.println();
System.err.println(" =========================== Java Backtrace ============================ ");
System.err.println();

new Exception().printStackTrace();

System.err.println();
System.err.println("===============================================================================");

System.exit(1);
}

public static void printASTBacktrace(final Node currentNode) {
if (currentNode != null) {
printMethodASTBacktrace(currentNode);
}

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

@Override
public Object visitFrame(FrameInstance frameInstance) {
printMethodASTBacktrace(frameInstance.getCallNode());
return null;
}

});
}

private static void printMethodASTBacktrace(Node currentNode) {
final List<Node> activeNodes = NodeUtil.findAllParents(currentNode, Node.class);
printASTForBacktrace(currentNode.getRootNode(), activeNodes, 0);
}

private static void printASTForBacktrace(Node node, List<Node> activeNodes, int indentation) {
for (int n = 0; n < indentation; n++) {
System.err.print(" ");
}

if (activeNodes.contains(node)) {
System.err.print("-> ");
} else {
System.err.print(" ");
}

System.err.println(node);

for (Node child : node.getChildren()) {
if (child != null) {
printASTForBacktrace(child, activeNodes, indentation + 1);
}
}
}

}
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -127,8 +127,7 @@ public class Options {
public static final Option<String> IR_INLINE_COMPILER_PASSES = string(IR, "ir.inline_passes", "Specify comma delimeted list of passes to run after inlining a method.");

public static final Option<Boolean> TRUFFLE_LOAD_CORE = bool(TRUFFLE, "truffle.load_core", true, "Load the Truffle core library.");
public static final Option<Boolean> TRUFFLE_PRINT_RUNTIME = bool(TRUFFLE, "truffle.printRuntime", false, "" +
"Print the name of the Truffle runtime on startup.");
public static final Option<Boolean> TRUFFLE_PRINT_RUNTIME = bool(TRUFFLE, "truffle.printRuntime", false, "Print the name of the Truffle runtime on startup.");
public static final Option<Boolean> TRUFFLE_RUNTIME_VERSION_CHECK = bool(TRUFFLE, "truffle.runtime.version_check", true, "Check the version of Truffle supplied by the JVM before starting.");
public static final Option<Boolean> TRUFFLE_PROC_BINDING = bool(TRUFFLE, "truffle.proc.binding", true, "Enable Proc#binding.");
public static final Option<Boolean> TRUFFLE_EXCEPTIONS_PRINT_JAVA = bool(TRUFFLE, "truffle.exceptions.print_java", false, "Print Java exceptions at the point of translating them to Ruby exceptions.");