Skip to content

Commit

Permalink
Showing 4 changed files with 13 additions and 10 deletions.
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
@@ -134,7 +134,7 @@ public class Options {
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_HASH_PACKED_ARRAY_MAX = integer(TRUFFLE, "truffle.hash.packed_array_max", 3, "Maximum size of a Hash to use with the packed array storage strategy.");

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<Boolean> TRUFFLE_YIELDS = bool(TRUFFLE, "truffle.yields", false, "Insert GIL yieldpoints");
public static final Option<Integer> TRUFFLE_INSTRUMENTATION_SERVER_PORT = integer(TRUFFLE, "truffle.instrumentation_server_port", 0, "Port number to run an HTTP server on that provides instrumentation services");
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.");
Original file line number Diff line number Diff line change
@@ -88,8 +88,6 @@
*/
public class BodyTranslator extends Translator {

private static final int PASS_A_LOT = Options.TRUFFLE_PASSALOT.load();

protected final BodyTranslator parent;
protected final TranslatorEnvironment environment;

@@ -2203,12 +2201,6 @@ public RubyNode visitNewlineNode(org.jruby.ast.NewlineNode node) {

final List<RubyNode> lineSequence = new ArrayList<>();

if (PASS_A_LOT > 0) {
if (PASS_A_LOT > Math.random() * 100) {
lineSequence.add(new ThreadPassNode(context, sourceSection));
}
}

lineSequence.add(new TraceNode(context, sourceSection));
lineSequence.add(node.getNextNode().accept(this));

@@ -2738,7 +2730,7 @@ private RubyNode visitWhileNode(org.jruby.ast.WhileNode node, boolean conditionI
condition = new NotNode(context, sourceSection, condition);
}

final RubyNode body;
RubyNode body;
final BreakID whileBreakID = environment.getParseEnvironment().allocateBreakID();

final boolean oldTranslatingWhile = translatingWhile;
@@ -2760,6 +2752,10 @@ private RubyNode visitWhileNode(org.jruby.ast.WhileNode node, boolean conditionI

final RubyNode loop;

if (YIELDS) {
body = SequenceNode.sequence(context, sourceSection, new ThreadPassNode(context, sourceSection), body);
}

if (node.evaluateAtStart()) {
loop = WhileNode.createWhile(context, sourceSection, condition, body);
} else {
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
import org.jruby.truffle.nodes.cast.ArrayCastNodeGen;
import org.jruby.truffle.nodes.control.IfNode;
import org.jruby.truffle.nodes.control.SequenceNode;
import org.jruby.truffle.nodes.core.ThreadPassNode;
import org.jruby.truffle.nodes.defined.DefinedWrapperNode;
import org.jruby.truffle.nodes.dispatch.RespondToNode;
import org.jruby.truffle.nodes.literal.LiteralNode;
@@ -155,6 +156,10 @@ public RubyNode compileFunctionNode(SourceSection sourceSection, String methodNa
}
}

if (YIELDS) {
body = SequenceNode.sequence(context, sourceSection, new ThreadPassNode(context, sourceSection), body);
}

body = SequenceNode.sequence(context, sourceSection, prelude, body);

if (environment.getFlipFlopStates().size() > 0) {
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@

public abstract class Translator extends org.jruby.ast.visitor.AbstractNodeVisitor<RubyNode> {

protected static final boolean YIELDS = Options.TRUFFLE_YIELDS.load();

public static final Set<String> PRINT_AST_METHOD_NAMES = new HashSet<>(Arrays.asList(Options.TRUFFLE_TRANSLATOR_PRINT_AST.load().split(",")));
public static final Set<String> PRINT_FULL_AST_METHOD_NAMES = new HashSet<>(Arrays.asList(Options.TRUFFLE_TRANSLATOR_PRINT_FULL_AST.load().split(",")));
public static final Set<String> PRINT_PARSE_TREE_METHOD_NAMES = new HashSet<>(Arrays.asList(Options.TRUFFLE_TRANSLATOR_PRINT_PARSE_TREE.load().split(",")));

0 comments on commit f491c64

Please sign in to comment.