changeset 46703:f152b500376e

8175318: Performance issue regarding local JNI references Summary: Avoid unnecessary repeated clears. Reviewed-by: shade, simonis
author kbarrett
date Fri, 21 Jul 2017 16:37:01 -0400
parents 13ae789b982e
children 211b3f6b75ef
files hotspot/src/share/vm/runtime/jniHandles.cpp hotspot/src/share/vm/runtime/jniHandles.hpp
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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();
     }
--- a/hotspot/src/share/vm/runtime/jniHandles.hpp	Fri Jul 07 12:49:11 2017 +0200
+++ b/hotspot/src/share/vm/runtime/jniHandles.hpp	Fri Jul 21 16:37:01 2017 -0400
@@ -149,11 +149,6 @@
   // Fill block with bad_handle values
   void zap();
 
- protected:
-  // No more handles in the both the current and following blocks
-  void clear() { _top = 0; }
-
- private:
   // Free list computation
   void rebuild_free_list();