< prev index next >

src/hotspot/share/runtime/interfaceSupport.cpp

Print this page

        

@@ -33,10 +33,11 @@
 #include "runtime/init.hpp"
 #include "runtime/interfaceSupport.inline.hpp"
 #include "runtime/orderAccess.inline.hpp"
 #include "runtime/os.inline.hpp"
 #include "runtime/thread.inline.hpp"
+#include "runtime/safepointVerifiers.hpp"
 #include "runtime/vframe.hpp"
 #include "runtime/vmThread.hpp"
 #include "utilities/preserveException.hpp"
 
 // Implementation of InterfaceSupport

@@ -296,5 +297,42 @@
   if (ScavengeALot || FullGCALot) {
     srand(ScavengeALotInterval * FullGCALotInterval);
   }
 #endif
 }
+
+#ifdef ASSERT
+// JRT_LEAF rules:
+// A JRT_LEAF method may not interfere with safepointing by
+//   1) acquiring or blocking on a Mutex or JavaLock - checked
+//   2) allocating heap memory - checked
+//   3) executing a VM operation - checked
+//   4) executing a system call (including malloc) that could block or grab a lock
+//   5) invoking GC
+//   6) reaching a safepoint
+//   7) running too long
+// Nor may any method it calls.
+JRTLeafVerifier::JRTLeafVerifier()
+  : NoSafepointVerifier(true, JRTLeafVerifier::should_verify_GC())
+{
+}
+
+JRTLeafVerifier::~JRTLeafVerifier()
+{
+}
+
+bool JRTLeafVerifier::should_verify_GC() {
+  switch (JavaThread::current()->thread_state()) {
+  case _thread_in_Java:
+    // is in a leaf routine, there must be no safepoint.
+    return true;
+  case _thread_in_native:
+    // A native thread is not subject to safepoints.
+    // Even while it is in a leaf routine, GC is ok
+    return false;
+  default:
+    // Leaf routines cannot be called from other contexts.
+    ShouldNotReachHere();
+    return false;
+  }
+}
+#endif
< prev index next >