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: 371cf62d7e91
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 92d63ce29e6e
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Sep 13, 2016

  1. Copy the full SHA
    53ec720 View commit details
  2. Copy the full SHA
    d7b6cd7 View commit details
  3. [Truffle] Make set_trac_func invalidates an Assumption which InlinedC…

    …oreMethodNode can check.
    eregon committed Sep 13, 2016
    Copy the full SHA
    55a9641 View commit details
  4. Copy the full SHA
    92d63ce View commit details
4 changes: 2 additions & 2 deletions truffle/.factorypath
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle/truffle-api/0.16/truffle-api-0.16.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle/truffle-dsl-processor/0.16/truffle-dsl-processor-0.16.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle/truffle-api/0.17/truffle-api-0.17.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/oracle/truffle/truffle-dsl-processor/0.17/truffle-dsl-processor-0.17.jar" enabled="true" runInBatchMode="false"/>
</factorypath>
6 changes: 3 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -160,6 +160,9 @@ public RubyContext(Ruby jrubyRuntime, TruffleLanguage.Env env) {

// Capture known builtin methods

final Instrumenter instrumenter = env.lookup(Instrumenter.class);
attachmentsManager = new AttachmentsManager(this, instrumenter);
traceManager = new TraceManager(this, instrumenter);
coreMethods = new CoreMethods(coreLibrary);

// Load the reset of the core library
@@ -178,9 +181,6 @@ public RubyContext(Ruby jrubyRuntime, TruffleLanguage.Env env) {
instrumentationServerManager = null;
}

final Instrumenter instrumenter = env.lookup(Instrumenter.class);
attachmentsManager = new AttachmentsManager(this, instrumenter);
traceManager = new TraceManager(this, instrumenter);
coverageManager = new CoverageManager(this, instrumenter);

coreLibrary.initializePostBoot();
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.core;

import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeFactory;
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -30,6 +31,7 @@ public class InlinedCoreMethodNode extends RubyNode {

private final RubyCallNodeParameters callNodeParameters;
private final InternalMethod method;
private final Assumption tracingUnused;

@Child InlinableBuiltin builtin;
@Child LookupMethodNode lookupMethodNode;
@@ -40,6 +42,7 @@ public InlinedCoreMethodNode(RubyCallNodeParameters callNodeParameters, Internal
super(callNodeParameters.getContext(), callNodeParameters.getSection());
this.callNodeParameters = callNodeParameters;
this.method = method;
this.tracingUnused = callNodeParameters.getContext().getTraceManager().getUnusedAssumption();
this.builtin = builtin;
this.lookupMethodNode = LookupMethodNodeGen.create(callNodeParameters.getContext(), callNodeParameters.getSection(), false, false, null, null);
this.receiverNode = callNodeParameters.getReceiver();
@@ -57,14 +60,13 @@ public Object execute(VirtualFrame frame) {
final InternalMethod lookedUpMethod = lookupMethodNode.executeLookupMethod(frame, self, method.getName());
final Object[] arguments = executeArguments(frame, self);

if (lookedUpMethod != method || !guard(arguments)) {
if (lookedUpMethod == method && guard(arguments) && tracingUnused.isValid()) {
return builtin.executeBuiltin(frame, arguments);
} else {
CompilerDirectives.transferToInterpreterAndInvalidate();
RubyCallNode callNode = rewriteToCallNode();
Object[] argumentsObjects = ArrayUtils.extractRange(arguments, 1, arguments.length);
return callNode.executeWithArgumentEvaluated(frame, arguments[0], argumentsObjects);
return rewriteToCallNode().executeWithArgumentsEvaluated(frame, arguments[0], argumentsObjects);
}

return builtin.executeBuiltin(frame, arguments);
}

@ExplodeLoop
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.core.kernel;

import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
@@ -24,6 +25,8 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.CyclicAssumption;

import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.string.StringOperations;
@@ -46,18 +49,24 @@ public class TraceManager {

private final RubyContext context;
private final Instrumenter instrumenter;
private final CyclicAssumption unusedAssumption;

private Collection<EventBinding<?>> instruments;
private boolean isInTraceFunc = false;

public TraceManager(RubyContext context, Instrumenter instrumenter) {
this.context = context;
this.instrumenter = instrumenter;
this.unusedAssumption = new CyclicAssumption("set_trace_func is not used");
}

public Assumption getUnusedAssumption() {
return unusedAssumption.getAssumption();
}

@TruffleBoundary
public void setTraceFunc(final DynamicObject traceFunc) {
assert RubyGuards.isRubyProc(traceFunc);
assert traceFunc == null || RubyGuards.isRubyProc(traceFunc);

if (instruments != null) {
for (EventBinding<?> instrument : instruments) {
@@ -66,10 +75,15 @@ public void setTraceFunc(final DynamicObject traceFunc) {
}

if (traceFunc == null) {
// Update to a new valid assumption
unusedAssumption.invalidate();
instruments = null;
return;
}

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

instruments = new ArrayList<>();

instruments.add(instrumenter.attachFactory(SourceSectionFilter.newBuilder().tagIs(LineTag.class).build(), new ExecutionEventNodeFactory() {
Original file line number Diff line number Diff line change
@@ -93,10 +93,10 @@ public Object execute(VirtualFrame frame) {

final Object[] argumentsObjects = executeArguments(frame);

return executeWithArgumentEvaluated(frame, receiverObject, argumentsObjects);
return executeWithArgumentsEvaluated(frame, receiverObject, argumentsObjects);
}

public Object executeWithArgumentEvaluated(VirtualFrame frame, Object receiverObject, Object[] argumentsObjects) {
public Object executeWithArgumentsEvaluated(VirtualFrame frame, Object receiverObject, Object[] argumentsObjects) {
final DynamicObject blockObject = executeBlock(frame);

if (dispatchHead == null) {