< prev index next >

src/share/vm/runtime/synchronizer.hpp

Print this page
rev 13265 : 8180932: Parallelize safepoint cleanup
Summary: Provide infrastructure to do safepoint cleanup tasks using parallel worker threads
Reviewed-by: dholmes, rehn, dcubed, thartmann


  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 "oops/markOop.hpp"
  29 #include "runtime/basicLock.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "runtime/perfData.hpp"
  32 
  33 class ObjectMonitor;
  34 






  35 class ObjectSynchronizer : AllStatic {
  36   friend class VMStructs;
  37  public:
  38   typedef enum {
  39     owner_self,
  40     owner_none,
  41     owner_other
  42   } LockOwnership;
  43 
  44   typedef enum {
  45     inflate_cause_vm_internal = 0,
  46     inflate_cause_monitor_enter = 1,
  47     inflate_cause_wait = 2,
  48     inflate_cause_notify = 3,
  49     inflate_cause_hash_code = 4,
  50     inflate_cause_jni_enter = 5,
  51     inflate_cause_jni_exit = 6,
  52     inflate_cause_nof = 7 // Number of causes
  53   } InflateCause;
  54 


 110   static const char* inflate_cause_name(const InflateCause cause);
 111 
 112   // Returns the identity hash value for an oop
 113   // NOTE: It may cause monitor inflation
 114   static intptr_t identity_hash_value_for(Handle obj);
 115   static intptr_t FastHashCode(Thread * Self, oop obj);
 116 
 117   // java.lang.Thread support
 118   static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj);
 119   static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj);
 120 
 121   static JavaThread* get_lock_owner(Handle h_obj, bool doLock);
 122 
 123   // JNI detach support
 124   static void release_monitors_owned_by_thread(TRAPS);
 125   static void monitors_iterate(MonitorClosure* m);
 126 
 127   // GC: we current use aggressive monitor deflation policy
 128   // Basically we deflate all monitors that are not busy.
 129   // An adaptive profile-based deflation policy could be used if needed
 130   static void deflate_idle_monitors();




 131   // For a given monitor list: global or per-thread, deflate idle monitors
 132   static int deflate_monitor_list(ObjectMonitor** listheadp,
 133                                   ObjectMonitor** freeHeadp,
 134                                   ObjectMonitor** freeTailp);
 135   static bool deflate_monitor(ObjectMonitor* mid, oop obj,
 136                               ObjectMonitor** freeHeadp,
 137                               ObjectMonitor** freeTailp);
 138   static bool is_cleanup_needed();
 139   static void oops_do(OopClosure* f);
 140   // Process oops in thread local used monitors
 141   static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
 142 
 143   // debugging
 144   static void sanity_checks(const bool verbose,
 145                             const unsigned int cache_line_size,
 146                             int *error_cnt_ptr, int *warning_cnt_ptr);
 147   static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
 148 
 149  private:
 150   enum { _BLOCKSIZE = 128 };




  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 "oops/markOop.hpp"
  29 #include "runtime/basicLock.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "runtime/perfData.hpp"
  32 
  33 class ObjectMonitor;
  34 
  35 struct DeflateMonitorCounters {
  36   int nInuse;          // currently associated with objects
  37   int nInCirculation;  // extant
  38   int nScavenged;      // reclaimed
  39 };
  40 
  41 class ObjectSynchronizer : AllStatic {
  42   friend class VMStructs;
  43  public:
  44   typedef enum {
  45     owner_self,
  46     owner_none,
  47     owner_other
  48   } LockOwnership;
  49 
  50   typedef enum {
  51     inflate_cause_vm_internal = 0,
  52     inflate_cause_monitor_enter = 1,
  53     inflate_cause_wait = 2,
  54     inflate_cause_notify = 3,
  55     inflate_cause_hash_code = 4,
  56     inflate_cause_jni_enter = 5,
  57     inflate_cause_jni_exit = 6,
  58     inflate_cause_nof = 7 // Number of causes
  59   } InflateCause;
  60 


 116   static const char* inflate_cause_name(const InflateCause cause);
 117 
 118   // Returns the identity hash value for an oop
 119   // NOTE: It may cause monitor inflation
 120   static intptr_t identity_hash_value_for(Handle obj);
 121   static intptr_t FastHashCode(Thread * Self, oop obj);
 122 
 123   // java.lang.Thread support
 124   static bool current_thread_holds_lock(JavaThread* thread, Handle h_obj);
 125   static LockOwnership query_lock_ownership(JavaThread * self, Handle h_obj);
 126 
 127   static JavaThread* get_lock_owner(Handle h_obj, bool doLock);
 128 
 129   // JNI detach support
 130   static void release_monitors_owned_by_thread(TRAPS);
 131   static void monitors_iterate(MonitorClosure* m);
 132 
 133   // GC: we current use aggressive monitor deflation policy
 134   // Basically we deflate all monitors that are not busy.
 135   // An adaptive profile-based deflation policy could be used if needed
 136   static void deflate_idle_monitors(DeflateMonitorCounters* counters);
 137   static void deflate_thread_local_monitors(Thread* thread, DeflateMonitorCounters* counters);
 138   static void prepare_deflate_idle_monitors(DeflateMonitorCounters* counters);
 139   static void finish_deflate_idle_monitors(DeflateMonitorCounters* counters);
 140 
 141   // For a given monitor list: global or per-thread, deflate idle monitors
 142   static int deflate_monitor_list(ObjectMonitor** listheadp,
 143                                   ObjectMonitor** freeHeadp,
 144                                   ObjectMonitor** freeTailp);
 145   static bool deflate_monitor(ObjectMonitor* mid, oop obj,
 146                               ObjectMonitor** freeHeadp,
 147                               ObjectMonitor** freeTailp);
 148   static bool is_cleanup_needed();
 149   static void oops_do(OopClosure* f);
 150   // Process oops in thread local used monitors
 151   static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
 152 
 153   // debugging
 154   static void sanity_checks(const bool verbose,
 155                             const unsigned int cache_line_size,
 156                             int *error_cnt_ptr, int *warning_cnt_ptr);
 157   static int  verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
 158 
 159  private:
 160   enum { _BLOCKSIZE = 128 };


< prev index next >