< prev index next >

src/hotspot/share/runtime/threadSMR.hpp

Print this page
rev 49501 : 8200374: Add ThreadsSMRSupport::verify_hazard_pointer_scanned() to verify threads_do().
   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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_THREADSMR_HPP
  26 #define SHARE_VM_RUNTIME_THREADSMR_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/timer.hpp"
  30 


  31 // Thread Safe Memory Reclamation (Thread-SMR) support.
  32 //
  33 // ThreadsListHandles are used to safely perform operations on one or more
  34 // threads without the risk of the thread or threads exiting during the
  35 // operation. It is no longer necessary to hold the Threads_lock to safely
  36 // perform an operation on a target thread.
  37 //
  38 // There are several different ways to refer to java.lang.Thread objects
  39 // so we have a few ways to get a protected JavaThread *:
  40 //
  41 // JNI jobject example:
  42 //   jobject jthread = ...;
  43 //   :
  44 //   ThreadsListHandle tlh;
  45 //   JavaThread* jt = NULL;
  46 //   bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &jt, NULL);
  47 //   if (is_alive) {
  48 //     :  // do stuff with 'jt'...
  49 //   }
  50 //


 107   static ThreadsList*          _to_delete_list;
 108   static uint                  _to_delete_list_cnt;
 109   static uint                  _to_delete_list_max;
 110 
 111   static ThreadsList *acquire_stable_list_fast_path(Thread *self);
 112   static ThreadsList *acquire_stable_list_nested_path(Thread *self);
 113   static void add_deleted_thread_times(uint add_value);
 114   static void add_tlh_times(uint add_value);
 115   static void clear_delete_notify();
 116   static Monitor* delete_lock() { return _delete_lock; }
 117   static bool delete_notify();
 118   static void free_list(ThreadsList* threads);
 119   static void inc_deleted_thread_cnt();
 120   static void inc_java_thread_list_alloc_cnt();
 121   static void inc_tlh_cnt();
 122   static bool is_a_protected_JavaThread(JavaThread *thread);
 123   static void release_stable_list_fast_path(Thread *self);
 124   static void release_stable_list_nested_path(Thread *self);
 125   static void release_stable_list_wake_up(char *log_str);
 126   static void set_delete_notify();


 127   static void update_deleted_thread_time_max(uint new_value);
 128   static void update_java_thread_list_max(uint new_value);
 129   static void update_tlh_time_max(uint new_value);

 130   static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
 131 
 132  public:
 133   static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
 134   static void add_thread(JavaThread *thread);
 135   static ThreadsList* get_java_thread_list();
 136   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
 137   static void release_stable_list(Thread *self);
 138   static void remove_thread(JavaThread *thread);
 139   static void smr_delete(JavaThread *thread);
 140   static void update_tlh_stats(uint millis);
 141 
 142   // Logging and printing support:
 143   static void log_statistics();
 144   static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
 145   static void print_info_on(outputStream* st);
 146 };
 147 
 148 // A fast list of JavaThreads.
 149 //


   1 /*
   2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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_THREADSMR_HPP
  26 #define SHARE_VM_RUNTIME_THREADSMR_HPP
  27 
  28 #include "memory/allocation.hpp"
  29 #include "runtime/timer.hpp"
  30 
  31 class ThreadClosure;
  32 
  33 // Thread Safe Memory Reclamation (Thread-SMR) support.
  34 //
  35 // ThreadsListHandles are used to safely perform operations on one or more
  36 // threads without the risk of the thread or threads exiting during the
  37 // operation. It is no longer necessary to hold the Threads_lock to safely
  38 // perform an operation on a target thread.
  39 //
  40 // There are several different ways to refer to java.lang.Thread objects
  41 // so we have a few ways to get a protected JavaThread *:
  42 //
  43 // JNI jobject example:
  44 //   jobject jthread = ...;
  45 //   :
  46 //   ThreadsListHandle tlh;
  47 //   JavaThread* jt = NULL;
  48 //   bool is_alive = tlh.cv_internal_thread_to_JavaThread(jthread, &jt, NULL);
  49 //   if (is_alive) {
  50 //     :  // do stuff with 'jt'...
  51 //   }
  52 //


 109   static ThreadsList*          _to_delete_list;
 110   static uint                  _to_delete_list_cnt;
 111   static uint                  _to_delete_list_max;
 112 
 113   static ThreadsList *acquire_stable_list_fast_path(Thread *self);
 114   static ThreadsList *acquire_stable_list_nested_path(Thread *self);
 115   static void add_deleted_thread_times(uint add_value);
 116   static void add_tlh_times(uint add_value);
 117   static void clear_delete_notify();
 118   static Monitor* delete_lock() { return _delete_lock; }
 119   static bool delete_notify();
 120   static void free_list(ThreadsList* threads);
 121   static void inc_deleted_thread_cnt();
 122   static void inc_java_thread_list_alloc_cnt();
 123   static void inc_tlh_cnt();
 124   static bool is_a_protected_JavaThread(JavaThread *thread);
 125   static void release_stable_list_fast_path(Thread *self);
 126   static void release_stable_list_nested_path(Thread *self);
 127   static void release_stable_list_wake_up(char *log_str);
 128   static void set_delete_notify();
 129   static void threads_do(ThreadClosure *tc);
 130   static void threads_do(ThreadClosure *tc, ThreadsList *list);
 131   static void update_deleted_thread_time_max(uint new_value);
 132   static void update_java_thread_list_max(uint new_value);
 133   static void update_tlh_time_max(uint new_value);
 134   static void verify_hazard_pointer_scanned(Thread *self, ThreadsList *threads);
 135   static ThreadsList* xchg_java_thread_list(ThreadsList* new_list);
 136 
 137  public:
 138   static ThreadsList *acquire_stable_list(Thread *self, bool is_ThreadsListSetter);
 139   static void add_thread(JavaThread *thread);
 140   static ThreadsList* get_java_thread_list();
 141   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
 142   static void release_stable_list(Thread *self);
 143   static void remove_thread(JavaThread *thread);
 144   static void smr_delete(JavaThread *thread);
 145   static void update_tlh_stats(uint millis);
 146 
 147   // Logging and printing support:
 148   static void log_statistics();
 149   static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
 150   static void print_info_on(outputStream* st);
 151 };
 152 
 153 // A fast list of JavaThreads.
 154 //


< prev index next >