1 /*
2 * Copyright (c) 2005, 2006, 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 *
23 */
24
25 // This class describes operations to implement Store-Free Biased
26 // Locking. The high-level properties of the scheme are similar to
27 // IBM's lock reservation, Dice-Moir-Scherer QR locks, and other biased
28 // locking mechanisms. The principal difference is in the handling of
29 // recursive locking which is how this technique achieves a more
30 // efficient fast path than these other schemes.
31 //
32 // The basic observation is that in HotSpot's current fast locking
33 // scheme, recursive locking (in the fast path) causes no update to
34 // the object header. The recursion is described simply by stack
35 // records containing a specific value (NULL). Only the last unlock by
36 // a given thread causes an update to the object header.
37 //
38 // This observation, coupled with the fact that HotSpot only compiles
39 // methods for which monitor matching is obeyed (and which therefore
40 // can not throw IllegalMonitorStateException), implies that we can
41 // completely eliminate modifications to the object header for
42 // recursive locking in compiled code, and perform similar recursion
43 // checks and throwing of IllegalMonitorStateException in the
44 // interpreter with little or no impact on the performance of the fast
168 static bool enabled();
169
170 // This should be called by JavaThreads to revoke the bias of an object
171 static Condition revoke_and_rebias(Handle obj, bool attempt_rebias, TRAPS);
172
173 // These do not allow rebiasing; they are used by deoptimization to
174 // ensure that monitors on the stack can be migrated
175 static void revoke(GrowableArray<Handle>* objs);
176 static void revoke_at_safepoint(Handle obj);
177 static void revoke_at_safepoint(GrowableArray<Handle>* objs);
178
179 static void print_counters() { _counters.print(); }
180 static BiasedLockingCounters* counters() { return &_counters; }
181
182 // These routines are GC-related and should not be called by end
183 // users. GCs which do not do preservation of mark words do not need
184 // to call these routines.
185 static void preserve_marks();
186 static void restore_marks();
187 };
|
1 /*
2 * Copyright (c) 2005, 2010, 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 *
23 */
24
25 #ifndef SHARE_VM_RUNTIME_BIASEDLOCKING_HPP
26 #define SHARE_VM_RUNTIME_BIASEDLOCKING_HPP
27
28 #include "runtime/handles.hpp"
29 #include "utilities/growableArray.hpp"
30
31 // This class describes operations to implement Store-Free Biased
32 // Locking. The high-level properties of the scheme are similar to
33 // IBM's lock reservation, Dice-Moir-Scherer QR locks, and other biased
34 // locking mechanisms. The principal difference is in the handling of
35 // recursive locking which is how this technique achieves a more
36 // efficient fast path than these other schemes.
37 //
38 // The basic observation is that in HotSpot's current fast locking
39 // scheme, recursive locking (in the fast path) causes no update to
40 // the object header. The recursion is described simply by stack
41 // records containing a specific value (NULL). Only the last unlock by
42 // a given thread causes an update to the object header.
43 //
44 // This observation, coupled with the fact that HotSpot only compiles
45 // methods for which monitor matching is obeyed (and which therefore
46 // can not throw IllegalMonitorStateException), implies that we can
47 // completely eliminate modifications to the object header for
48 // recursive locking in compiled code, and perform similar recursion
49 // checks and throwing of IllegalMonitorStateException in the
50 // interpreter with little or no impact on the performance of the fast
174 static bool enabled();
175
176 // This should be called by JavaThreads to revoke the bias of an object
177 static Condition revoke_and_rebias(Handle obj, bool attempt_rebias, TRAPS);
178
179 // These do not allow rebiasing; they are used by deoptimization to
180 // ensure that monitors on the stack can be migrated
181 static void revoke(GrowableArray<Handle>* objs);
182 static void revoke_at_safepoint(Handle obj);
183 static void revoke_at_safepoint(GrowableArray<Handle>* objs);
184
185 static void print_counters() { _counters.print(); }
186 static BiasedLockingCounters* counters() { return &_counters; }
187
188 // These routines are GC-related and should not be called by end
189 // users. GCs which do not do preservation of mark words do not need
190 // to call these routines.
191 static void preserve_marks();
192 static void restore_marks();
193 };
194
195 #endif // SHARE_VM_RUNTIME_BIASEDLOCKING_HPP
|