# HG changeset patch # User Michael Van De Vanter # Date 1424313049 28800 # Node ID 4d66c000d253691948a805724891fd44e96cb0f6 # Parent 745ecef4c9cddafb5b29471d10444fc2a12a4ba8 Truffle/Instrumentation: more cleanup in Probe diff -r 745ecef4c9cd -r 4d66c000d253 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Wed Feb 18 18:07:48 2015 -0800 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Wed Feb 18 18:30:49 2015 -0800 @@ -81,6 +81,8 @@ */ private static final List> probes = new ArrayList<>(); + @CompilationFinal private static SyntaxTagTrap tagTrap = null; + private static final class FindSourceVisitor implements NodeVisitor { Source source = null; @@ -184,7 +186,7 @@ for (WeakReference ref : probes) { final Probe probe = ref.get(); if (probe != null) { - probe.setTrap(newTagTrap); + probe.notifyTrapSet(); } } } @@ -205,8 +207,7 @@ */ @CompilationFinal private Assumption probeStateUnchangedAssumption = probeStateUnchangedCyclic.getAssumption(); - // Must invalidate whenever either of these these changes. - @CompilationFinal private SyntaxTagTrap tagTrap = null; + // Must invalidate whenever this changes. @CompilationFinal private boolean isTrapActive = false; /** @@ -336,21 +337,13 @@ probeStateUnchangedCyclic.invalidate(); } - private void setTrap(SyntaxTagTrap newTagTrap) { - // No-op if same trap; traps are immutable - if (this.tagTrap != newTagTrap) { - if (newTagTrap == null) { - this.tagTrap = null; - if (isTrapActive) { - isTrapActive = false; - invalidateProbeUnchanged(); - } - } else { // new trap is non-null - this.tagTrap = newTagTrap; - this.isTrapActive = this.isTaggedAs(newTagTrap.getTag()); - invalidateProbeUnchanged(); - } + private void notifyTrapSet() { + if (tagTrap == null && !isTrapActive) { + // Special case, could be common, where we don't need to do anything. + return; } + this.isTrapActive = this.isTaggedAs(tagTrap.getTag()); + invalidateProbeUnchanged(); } private String getTagsDescription() {