< prev index next >

src/hotspot/share/runtime/biasedLocking.cpp

Print this page
rev 59866 : 8249192: MonitorInfo stores raw oops across safepoints
Summary: Change raw oops in MonitorInfo to Handles and update Resource/HandleMarks.
Reviewed-by: sspitsyn, dholmes, coleenp, dcubed


 889   if (!UseBiasedLocking)
 890     return;
 891 
 892   assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
 893 
 894   assert(_preserved_oop_stack  == NULL, "double initialization");
 895   assert(_preserved_mark_stack == NULL, "double initialization");
 896 
 897   // In order to reduce the number of mark words preserved during GC
 898   // due to the presence of biased locking, we reinitialize most mark
 899   // words to the class's prototype during GC -- even those which have
 900   // a currently valid bias owner. One important situation where we
 901   // must not clobber a bias is when a biased object is currently
 902   // locked. To handle this case we iterate over the currently-locked
 903   // monitors in a prepass and, if they are biased, preserve their
 904   // mark words here. This should be a relatively small set of objects
 905   // especially compared to the number of objects in the heap.
 906   _preserved_mark_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<markWord>(10, true);
 907   _preserved_oop_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Handle>(10, true);
 908 
 909   ResourceMark rm;
 910   Thread* cur = Thread::current();



 911   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) {
 912     if (thread->has_last_Java_frame()) {
 913       RegisterMap rm(thread);
 914       for (javaVFrame* vf = thread->last_java_vframe(&rm); vf != NULL; vf = vf->java_sender()) {
 915         GrowableArray<MonitorInfo*> *monitors = vf->monitors();
 916         if (monitors != NULL) {
 917           int len = monitors->length();
 918           // Walk monitors youngest to oldest
 919           for (int i = len - 1; i >= 0; i--) {
 920             MonitorInfo* mon_info = monitors->at(i);
 921             if (mon_info->owner_is_scalar_replaced()) continue;
 922             oop owner = mon_info->owner();
 923             if (owner != NULL) {
 924               markWord mark = owner->mark();
 925               if (mark.has_bias_pattern()) {
 926                 _preserved_oop_stack->push(Handle(cur, owner));
 927                 _preserved_mark_stack->push(mark);
 928               }
 929             }
 930           }




 889   if (!UseBiasedLocking)
 890     return;
 891 
 892   assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
 893 
 894   assert(_preserved_oop_stack  == NULL, "double initialization");
 895   assert(_preserved_mark_stack == NULL, "double initialization");
 896 
 897   // In order to reduce the number of mark words preserved during GC
 898   // due to the presence of biased locking, we reinitialize most mark
 899   // words to the class's prototype during GC -- even those which have
 900   // a currently valid bias owner. One important situation where we
 901   // must not clobber a bias is when a biased object is currently
 902   // locked. To handle this case we iterate over the currently-locked
 903   // monitors in a prepass and, if they are biased, preserve their
 904   // mark words here. This should be a relatively small set of objects
 905   // especially compared to the number of objects in the heap.
 906   _preserved_mark_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<markWord>(10, true);
 907   _preserved_oop_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Handle>(10, true);
 908 

 909   Thread* cur = Thread::current();
 910   ResourceMark rm(cur);
 911   HandleMark hm(cur);
 912 
 913   for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thread = jtiwh.next(); ) {
 914     if (thread->has_last_Java_frame()) {
 915       RegisterMap rm(thread);
 916       for (javaVFrame* vf = thread->last_java_vframe(&rm); vf != NULL; vf = vf->java_sender()) {
 917         GrowableArray<MonitorInfo*> *monitors = vf->monitors();
 918         if (monitors != NULL) {
 919           int len = monitors->length();
 920           // Walk monitors youngest to oldest
 921           for (int i = len - 1; i >= 0; i--) {
 922             MonitorInfo* mon_info = monitors->at(i);
 923             if (mon_info->owner_is_scalar_replaced()) continue;
 924             oop owner = mon_info->owner();
 925             if (owner != NULL) {
 926               markWord mark = owner->mark();
 927               if (mark.has_bias_pattern()) {
 928                 _preserved_oop_stack->push(Handle(cur, owner));
 929                 _preserved_mark_stack->push(mark);
 930               }
 931             }
 932           }


< prev index next >