Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java @ 19491:4d66c000d253
Truffle/Instrumentation: more cleanup in Probe
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 18 Feb 2015 18:30:49 -0800 |
parents | 745ecef4c9cd |
children | 5a91549293df |
comparison
equal
deleted
inserted
replaced
19490:745ecef4c9cd | 19491:4d66c000d253 |
---|---|
78 | 78 |
79 /** | 79 /** |
80 * All Probes that have been created. | 80 * All Probes that have been created. |
81 */ | 81 */ |
82 private static final List<WeakReference<Probe>> probes = new ArrayList<>(); | 82 private static final List<WeakReference<Probe>> probes = new ArrayList<>(); |
83 | |
84 @CompilationFinal private static SyntaxTagTrap tagTrap = null; | |
83 | 85 |
84 private static final class FindSourceVisitor implements NodeVisitor { | 86 private static final class FindSourceVisitor implements NodeVisitor { |
85 | 87 |
86 Source source = null; | 88 Source source = null; |
87 | 89 |
182 */ | 184 */ |
183 public static void setTagTrap(SyntaxTagTrap newTagTrap) { | 185 public static void setTagTrap(SyntaxTagTrap newTagTrap) { |
184 for (WeakReference<Probe> ref : probes) { | 186 for (WeakReference<Probe> ref : probes) { |
185 final Probe probe = ref.get(); | 187 final Probe probe = ref.get(); |
186 if (probe != null) { | 188 if (probe != null) { |
187 probe.setTrap(newTagTrap); | 189 probe.notifyTrapSet(); |
188 } | 190 } |
189 } | 191 } |
190 } | 192 } |
191 | 193 |
192 private final SourceSection sourceSection; | 194 private final SourceSection sourceSection; |
203 * there may have been a deopt). Every time a check fails, gets replaced by a new unchanged | 205 * there may have been a deopt). Every time a check fails, gets replaced by a new unchanged |
204 * assumption. | 206 * assumption. |
205 */ | 207 */ |
206 @CompilationFinal private Assumption probeStateUnchangedAssumption = probeStateUnchangedCyclic.getAssumption(); | 208 @CompilationFinal private Assumption probeStateUnchangedAssumption = probeStateUnchangedCyclic.getAssumption(); |
207 | 209 |
208 // Must invalidate whenever either of these these changes. | 210 // Must invalidate whenever this changes. |
209 @CompilationFinal private SyntaxTagTrap tagTrap = null; | |
210 @CompilationFinal private boolean isTrapActive = false; | 211 @CompilationFinal private boolean isTrapActive = false; |
211 | 212 |
212 /** | 213 /** |
213 * Intended for use only by {@link ProbeNode}. | 214 * Intended for use only by {@link ProbeNode}. |
214 */ | 215 */ |
334 | 335 |
335 private void invalidateProbeUnchanged() { | 336 private void invalidateProbeUnchanged() { |
336 probeStateUnchangedCyclic.invalidate(); | 337 probeStateUnchangedCyclic.invalidate(); |
337 } | 338 } |
338 | 339 |
339 private void setTrap(SyntaxTagTrap newTagTrap) { | 340 private void notifyTrapSet() { |
340 // No-op if same trap; traps are immutable | 341 if (tagTrap == null && !isTrapActive) { |
341 if (this.tagTrap != newTagTrap) { | 342 // Special case, could be common, where we don't need to do anything. |
342 if (newTagTrap == null) { | 343 return; |
343 this.tagTrap = null; | 344 } |
344 if (isTrapActive) { | 345 this.isTrapActive = this.isTaggedAs(tagTrap.getTag()); |
345 isTrapActive = false; | 346 invalidateProbeUnchanged(); |
346 invalidateProbeUnchanged(); | |
347 } | |
348 } else { // new trap is non-null | |
349 this.tagTrap = newTagTrap; | |
350 this.isTrapActive = this.isTaggedAs(newTagTrap.getTag()); | |
351 invalidateProbeUnchanged(); | |
352 } | |
353 } | |
354 } | 347 } |
355 | 348 |
356 private String getTagsDescription() { | 349 private String getTagsDescription() { |
357 final StringBuilder sb = new StringBuilder(); | 350 final StringBuilder sb = new StringBuilder(); |
358 sb.append("["); | 351 sb.append("["); |