8175318: Performance issue regarding local JNI references

Avoid unnecessary repeated clears.

Reviewed-by: shade, simonis
This commit is contained in:
Kim Barrett 2017-07-21 16:37:01 -04:00
parent 98bd53b5c2
commit 3fbf0c2e96
2 changed files with 11 additions and 7 deletions

View File

@ -276,7 +276,7 @@ JNIHandleBlock* JNIHandleBlock::_block_list = NULL;
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 @@ JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread) {
_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 @@ jobject JNIHandleBlock::allocate_handle(oop obj) {
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();
}

View File

@ -149,11 +149,6 @@ class JNIHandleBlock : public CHeapObj<mtInternal> {
// 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();