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
45 // The direct lock/unlock calls do not force a collection if an unlock
46 // decrements the count to zero. Avoid calling these if at all possible.
47
48 class GC_locker: public AllStatic {
49 private:
50 static volatile jint _jni_lock_count; // number of jni active instances
51 static volatile jint _lock_count; // number of other active instances
52 static volatile bool _needs_gc; // heap is filling, we need a GC
53 // note: bool is typedef'd as jint
54 static volatile bool _doing_gc; // unlock_critical() is doing a GC
55
56 // Accessors
57 static bool is_jni_active() {
58 return _jni_lock_count > 0;
59 }
60
61 static void set_needs_gc() {
62 assert(SafepointSynchronize::is_at_safepoint(),
63 "needs_gc is only set at a safepoint");
|
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 static volatile jint _jni_lock_count; // number of jni active instances
55 static volatile jint _lock_count; // number of other active instances
56 static volatile bool _needs_gc; // heap is filling, we need a GC
57 // note: bool is typedef'd as jint
58 static volatile bool _doing_gc; // unlock_critical() is doing a GC
59
60 // Accessors
61 static bool is_jni_active() {
62 return _jni_lock_count > 0;
63 }
64
65 static void set_needs_gc() {
66 assert(SafepointSynchronize::is_at_safepoint(),
67 "needs_gc is only set at a safepoint");
|