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: 01d20db5f21b
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 31979422e923
Choose a head ref
  • 12 commits
  • 12 files changed
  • 2 contributors

Commits on Mar 14, 2016

  1. Copy the full SHA
    83719db View commit details
  2. Copy the full SHA
    8ddbeeb View commit details
  3. Copy the full SHA
    88bce05 View commit details
  4. Copy the full SHA
    4f74c87 View commit details

Commits on Mar 21, 2016

  1. Replacing string based tags with annotations and keeping the same amo…

    …unt of flexibility
    Jaroslav Tulach committed Mar 21, 2016
    Copy the full SHA
    8aaed63 View commit details

Commits on Mar 23, 2016

  1. Copy the full SHA
    22406ae View commit details
  2. Copy the full SHA
    0c990dc View commit details
  3. [Truffle] Tidy-up tags.

    chrisseaton committed Mar 23, 2016
    Copy the full SHA
    99c7889 View commit details
  4. Copy the full SHA
    07c82ba View commit details

Commits on Mar 30, 2016

  1. Copy the full SHA
    a069009 View commit details
  2. Merge branch 'truffle-new-tagging' into truffle-head

    # Conflicts:
    #	truffle/pom.rb
    #	truffle/pom.xml
    chrisseaton committed Mar 30, 2016
    Copy the full SHA
    3b61f74 View commit details
  3. Copy the full SHA
    3197942 View commit details
2 changes: 1 addition & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@
repository( :url => 'http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/',
:id => 'truffle' )

truffle_version = '47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT'
truffle_version = '551e8475af2fc8769bc3ead07c9156fe0ccbe338-SNAPSHOT'
jar 'com.oracle.truffle:truffle-api:' + truffle_version
jar 'com.oracle.truffle:truffle-debug:' + truffle_version
jar 'com.oracle.truffle:truffle-dsl-processor:' + truffle_version, :scope => 'provided'
8 changes: 4 additions & 4 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -41,23 +41,23 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
<version>551e8475af2fc8769bc3ead07c9156fe0ccbe338-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-debug</artifactId>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
<version>551e8475af2fc8769bc3ead07c9156fe0ccbe338-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-dsl-processor</artifactId>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
<version>551e8475af2fc8769bc3ead07c9156fe0ccbe338-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-tck</artifactId>
<version>47a45558a6e6ca5398e2ebb5579d0891b3a8f282-SNAPSHOT</version>
<version>551e8475af2fc8769bc3ead07c9156fe0ccbe338-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
11 changes: 11 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/RubyLanguage.java
Original file line number Diff line number Diff line change
@@ -15,21 +15,32 @@
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.instrument.Visualizer;
import com.oracle.truffle.api.instrument.WrapperNode;
import com.oracle.truffle.api.instrumentation.ProvidedTags;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.source.Source;
import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.runtime.Constants;
import org.jruby.truffle.core.kernel.TraceManager;
import org.jruby.truffle.extra.AttachmentsManager;
import org.jruby.truffle.interop.JRubyContextWrapper;
import org.jruby.truffle.language.LazyRubyRootNode;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.stdlib.CoverageManager;

import java.io.IOException;

@TruffleLanguage.Registration(
name = "Ruby",
version = Constants.RUBY_VERSION,
mimeType = RubyLanguage.MIME_TYPE)
@ProvidedTags({
CoverageManager.LineTag.class,
AttachmentsManager.LineTag.class,
TraceManager.CallTag.class,
TraceManager.ClassTag.class,
TraceManager.LineTag.class
})
public class RubyLanguage extends TruffleLanguage<RubyContext> {

public static final String MIME_TYPE = "application/x-ruby";
Original file line number Diff line number Diff line change
@@ -36,11 +36,13 @@
import java.util.Collection;

public class TraceManager {

public static final String LINE_TAG = "org.jruby.truffle.trace.line";
public static final String CLASS_TAG = "org.jruby.truffle.trace.class";
public static final String CALL_TAG = "org.jruby.truffle.trace.call";

public static @interface LineTag {
}
public static @interface CallTag {
}
public static @interface ClassTag {
}

private final RubyContext context;
private final Instrumenter instrumenter;

@@ -68,21 +70,21 @@ public void setTraceFunc(final DynamicObject traceFunc) {

instruments = new ArrayList<>();

instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(LINE_TAG).build(), new ExecutionEventNodeFactory() {
instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(LineTag.class).build(), new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext eventContext) {
return new BaseEventEventNode(context, traceFunc, context.getCoreStrings().LINE.createInstance());
}
}));

instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(CALL_TAG).build(), new ExecutionEventNodeFactory() {
instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(CallTag.class).build(), new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext eventContext) {
return new CallEventEventNode(context, traceFunc, context.getCoreStrings().CALL.createInstance());
}
}));

instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(CLASS_TAG).build(), new ExecutionEventNodeFactory() {
instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(ClassTag.class).build(), new ExecutionEventNodeFactory() {
@Override
public ExecutionEventNode create(EventContext eventContext) {
return new BaseEventEventNode(context, traceFunc, context.getCoreStrings().CLASS.createInstance());
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ DynamicObjectFactory createTracePointShape(DynamicObject logicalClass,

DynamicObject createTracePoint(
DynamicObjectFactory factory,
@Nullable String[] tags,
@Nullable Class[] tags,
@Nullable DynamicObject event,
@Nullable DynamicObject path,
int line,
@@ -35,8 +35,8 @@ DynamicObject createTracePoint(

boolean isTracePoint(DynamicObject object);

String[] getTags(DynamicObject object);
void setTags(DynamicObject object, String[] value);
Class[] getTags(DynamicObject object);
void setTags(DynamicObject object, Class[] value);

DynamicObject getEvent(DynamicObject object);
void setEvent(DynamicObject object, DynamicObject value);
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isTracePoint(tracePoint)")
public DynamicObject initialize(DynamicObject tracePoint, Object[] args, DynamicObject block) {
Layouts.TRACE_POINT.setTags(tracePoint, new String[]{TraceManager.LINE_TAG});
Layouts.TRACE_POINT.setTags(tracePoint, new Class<?>[]{TraceManager.LineTag.class});
Layouts.TRACE_POINT.setProc(tracePoint, block);
return tracePoint;
}
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@
import org.jruby.truffle.language.RubyGuards;

public class AttachmentsManager {

public static final String LINE_TAG = "org.jruby.truffle.attachments.line";
public @interface LineTag {
}

private final RubyContext context;
private final Instrumenter instrumenter;
@@ -44,7 +44,7 @@ public synchronized EventBinding<?> attach(String file, int line, final DynamicO
assert RubyGuards.isRubyProc(block);

final Source source = context.getSourceCache().getBestSourceFuzzily(file);
SourceSectionFilter filter = SourceSectionFilter.newBuilder().sourceIs(source).lineIs(line).tagIs(LINE_TAG).build();
SourceSectionFilter filter = SourceSectionFilter.newBuilder().sourceIs(source).lineIs(line).tagIs(LineTag.class).build();
return instrumenter.attachFactory(filter, new ExecutionEventNodeFactory() {
public ExecutionEventNode create(EventContext eventContext) {
return new AttachmentEventNode(context, block);
50 changes: 46 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/language/RubyNode.java
Original file line number Diff line number Diff line change
@@ -19,26 +19,38 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.DynamicObjectFactory;
import com.oracle.truffle.api.source.SourceSection;
import java.lang.annotation.Annotation;
import jnr.ffi.provider.MemoryManager;
import org.jcodings.Encoding;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.kernel.TraceManager;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.CoreStrings;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.extra.AttachmentsManager;
import org.jruby.truffle.platform.posix.Sockets;
import org.jruby.truffle.platform.posix.TrufflePosix;
import org.jruby.truffle.stdlib.CoverageManager;
import org.jruby.util.ByteList;

@TypeSystemReference(RubyTypes.class)
@ImportStatic(RubyGuards.class)
@Instrumentable(factory = RubyNodeWrapper.class)
@TraceManager.CallTag
@AttachmentsManager.LineTag
@TraceManager.LineTag
@CoverageManager.LineTag
public abstract class RubyNode extends Node {

private static final int FLAG_NEWLINE = 0;
private static final int FLAG_CALL = 1;

private final RubyContext context;
@CompilationFinal private SourceSection sourceSection;
@CompilationFinal private int flags;

public RubyNode(RubyContext context, SourceSection sourceSection) {
this.context = context;
@@ -208,13 +220,43 @@ public RubyContext getContext() {
}

// Source section

public void unsafeSetSourceSection(SourceSection sourceSection) {
this.sourceSection = sourceSection;
}

@Override
public SourceSection getSourceSection() {
return sourceSection;
}

// Tags

public void unsafeSetIsNewLine() {
flags |= 1 << FLAG_NEWLINE;
}

public void unsafeSetIsCall() {
flags |= 1 << FLAG_CALL;
}

private boolean isNewLine() {
return ((flags >> FLAG_NEWLINE) & 1) == 1;
}

private boolean isCall() {
return ((flags >> FLAG_CALL) & 1) == 1;
}

@Override
protected boolean isTaggedWith(Class<?> tag) {
if (tag == TraceManager.CallTag.class) {
return isCall();
}

if (tag == AttachmentsManager.LineTag.class
|| tag == TraceManager.LineTag.class
|| tag == CoverageManager.LineTag.class) {
return isNewLine();
}

return false;
}

}
Original file line number Diff line number Diff line change
@@ -37,8 +37,7 @@ public RubyRootNode(RubyContext context, SourceSection sourceSection, FrameDescr
this.needsDeclarationFrame = needsDeclarationFrame;
this.body = body;

final SourceSection currentBodySourceSection = body.getEncapsulatingSourceSection();
body.unsafeSetSourceSection(currentBodySourceSection.withTags(TraceManager.CALL_TAG));
body.unsafeSetIsCall();

if (context.getCallGraph() != null) {
context.getCallGraph().registerRootNode(this);
Original file line number Diff line number Diff line change
@@ -17,8 +17,10 @@
import org.jruby.runtime.Visibility;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.kernel.TraceManager;
import org.jruby.truffle.extra.AttachmentsManager;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.stdlib.CoverageManager;

/**
* Define a method from a module body (module/class/class << self ... end).
@@ -33,7 +35,7 @@ public class ModuleBodyDefinitionNode extends RubyNode {

public ModuleBodyDefinitionNode(RubyContext context, SourceSection sourceSection, String name, SharedMethodInfo sharedMethodInfo,
CallTarget callTarget, boolean captureBlock) {
super(context, sourceSection.withTags(TraceManager.CLASS_TAG));
super(context, sourceSection);
this.name = name;
this.sharedMethodInfo = sharedMethodInfo;
this.callTarget = callTarget;
@@ -64,4 +66,13 @@ public Object execute(VirtualFrame frame) {
return executeMethod(frame);
}

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

return super.isTaggedWith(tag);
}

}
Original file line number Diff line number Diff line change
@@ -3150,7 +3150,7 @@ private RubyNode addNewlineIfNeeded(org.jruby.ast.Node jrubyNode, RubyNode node)
if (context.getCoverageManager() != null) {
context.getCoverageManager().setLineHasCode(current.getLineLocation());
}
node.unsafeSetSourceSection(current.withTags(AttachmentsManager.LINE_TAG, TraceManager.LINE_TAG, CoverageManager.LINE_TAG));
node.unsafeSetIsNewLine();
}

return node;
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@
import java.util.concurrent.atomic.AtomicLongArray;

public class CoverageManager {

public static final String LINE_TAG = "org.jruby.truffle.coverage.line";
public @interface LineTag {
}

public static final long NO_CODE = -1;

@@ -66,7 +66,7 @@ public void enable() {
throw new UnsupportedOperationException();
}

instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(LINE_TAG).build(), new ExecutionEventNodeFactory() {
instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(LineTag.class).build(), new ExecutionEventNodeFactory() {

@Override
public ExecutionEventNode create(EventContext eventContext) {