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

Commits on Jan 11, 2017

  1. Copy the full SHA
    da430e2 View commit details
  2. [Truffle] Remembering that lazy nodes aren't necessarily a root node,…

    … report the root name as well when logging a resolution.
    chrisseaton committed Jan 11, 2017
    Copy the full SHA
    e1e0174 View commit details
  3. Copy the full SHA
    3745e5d View commit details
  4. Copy the full SHA
    6d6b8ff View commit details
  5. Copy the full SHA
    e86c98d View commit details
  6. Copy the full SHA
    8af8fc0 View commit details
2 changes: 1 addition & 1 deletion tool/truffle/options.yml
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ INLINE_JS: [inline_js, boolean, false, Allow inline JavaScript]

CORE_LOAD_PATH: [core.load_path, string, 'truffle:/jruby-truffle', Location to load the Truffle core library from]
CORE_PARALLEL_LOAD: [core.parallel_load, boolean, false, Load the Truffle core library in parallel]
LAZY_TRANSLATION: [lazy_translation, boolean, false, Lazily translate from the parser AST to the Truffle AST]
LAZY_TRANSLATION: [lazy_translation, boolean, true, Lazily translate from the parser AST to the Truffle AST]
LAZY_TRANSLATION_LOG: [lazy_translation.log, boolean, false, Log lazy translations from the parser AST to the Truffle AST]

ARRAY_UNINITIALIZED_SIZE: [array.uninitialized_size, integer, 32, How large an Array to allocate when we have no other information to go on]
2 changes: 2 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/RubyLanguage.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.core.kernel.TraceManager;
import org.jruby.truffle.language.LazyRubyNode;
import org.jruby.truffle.language.LazyRubyRootNode;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.stdlib.CoverageManager;
@@ -36,6 +37,7 @@
TraceManager.CallTag.class,
TraceManager.ClassTag.class,
TraceManager.LineTag.class,
LazyRubyNode.LazyTag.class,
StandardTags.RootTag.class,
StandardTags.StatementTag.class,
StandardTags.CallTag.class
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.LazyRubyNode;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.objects.LogicalClassNode;
@@ -80,6 +81,10 @@ public void setTraceFunc(final DynamicObject traceFunc) {
return;
}

// TODO CS 11-Jan-17 race conditions here?

LazyRubyNode.resolveAll(context);

// Invalidate current assumption
unusedAssumption.getAssumption().invalidate();

Original file line number Diff line number Diff line change
@@ -11,14 +11,19 @@

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrumentation.SourceSectionFilter;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.Log;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;

import java.util.function.Supplier;

public class LazyRubyNode extends RubyNode {

public @interface LazyTag {
}

private final Supplier<RubyNode> resolver;
private RubyNode resolved = null;

@@ -38,24 +43,39 @@ public SourceSection getSourceSection() {

@Override
protected boolean isTaggedWith(Class<?> tag) {
if (tag == LazyTag.class) {
resolve();
return true;
}

return resolve().isTaggedWith(tag);
}

public RubyNode resolve() {
CompilerDirectives.transferToInterpreterAndInvalidate();

return atomic(() -> {
if (resolved != null) {
return resolved;
}

if (getContext().getOptions().LAZY_TRANSLATION_LOG) {
Log.LOGGER.info(() -> "lazy translating " + RubyLanguage.fileLine(getParent().getEncapsulatingSourceSection()));
Log.LOGGER.info(() -> "lazy translating " + RubyLanguage.fileLine(getParent().getEncapsulatingSourceSection()) + " in " + getRootNode());
}

resolved = resolver.get();
transferFlagsTo(resolved);

replace(resolved, "lazy node resolved");
return resolved;
});
}

public static void resolveAll(RubyContext context) {
context.getInstrumenter().querySourceSections(SourceSectionFilter.newBuilder()
.mimeTypeIs(RubyLanguage.MIME_TYPE)
.tagIs(LazyRubyNode.LazyTag.class)
.build());
}

}
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public abstract class RubyBaseNode extends Node {
private int sourceCharIndex = -1;
private int sourceLength;

private int flags;
protected int flags;

// Guards which use the context and so can't be static

@@ -257,6 +257,10 @@ private boolean isRoot() {
return ((flags >> FLAG_ROOT) & 1) == 1;
}

protected void transferFlagsTo(RubyBaseNode to) {
to.flags = flags;
}

@Override
protected boolean isTaggedWith(Class<?> tag) {
if (tag == TraceManager.CallTag.class || tag == StandardTags.CallTag.class) {
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ public class OptionsCatalog {
public static final OptionDescription INLINE_JS = new BooleanOptionDescription("inline_js", "Allow inline JavaScript", false);
public static final OptionDescription CORE_LOAD_PATH = new StringOptionDescription("core.load_path", "Location to load the Truffle core library from", "truffle:/jruby-truffle");
public static final OptionDescription CORE_PARALLEL_LOAD = new BooleanOptionDescription("core.parallel_load", "Load the Truffle core library in parallel", false);
public static final OptionDescription LAZY_TRANSLATION = new BooleanOptionDescription("lazy_translation", "Lazily translate from the parser AST to the Truffle AST", false);
public static final OptionDescription LAZY_TRANSLATION = new BooleanOptionDescription("lazy_translation", "Lazily translate from the parser AST to the Truffle AST", true);
public static final OptionDescription LAZY_TRANSLATION_LOG = new BooleanOptionDescription("lazy_translation.log", "Log lazy translations from the parser AST to the Truffle AST", false);
public static final OptionDescription ARRAY_UNINITIALIZED_SIZE = new IntegerOptionDescription("array.uninitialized_size", "How large an Array to allocate when we have no other information to go on", 32);
public static final OptionDescription ARRAY_SMALL = new IntegerOptionDescription("array.small", "Maximum size of an Array to consider small for optimisations", 3);
Original file line number Diff line number Diff line change
@@ -287,7 +287,7 @@ public MethodDefinitionNode compileMethodNode(SourceIndexLength sourceSection, S

final RubyNode body;

if (context.getOptions().LAZY_TRANSLATION && parserContext != ParserContext.EVAL) {
if (context.getOptions().LAZY_TRANSLATION && parserContext != ParserContext.EVAL && !context.getCoverageManager().isEnabled()) {
final TranslatorState state = getCurrentState();

body = new LazyRubyNode(() -> {