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

Commits on Aug 14, 2015

  1. Copy the full SHA
    e15e81a View commit details
  2. 2
    Copy the full SHA
    9cb6471 View commit details
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeVisitor;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubySyntaxTag;

public class RubyDefaultASTProber implements NodeVisitor, ASTProber {

@@ -26,6 +27,7 @@ public boolean visit(Node node) {
if (rubyNode.isAtNewline()) {
// Identify statements using "newline" nodes created by the JRuby parser.
rubyNode.probe().tagAs(StandardSyntaxTag.STATEMENT, null);
rubyNode.probe().tagAs(RubySyntaxTag.LINE, null);
}
}
return true;
60 changes: 60 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/runtime/RubySyntaxTag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* 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;

import com.oracle.truffle.api.instrument.SyntaxTag;

/**
* Syntax tags for Ruby-language statements. The set of tags are derived from the events provided for the
* Kernel#set_trace_func and TracePoint APIs.
*/
public enum RubySyntaxTag implements SyntaxTag {

LINE("line", "Execute code one a new line"),

CLASS("class", "Start a class or module definition"),

END("end", "Finish a class or module definition"),

CALL("call", "Call a Ruby method"),

RETURN("return", "Return from a Ruby method"),

C_CALL("c_call", "Call a C-language routine"),

C_RETURN("c_return", "Return from a C-language routine"),

RAISE("raise", "Raise an exception"),

B_CALL("b_call", "Event hook at block entry"),

B_RETURN("b_return", "Event hook at block ending"),

THREAD_BEGIN("thread_begin", "Event hook at thread beginning"),

THREAD_END("thread_end", "Event hook at thread ending");

private final String name;
private final String description;

RubySyntaxTag(String name, String description) {
this.name = name;
this.description = description;
}

public String getName() {
return name;
}

@Override
public String getDescription() {
return description;
}
}
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
import org.jruby.truffle.nodes.dispatch.RubyCallNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.RubySyntaxTag;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyBinding;
import org.jruby.truffle.nodes.RubyGuards;
@@ -68,7 +69,7 @@ public void notifyFailure(Node node, VirtualFrame virtualFrame, RuntimeException

};

final AdvancedInstrumentRootFactory factory = new AdvancedInstrumentRootFactory() {
final AdvancedInstrumentRootFactory lineEventFactory = new AdvancedInstrumentRootFactory() {

@Override
public AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node) {
@@ -88,16 +89,9 @@ public AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node) {
@Override
public Object executeRoot(Node node, VirtualFrame frame) {
if (!inTraceFuncProfile.profile(isInTraceFunc)) {
final Object self = RubyArguments.getSelf(frame.getArguments());
final Object self = context.getCoreLibrary().getNilObject();
final Object classname = self;

final Object id;

if (node instanceof RubyCallNode) {
id = context.getSymbol(((RubyCallNode) node).getName());
} else {
id = context.getCoreLibrary().getNilObject();
}
final Object id = context.getCoreLibrary().getNilObject();

final RubyBinding binding = new RubyBinding(
context.getCoreLibrary().getBindingClass(),
@@ -144,8 +138,8 @@ public String instrumentationInfo() {
};

instruments = new ArrayList<>();
for (Probe probe : Probe.findProbesTaggedAs(StandardSyntaxTag.STATEMENT)) {
final Instrument instrument = Instrument.create(listener, factory, null, "set_trace_func");
for (Probe probe : Probe.findProbesTaggedAs(RubySyntaxTag.LINE)) {
final Instrument instrument = Instrument.create(listener, lineEventFactory, null, "set_trace_func");
instruments.add(instrument);
probe.attach(instrument);
}
@@ -162,7 +156,7 @@ public void newProbeInserted(Probe probe) {
@Override
public void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) {
if (tag == StandardSyntaxTag.STATEMENT) {
final Instrument instrument = Instrument.create(listener, factory, null, "set_trace_func");
final Instrument instrument = Instrument.create(listener, lineEventFactory, null, "set_trace_func");
instruments.add(instrument);
probe.attach(instrument);
}