< prev index next >

src/hotspot/share/runtime/synchronizer.cpp

Print this page
rev 47794 : Port 09.17.Thread_SMR_logging_update from JDK9 to JDK10


 877     return self->is_lock_owned((address)mark->locker()) ?
 878       owner_self : owner_other;
 879   }
 880 
 881   // CASE: inflated. Mark (tagged pointer) points to an objectMonitor.
 882   // The Object:ObjectMonitor relationship is stable as long as we're
 883   // not at a safepoint.
 884   if (mark->has_monitor()) {
 885     void * owner = mark->monitor()->_owner;
 886     if (owner == NULL) return owner_none;
 887     return (owner == self ||
 888             self->is_lock_owned((address)owner)) ? owner_self : owner_other;
 889   }
 890 
 891   // CASE: neutral
 892   assert(mark->is_neutral(), "sanity check");
 893   return owner_none;           // it's unlocked
 894 }
 895 
 896 // FIXME: jvmti should call this
 897 JavaThread* ObjectSynchronizer::get_lock_owner(Handle h_obj, bool doLock) {
 898   if (UseBiasedLocking) {
 899     if (SafepointSynchronize::is_at_safepoint()) {
 900       BiasedLocking::revoke_at_safepoint(h_obj);
 901     } else {
 902       BiasedLocking::revoke_and_rebias(h_obj, false, JavaThread::current());
 903     }
 904     assert(!h_obj->mark()->has_bias_pattern(), "biases should be revoked by now");
 905   }
 906 
 907   oop obj = h_obj();
 908   address owner = NULL;
 909 
 910   markOop mark = ReadStableMark(obj);
 911 
 912   // Uncontended case, header points to stack
 913   if (mark->has_locker()) {
 914     owner = (address) mark->locker();
 915   }
 916 
 917   // Contended case, header points to ObjectMonitor (tagged pointer)
 918   if (mark->has_monitor()) {
 919     ObjectMonitor* monitor = mark->monitor();
 920     assert(monitor != NULL, "monitor should be non-null");
 921     owner = (address) monitor->owner();
 922   }
 923 
 924   if (owner != NULL) {
 925     // owning_thread_from_monitor_owner() may also return NULL here
 926     return Threads::owning_thread_from_monitor_owner(owner, doLock);
 927   }
 928 
 929   // Unlocked case, header in place
 930   // Cannot have assertion since this object may have been
 931   // locked by another thread when reaching here.
 932   // assert(mark->is_neutral(), "sanity check");
 933 
 934   return NULL;
 935 }
 936 
 937 // Visitors ...
 938 
 939 void ObjectSynchronizer::monitors_iterate(MonitorClosure* closure) {
 940   PaddedEnd<ObjectMonitor> * block = OrderAccess::load_acquire(&gBlockList);
 941   while (block != NULL) {
 942     assert(block->object() == CHAINMARKER, "must be a block header");
 943     for (int i = _BLOCKSIZE - 1; i > 0; i--) {
 944       ObjectMonitor* mid = (ObjectMonitor *)(block + i);
 945       oop object = (oop)mid->object();
 946       if (object != NULL) {




 877     return self->is_lock_owned((address)mark->locker()) ?
 878       owner_self : owner_other;
 879   }
 880 
 881   // CASE: inflated. Mark (tagged pointer) points to an objectMonitor.
 882   // The Object:ObjectMonitor relationship is stable as long as we're
 883   // not at a safepoint.
 884   if (mark->has_monitor()) {
 885     void * owner = mark->monitor()->_owner;
 886     if (owner == NULL) return owner_none;
 887     return (owner == self ||
 888             self->is_lock_owned((address)owner)) ? owner_self : owner_other;
 889   }
 890 
 891   // CASE: neutral
 892   assert(mark->is_neutral(), "sanity check");
 893   return owner_none;           // it's unlocked
 894 }
 895 
 896 // FIXME: jvmti should call this
 897 JavaThread* ObjectSynchronizer::get_lock_owner(ThreadsList * t_list, Handle h_obj) {
 898   if (UseBiasedLocking) {
 899     if (SafepointSynchronize::is_at_safepoint()) {
 900       BiasedLocking::revoke_at_safepoint(h_obj);
 901     } else {
 902       BiasedLocking::revoke_and_rebias(h_obj, false, JavaThread::current());
 903     }
 904     assert(!h_obj->mark()->has_bias_pattern(), "biases should be revoked by now");
 905   }
 906 
 907   oop obj = h_obj();
 908   address owner = NULL;
 909 
 910   markOop mark = ReadStableMark(obj);
 911 
 912   // Uncontended case, header points to stack
 913   if (mark->has_locker()) {
 914     owner = (address) mark->locker();
 915   }
 916 
 917   // Contended case, header points to ObjectMonitor (tagged pointer)
 918   if (mark->has_monitor()) {
 919     ObjectMonitor* monitor = mark->monitor();
 920     assert(monitor != NULL, "monitor should be non-null");
 921     owner = (address) monitor->owner();
 922   }
 923 
 924   if (owner != NULL) {
 925     // owning_thread_from_monitor_owner() may also return NULL here
 926     return Threads::owning_thread_from_monitor_owner(t_list, owner);
 927   }
 928 
 929   // Unlocked case, header in place
 930   // Cannot have assertion since this object may have been
 931   // locked by another thread when reaching here.
 932   // assert(mark->is_neutral(), "sanity check");
 933 
 934   return NULL;
 935 }
 936 
 937 // Visitors ...
 938 
 939 void ObjectSynchronizer::monitors_iterate(MonitorClosure* closure) {
 940   PaddedEnd<ObjectMonitor> * block = OrderAccess::load_acquire(&gBlockList);
 941   while (block != NULL) {
 942     assert(block->object() == CHAINMARKER, "must be a block header");
 943     for (int i = _BLOCKSIZE - 1; i > 0; i--) {
 944       ObjectMonitor* mid = (ObjectMonitor *)(block + i);
 945       oop object = (oop)mid->object();
 946       if (object != NULL) {


< prev index next >