1 #ifdef USE_PRAGMA_IDENT_HDR
2 #pragma ident "@(#)gcLocker.hpp 1.60 07/05/17 15:54:47 JVM"
3 #endif
4 /*
5 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 *
170 ~Pause_No_GC_Verifier() {}
171 #endif
172 };
173
174
175 // A No_Safepoint_Verifier object will throw an assertion failure if
176 // the current thread passes a possible safepoint while this object is
177 // instantiated. A safepoint, will either be: an oop allocation, blocking
178 // on a Mutex or JavaLock, or executing a VM operation.
179 //
180 // If StrictSafepointChecks is turned off, it degrades into a No_GC_Verifier
181 //
182 class No_Safepoint_Verifier : public No_GC_Verifier {
183 friend class Pause_No_Safepoint_Verifier;
184
185 private:
186 bool _activated;
187 Thread *_thread;
188 public:
189 #ifdef ASSERT
190 No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) : No_GC_Verifier(verifygc) {
191 _thread = Thread::current();
192 if (_activated) {
193 _thread->_allow_allocation_count++;
194 _thread->_allow_safepoint_count++;
195 }
196 }
197
198 ~No_Safepoint_Verifier() {
199 if (_activated) {
200 _thread->_allow_allocation_count--;
201 _thread->_allow_safepoint_count--;
202 }
203 }
204 #else
205 No_Safepoint_Verifier(bool activated = true, bool verifygc = true) : No_GC_Verifier(verifygc){}
206 ~No_Safepoint_Verifier() {}
207 #endif
208 };
209
210 // A Pause_No_Safepoint_Verifier is used to temporarily pause the
|
1 #ifdef USE_PRAGMA_IDENT_HDR
2 #pragma ident "@(#)gcLocker.hpp 1.60 07/05/17 15:54:47 JVM"
3 #endif
4 /*
5 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 *
170 ~Pause_No_GC_Verifier() {}
171 #endif
172 };
173
174
175 // A No_Safepoint_Verifier object will throw an assertion failure if
176 // the current thread passes a possible safepoint while this object is
177 // instantiated. A safepoint, will either be: an oop allocation, blocking
178 // on a Mutex or JavaLock, or executing a VM operation.
179 //
180 // If StrictSafepointChecks is turned off, it degrades into a No_GC_Verifier
181 //
182 class No_Safepoint_Verifier : public No_GC_Verifier {
183 friend class Pause_No_Safepoint_Verifier;
184
185 private:
186 bool _activated;
187 Thread *_thread;
188 public:
189 #ifdef ASSERT
190 No_Safepoint_Verifier(bool activated = true, bool verifygc = true ) :
191 No_GC_Verifier(verifygc),
192 _activated(activated) {
193 _thread = Thread::current();
194 if (_activated) {
195 _thread->_allow_allocation_count++;
196 _thread->_allow_safepoint_count++;
197 }
198 }
199
200 ~No_Safepoint_Verifier() {
201 if (_activated) {
202 _thread->_allow_allocation_count--;
203 _thread->_allow_safepoint_count--;
204 }
205 }
206 #else
207 No_Safepoint_Verifier(bool activated = true, bool verifygc = true) : No_GC_Verifier(verifygc){}
208 ~No_Safepoint_Verifier() {}
209 #endif
210 };
211
212 // A Pause_No_Safepoint_Verifier is used to temporarily pause the
|