< prev index next >

src/hotspot/share/runtime/synchronizer.hpp

Print this page
rev 47862 : imported patch 10.07.open.rebase_20171110.dcubed


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
  26 #define SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
  27 
  28 #include "memory/padded.hpp"
  29 #include "oops/markOop.hpp"
  30 #include "runtime/basicLock.hpp"
  31 #include "runtime/handles.hpp"
  32 #include "runtime/perfData.hpp"
  33 
  34 class ObjectMonitor;

  35 
  36 struct DeflateMonitorCounters {
  37   int nInuse;          // currently associated with objects
  38   int nInCirculation;  // extant
  39   int nScavenged;      // reclaimed
  40 };
  41 
  42 class ObjectSynchronizer : AllStatic {
  43   friend class VMStructs;
  44  public:
  45   typedef enum {
  46     owner_self,
  47     owner_none,
  48     owner_other
  49   } LockOwnership;
  50 
  51   typedef enum {
  52     inflate_cause_vm_internal = 0,
  53     inflate_cause_monitor_enter = 1,
  54     inflate_cause_wait = 2,


 108   static ObjectMonitor * omAlloc(Thread * Self);
 109   static void omRelease(Thread * Self, ObjectMonitor * m,
 110                         bool FromPerThreadAlloc);
 111   static void omFlush(Thread * Self);
 112 
 113   // Inflate light weight monitor to heavy weight monitor
 114   static ObjectMonitor* inflate(Thread * Self, oop obj, const InflateCause cause);
 115   // This version is only for internal use
 116   static ObjectMonitor* inflate_helper(oop obj);
 117   static const char* inflate_cause_name(const InflateCause cause);
 118 
 119   // Returns the identity hash value for an oop
 120   // NOTE: It may cause monitor inflation
 121   static intptr_t identity_hash_value_for(Handle obj);
 122   static intptr_t FastHashCode(Thread * Self, oop obj);
 123 
 124   // java.lang.Thread support
 125   static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj);
 126   static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj);
 127 
 128   static JavaThread* get_lock_owner(Handle h_obj, bool doLock);
 129 
 130   // JNI detach support
 131   static void release_monitors_owned_by_thread(TRAPS);
 132   static void monitors_iterate(MonitorClosure* m);
 133 
 134   // GC: we current use aggressive monitor deflation policy
 135   // Basically we deflate all monitors that are not busy.
 136   // An adaptive profile-based deflation policy could be used if needed
 137   static void deflate_idle_monitors(DeflateMonitorCounters* counters);
 138   static void deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters);
 139   static void prepare_deflate_idle_monitors(DeflateMonitorCounters* counters);
 140   static void finish_deflate_idle_monitors(DeflateMonitorCounters* counters);
 141 
 142   // For a given monitor list: global or per-thread, deflate idle monitors
 143   static int deflate_monitor_list(ObjectMonitor** listheadp,
 144                                   ObjectMonitor** freeHeadp,
 145                                   ObjectMonitor** freeTailp);
 146   static bool deflate_monitor(ObjectMonitor* mid, oop obj,
 147                               ObjectMonitor** freeHeadp,
 148                               ObjectMonitor** freeTailp);




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
  26 #define SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
  27 
  28 #include "memory/padded.hpp"
  29 #include "oops/markOop.hpp"
  30 #include "runtime/basicLock.hpp"
  31 #include "runtime/handles.hpp"
  32 #include "runtime/perfData.hpp"
  33 
  34 class ObjectMonitor;
  35 class ThreadsList;
  36 
  37 struct DeflateMonitorCounters {
  38   int nInuse;          // currently associated with objects
  39   int nInCirculation;  // extant
  40   int nScavenged;      // reclaimed
  41 };
  42 
  43 class ObjectSynchronizer : AllStatic {
  44   friend class VMStructs;
  45  public:
  46   typedef enum {
  47     owner_self,
  48     owner_none,
  49     owner_other
  50   } LockOwnership;
  51 
  52   typedef enum {
  53     inflate_cause_vm_internal = 0,
  54     inflate_cause_monitor_enter = 1,
  55     inflate_cause_wait = 2,


 109   static ObjectMonitor * omAlloc(Thread * Self);
 110   static void omRelease(Thread * Self, ObjectMonitor * m,
 111                         bool FromPerThreadAlloc);
 112   static void omFlush(Thread * Self);
 113 
 114   // Inflate light weight monitor to heavy weight monitor
 115   static ObjectMonitor* inflate(Thread * Self, oop obj, const InflateCause cause);
 116   // This version is only for internal use
 117   static ObjectMonitor* inflate_helper(oop obj);
 118   static const char* inflate_cause_name(const InflateCause cause);
 119 
 120   // Returns the identity hash value for an oop
 121   // NOTE: It may cause monitor inflation
 122   static intptr_t identity_hash_value_for(Handle obj);
 123   static intptr_t FastHashCode(Thread * Self, oop obj);
 124 
 125   // java.lang.Thread support
 126   static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj);
 127   static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj);
 128 
 129   static JavaThread* get_lock_owner(ThreadsList * t_list, Handle h_obj);
 130 
 131   // JNI detach support
 132   static void release_monitors_owned_by_thread(TRAPS);
 133   static void monitors_iterate(MonitorClosure* m);
 134 
 135   // GC: we current use aggressive monitor deflation policy
 136   // Basically we deflate all monitors that are not busy.
 137   // An adaptive profile-based deflation policy could be used if needed
 138   static void deflate_idle_monitors(DeflateMonitorCounters* counters);
 139   static void deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters);
 140   static void prepare_deflate_idle_monitors(DeflateMonitorCounters* counters);
 141   static void finish_deflate_idle_monitors(DeflateMonitorCounters* counters);
 142 
 143   // For a given monitor list: global or per-thread, deflate idle monitors
 144   static int deflate_monitor_list(ObjectMonitor** listheadp,
 145                                   ObjectMonitor** freeHeadp,
 146                                   ObjectMonitor** freeTailp);
 147   static bool deflate_monitor(ObjectMonitor* mid, oop obj,
 148                               ObjectMonitor** freeHeadp,
 149                               ObjectMonitor** freeTailp);


< prev index next >