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

Commits on Jan 27, 2015

  1. 3
    Copy the full SHA
    9549565 View commit details
  2. 1
    Copy the full SHA
    17be927 View commit details
  3. 4
    Copy the full SHA
    0919714 View commit details
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -154,6 +154,8 @@ public class Options {
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_AST = string(TRUFFLE, "truffle.translator.print_asts", "", "Comma delimited list of method names to print the AST of after translation.");
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_FULL_AST = string(TRUFFLE, "truffle.translator.print_full_asts", "", "Comma delimited list of method names to print the full AST of after translation.");
public static final Option<String> TRUFFLE_TRANSLATOR_PRINT_PARSE_TREE = string(TRUFFLE, "truffle.translator.print_parse_trees", "", "Comma delimited list of method names to print the JRuby parse tree of before translation.");
public static final Option<Integer> TRUFFLE_PASSALOT = integer(TRUFFLE, "truffle.passalot", 0, "Probabilty between 0 and 100 to randomly insert Thread.pass at a given line.");
public static final Option<Integer> TRUFFLE_STACK_SERVER_PORT = integer(TRUFFLE, "truffle.stack_server_port", 0, "Port number to run an HTTP server on that returns stack traces");

public static final Option<Boolean> NATIVE_ENABLED = bool(NATIVE, "native.enabled", true, "Enable/disable native code, including POSIX features and C exts.");
public static final Option<Boolean> NATIVE_VERBOSE = bool(NATIVE, "native.verbose", false, "Enable verbose logging of native extension loading.");
Original file line number Diff line number Diff line change
@@ -57,7 +57,6 @@ public RubyCallNode(RubyContext context, SourceSection section, String methodNam
this(context, section, methodName, receiver, block, isSplatted, false, false, arguments);
}


public RubyCallNode(RubyContext context, SourceSection section, String methodName, RubyNode receiver, RubyNode block, boolean isSplatted, boolean ignoreVisibility, boolean rubiniusPrimitive, RubyNode... arguments) {
this(context, section, methodName, receiver, block, isSplatted, false, ignoreVisibility, rubiniusPrimitive, arguments);
}
26 changes: 0 additions & 26 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubyCallStack.java
Original file line number Diff line number Diff line change
@@ -34,32 +34,6 @@ public static RubyModule getCurrentDeclaringModule() {
return method.getDeclaringModule();
}

public static InternalMethod getCurrentMethod() {
CompilerAsserts.neverPartOfCompilation();

final FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
final MethodLike method = getMethod(currentFrame);

if (method instanceof InternalMethod) {
return (InternalMethod) method;
}

return Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<InternalMethod>() {

@Override
public InternalMethod visitFrame(FrameInstance frameInstance) {
final MethodLike maybeMethod = getMethod(frameInstance);

if (maybeMethod instanceof InternalMethod) {
return (InternalMethod) maybeMethod;
} else {
return null;
}
}

});
}

