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_MEMORY_GCLOCKER_HPP
26 #define SHARE_VM_MEMORY_GCLOCKER_HPP
27
28 #include "gc_interface/collectedHeap.hpp"
29 #include "memory/genCollectedHeap.hpp"
30 #include "memory/universe.hpp"
31 #include "oops/oop.hpp"
32 #ifdef TARGET_OS_FAMILY_linux
33 # include "os_linux.inline.hpp"
34 # include "thread_linux.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_FAMILY_solaris
37 # include "os_solaris.inline.hpp"
38 # include "thread_solaris.inline.hpp"
39 #endif
40 #ifdef TARGET_OS_FAMILY_windows
41 # include "os_windows.inline.hpp"
42 # include "thread_windows.inline.hpp"
43 #endif
44 #ifdef TARGET_OS_FAMILY_bsd
45 # include "os_bsd.inline.hpp"
46 # include "thread_bsd.inline.hpp"
47 #endif
48
49 // The direct lock/unlock calls do not force a collection if an unlock
50 // decrements the count to zero. Avoid calling these if at all possible.
51
52 class GC_locker: public AllStatic {
53 private:
54 // The _jni_lock_count keeps track of the number of threads that are
55 // currently in a critical region. It's only kept up to date when
56 // _needs_gc is true. The current value is computed during
57 // safepointing and decremented during the slow path of GC_locker
58 // unlocking.
59 static volatile jint _jni_lock_count; // number of jni active instances.
60
61 static volatile jint _lock_count; // number of other active instances
62 static volatile bool _needs_gc; // heap is filling, we need a GC
63 // note: bool is typedef'd as jint
64 static volatile bool _doing_gc; // unlock_critical() is doing a GC
65
66 #ifdef ASSERT
|
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_MEMORY_GCLOCKER_HPP
26 #define SHARE_VM_MEMORY_GCLOCKER_HPP
27
28 #include "gc_interface/collectedHeap.hpp"
29 #include "memory/genCollectedHeap.hpp"
30 #include "memory/universe.hpp"
31 #include "oops/oop.hpp"
32 #include "runtime/thread.inline.hpp"
33 #ifdef TARGET_OS_FAMILY_linux
34 # include "os_linux.inline.hpp"
35 #endif
36 #ifdef TARGET_OS_FAMILY_solaris
37 # include "os_solaris.inline.hpp"
38 #endif
39 #ifdef TARGET_OS_FAMILY_windows
40 # include "os_windows.inline.hpp"
41 #endif
42 #ifdef TARGET_OS_FAMILY_bsd
43 # include "os_bsd.inline.hpp"
44 #endif
45
46 // The direct lock/unlock calls do not force a collection if an unlock
47 // decrements the count to zero. Avoid calling these if at all possible.
48
49 class GC_locker: public AllStatic {
50 private:
51 // The _jni_lock_count keeps track of the number of threads that are
52 // currently in a critical region. It's only kept up to date when
53 // _needs_gc is true. The current value is computed during
54 // safepointing and decremented during the slow path of GC_locker
55 // unlocking.
56 static volatile jint _jni_lock_count; // number of jni active instances.
57
58 static volatile jint _lock_count; // number of other active instances
59 static volatile bool _needs_gc; // heap is filling, we need a GC
60 // note: bool is typedef'd as jint
61 static volatile bool _doing_gc; // unlock_critical() is doing a GC
62
63 #ifdef ASSERT
|