8191870: Remove badJNIHandle
authorkbarrett
Tue, 28 Nov 2017 15:52:32 -0500
changeset 48147 1b57d99567ed
parent 48146 646ed97b7e0d
child 48149 5a449dbca6d0
8191870: Remove badJNIHandle Reviewed-by: coleenp, eosterlund, dcubed
src/hotspot/share/runtime/globals.hpp
src/hotspot/share/runtime/jniHandles.cpp
src/hotspot/share/runtime/jniHandles.hpp
src/hotspot/share/runtime/sharedRuntime.cpp
src/hotspot/share/utilities/globalDefinitions.hpp
--- a/src/hotspot/share/runtime/globals.hpp	Tue Nov 28 19:02:23 2017 +0100
+++ b/src/hotspot/share/runtime/globals.hpp	Tue Nov 28 15:52:32 2017 -0500
@@ -917,9 +917,6 @@
   notproduct(bool, ZapVMHandleArea, trueInDebug,                            \
           "Zap freed VM handle space with 0xBCBCBCBC")                      \
                                                                             \
-  develop(bool, ZapJNIHandleArea, trueInDebug,                              \
-          "Zap freed JNI handle space with 0xFEFEFEFE")                     \
-                                                                            \
   notproduct(bool, ZapStackSegments, trueInDebug,                           \
           "Zap allocated/freed stack segments with 0xFADFADED")             \
                                                                             \
--- a/src/hotspot/share/runtime/jniHandles.cpp	Tue Nov 28 19:02:23 2017 +0100
+++ b/src/hotspot/share/runtime/jniHandles.cpp	Tue Nov 28 15:52:32 2017 -0500
@@ -279,13 +279,15 @@
 #endif
 
 
+#ifdef ASSERT
 void JNIHandleBlock::zap() {
   // Zap block values
   _top = 0;
   for (int index = 0; index < block_size_in_oops; index++) {
-    _handles[index] = badJNIHandle;
+    _handles[index] = NULL;
   }
 }
+#endif // ASSERT
 
 JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread)  {
   assert(thread == NULL || thread == Thread::current(), "sanity check");
@@ -307,7 +309,7 @@
       // Allocate new block
       block = new JNIHandleBlock();
       _blocks_allocated++;
-      if (ZapJNIHandleArea) block->zap();
+      block->zap();
       #ifndef PRODUCT
       // Link new block to list of all allocated blocks
       block->_block_list_link = _block_list;
@@ -339,7 +341,7 @@
   // we _don't_ want the block to be kept on the free_handle_block.
   // See for instance JavaThread::exit().
   if (thread != NULL ) {
-    if (ZapJNIHandleArea) block->zap();
+    block->zap();
     JNIHandleBlock* freelist = thread->free_handle_block();
     block->_pop_frame_link = NULL;
     thread->set_free_handle_block(block);
@@ -360,7 +362,7 @@
     MutexLockerEx ml(JNIHandleBlockFreeList_lock,
                      Mutex::_no_safepoint_check_flag);
     while (block != NULL) {
-      if (ZapJNIHandleArea) block->zap();
+      block->zap();
       JNIHandleBlock* next = block->_next;
       block->_next = _block_free_list;
       _block_free_list = block;
@@ -453,13 +455,13 @@
         break;
       }
       current->_top = 0;
-      if (ZapJNIHandleArea) current->zap();
+      current->zap();
     }
     // Clear initial block
     _free_list = NULL;
     _allocate_before_rebuild = 0;
     _last = this;
-    if (ZapJNIHandleArea) zap();
+    zap();
   }
 
   // Try last block
--- a/src/hotspot/share/runtime/jniHandles.hpp	Tue Nov 28 19:02:23 2017 +0100
+++ b/src/hotspot/share/runtime/jniHandles.hpp	Tue Nov 28 15:52:32 2017 -0500
@@ -148,7 +148,7 @@
   static int      _blocks_allocated;            // For debugging/printing
 
   // Fill block with bad_handle values
-  void zap();
+  void zap() NOT_DEBUG_RETURN;
 
   // Free list computation
   void rebuild_free_list();
@@ -219,9 +219,8 @@
 template<bool external_guard>
 inline oop JNIHandles::guard_value(oop value) {
   if (!external_guard) {
-    assert(value != badJNIHandle, "Pointing to zapped jni handle area");
     assert(value != deleted_handle(), "Used a deleted global handle");
-  } else if ((value == badJNIHandle) || (value == deleted_handle())) {
+  } else if (value == deleted_handle()) {
     value = NULL;
   }
   return value;
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Tue Nov 28 19:02:23 2017 +0100
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Tue Nov 28 15:52:32 2017 -0500
@@ -970,7 +970,7 @@
 {
   // We return a bad value here to make sure that the exception is
   // forwarded before we look at the return value.
-  THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badJNIHandle);
+  THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badAddress);
 }
 JNI_END
 
--- a/src/hotspot/share/utilities/globalDefinitions.hpp	Tue Nov 28 19:02:23 2017 +0100
+++ b/src/hotspot/share/utilities/globalDefinitions.hpp	Tue Nov 28 15:52:32 2017 -0500
@@ -951,7 +951,6 @@
 const int      freeBlockPad     = 0xBA;                     // value used to pad freed blocks.
 const int      uninitBlockPad   = 0xF1;                     // value used to zap newly malloc'd blocks.
 const juint    uninitMetaWordVal= 0xf7f7f7f7;               // value used to zap newly allocated metachunk
-const intptr_t badJNIHandleVal  = (intptr_t) UCONST64(0xFEFEFEFEFEFEFEFE); // value used to zap jni handle area
 const juint    badHeapWordVal   = 0xBAADBABE;               // value used to zap heap after GC
 const juint    badMetaWordVal   = 0xBAADFADE;               // value used to zap metadata heap after GC
 const int      badCodeHeapNewVal= 0xCC;                     // value used to zap Code heap at allocation
@@ -963,7 +962,6 @@
 #define       badAddress        ((address)::badAddressVal)
 #define       badOop            (cast_to_oop(::badOopVal))
 #define       badHeapWord       (::badHeapWordVal)
-#define       badJNIHandle      (cast_to_oop(::badJNIHandleVal))
 
 // Default TaskQueue size is 16K (32-bit) or 128K (64-bit)
 #define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17))