Skip to content

Commit

Permalink
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -49,7 +49,8 @@ public DynamicObject allocate(DynamicObject classToAllocate, Object... values) {

@Specialization(guards = {
"cachedClassToAllocate == classToAllocate",
"!cachedIsSingleton"
"!cachedIsSingleton",
"!isTracing()"
}, assumptions = "getTracingAssumption()", limit = "getCacheLimit()")
public DynamicObject allocateCached(
DynamicObject classToAllocate,
@@ -63,14 +64,15 @@ public DynamicObject allocateCached(
@CompilerDirectives.TruffleBoundary
@Specialization(
contains = "allocateCached",
guards = "!isSingleton(classToAllocate)",
guards = {"!isSingleton(classToAllocate)", "!isTracing()"},
assumptions = "getTracingAssumption()")
public DynamicObject allocateUncached(DynamicObject classToAllocate, Object[] values) {
return getInstanceFactory(classToAllocate).newInstance(values);
}

@CompilerDirectives.TruffleBoundary
@Specialization(guards = {"!isSingleton(classToAllocate)", "isTracing()"})
@Specialization(guards = {"!isSingleton(classToAllocate)", "isTracing()"},
assumptions = "getTracingAssumption()")
public DynamicObject allocateTracing(DynamicObject classToAllocate, Object[] values) {
final DynamicObject object = getInstanceFactory(classToAllocate).newInstance(values);

@@ -114,7 +116,7 @@ protected Assumption getTracingAssumption() {
}

protected boolean isTracing() {
return !getContext().getObjectSpaceManager().getTracingAssumption().isValid();
return getContext().getObjectSpaceManager().isTracing();
}

protected boolean isSingleton(DynamicObject classToAllocate) {
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.utilities.AssumedValue;
import com.oracle.truffle.api.utilities.CyclicAssumption;
import org.jruby.RubyGC;
import org.jruby.truffle.nodes.core.ThreadNodes;
@@ -60,6 +61,7 @@ public void clearFinalizers() {
private DynamicObject finalizerThread;

private final CyclicAssumption tracingAssumption = new CyclicAssumption("objspace-tracing");
@CompilerDirectives.CompilationFinal private boolean isTracing = false;
private int tracingAssumptionActivations = 0;
private boolean tracingPaused = false;

@@ -147,14 +149,16 @@ public void traceAllocationsStart() {
tracingAssumptionActivations++;

if (tracingAssumptionActivations == 1) {
tracingAssumption.getAssumption().invalidate();
isTracing = true;
tracingAssumption.invalidate();
}
}

public void traceAllocationsStop() {
tracingAssumptionActivations--;

if (tracingAssumptionActivations == 0) {
isTracing = false;
tracingAssumption.invalidate();
}
}
@@ -177,4 +181,8 @@ public Assumption getTracingAssumption() {
return tracingAssumption.getAssumption();
}

public boolean isTracing() {
return isTracing;
}

}

1 comment on commit de630e0

@eregon
Copy link
Member

@eregon eregon commented on de630e0 Sep 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sorry, something went wrong.

Please sign in to comment.