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 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
26 #define SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
27
28 #include "oops/markOop.hpp"
29 #include "runtime/basicLock.hpp"
30 #include "runtime/handles.hpp"
31 #include "runtime/perfData.hpp"
32
33 class ObjectMonitor;
34
35 struct DeflateMonitorCounters {
36 int nInuse; // currently associated with objects
37 int nInCirculation; // extant
38 int nScavenged; // reclaimed
39 };
40
41 class ObjectSynchronizer : AllStatic {
42 friend class VMStructs;
43 public:
44 typedef enum {
45 owner_self,
46 owner_none,
47 owner_other
142 static int deflate_monitor_list(ObjectMonitor** listheadp,
143 ObjectMonitor** freeHeadp,
144 ObjectMonitor** freeTailp);
145 static bool deflate_monitor(ObjectMonitor* mid, oop obj,
146 ObjectMonitor** freeHeadp,
147 ObjectMonitor** freeTailp);
148 static bool is_cleanup_needed();
149 static void oops_do(OopClosure* f);
150 // Process oops in thread local used monitors
151 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
152
153 // debugging
154 static void sanity_checks(const bool verbose,
155 const unsigned int cache_line_size,
156 int *error_cnt_ptr, int *warning_cnt_ptr);
157 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
158
159 private:
160 enum { _BLOCKSIZE = 128 };
161 // global list of blocks of monitors
162 // gBlockList is really PaddedEnd<ObjectMonitor> *, but we don't
163 // want to expose the PaddedEnd template more than necessary.
164 static ObjectMonitor * volatile gBlockList;
165 // global monitor free list
166 static ObjectMonitor * volatile gFreeList;
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
|
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 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
26 #define SHARE_VM_RUNTIME_SYNCHRONIZER_HPP
27
28 #include "memory/padded.hpp"
29 #include "oops/markOop.hpp"
30 #include "runtime/basicLock.hpp"
31 #include "runtime/handles.hpp"
32 #include "runtime/perfData.hpp"
33
34 class ObjectMonitor;
35
36 struct DeflateMonitorCounters {
37 int nInuse; // currently associated with objects
38 int nInCirculation; // extant
39 int nScavenged; // reclaimed
40 };
41
42 class ObjectSynchronizer : AllStatic {
43 friend class VMStructs;
44 public:
45 typedef enum {
46 owner_self,
47 owner_none,
48 owner_other
143 static int deflate_monitor_list(ObjectMonitor** listheadp,
144 ObjectMonitor** freeHeadp,
145 ObjectMonitor** freeTailp);
146 static bool deflate_monitor(ObjectMonitor* mid, oop obj,
147 ObjectMonitor** freeHeadp,
148 ObjectMonitor** freeTailp);
149 static bool is_cleanup_needed();
150 static void oops_do(OopClosure* f);
151 // Process oops in thread local used monitors
152 static void thread_local_used_oops_do(Thread* thread, OopClosure* f);
153
154 // debugging
155 static void sanity_checks(const bool verbose,
156 const unsigned int cache_line_size,
157 int *error_cnt_ptr, int *warning_cnt_ptr);
158 static int verify_objmon_isinpool(ObjectMonitor *addr) PRODUCT_RETURN0;
159
160 private:
161 enum { _BLOCKSIZE = 128 };
162 // global list of blocks of monitors
163 static PaddedEnd<ObjectMonitor> * volatile gBlockList;
164 // global monitor free list
165 static ObjectMonitor * volatile gFreeList;
166 // global monitor in-use list, for moribund threads,
167 // monitors they inflated need to be scanned for deflation
168 static ObjectMonitor * volatile gOmInUseList;
169 // count of entries in gOmInUseList
170 static int gOmInUseCount;
171
172 // Process oops in all monitors
173 static void global_oops_do(OopClosure* f);
174 // Process oops in all global used monitors (i.e. moribund thread's monitors)
175 static void global_used_oops_do(OopClosure* f);
176 // Process oops in monitors on the given list
177 static void list_oops_do(ObjectMonitor* list, OopClosure* f);
178
179 };
180
181 // ObjectLocker enforced balanced locking and can never thrown an
182 // IllegalMonitorStateException. However, a pending exception may
183 // have to pass through, and we must also be able to deal with
|