Skip to content
Snippets Groups Projects
Commit cb87229b authored by Mick Jordan's avatar Mick Jordan
Browse files

Minor fixes to tracemem code; honor tracingState as per GNU R

parent 9a114e62
Branches
No related tags found
No related merge requests found
......@@ -174,6 +174,7 @@ public class TraceFunctions {
}
private static final class TracememListener implements MemoryTracer.Listener {
@Override
public void reportCopying(RAbstractVector src, RAbstractVector dest) {
if (getTracedObjects().contains(src)) {
printToStdout(String.format("tracemem[0x%x -> 0x%x]: %s", src.hashCode(), dest.hashCode(), getStackTrace()));
......@@ -233,7 +234,7 @@ public class TraceFunctions {
return result;
}
private Object getResult(Object x) {
private static Object getResult(Object x) {
if (!isRNull(x) && getTracedObjects().contains(x)) {
RContext.getInstance().setVisible(true);
return formatHashCode(x);
......
......@@ -25,11 +25,12 @@ package com.oracle.truffle.r.runtime.data;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
/**
* Helper for tracing memory related events. All implementors of {@link RAbstractVector} are
* expected to report to {@link MemoryTracer} and othes can listen to them through {@link Listener}
* expected to report to {@link MemoryTracer} and others can listen to them through {@link Listener}
* interface. Use method {@link #reportEvents()} to start the tracing.
*/
public final class MemoryTracer {
......@@ -58,10 +59,11 @@ public final class MemoryTracer {
/**
* Reports copy event to the listener. If there are no traced objects, this should turn into
* no-op.
* no-op. TODO might be worth interposing on a change in {@code tracingState} to turn off the
* collection.
*/
public static void reportCopying(RAbstractVector source, RAbstractVector dest) {
if (!noMemoryTracingAssumption.isValid() && listener != null) {
if (!noMemoryTracingAssumption.isValid() && listener != null && RContext.getInstance().stateInstrumentation.getTracingState()) {
listener.reportCopying(source, dest);
}
}
......
......@@ -162,11 +162,8 @@ public final class InstrumentationState implements RContext.ContextState {
private InstrumentationState(Instrumenter instrumenter) {
this.instrumenter = instrumenter;
this.rprofState = new RprofState();
<<<<<<< HEAD
this.browserState = new BrowserState();
=======
this.tracememContext = new TracememContext();
>>>>>>> d9025ad903ab788e763440a9679cafcfbb92ed87
this.browserState = new BrowserState();
}
public void putTraceBinding(SourceSection ss, EventBinding<?> binding) {
......@@ -218,7 +215,10 @@ public final class InstrumentationState implements RContext.ContextState {
return rprofState;
}
<<<<<<< HEAD
public TracememContext getTracemem() {
return tracememContext;
}
public BrowserState getBrowserState() {
return browserState;
}
......@@ -231,10 +231,6 @@ public final class InstrumentationState implements RContext.ContextState {
public boolean debugGloballyDisabled() {
return debugGloballyDisabled;
=======
public TracememContext getTracemem() {
return tracememContext;
>>>>>>> d9025ad903ab788e763440a9679cafcfbb92ed87
}
public static InstrumentationState newContext(@SuppressWarnings("unused") RContext context, Instrumenter instrumenter) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment