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_OOPS_OOP_HPP
26 #define SHARE_VM_OOPS_OOP_HPP
27
28 #include "gc/shared/specialized_oop_closures.hpp"
29 #include "memory/iterator.hpp"
30 #include "memory/memRegion.hpp"
31 #include "oops/metadata.hpp"
32 #include "utilities/macros.hpp"
33
34 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
35 // the format of Java objects so the fields can be accessed from C++.
36 // oopDesc is abstract.
37 // (see oopHierarchy for complete oop class hierarchy)
38 //
39 // no virtual functions allowed
40
41 // store into oop with store check
42 template <class T> inline void oop_store(T* p, oop v);
43 template <class T> inline void oop_store(volatile T* p, oop v);
44
45 extern bool always_do_update_barrier;
46
47 // Forward declarations.
48 class OopClosure;
49 class ScanClosure;
50 class FastScanClosure;
51 class FilteringClosure;
52 class BarrierSet;
58 class oopDesc {
59 friend class VMStructs;
60 friend class JVMCIVMStructs;
61 private:
62 volatile markOop _mark;
63 union _metadata {
64 Klass* _klass;
65 narrowKlass _compressed_klass;
66 } _metadata;
67
68 // Fast access to barrier set. Must be initialized.
69 static BarrierSet* _bs;
70
71 public:
72 markOop mark() const { return _mark; }
73 markOop* mark_addr() const { return (markOop*) &_mark; }
74
75 void set_mark(volatile markOop m) { _mark = m; }
76
77 inline void release_set_mark(markOop m);
78 inline markOop cas_set_mark(markOop new_mark, markOop old_mark);
79
80 // Used only to re-initialize the mark word (e.g., of promoted
81 // objects during a GC) -- requires a valid klass pointer
82 inline void init_mark();
83
84 inline Klass* klass() const;
85 inline Klass* klass_or_null() const volatile;
86 inline Klass** klass_addr();
87 inline narrowKlass* compressed_klass_addr();
88
89 inline void set_klass(Klass* k);
90
91 // For klass field compression
92 inline int klass_gap() const;
93 inline void set_klass_gap(int z);
94 // For when the klass pointer is being used as a linked list "next" field.
95 inline void set_klass_to_list_ptr(oop k);
96 inline oop list_ptr_from_klass();
97
98 // size of object header, aligned to platform wordSize
281 inline bool is_locked() const;
282 inline bool is_unlocked() const;
283 inline bool has_bias_pattern() const;
284
285 // asserts
286 inline bool is_oop(bool ignore_mark_word = false) const;
287 inline bool is_oop_or_null(bool ignore_mark_word = false) const;
288 #ifndef PRODUCT
289 inline bool is_unlocked_oop() const;
290 #endif
291
292 // garbage collection
293 inline bool is_gc_marked() const;
294
295 inline bool is_scavengable() const;
296
297 // Forward pointer operations for scavenge
298 inline bool is_forwarded() const;
299
300 inline void forward_to(oop p);
301 inline bool cas_forward_to(oop p, markOop compare);
302
303 #if INCLUDE_ALL_GCS
304 // Like "forward_to", but inserts the forwarding pointer atomically.
305 // Exactly one thread succeeds in inserting the forwarding pointer, and
306 // this call returns "NULL" for that thread; any other thread has the
307 // value of the forwarding pointer returned and does not modify "this".
308 inline oop forward_to_atomic(oop p);
309 #endif // INCLUDE_ALL_GCS
310
311 inline oop forwardee() const;
312
313 // Age of object during scavenge
314 inline uint age() const;
315 inline void incr_age();
316
317 // mark-sweep support
318 void follow_body(int begin, int end);
319
320 // Fast access to barrier set
321 static BarrierSet* bs() { return _bs; }
|
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_OOPS_OOP_HPP
26 #define SHARE_VM_OOPS_OOP_HPP
27
28 #include "gc/shared/specialized_oop_closures.hpp"
29 #include "memory/iterator.hpp"
30 #include "memory/memRegion.hpp"
31 #include "oops/metadata.hpp"
32 #include "utilities/macros.hpp"
33 #include "runtime/atomic.hpp"
34
35 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe
36 // the format of Java objects so the fields can be accessed from C++.
37 // oopDesc is abstract.
38 // (see oopHierarchy for complete oop class hierarchy)
39 //
40 // no virtual functions allowed
41
42 // store into oop with store check
43 template <class T> inline void oop_store(T* p, oop v);
44 template <class T> inline void oop_store(volatile T* p, oop v);
45
46 extern bool always_do_update_barrier;
47
48 // Forward declarations.
49 class OopClosure;
50 class ScanClosure;
51 class FastScanClosure;
52 class FilteringClosure;
53 class BarrierSet;
59 class oopDesc {
60 friend class VMStructs;
61 friend class JVMCIVMStructs;
62 private:
63 volatile markOop _mark;
64 union _metadata {
65 Klass* _klass;
66 narrowKlass _compressed_klass;
67 } _metadata;
68
69 // Fast access to barrier set. Must be initialized.
70 static BarrierSet* _bs;
71
72 public:
73 markOop mark() const { return _mark; }
74 markOop* mark_addr() const { return (markOop*) &_mark; }
75
76 void set_mark(volatile markOop m) { _mark = m; }
77
78 inline void release_set_mark(markOop m);
79 inline markOop cas_set_mark(markOop new_mark, markOop old_mark, memory_order order = memory_order_seq_cst);
80
81 // Used only to re-initialize the mark word (e.g., of promoted
82 // objects during a GC) -- requires a valid klass pointer
83 inline void init_mark();
84
85 inline Klass* klass() const;
86 inline Klass* klass_or_null() const volatile;
87 inline Klass** klass_addr();
88 inline narrowKlass* compressed_klass_addr();
89
90 inline void set_klass(Klass* k);
91
92 // For klass field compression
93 inline int klass_gap() const;
94 inline void set_klass_gap(int z);
95 // For when the klass pointer is being used as a linked list "next" field.
96 inline void set_klass_to_list_ptr(oop k);
97 inline oop list_ptr_from_klass();
98
99 // size of object header, aligned to platform wordSize
282 inline bool is_locked() const;
283 inline bool is_unlocked() const;
284 inline bool has_bias_pattern() const;
285
286 // asserts
287 inline bool is_oop(bool ignore_mark_word = false) const;
288 inline bool is_oop_or_null(bool ignore_mark_word = false) const;
289 #ifndef PRODUCT
290 inline bool is_unlocked_oop() const;
291 #endif
292
293 // garbage collection
294 inline bool is_gc_marked() const;
295
296 inline bool is_scavengable() const;
297
298 // Forward pointer operations for scavenge
299 inline bool is_forwarded() const;
300
301 inline void forward_to(oop p);
302 inline bool cas_forward_to(oop p, markOop compare, memory_order order = memory_order_seq_cst);
303
304 #if INCLUDE_ALL_GCS
305 // Like "forward_to", but inserts the forwarding pointer atomically.
306 // Exactly one thread succeeds in inserting the forwarding pointer, and
307 // this call returns "NULL" for that thread; any other thread has the
308 // value of the forwarding pointer returned and does not modify "this".
309 inline oop forward_to_atomic(oop p);
310 #endif // INCLUDE_ALL_GCS
311
312 inline oop forwardee() const;
313
314 // Age of object during scavenge
315 inline uint age() const;
316 inline void incr_age();
317
318 // mark-sweep support
319 void follow_body(int begin, int end);
320
321 // Fast access to barrier set
322 static BarrierSet* bs() { return _bs; }
|