1 /*
2 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
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 *
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 *
167 // global monitor in-use list, for moribund threads,
168 // monitors they inflated need to be scanned for deflation
169 static ObjectMonitor * volatile gOmInUseList;
170 // count of entries in gOmInUseList
171 static int gOmInUseCount;
172
173 // Process oops in all monitors
174 static void global_oops_do(OopClosure* f);
175 // Process oops in all global used monitors (i.e. moribund thread's monitors)
176 static void global_used_oops_do(OopClosure* f);
177 // Process oops in monitors on the given list
178 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
179
180 };
181
182 // ObjectLocker enforced balanced locking and can never thrown an
183 // IllegalMonitorStateException. However, a pending exception may
184 // have to pass through, and we must also be able to deal with
185 // asynchronous exceptions. The caller is responsible for checking
186 // the threads pending exception if needed.
187 // doLock was added to support classloading with UnsyncloadClass which
188 // requires flag based choice of locking the classloader lock.
189 class ObjectLocker : public StackObj {
190 private:
191 Thread* _thread;
192 Handle _obj;
193 BasicLock _lock;
194 bool _dolock; // default true
195 public:
196 ObjectLocker(Handle obj, Thread* thread, bool doLock = true);
197 ~ObjectLocker();
198
199 // Monitor behavior
200 void wait(TRAPS) { ObjectSynchronizer::wait(_obj, 0, CHECK); } // wait forever
201 void notify_all(TRAPS) { ObjectSynchronizer::notifyall(_obj, CHECK); }
202 void waitUninterruptibly(TRAPS) { ObjectSynchronizer::waitUninterruptibly(_obj, 0, CHECK); }
203 // complete_exit gives up lock completely, returning recursion count
204 // reenter reclaims lock with original recursion count
205 intptr_t complete_exit(TRAPS) { return ObjectSynchronizer::complete_exit(_obj, THREAD); }
206 void reenter(intptr_t recursion, TRAPS) { ObjectSynchronizer::reenter(_obj, recursion, CHECK); }
207 };
208
|
1 /*
2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
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 *
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 *
167 // global monitor in-use list, for moribund threads,
168 // monitors they inflated need to be scanned for deflation
169 static ObjectMonitor * volatile gOmInUseList;
170 // count of entries in gOmInUseList
171 static int gOmInUseCount;
172
173 // Process oops in all monitors
174 static void global_oops_do(OopClosure* f);
175 // Process oops in all global used monitors (i.e. moribund thread's monitors)
176 static void global_used_oops_do(OopClosure* f);
177 // Process oops in monitors on the given list
178 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
179
180 };
181
182 // ObjectLocker enforced balanced locking and can never thrown an
183 // IllegalMonitorStateException. However, a pending exception may
184 // have to pass through, and we must also be able to deal with
185 // asynchronous exceptions. The caller is responsible for checking
186 // the threads pending exception if needed.
187 class ObjectLocker : public StackObj {
188 private:
189 Thread* _thread;
190 Handle _obj;
191 BasicLock _lock;
192 bool _dolock; // default true
193 public:
194 ObjectLocker(Handle obj, Thread* thread, bool doLock = true);
195 ~ObjectLocker();
196
197 // Monitor behavior
198 void wait(TRAPS) { ObjectSynchronizer::wait(_obj, 0, CHECK); } // wait forever
199 void notify_all(TRAPS) { ObjectSynchronizer::notifyall(_obj, CHECK); }
200 void waitUninterruptibly(TRAPS) { ObjectSynchronizer::waitUninterruptibly(_obj, 0, CHECK); }
201 // complete_exit gives up lock completely, returning recursion count
202 // reenter reclaims lock with original recursion count
203 intptr_t complete_exit(TRAPS) { return ObjectSynchronizer::complete_exit(_obj, THREAD); }
204 void reenter(intptr_t recursion, TRAPS) { ObjectSynchronizer::reenter(_obj, recursion, CHECK); }
205 };
206
|