hotspot/src/share/vm/runtime/jniHandles.cpp
changeset 46703 f152b500376e
parent 46625 edefffab74e2
--- a/hotspot/src/share/vm/runtime/jniHandles.cpp	Fri Jul 07 12:49:11 2017 +0200
+++ b/hotspot/src/share/vm/runtime/jniHandles.cpp	Fri Jul 21 16:37:01 2017 -0400
@@ -276,7 +276,7 @@
 
 void JNIHandleBlock::zap() {
   // Zap block values
-  _top  = 0;
+  _top = 0;
   for (int index = 0; index < block_size_in_oops; index++) {
     _handles[index] = badJNIHandle;
   }
@@ -314,7 +314,7 @@
       _block_free_list = _block_free_list->_next;
     }
   }
-  block->_top  = 0;
+  block->_top = 0;
   block->_next = NULL;
   block->_pop_frame_link = NULL;
   block->_planned_capacity = block_size_in_oops;
@@ -444,6 +444,15 @@
       assert(current->_last == NULL, "only first block should have _last set");
       assert(current->_free_list == NULL,
              "only first block should have _free_list set");
+      if (current->_top == 0) {
+        // All blocks after the first clear trailing block are already cleared.
+#ifdef ASSERT
+        for (current = current->_next; current != NULL; current = current->_next) {
+          assert(current->_top == 0, "trailing blocks must already be cleared");
+        }
+#endif
+        break;
+      }
       current->_top = 0;
       if (ZapJNIHandleArea) current->zap();
     }