< prev index next >

src/hotspot/share/runtime/biasedLocking.cpp

Print this page
rev 56099 : imported patch 8226705-rebase
rev 56101 : [mq]: 8226705-refactor


 868 
 869 
 870 void BiasedLocking::revoke_at_safepoint(Handle h_obj) {
 871   assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
 872   oop obj = h_obj();
 873   HeuristicsResult heuristics = update_heuristics(obj);
 874   if (heuristics == HR_SINGLE_REVOKE) {
 875     JavaThread* biased_locker = NULL;
 876     single_revoke_at_safepoint(obj, false, NULL, &biased_locker);
 877     if (biased_locker) {
 878       clean_up_cached_monitor_info(biased_locker);
 879     }
 880   } else if ((heuristics == HR_BULK_REBIAS) ||
 881              (heuristics == HR_BULK_REVOKE)) {
 882     bulk_revoke_at_safepoint(obj, (heuristics == HR_BULK_REBIAS), NULL);
 883     clean_up_cached_monitor_info();
 884   }
 885 }
 886 
 887 
 888 void BiasedLocking::revoke_at_safepoint(GrowableArray<Handle>* objs) {
 889   assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
 890   int len = objs->length();
 891   for (int i = 0; i < len; i++) {
 892     oop obj = (objs->at(i))();
 893     HeuristicsResult heuristics = update_heuristics(obj);
 894     if (heuristics == HR_SINGLE_REVOKE) {
 895       single_revoke_at_safepoint(obj, false, NULL, NULL);
 896     } else if ((heuristics == HR_BULK_REBIAS) ||
 897                (heuristics == HR_BULK_REVOKE)) {
 898       bulk_revoke_at_safepoint(obj, (heuristics == HR_BULK_REBIAS), NULL);
 899     }
 900   }
 901   clean_up_cached_monitor_info();
 902 }
 903 
 904 
 905 void BiasedLocking::preserve_marks() {
 906   if (!UseBiasedLocking)
 907     return;
 908 
 909   assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
 910 
 911   assert(_preserved_oop_stack  == NULL, "double initialization");
 912   assert(_preserved_mark_stack == NULL, "double initialization");
 913 
 914   // In order to reduce the number of mark words preserved during GC
 915   // due to the presence of biased locking, we reinitialize most mark
 916   // words to the class's prototype during GC -- even those which have
 917   // a currently valid bias owner. One important situation where we
 918   // must not clobber a bias is when a biased object is currently
 919   // locked. To handle this case we iterate over the currently-locked
 920   // monitors in a prepass and, if they are biased, preserve their
 921   // mark words here. This should be a relatively small set of objects
 922   // especially compared to the number of objects in the heap.
 923   _preserved_mark_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<markWord>(10, true);
 924   _preserved_oop_stack = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<Handle>(10, true);




 868 
 869 
 870 void BiasedLocking::revoke_at_safepoint(Handle h_obj) {
 871   assert(SafepointSynchronize::is_at_safepoint(), "must only be called while at safepoint");
 872   oop obj = h_obj();
 873   HeuristicsResult heuristics = update_heuristics(obj);
 874   if (heuristics == HR_SINGLE_REVOKE) {
 875     JavaThread* biased_locker = NULL;
 876     single_revoke_at_safepoint(obj, false, NULL, &biased_locker);
 877     if (biased_locker) {
 878       clean_up_cached_monitor_info(biased_locker);
 879     }
 880   } else if ((heuristics == HR_BULK_REBIAS) ||
 881              (heuristics == HR_BULK_REVOKE)) {
 882     bulk_revoke_at_safepoint(obj, (heuristics == HR_BULK_REBIAS), NULL);
 883     clean_up_cached_monitor_info();
 884   }
 885 }
 886 
 887 

















 888 void BiasedLocking::preserve_marks() {
 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);


< prev index next >