1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/runtime/jniHandles.cpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,576 @@ 1.4 +/* 1.5 + * Copyright 1998-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +# include "incls/_precompiled.incl" 1.29 +# include "incls/_jniHandles.cpp.incl" 1.30 + 1.31 + 1.32 +JNIHandleBlock* JNIHandles::_global_handles = NULL; 1.33 +JNIHandleBlock* JNIHandles::_weak_global_handles = NULL; 1.34 +oop JNIHandles::_deleted_handle = NULL; 1.35 + 1.36 + 1.37 +jobject JNIHandles::make_local(oop obj) { 1.38 + if (obj == NULL) { 1.39 + return NULL; // ignore null handles 1.40 + } else { 1.41 + Thread* thread = Thread::current(); 1.42 + assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 1.43 + return thread->active_handles()->allocate_handle(obj); 1.44 + } 1.45 +} 1.46 + 1.47 + 1.48 +// optimized versions 1.49 + 1.50 +jobject JNIHandles::make_local(Thread* thread, oop obj) { 1.51 + if (obj == NULL) { 1.52 + return NULL; // ignore null handles 1.53 + } else { 1.54 + assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 1.55 + return thread->active_handles()->allocate_handle(obj); 1.56 + } 1.57 +} 1.58 + 1.59 + 1.60 +jobject JNIHandles::make_local(JNIEnv* env, oop obj) { 1.61 + if (obj == NULL) { 1.62 + return NULL; // ignore null handles 1.63 + } else { 1.64 + JavaThread* thread = JavaThread::thread_from_jni_environment(env); 1.65 + assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 1.66 + return thread->active_handles()->allocate_handle(obj); 1.67 + } 1.68 +} 1.69 + 1.70 + 1.71 +jobject JNIHandles::make_global(Handle obj) { 1.72 + jobject res = NULL; 1.73 + if (!obj.is_null()) { 1.74 + // ignore null handles 1.75 + MutexLocker ml(JNIGlobalHandle_lock); 1.76 + assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); 1.77 + res = _global_handles->allocate_handle(obj()); 1.78 + } else { 1.79 + CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 1.80 + } 1.81 + 1.82 + return res; 1.83 +} 1.84 + 1.85 + 1.86 +jobject JNIHandles::make_weak_global(Handle obj) { 1.87 + jobject res = NULL; 1.88 + if (!obj.is_null()) { 1.89 + // ignore null handles 1.90 + MutexLocker ml(JNIGlobalHandle_lock); 1.91 + assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); 1.92 + res = _weak_global_handles->allocate_handle(obj()); 1.93 + } else { 1.94 + CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 1.95 + } 1.96 + return res; 1.97 +} 1.98 + 1.99 +jmethodID JNIHandles::make_jmethod_id(methodHandle mh) { 1.100 + return (jmethodID) make_weak_global(mh); 1.101 +} 1.102 + 1.103 + 1.104 + 1.105 +void JNIHandles::change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh) { 1.106 + MutexLocker ml(JNIGlobalHandle_lock); // Is this necessary? 1.107 + Handle obj = (Handle)mh; 1.108 + oop* jobj = (oop*)jmid; 1.109 + *jobj = obj(); 1.110 +} 1.111 + 1.112 + 1.113 +void JNIHandles::destroy_global(jobject handle) { 1.114 + if (handle != NULL) { 1.115 + assert(is_global_handle(handle), "Invalid delete of global JNI handle"); 1.116 + *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it 1.117 + } 1.118 +} 1.119 + 1.120 + 1.121 +void JNIHandles::destroy_weak_global(jobject handle) { 1.122 + if (handle != NULL) { 1.123 + assert(!CheckJNICalls || is_weak_global_handle(handle), "Invalid delete of weak global JNI handle"); 1.124 + *((oop*)handle) = deleted_handle(); // Mark the handle as deleted, allocate will reuse it 1.125 + } 1.126 +} 1.127 + 1.128 +void JNIHandles::destroy_jmethod_id(jmethodID mid) { 1.129 + destroy_weak_global((jobject)mid); 1.130 +} 1.131 + 1.132 + 1.133 +void JNIHandles::oops_do(OopClosure* f) { 1.134 + f->do_oop(&_deleted_handle); 1.135 + _global_handles->oops_do(f); 1.136 +} 1.137 + 1.138 + 1.139 +void JNIHandles::weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f) { 1.140 + _weak_global_handles->weak_oops_do(is_alive, f); 1.141 +} 1.142 + 1.143 + 1.144 +void JNIHandles::initialize() { 1.145 + _global_handles = JNIHandleBlock::allocate_block(); 1.146 + _weak_global_handles = JNIHandleBlock::allocate_block(); 1.147 + EXCEPTION_MARK; 1.148 + // We will never reach the CATCH below since Exceptions::_throw will cause 1.149 + // the VM to exit if an exception is thrown during initialization 1.150 + klassOop k = SystemDictionary::object_klass(); 1.151 + _deleted_handle = instanceKlass::cast(k)->allocate_permanent_instance(CATCH); 1.152 +} 1.153 + 1.154 + 1.155 +bool JNIHandles::is_local_handle(Thread* thread, jobject handle) { 1.156 + JNIHandleBlock* block = thread->active_handles(); 1.157 + 1.158 + // Look back past possible native calls to jni_PushLocalFrame. 1.159 + while (block != NULL) { 1.160 + if (block->chain_contains(handle)) { 1.161 + return true; 1.162 + } 1.163 + block = block->pop_frame_link(); 1.164 + } 1.165 + return false; 1.166 +} 1.167 + 1.168 + 1.169 +// Determine if the handle is somewhere in the current thread's stack. 1.170 +// We easily can't isolate any particular stack frame the handle might 1.171 +// come from, so we'll check the whole stack. 1.172 + 1.173 +bool JNIHandles::is_frame_handle(JavaThread* thr, jobject obj) { 1.174 + // If there is no java frame, then this must be top level code, such 1.175 + // as the java command executable, in which case, this type of handle 1.176 + // is not permitted. 1.177 + return (thr->has_last_Java_frame() && 1.178 + (void*)obj < (void*)thr->stack_base() && 1.179 + (void*)obj >= (void*)thr->last_Java_sp()); 1.180 +} 1.181 + 1.182 + 1.183 +bool JNIHandles::is_global_handle(jobject handle) { 1.184 + return _global_handles->chain_contains(handle); 1.185 +} 1.186 + 1.187 + 1.188 +bool JNIHandles::is_weak_global_handle(jobject handle) { 1.189 + return _weak_global_handles->chain_contains(handle); 1.190 +} 1.191 + 1.192 +long JNIHandles::global_handle_memory_usage() { 1.193 + return _global_handles->memory_usage(); 1.194 +} 1.195 + 1.196 +long JNIHandles::weak_global_handle_memory_usage() { 1.197 + return _weak_global_handles->memory_usage(); 1.198 +} 1.199 + 1.200 + 1.201 +class AlwaysAliveClosure: public BoolObjectClosure { 1.202 +public: 1.203 + bool do_object_b(oop obj) { return true; } 1.204 + void do_object(oop obj) { assert(false, "Don't call"); } 1.205 +}; 1.206 + 1.207 +class CountHandleClosure: public OopClosure { 1.208 +private: 1.209 + int _count; 1.210 +public: 1.211 + CountHandleClosure(): _count(0) {} 1.212 + void do_oop(oop* unused) { 1.213 + _count++; 1.214 + } 1.215 + int count() { return _count; } 1.216 +}; 1.217 + 1.218 +// We assume this is called at a safepoint: no lock is needed. 1.219 +void JNIHandles::print_on(outputStream* st) { 1.220 + assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); 1.221 + assert(_global_handles != NULL && _weak_global_handles != NULL, 1.222 + "JNIHandles not initialized"); 1.223 + 1.224 + CountHandleClosure global_handle_count; 1.225 + AlwaysAliveClosure always_alive; 1.226 + oops_do(&global_handle_count); 1.227 + weak_oops_do(&always_alive, &global_handle_count); 1.228 + 1.229 + st->print_cr("JNI global references: %d", global_handle_count.count()); 1.230 + st->cr(); 1.231 + st->flush(); 1.232 +} 1.233 + 1.234 +class VerifyHandleClosure: public OopClosure { 1.235 +public: 1.236 + void do_oop(oop* root) { 1.237 + (*root)->verify(); 1.238 + } 1.239 +}; 1.240 + 1.241 +void JNIHandles::verify() { 1.242 + VerifyHandleClosure verify_handle; 1.243 + AlwaysAliveClosure always_alive; 1.244 + 1.245 + oops_do(&verify_handle); 1.246 + weak_oops_do(&always_alive, &verify_handle); 1.247 +} 1.248 + 1.249 + 1.250 + 1.251 +void jni_handles_init() { 1.252 + JNIHandles::initialize(); 1.253 +} 1.254 + 1.255 + 1.256 +int JNIHandleBlock::_blocks_allocated = 0; 1.257 +JNIHandleBlock* JNIHandleBlock::_block_free_list = NULL; 1.258 +#ifndef PRODUCT 1.259 +JNIHandleBlock* JNIHandleBlock::_block_list = NULL; 1.260 +#endif 1.261 + 1.262 + 1.263 +void JNIHandleBlock::zap() { 1.264 + // Zap block values 1.265 + _top = 0; 1.266 + for (int index = 0; index < block_size_in_oops; index++) { 1.267 + _handles[index] = badJNIHandle; 1.268 + } 1.269 +} 1.270 + 1.271 +JNIHandleBlock* JNIHandleBlock::allocate_block(Thread* thread) { 1.272 + assert(thread == NULL || thread == Thread::current(), "sanity check"); 1.273 + JNIHandleBlock* block; 1.274 + // Check the thread-local free list for a block so we don't 1.275 + // have to acquire a mutex. 1.276 + if (thread != NULL && thread->free_handle_block() != NULL) { 1.277 + block = thread->free_handle_block(); 1.278 + thread->set_free_handle_block(block->_next); 1.279 + } 1.280 + else { 1.281 + // locking with safepoint checking introduces a potential deadlock: 1.282 + // - we would hold JNIHandleBlockFreeList_lock and then Threads_lock 1.283 + // - another would hold Threads_lock (jni_AttachCurrentThread) and then 1.284 + // JNIHandleBlockFreeList_lock (JNIHandleBlock::allocate_block) 1.285 + MutexLockerEx ml(JNIHandleBlockFreeList_lock, 1.286 + Mutex::_no_safepoint_check_flag); 1.287 + if (_block_free_list == NULL) { 1.288 + // Allocate new block 1.289 + block = new JNIHandleBlock(); 1.290 + _blocks_allocated++; 1.291 + if (TraceJNIHandleAllocation) { 1.292 + tty->print_cr("JNIHandleBlock " INTPTR_FORMAT " allocated (%d total blocks)", 1.293 + block, _blocks_allocated); 1.294 + } 1.295 + if (ZapJNIHandleArea) block->zap(); 1.296 + #ifndef PRODUCT 1.297 + // Link new block to list of all allocated blocks 1.298 + block->_block_list_link = _block_list; 1.299 + _block_list = block; 1.300 + #endif 1.301 + } else { 1.302 + // Get block from free list 1.303 + block = _block_free_list; 1.304 + _block_free_list = _block_free_list->_next; 1.305 + } 1.306 + } 1.307 + block->_top = 0; 1.308 + block->_next = NULL; 1.309 + block->_pop_frame_link = NULL; 1.310 + // _last, _free_list & _allocate_before_rebuild initialized in allocate_handle 1.311 + debug_only(block->_last = NULL); 1.312 + debug_only(block->_free_list = NULL); 1.313 + debug_only(block->_allocate_before_rebuild = -1); 1.314 + return block; 1.315 +} 1.316 + 1.317 + 1.318 +void JNIHandleBlock::release_block(JNIHandleBlock* block, Thread* thread) { 1.319 + assert(thread == NULL || thread == Thread::current(), "sanity check"); 1.320 + JNIHandleBlock* pop_frame_link = block->pop_frame_link(); 1.321 + // Put returned block at the beginning of the thread-local free list. 1.322 + // Note that if thread == NULL, we use it as an implicit argument that 1.323 + // we _don't_ want the block to be kept on the free_handle_block. 1.324 + // See for instance JavaThread::exit(). 1.325 + if (thread != NULL ) { 1.326 + if (ZapJNIHandleArea) block->zap(); 1.327 + JNIHandleBlock* freelist = thread->free_handle_block(); 1.328 + block->_pop_frame_link = NULL; 1.329 + thread->set_free_handle_block(block); 1.330 + 1.331 + // Add original freelist to end of chain 1.332 + if ( freelist != NULL ) { 1.333 + while ( block->_next != NULL ) block = block->_next; 1.334 + block->_next = freelist; 1.335 + } 1.336 + block = NULL; 1.337 + } 1.338 + if (block != NULL) { 1.339 + // Return blocks to free list 1.340 + // locking with safepoint checking introduces a potential deadlock: 1.341 + // - we would hold JNIHandleBlockFreeList_lock and then Threads_lock 1.342 + // - another would hold Threads_lock (jni_AttachCurrentThread) and then 1.343 + // JNIHandleBlockFreeList_lock (JNIHandleBlock::allocate_block) 1.344 + MutexLockerEx ml(JNIHandleBlockFreeList_lock, 1.345 + Mutex::_no_safepoint_check_flag); 1.346 + while (block != NULL) { 1.347 + if (ZapJNIHandleArea) block->zap(); 1.348 + JNIHandleBlock* next = block->_next; 1.349 + block->_next = _block_free_list; 1.350 + _block_free_list = block; 1.351 + block = next; 1.352 + } 1.353 + } 1.354 + if (pop_frame_link != NULL) { 1.355 + // As a sanity check we release blocks pointed to by the pop_frame_link. 1.356 + // This should never happen (only if PopLocalFrame is not called the 1.357 + // correct number of times). 1.358 + release_block(pop_frame_link, thread); 1.359 + } 1.360 +} 1.361 + 1.362 + 1.363 +void JNIHandleBlock::oops_do(OopClosure* f) { 1.364 + JNIHandleBlock* current_chain = this; 1.365 + // Iterate over chain of blocks, followed by chains linked through the 1.366 + // pop frame links. 1.367 + while (current_chain != NULL) { 1.368 + for (JNIHandleBlock* current = current_chain; current != NULL; 1.369 + current = current->_next) { 1.370 + assert(current == current_chain || current->pop_frame_link() == NULL, 1.371 + "only blocks first in chain should have pop frame link set"); 1.372 + for (int index = 0; index < current->_top; index++) { 1.373 + oop* root = &(current->_handles)[index]; 1.374 + oop value = *root; 1.375 + // traverse heap pointers only, not deleted handles or free list 1.376 + // pointers 1.377 + if (value != NULL && Universe::heap()->is_in_reserved(value)) { 1.378 + f->do_oop(root); 1.379 + } 1.380 + } 1.381 + // the next handle block is valid only if current block is full 1.382 + if (current->_top < block_size_in_oops) { 1.383 + break; 1.384 + } 1.385 + } 1.386 + current_chain = current_chain->pop_frame_link(); 1.387 + } 1.388 +} 1.389 + 1.390 + 1.391 +void JNIHandleBlock::weak_oops_do(BoolObjectClosure* is_alive, 1.392 + OopClosure* f) { 1.393 + for (JNIHandleBlock* current = this; current != NULL; current = current->_next) { 1.394 + assert(current->pop_frame_link() == NULL, 1.395 + "blocks holding weak global JNI handles should not have pop frame link set"); 1.396 + for (int index = 0; index < current->_top; index++) { 1.397 + oop* root = &(current->_handles)[index]; 1.398 + oop value = *root; 1.399 + // traverse heap pointers only, not deleted handles or free list pointers 1.400 + if (value != NULL && Universe::heap()->is_in_reserved(value)) { 1.401 + if (is_alive->do_object_b(value)) { 1.402 + // The weakly referenced object is alive, update pointer 1.403 + f->do_oop(root); 1.404 + } else { 1.405 + // The weakly referenced object is not alive, clear the reference by storing NULL 1.406 + if (TraceReferenceGC) { 1.407 + tty->print_cr("Clearing JNI weak reference (" INTPTR_FORMAT ")", root); 1.408 + } 1.409 + *root = NULL; 1.410 + } 1.411 + } 1.412 + } 1.413 + // the next handle block is valid only if current block is full 1.414 + if (current->_top < block_size_in_oops) { 1.415 + break; 1.416 + } 1.417 + } 1.418 +} 1.419 + 1.420 + 1.421 +jobject JNIHandleBlock::allocate_handle(oop obj) { 1.422 + assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 1.423 + if (_top == 0) { 1.424 + // This is the first allocation or the initial block got zapped when 1.425 + // entering a native function. If we have any following blocks they are 1.426 + // not valid anymore. 1.427 + for (JNIHandleBlock* current = _next; current != NULL; 1.428 + current = current->_next) { 1.429 + assert(current->_last == NULL, "only first block should have _last set"); 1.430 + assert(current->_free_list == NULL, 1.431 + "only first block should have _free_list set"); 1.432 + current->_top = 0; 1.433 + if (ZapJNIHandleArea) current->zap(); 1.434 + } 1.435 + // Clear initial block 1.436 + _free_list = NULL; 1.437 + _allocate_before_rebuild = 0; 1.438 + _last = this; 1.439 + if (ZapJNIHandleArea) zap(); 1.440 + } 1.441 + 1.442 + // Try last block 1.443 + if (_last->_top < block_size_in_oops) { 1.444 + oop* handle = &(_last->_handles)[_last->_top++]; 1.445 + *handle = obj; 1.446 + return (jobject) handle; 1.447 + } 1.448 + 1.449 + // Try free list 1.450 + if (_free_list != NULL) { 1.451 + oop* handle = _free_list; 1.452 + _free_list = (oop*) *_free_list; 1.453 + *handle = obj; 1.454 + return (jobject) handle; 1.455 + } 1.456 + // Check if unused block follow last 1.457 + if (_last->_next != NULL) { 1.458 + // update last and retry 1.459 + _last = _last->_next; 1.460 + return allocate_handle(obj); 1.461 + } 1.462 + 1.463 + // No space available, we have to rebuild free list or expand 1.464 + if (_allocate_before_rebuild == 0) { 1.465 + rebuild_free_list(); // updates _allocate_before_rebuild counter 1.466 + } else { 1.467 + // Append new block 1.468 + Thread* thread = Thread::current(); 1.469 + Handle obj_handle(thread, obj); 1.470 + // This can block, so we need to preserve obj accross call. 1.471 + _last->_next = JNIHandleBlock::allocate_block(thread); 1.472 + _last = _last->_next; 1.473 + _allocate_before_rebuild--; 1.474 + obj = obj_handle(); 1.475 + } 1.476 + return allocate_handle(obj); // retry 1.477 +} 1.478 + 1.479 + 1.480 +void JNIHandleBlock::rebuild_free_list() { 1.481 + assert(_allocate_before_rebuild == 0 && _free_list == NULL, "just checking"); 1.482 + int free = 0; 1.483 + int blocks = 0; 1.484 + for (JNIHandleBlock* current = this; current != NULL; current = current->_next) { 1.485 + for (int index = 0; index < current->_top; index++) { 1.486 + oop* handle = &(current->_handles)[index]; 1.487 + if (*handle == JNIHandles::deleted_handle()) { 1.488 + // this handle was cleared out by a delete call, reuse it 1.489 + *handle = (oop) _free_list; 1.490 + _free_list = handle; 1.491 + free++; 1.492 + } 1.493 + } 1.494 + // we should not rebuild free list if there are unused handles at the end 1.495 + assert(current->_top == block_size_in_oops, "just checking"); 1.496 + blocks++; 1.497 + } 1.498 + // Heuristic: if more than half of the handles are free we rebuild next time 1.499 + // as well, otherwise we append a corresponding number of new blocks before 1.500 + // attempting a free list rebuild again. 1.501 + int total = blocks * block_size_in_oops; 1.502 + int extra = total - 2*free; 1.503 + if (extra > 0) { 1.504 + // Not as many free handles as we would like - compute number of new blocks to append 1.505 + _allocate_before_rebuild = (extra + block_size_in_oops - 1) / block_size_in_oops; 1.506 + } 1.507 + if (TraceJNIHandleAllocation) { 1.508 + tty->print_cr("Rebuild free list JNIHandleBlock " INTPTR_FORMAT " blocks=%d used=%d free=%d add=%d", 1.509 + this, blocks, total-free, free, _allocate_before_rebuild); 1.510 + } 1.511 +} 1.512 + 1.513 + 1.514 +bool JNIHandleBlock::contains(jobject handle) const { 1.515 + return ((jobject)&_handles[0] <= handle && handle<(jobject)&_handles[_top]); 1.516 +} 1.517 + 1.518 + 1.519 +bool JNIHandleBlock::chain_contains(jobject handle) const { 1.520 + for (JNIHandleBlock* current = (JNIHandleBlock*) this; current != NULL; current = current->_next) { 1.521 + if (current->contains(handle)) { 1.522 + return true; 1.523 + } 1.524 + } 1.525 + return false; 1.526 +} 1.527 + 1.528 + 1.529 +int JNIHandleBlock::length() const { 1.530 + int result = 1; 1.531 + for (JNIHandleBlock* current = _next; current != NULL; current = current->_next) { 1.532 + result++; 1.533 + } 1.534 + return result; 1.535 +} 1.536 + 1.537 +// This method is not thread-safe, i.e., must be called whule holding a lock on the 1.538 +// structure. 1.539 +long JNIHandleBlock::memory_usage() const { 1.540 + return length() * sizeof(JNIHandleBlock); 1.541 +} 1.542 + 1.543 + 1.544 +#ifndef PRODUCT 1.545 + 1.546 +bool JNIHandleBlock::any_contains(jobject handle) { 1.547 + for (JNIHandleBlock* current = _block_list; current != NULL; current = current->_block_list_link) { 1.548 + if (current->contains(handle)) { 1.549 + return true; 1.550 + } 1.551 + } 1.552 + return false; 1.553 +} 1.554 + 1.555 +void JNIHandleBlock::print_statistics() { 1.556 + int used_blocks = 0; 1.557 + int free_blocks = 0; 1.558 + int used_handles = 0; 1.559 + int free_handles = 0; 1.560 + JNIHandleBlock* block = _block_list; 1.561 + while (block != NULL) { 1.562 + if (block->_top > 0) { 1.563 + used_blocks++; 1.564 + } else { 1.565 + free_blocks++; 1.566 + } 1.567 + used_handles += block->_top; 1.568 + free_handles += (block_size_in_oops - block->_top); 1.569 + block = block->_block_list_link; 1.570 + } 1.571 + tty->print_cr("JNIHandleBlocks statistics"); 1.572 + tty->print_cr("- blocks allocated: %d", used_blocks + free_blocks); 1.573 + tty->print_cr("- blocks in use: %d", used_blocks); 1.574 + tty->print_cr("- blocks free: %d", free_blocks); 1.575 + tty->print_cr("- handles in use: %d", used_handles); 1.576 + tty->print_cr("- handles free: %d", free_handles); 1.577 +} 1.578 + 1.579 +#endif