comparison src/share/vm/oops/instanceRefKlass.cpp @ 6108:c52a6a39546c

7158682: G1: Handle leak when running nsk.sysdict tests Summary: Place HandleMarks in the code that allocates handles for the pending list lock so that the handles are freed and multiple, unsuccessful, attempts to schedule a GC do not cause an OOM. Reviewed-by: brutisso
author johnc
date Wed, 30 May 2012 10:26:24 -0700
parents b632e80fc9dc
children da91efe96a93
comparison
equal deleted inserted replaced
6107:5c8bd7c16119 6108:c52a6a39546c
513 } 513 }
514 514
515 void instanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) { 515 void instanceRefKlass::acquire_pending_list_lock(BasicLock *pending_list_basic_lock) {
516 // we may enter this with pending exception set 516 // we may enter this with pending exception set
517 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument 517 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument
518
519 // Create a HandleMark in case we retry a GC multiple times.
520 // Each time we attempt the GC, we allocate the handle below
521 // to hold the pending list lock. We want to free this handle.
522 HandleMark hm;
523
518 Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock()); 524 Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock());
519 ObjectSynchronizer::fast_enter(h_lock, pending_list_basic_lock, false, THREAD); 525 ObjectSynchronizer::fast_enter(h_lock, pending_list_basic_lock, false, THREAD);
520 assert(ObjectSynchronizer::current_thread_holds_lock( 526 assert(ObjectSynchronizer::current_thread_holds_lock(
521 JavaThread::current(), h_lock), 527 JavaThread::current(), h_lock),
522 "Locking should have succeeded"); 528 "Locking should have succeeded");
525 531
526 void instanceRefKlass::release_and_notify_pending_list_lock( 532 void instanceRefKlass::release_and_notify_pending_list_lock(
527 BasicLock *pending_list_basic_lock) { 533 BasicLock *pending_list_basic_lock) {
528 // we may enter this with pending exception set 534 // we may enter this with pending exception set
529 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument 535 PRESERVE_EXCEPTION_MARK; // exceptions are never thrown, needed for TRAPS argument
530 // 536
537 // Create a HandleMark in case we retry a GC multiple times.
538 // Each time we attempt the GC, we allocate the handle below
539 // to hold the pending list lock. We want to free this handle.
540 HandleMark hm;
541
531 Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock()); 542 Handle h_lock(THREAD, java_lang_ref_Reference::pending_list_lock());
532 assert(ObjectSynchronizer::current_thread_holds_lock( 543 assert(ObjectSynchronizer::current_thread_holds_lock(
533 JavaThread::current(), h_lock), 544 JavaThread::current(), h_lock),
534 "Lock should be held"); 545 "Lock should be held");
535 // Notify waiters on pending lists lock if there is any reference. 546 // Notify waiters on pending lists lock if there is any reference.