changeset 15943:14ac87c56a27

Truffle: NPE guard in InstrumentationNode
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 27 May 2014 21:18:16 -0700
parents 079229f002a3
children eedf6c293639
files graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/InstrumentationNode.java
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/InstrumentationNode.java	Sat May 24 10:48:18 2014 -0700
+++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/InstrumentationNode.java	Tue May 27 21:18:16 2014 -0700
@@ -62,7 +62,7 @@
     }
 
     /**
-     * @return the instance of {@link Probe} to which this instrument is attached.
+     * Gets the {@link Probe} to which this instrument is attached; {@code null} if not attached.
      */
     protected Probe getProbe() {
         final InstrumentationNode parent = (InstrumentationNode) getParent();
@@ -96,13 +96,16 @@
     }
 
     /**
-     * Reports to the instance of {@link Probe} holding this instrument that some essential state
-     * has changed that requires deoptimization.
+     * Reports to the instance of {@link Probe} holding this instrument, if any, that some essential
+     * state has changed that requires deoptimization.
      */
     @CompilerDirectives.SlowPath
     protected void notifyProbeChanged(Instrument instrument) {
-        final ProbeImpl probe = (ProbeImpl) getProbe();
-        probe.notifyProbeChanged(instrument);
+        Probe probe = getProbe();
+        if (probe != null) {
+            final ProbeImpl probeImpl = (ProbeImpl) probe;
+            probeImpl.notifyProbeChanged(instrument);
+        }
     }
 
     protected void internalEnter(Node astNode, VirtualFrame frame) {