15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #ifndef SHARE_RUNTIME_LOCKSTACK_HPP
28 #define SHARE_RUNTIME_LOCKSTACK_HPP
29
30 #include "oops/oopsHierarchy.hpp"
31 #include "utilities/globalDefinitions.hpp"
32 #include "utilities/sizes.hpp"
33
34 class JavaThread;
35 class OopClosure;
36 class outputStream;
37 template<typename>
38 class GrowableArray;
39
40 class LockStack {
41 friend class LockStackTest;
42 friend class VMStructs;
43 JVMCI_ONLY(friend class JVMCIVMStructs;)
44 public:
45 static const int CAPACITY = 8;
46 private:
47
48 // TODO: It would be very useful if JavaThread::lock_stack_offset() and friends were constexpr,
49 // but this is currently not the case because we're using offset_of() which is non-constexpr,
50 // GCC would warn about non-standard-layout types if we were using offsetof() (which *is* constexpr).
51 static const int lock_stack_offset;
52 static const int lock_stack_top_offset;
53 static const int lock_stack_base_offset;
54
55 // The offset of the next element, in bytes, relative to the JavaThread structure.
56 // We do this instead of a simple index into the array because this allows for
57 // efficient addressing in generated code.
58 uint32_t _top;
106
107 // Try recursive exit.
108 // Precondition: This lock-stack must contain the oop.
109 inline bool try_recursive_exit(oop o);
110
111 // Removes an oop from an arbitrary location of this lock-stack.
112 // Precondition: This lock-stack must contain the oop.
113 // Returns the number of oops removed.
114 inline size_t remove(oop o);
115
116 // Tests whether the oop is on this lock-stack.
117 inline bool contains(oop o) const;
118
119 // GC support
120 inline void oops_do(OopClosure* cl);
121
122 // Printing
123 void print_on(outputStream* st);
124 };
125
126 #endif // SHARE_RUNTIME_LOCKSTACK_HPP
|
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #ifndef SHARE_RUNTIME_LOCKSTACK_HPP
28 #define SHARE_RUNTIME_LOCKSTACK_HPP
29
30 #include "oops/oopsHierarchy.hpp"
31 #include "utilities/globalDefinitions.hpp"
32 #include "utilities/sizes.hpp"
33
34 class JavaThread;
35 class ObjectMonitor;
36 class OopClosure;
37 class outputStream;
38 template<typename>
39 class GrowableArray;
40 class Thread;
41
42 class LockStack {
43 friend class LockStackTest;
44 friend class VMStructs;
45 JVMCI_ONLY(friend class JVMCIVMStructs;)
46 public:
47 static const int CAPACITY = 8;
48 private:
49
50 // TODO: It would be very useful if JavaThread::lock_stack_offset() and friends were constexpr,
51 // but this is currently not the case because we're using offset_of() which is non-constexpr,
52 // GCC would warn about non-standard-layout types if we were using offsetof() (which *is* constexpr).
53 static const int lock_stack_offset;
54 static const int lock_stack_top_offset;
55 static const int lock_stack_base_offset;
56
57 // The offset of the next element, in bytes, relative to the JavaThread structure.
58 // We do this instead of a simple index into the array because this allows for
59 // efficient addressing in generated code.
60 uint32_t _top;
108
109 // Try recursive exit.
110 // Precondition: This lock-stack must contain the oop.
111 inline bool try_recursive_exit(oop o);
112
113 // Removes an oop from an arbitrary location of this lock-stack.
114 // Precondition: This lock-stack must contain the oop.
115 // Returns the number of oops removed.
116 inline size_t remove(oop o);
117
118 // Tests whether the oop is on this lock-stack.
119 inline bool contains(oop o) const;
120
121 // GC support
122 inline void oops_do(OopClosure* cl);
123
124 // Printing
125 void print_on(outputStream* st);
126 };
127
128 class OMCache {
129 friend class VMStructs;
130 public:
131 static constexpr int CAPACITY = 8;
132
133 private:
134 struct OMCacheEntry {
135 oop _oop = nullptr;
136 ObjectMonitor* _monitor = nullptr;
137 } _entries[CAPACITY];
138 const oop _null_sentinel = nullptr;
139
140 public:
141 static ByteSize entries_offset() { return byte_offset_of(OMCache, _entries); }
142 static constexpr ByteSize oop_to_oop_difference() { return in_ByteSize(sizeof(OMCacheEntry)); }
143 static constexpr ByteSize oop_to_monitor_difference() { return in_ByteSize(sizeof(oop)); }
144
145 explicit OMCache(JavaThread* jt);
146
147 inline ObjectMonitor* get_monitor(oop o);
148 inline void set_monitor(ObjectMonitor* monitor);
149 inline void clear();
150
151 };
152
153 #endif // SHARE_RUNTIME_LOCKSTACK_HPP
|