Mercurial > hg > truffle
annotate src/share/vm/gc_implementation/shared/concurrentGCThread.hpp @ 5935:a735aec54ea4
7123170: JCK vm/jvmti/ResourceExhausted/resexh001/resexh00101/ tests fails since 7u4 b02
Summary: The JVMTI ResourceExhausted events must be generated in all places where OOME is thrown
Reviewed-by: acorn, coleenp, dcubed, dholmes, dsamersoff, jwilhelm, tonyp
Contributed-by: serguei.spitsyn@oracle.com
author | sspitsyn |
---|---|
date | Wed, 14 Mar 2012 20:06:48 -0700 |
parents | 2a241e764894 |
children | db9981fd3124 |
rev | line source |
---|---|
342 | 1 /* |
1972 | 2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
342 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
844
diff
changeset
|
21 * questions. |
342 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_CONCURRENTGCTHREAD_HPP |
26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_CONCURRENTGCTHREAD_HPP | |
27 | |
28 #ifndef SERIALGC | |
29 #include "runtime/thread.hpp" | |
30 #endif | |
31 | |
342 | 32 class VoidClosure; |
33 | |
34 // A SuspendibleThreadSet is (obviously) a set of threads that can be | |
35 // suspended. A thread can join and later leave the set, and periodically | |
36 // yield. If some thread (not in the set) requests, via suspend_all, that | |
37 // the threads be suspended, then the requesting thread is blocked until | |
38 // all the threads in the set have yielded or left the set. (Threads may | |
39 // not enter the set when an attempted suspension is in progress.) The | |
40 // suspending thread later calls resume_all, allowing the suspended threads | |
41 // to continue. | |
42 | |
43 class SuspendibleThreadSet { | |
44 Monitor* _m; | |
45 int _async; | |
46 bool _async_stop; | |
47 int _async_stopped; | |
48 bool _initialized; | |
49 double _suspend_all_start; | |
50 | |
51 void initialize_work(); | |
52 | |
53 public: | |
54 SuspendibleThreadSet() : _initialized(false) {} | |
55 | |
56 // Add the current thread to the set. May block if a suspension | |
57 // is in progress. | |
58 void join(); | |
59 // Removes the current thread from the set. | |
60 void leave(); | |
61 // Returns "true" iff an suspension is in progress. | |
62 bool should_yield() { return _async_stop; } | |
63 // Suspends the current thread if a suspension is in progress (for | |
64 // the duration of the suspension.) | |
65 void yield(const char* id); | |
66 // Return when all threads in the set are suspended. | |
67 void suspend_all(); | |
68 // Allow suspended threads to resume. | |
69 void resume_all(); | |
70 // Redundant initializations okay. | |
71 void initialize() { | |
72 // Double-check dirty read idiom. | |
73 if (!_initialized) initialize_work(); | |
74 } | |
75 }; | |
76 | |
77 | |
78 class ConcurrentGCThread: public NamedThread { | |
79 friend class VMStructs; | |
80 | |
81 protected: | |
794 | 82 bool _should_terminate; |
83 bool _has_terminated; | |
342 | 84 |
85 enum CGC_flag_type { | |
86 CGC_nil = 0x0, | |
87 CGC_dont_suspend = 0x1, | |
88 CGC_CGC_safepoint = 0x2, | |
89 CGC_VM_safepoint = 0x4 | |
90 }; | |
91 | |
92 static int _CGC_flag; | |
93 | |
94 static bool CGC_flag_is_set(int b) { return (_CGC_flag & b) != 0; } | |
95 static int set_CGC_flag(int b) { return _CGC_flag |= b; } | |
96 static int reset_CGC_flag(int b) { return _CGC_flag &= ~b; } | |
97 | |
98 // All instances share this one set. | |
99 static SuspendibleThreadSet _sts; | |
100 | |
101 // Create and start the thread (setting it's priority high.) | |
102 void create_and_start(); | |
103 | |
104 // Do initialization steps in the thread: record stack base and size, | |
105 // init thread local storage, set JNI handle block. | |
106 void initialize_in_thread(); | |
107 | |
108 // Wait until Universe::is_fully_initialized(); | |
109 void wait_for_universe_init(); | |
110 | |
111 // Record that the current thread is terminating, and will do more | |
112 // concurrent work. | |
113 void terminate(); | |
114 | |
115 public: | |
116 // Constructor | |
117 | |
118 ConcurrentGCThread(); | |
119 ~ConcurrentGCThread() {} // Exists to call NamedThread destructor. | |
120 | |
121 // Tester | |
122 bool is_ConcurrentGC_thread() const { return true; } | |
123 | |
124 static void safepoint_synchronize(); | |
125 static void safepoint_desynchronize(); | |
126 | |
127 // All overridings should probably do _sts::yield, but we allow | |
128 // overriding for distinguished debugging messages. Default is to do | |
129 // nothing. | |
130 virtual void yield() {} | |
131 | |
132 bool should_yield() { return _sts.should_yield(); } | |
133 | |
134 // they are prefixed by sts since there are already yield() and | |
135 // should_yield() (non-static) methods in this class and it was an | |
136 // easy way to differentiate them. | |
137 static void stsYield(const char* id); | |
138 static bool stsShouldYield(); | |
139 static void stsJoin(); | |
140 static void stsLeave(); | |
141 | |
142 }; | |
143 | |
144 // The SurrogateLockerThread is used by concurrent GC threads for | |
145 // manipulating Java monitors, in particular, currently for | |
146 // manipulating the pending_list_lock. XXX | |
147 class SurrogateLockerThread: public JavaThread { | |
148 friend class VMStructs; | |
149 public: | |
150 enum SLT_msg_type { | |
151 empty = 0, // no message | |
152 acquirePLL, // acquire pending list lock | |
153 releaseAndNotifyPLL // notify and release pending list lock | |
154 }; | |
155 private: | |
156 // the following are shared with the CMSThread | |
157 SLT_msg_type _buffer; // communication buffer | |
158 Monitor _monitor; // monitor controlling buffer | |
159 BasicLock _basicLock; // used for PLL locking | |
160 | |
161 public: | |
162 static SurrogateLockerThread* make(TRAPS); | |
163 | |
164 SurrogateLockerThread(); | |
165 | |
166 bool is_hidden_from_external_view() const { return true; } | |
167 | |
168 void loop(); // main method | |
169 | |
170 void manipulatePLL(SLT_msg_type msg); | |
171 | |
172 }; | |
1972 | 173 |
174 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_CONCURRENTGCTHREAD_HPP |