public static InternalMethod getCallingMethod() {
CompilerAsserts.neverPartOfCompilation();

Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
import org.jruby.truffle.translator.NodeWrapper;
import org.jruby.truffle.translator.TranslatorDriver;
import org.jruby.util.ByteList;
import org.jruby.util.cli.Options;

import java.io.File;
import java.io.IOException;
@@ -116,6 +117,10 @@ public RubyContext(Ruby runtime) {
rootLexicalScope = new LexicalScope(null, coreLibrary.getObjectClass());

rubiniusPrimitiveManager = RubiniusPrimitiveManager.create();

if (Options.TRUFFLE_STACK_SERVER_PORT.load() != 0) {
new StackServerManager(this, Options.TRUFFLE_STACK_SERVER_PORT.load()).start();
}
}

public Shape getEmptyShape() {
Original file line number Diff line number Diff line change
@@ -29,7 +29,9 @@ public String[] format(RubyContext context, RubyException exception, Backtrace b
final ArrayList<String> lines = new ArrayList<>();

if (activations.isEmpty()) {
lines.add(String.format("%s (%s)", exception.getMessage(), exception.getLogicalClass().getName()));
if (exception != null) {
lines.add(String.format("%s (%s)", exception.getMessage(), exception.getLogicalClass().getName()));
}
} else {
lines.add(formatInLine(activations, exception));

Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public ProcSignalHandler(RubyContext context, RubyProc proc) {
@Override
public void handle(Signal signal) {
final ThreadManager threadManager = context.getThreadManager();
context.getSafepointManager().pauseAllThreadsAndExecuteSignalHandler(new Consumer<RubyThread>() {
context.getSafepointManager().pauseAllThreadsAndExecuteFromNonRubyThread(new Consumer<RubyThread>() {

public void accept(RubyThread currentThread) {
if (currentThread == threadManager.getRootThread()) {
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@ public void pauseAllThreadsAndExecute(final Consumer<RubyThread> action) {
}
}

public void pauseAllThreadsAndExecuteSignalHandler(final Consumer<RubyThread> action) {
public void pauseAllThreadsAndExecuteFromNonRubyThread(final Consumer<RubyThread> action) {
CompilerDirectives.transferToInterpreter();

lock.lock();
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.runtime.subsystems;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import org.jruby.truffle.runtime.DebugOperations;
import org.jruby.truffle.runtime.RubyCallStack;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.backtrace.Backtrace;
import org.jruby.truffle.runtime.core.RubyThread;
import org.jruby.truffle.runtime.util.Consumer;

import java.io.IOException;
import java.io.PrintStream;
import java.net.InetSocketAddress;

public class StackServerManager {

private final RubyContext context;
private final int socket;

public StackServerManager(RubyContext context, int socket) {
this.context = context;
this.socket = socket;
}

public void start() {
final HttpServer server;

try {
server = HttpServer.create(new InetSocketAddress(socket), 0);
} catch (IOException e) {
e.printStackTrace();
return;
}

server.createContext("/", new HttpHandler() {

@Override
public void handle(HttpExchange httpExchange) throws IOException {
httpExchange.getResponseHeaders().set("Content-Type","text/plain");
httpExchange.sendResponseHeaders(200, 0);

final PrintStream stream = new PrintStream(httpExchange.getResponseBody());

context.getSafepointManager().pauseAllThreadsAndExecuteFromNonRubyThread(new Consumer<RubyThread>() {

@Override
public void accept(RubyThread thread) {
try {
for (String line : Backtrace.DISPLAY_FORMATTER.format(context, null,
RubyCallStack.getBacktrace(null))) {
stream.println(line);
}

stream.println();
} catch (Throwable e) {
e.printStackTrace();
}
}

});

httpExchange.getResponseBody().close();
}

});

server.start();
}

}
Original file line number Diff line number Diff line change
@@ -1959,7 +1959,35 @@ private RubyNode translateDummyAssignment(org.jruby.ast.Node dummyAssignment, Ru
@Override
public RubyNode visitNewlineNode(org.jruby.ast.NewlineNode node) {
final RubyNode child = node.getNextNode().accept(this);
return new TraceNode(context, child.getSourceSection(), child);

RubyNode translated = new TraceNode(context, child.getSourceSection(), child);

if (Options.TRUFFLE_PASSALOT.load() > 0) {
if (Options.TRUFFLE_PASSALOT.load() > Math.random() * 100) {
final LexicalScope lexicalScope = environment.getLexicalScope();
final RubyNode moduleNode = new LexicalScopeNode(context, translated.getSourceSection(), lexicalScope);

translated = SequenceNode.sequence(
translated.getContext(),
translated.getSourceSection(),
new RubyCallNode(
translated.getContext(),
translated.getSourceSection(),
"pass",
new ReadConstantNode(
translated.getContext(),
translated.getSourceSection(),
"Thread",
moduleNode,
lexicalScope
),
null,
false),
translated);
}
}

return translated;
}

@Override