src/share/vm/prims/jvmtiExport.cpp

Print this page
rev 1087 : in must_post_exception_events, check whether TraceJVMTI Exception triggers are enabled

@@ -2476,6 +2476,45 @@
   }
 
   // Notify heap/object tagging support
   JvmtiTagMap::gc_epilogue(_full);
 }
+
+
+// this is what we'll call at runtime from the athrow bytecode to see
+// whether we need to take the slow path for throws
+JRT_LEAF(jint, JvmtiExport::must_post_exception_events_jrt_leaf()) 
+return must_post_exception_events();
+JRT_END
+
+
+// this is the entry that is used from trace_exception.  When called
+// from there our thread_state is _thread_in_vm which fails the
+// jrt_leaf check if it calls a jrt_leaf entry (at least in debug)
+// 
+// This basically decides whether post_exception_throw is really going to do anything.
+jint JvmtiExport::must_post_exception_events() { 
+
+  JavaThread * thread = (JavaThread *) JavaThread::current();
+  JvmtiThreadState *state = thread->jvmti_thread_state();
+  if (state == NULL) {
+    return JNI_FALSE;
+  }
+
+#ifdef JVMTI_TRACE
+  // check whether EVT_TRIG_TRACE would have done anything
+  // EVT_TRIG_TRACE is a no-op if JVMTI_TRACE is not defined
+  if ((JvmtiTrace::event_trace_flags(JVMTI_EVENT_EXCEPTION) & JvmtiTrace::SHOW_EVENT_TRIGGER) != 0) {
+        return JNI_TRUE;
+  }
+#endif
+
+  // check whether we need to do set_exception_detected here
+  JvmtiEnvThreadStateIterator it(state);
+  for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) {
+        if (ets->is_enabled(JVMTI_EVENT_EXCEPTION))
+          return JNI_TRUE;
+  }
+  return JNI_FALSE;
+}
+
 #endif // JVMTI_KERNEL