Mercurial > hg > truffle
comparison src/share/vm/memory/gcLocker.hpp @ 17891:b6a2ba7d3ea7 hs25.20-b11
Merge
author | amurillo |
---|---|
date | Thu, 17 Apr 2014 16:09:07 -0700 |
parents | 9c3dc501b5eb |
children | 52b4284cb496 |
comparison
equal
deleted
inserted
replaced
17862:70dc2c030c69 | 17891:b6a2ba7d3ea7 |
---|---|
52 // currently in a critical region. It's only kept up to date when | 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 | 53 // _needs_gc is true. The current value is computed during |
54 // safepointing and decremented during the slow path of GC_locker | 54 // safepointing and decremented during the slow path of GC_locker |
55 // unlocking. | 55 // unlocking. |
56 static volatile jint _jni_lock_count; // number of jni active instances. | 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 | 57 static volatile bool _needs_gc; // heap is filling, we need a GC |
60 // note: bool is typedef'd as jint | 58 // note: bool is typedef'd as jint |
61 static volatile bool _doing_gc; // unlock_critical() is doing a GC | 59 static volatile bool _doing_gc; // unlock_critical() is doing a GC |
62 | 60 |
63 #ifdef ASSERT | 61 #ifdef ASSERT |
64 // This lock count is updated for all operations and is used to | 62 // This lock count is updated for all operations and is used to |
65 // validate the jni_lock_count that is computed during safepoints. | 63 // validate the jni_lock_count that is computed during safepoints. |
66 static volatile jint _debug_jni_lock_count; | 64 static volatile jint _debug_jni_lock_count; |
67 #endif | 65 #endif |
68 | |
69 // Accessors | |
70 static bool is_jni_active() { | |
71 assert(_needs_gc, "only valid when _needs_gc is set"); | |
72 return _jni_lock_count > 0; | |
73 } | |
74 | 66 |
75 // At a safepoint, visit all threads and count the number of active | 67 // At a safepoint, visit all threads and count the number of active |
76 // critical sections. This is used to ensure that all active | 68 // critical sections. This is used to ensure that all active |
77 // critical sections are exited before a new one is started. | 69 // critical sections are exited before a new one is started. |
78 static void verify_critical_count() NOT_DEBUG_RETURN; | 70 static void verify_critical_count() NOT_DEBUG_RETURN; |
80 static void jni_lock(JavaThread* thread); | 72 static void jni_lock(JavaThread* thread); |
81 static void jni_unlock(JavaThread* thread); | 73 static void jni_unlock(JavaThread* thread); |
82 | 74 |
83 static bool is_active_internal() { | 75 static bool is_active_internal() { |
84 verify_critical_count(); | 76 verify_critical_count(); |
85 return _lock_count > 0 || _jni_lock_count > 0; | 77 return _jni_lock_count > 0; |
86 } | 78 } |
87 | 79 |
88 public: | 80 public: |
89 // Accessors | 81 // Accessors |
90 static bool is_active() { | 82 static bool is_active() { |
129 // set at a subsequent safepoint and/or cleared under the | 121 // set at a subsequent safepoint and/or cleared under the |
130 // JNICritical_lock, so the caller may not safely assert upon | 122 // JNICritical_lock, so the caller may not safely assert upon |
131 // return from this method that "!needs_gc()" since that is | 123 // return from this method that "!needs_gc()" since that is |
132 // not a stable predicate. | 124 // not a stable predicate. |
133 static void stall_until_clear(); | 125 static void stall_until_clear(); |
134 | |
135 // Non-structured GC locking: currently needed for JNI. Use with care! | |
136 static void lock(); | |
137 static void unlock(); | |
138 | 126 |
139 // The following two methods are used for JNI critical regions. | 127 // The following two methods are used for JNI critical regions. |
140 // If we find that we failed to perform a GC because the GC_locker | 128 // If we find that we failed to perform a GC because the GC_locker |
141 // was active, arrange for one as soon as possible by allowing | 129 // was active, arrange for one as soon as possible by allowing |
142 // all threads in critical regions to complete, but not allowing | 130 // all threads in critical regions to complete, but not allowing |