427
428 /*
429 * JVMTI data structures may also contain weak oops. The iteration of them
430 * is placed here so that we don't need to add it to each of the collectors.
431 */
432 JvmtiExport::weak_oops_do(is_alive, f);
433 }
434
435
436 jobject JNIHandleBlock::allocate_handle(oop obj) {
437 assert(Universe::heap()->is_in_reserved(obj), "sanity check");
438 if (_top == 0) {
439 // This is the first allocation or the initial block got zapped when
440 // entering a native function. If we have any following blocks they are
441 // not valid anymore.
442 for (JNIHandleBlock* current = _next; current != NULL;
443 current = current->_next) {
444 assert(current->_last == NULL, "only first block should have _last set");
445 assert(current->_free_list == NULL,
446 "only first block should have _free_list set");
447 current->_top = 0;
448 if (ZapJNIHandleArea) current->zap();
449 }
450 // Clear initial block
451 _free_list = NULL;
452 _allocate_before_rebuild = 0;
453 _last = this;
454 if (ZapJNIHandleArea) zap();
455 }
456
457 // Try last block
458 if (_last->_top < block_size_in_oops) {
459 oop* handle = &(_last->_handles)[_last->_top++];
460 *handle = obj;
461 return (jobject) handle;
462 }
463
464 // Try free list
465 if (_free_list != NULL) {
466 oop* handle = _free_list;
|
427
428 /*
429 * JVMTI data structures may also contain weak oops. The iteration of them
430 * is placed here so that we don't need to add it to each of the collectors.
431 */
432 JvmtiExport::weak_oops_do(is_alive, f);
433 }
434
435
436 jobject JNIHandleBlock::allocate_handle(oop obj) {
437 assert(Universe::heap()->is_in_reserved(obj), "sanity check");
438 if (_top == 0) {
439 // This is the first allocation or the initial block got zapped when
440 // entering a native function. If we have any following blocks they are
441 // not valid anymore.
442 for (JNIHandleBlock* current = _next; current != NULL;
443 current = current->_next) {
444 assert(current->_last == NULL, "only first block should have _last set");
445 assert(current->_free_list == NULL,
446 "only first block should have _free_list set");
447 if (current->_top == 0) {
448 // All blocks after the first clear trailing block are already cleared.
449 #ifdef ASSERT
450 for ( ; current != NULL; current = current->_next) {
451 assert(current->_top == 0, "trailing blocks must already be cleared");
452 }
453 #endif
454 break;
455 }
456 current->_top = 0;
457 if (ZapJNIHandleArea) current->zap();
458 }
459 // Clear initial block
460 _free_list = NULL;
461 _allocate_before_rebuild = 0;
462 _last = this;
463 if (ZapJNIHandleArea) zap();
464 }
465
466 // Try last block
467 if (_last->_top < block_size_in_oops) {
468 oop* handle = &(_last->_handles)[_last->_top++];
469 *handle = obj;
470 return (jobject) handle;
471 }
472
473 // Try free list
474 if (_free_list != NULL) {
475 oop* handle = _free_list;
|