mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8191870: Remove badJNIHandle
Reviewed-by: coleenp, eosterlund, dcubed
This commit is contained in:
parent
6f31e2eada
commit
678aafa42c
5 changed files with 11 additions and 15 deletions
|
@ -917,9 +917,6 @@ public:
|
||||||
notproduct(bool, ZapVMHandleArea, trueInDebug, \
|
notproduct(bool, ZapVMHandleArea, trueInDebug, \
|
||||||
"Zap freed VM handle space with 0xBCBCBCBC") \
|
"Zap freed VM handle space with 0xBCBCBCBC") \
|
||||||
\
|
\
|
||||||
develop(bool, ZapJNIHandleArea, trueInDebug, \
|
|
||||||
"Zap freed JNI handle space with 0xFEFEFEFE") \
|
|
||||||
\
|
|
||||||
notproduct(bool, ZapStackSegments, trueInDebug, \
|
notproduct(bool, ZapStackSegments, trueInDebug, \
|
||||||
"Zap allocated/freed stack segments with 0xFADFADED") \
|
"Zap allocated/freed stack segments with 0xFADFADED") \
|
||||||
\
|
\
|
||||||
|
|
|
@ -279,13 +279,15 @@ JNIHandleBlock* JNIHandleBlock::_block_list = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef ASSERT
|
||||||
void JNIHandleBlock::zap() {
|
void JNIHandleBlock::zap() {
|
||||||
// Zap block values
|
// Zap block values
|
||||||
_top = 0;
|
_top = 0;
|
||||||
for (int index = 0; index < block_size_in_oops; index++) {
|
for (int index = 0; index < block_size_in_oops; index++) {
|
||||||
_handles[index] = badJNIHandle;
|
_handles[index] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ASSERT
|
||||||
|
|
||||||
JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread) {
|
JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread) {
|
||||||
assert(thread == NULL || thread == Thread::current(), "sanity check");
|
assert(thread == NULL || thread == Thread::current(), "sanity check");
|
||||||
|
@ -307,7 +309,7 @@ JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread) {
|
||||||
// Allocate new block
|
// Allocate new block
|
||||||
block = new JNIHandleBlock();
|
block = new JNIHandleBlock();
|
||||||
_blocks_allocated++;
|
_blocks_allocated++;
|
||||||
if (ZapJNIHandleArea) block->zap();
|
block->zap();
|
||||||
#ifndef PRODUCT
|
#ifndef PRODUCT
|
||||||
// Link new block to list of all allocated blocks
|
// Link new block to list of all allocated blocks
|
||||||
block->_block_list_link = _block_list;
|
block->_block_list_link = _block_list;
|
||||||
|
@ -339,7 +341,7 @@ void JNIHandleBlock::release_block(JNIHandleBlock* block, Thread* thread) {
|
||||||
// we _don't_ want the block to be kept on the free_handle_block.
|
// we _don't_ want the block to be kept on the free_handle_block.
|
||||||
// See for instance JavaThread::exit().
|
// See for instance JavaThread::exit().
|
||||||
if (thread != NULL ) {
|
if (thread != NULL ) {
|
||||||
if (ZapJNIHandleArea) block->zap();
|
block->zap();
|
||||||
JNIHandleBlock* freelist = thread->free_handle_block();
|
JNIHandleBlock* freelist = thread->free_handle_block();
|
||||||
block->_pop_frame_link = NULL;
|
block->_pop_frame_link = NULL;
|
||||||
thread->set_free_handle_block(block);
|
thread->set_free_handle_block(block);
|
||||||
|
@ -360,7 +362,7 @@ void JNIHandleBlock::release_block(JNIHandleBlock* block, Thread* thread) {
|
||||||
MutexLockerEx ml(JNIHandleBlockFreeList_lock,
|
MutexLockerEx ml(JNIHandleBlockFreeList_lock,
|
||||||
Mutex::_no_safepoint_check_flag);
|
Mutex::_no_safepoint_check_flag);
|
||||||
while (block != NULL) {
|
while (block != NULL) {
|
||||||
if (ZapJNIHandleArea) block->zap();
|
block->zap();
|
||||||
JNIHandleBlock* next = block->_next;
|
JNIHandleBlock* next = block->_next;
|
||||||
block->_next = _block_free_list;
|
block->_next = _block_free_list;
|
||||||
_block_free_list = block;
|
_block_free_list = block;
|
||||||
|
@ -453,13 +455,13 @@ jobject JNIHandleBlock::allocate_handle(oop obj) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
current->_top = 0;
|
current->_top = 0;
|
||||||
if (ZapJNIHandleArea) current->zap();
|
current->zap();
|
||||||
}
|
}
|
||||||
// Clear initial block
|
// Clear initial block
|
||||||
_free_list = NULL;
|
_free_list = NULL;
|
||||||
_allocate_before_rebuild = 0;
|
_allocate_before_rebuild = 0;
|
||||||
_last = this;
|
_last = this;
|
||||||
if (ZapJNIHandleArea) zap();
|
zap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try last block
|
// Try last block
|
||||||
|
|
|
@ -148,7 +148,7 @@ class JNIHandleBlock : public CHeapObj<mtInternal> {
|
||||||
static int _blocks_allocated; // For debugging/printing
|
static int _blocks_allocated; // For debugging/printing
|
||||||
|
|
||||||
// Fill block with bad_handle values
|
// Fill block with bad_handle values
|
||||||
void zap();
|
void zap() NOT_DEBUG_RETURN;
|
||||||
|
|
||||||
// Free list computation
|
// Free list computation
|
||||||
void rebuild_free_list();
|
void rebuild_free_list();
|
||||||
|
@ -219,9 +219,8 @@ inline oop& JNIHandles::jweak_ref(jobject handle) {
|
||||||
template<bool external_guard>
|
template<bool external_guard>
|
||||||
inline oop JNIHandles::guard_value(oop value) {
|
inline oop JNIHandles::guard_value(oop value) {
|
||||||
if (!external_guard) {
|
if (!external_guard) {
|
||||||
assert(value != badJNIHandle, "Pointing to zapped jni handle area");
|
|
||||||
assert(value != deleted_handle(), "Used a deleted global handle");
|
assert(value != deleted_handle(), "Used a deleted global handle");
|
||||||
} else if ((value == badJNIHandle) || (value == deleted_handle())) {
|
} else if (value == deleted_handle()) {
|
||||||
value = NULL;
|
value = NULL;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
|
@ -970,7 +970,7 @@ JNI_ENTRY(void*, throw_unsatisfied_link_error(JNIEnv* env, ...))
|
||||||
{
|
{
|
||||||
// We return a bad value here to make sure that the exception is
|
// We return a bad value here to make sure that the exception is
|
||||||
// forwarded before we look at the return value.
|
// forwarded before we look at the return value.
|
||||||
THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badJNIHandle);
|
THROW_(vmSymbols::java_lang_UnsatisfiedLinkError(), (void*)badAddress);
|
||||||
}
|
}
|
||||||
JNI_END
|
JNI_END
|
||||||
|
|
||||||
|
|
|
@ -951,7 +951,6 @@ const int badResourceValue = 0xAB; // value used to zap
|
||||||
const int freeBlockPad = 0xBA; // value used to pad freed blocks.
|
const int freeBlockPad = 0xBA; // value used to pad freed blocks.
|
||||||
const int uninitBlockPad = 0xF1; // value used to zap newly malloc'd 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 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 badHeapWordVal = 0xBAADBABE; // value used to zap heap after GC
|
||||||
const juint badMetaWordVal = 0xBAADFADE; // value used to zap metadata 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
|
const int badCodeHeapNewVal= 0xCC; // value used to zap Code heap at allocation
|
||||||
|
@ -963,7 +962,6 @@ const int badCodeHeapFreeVal = 0xDD; // value used to zap
|
||||||
#define badAddress ((address)::badAddressVal)
|
#define badAddress ((address)::badAddressVal)
|
||||||
#define badOop (cast_to_oop(::badOopVal))
|
#define badOop (cast_to_oop(::badOopVal))
|
||||||
#define badHeapWord (::badHeapWordVal)
|
#define badHeapWord (::badHeapWordVal)
|
||||||
#define badJNIHandle (cast_to_oop(::badJNIHandleVal))
|
|
||||||
|
|
||||||
// Default TaskQueue size is 16K (32-bit) or 128K (64-bit)
|
// Default TaskQueue size is 16K (32-bit) or 128K (64-bit)
|
||||||
#define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17))
|
#define TASKQUEUE_SIZE (NOT_LP64(1<<14) LP64_ONLY(1<<17))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue