Mercurial > hg > truffle
comparison src/share/vm/oops/oop.hpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | b632e80fc9dc |
children | 22b8d3d181d9 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
26 #define SHARE_VM_OOPS_OOP_HPP | 26 #define SHARE_VM_OOPS_OOP_HPP |
27 | 27 |
28 #include "memory/iterator.hpp" | 28 #include "memory/iterator.hpp" |
29 #include "memory/memRegion.hpp" | 29 #include "memory/memRegion.hpp" |
30 #include "memory/specialized_oop_closures.hpp" | 30 #include "memory/specialized_oop_closures.hpp" |
31 #include "oops/metadata.hpp" | |
31 #include "utilities/top.hpp" | 32 #include "utilities/top.hpp" |
32 | 33 |
33 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe | 34 // oopDesc is the top baseclass for objects classes. The {name}Desc classes describe |
34 // the format of Java objects so the fields can be accessed from C++. | 35 // the format of Java objects so the fields can be accessed from C++. |
35 // oopDesc is abstract. | 36 // oopDesc is abstract. |
38 // no virtual functions allowed | 39 // no virtual functions allowed |
39 | 40 |
40 // store into oop with store check | 41 // store into oop with store check |
41 template <class T> void oop_store(T* p, oop v); | 42 template <class T> void oop_store(T* p, oop v); |
42 template <class T> void oop_store(volatile T* p, oop v); | 43 template <class T> void oop_store(volatile T* p, oop v); |
43 | |
44 // store into oop without store check | |
45 template <class T> void oop_store_without_check(T* p, oop v); | |
46 template <class T> void oop_store_without_check(volatile T* p, oop v); | |
47 | 44 |
48 extern bool always_do_update_barrier; | 45 extern bool always_do_update_barrier; |
49 | 46 |
50 // Forward declarations. | 47 // Forward declarations. |
51 class OopClosure; | 48 class OopClosure; |
61 class oopDesc { | 58 class oopDesc { |
62 friend class VMStructs; | 59 friend class VMStructs; |
63 private: | 60 private: |
64 volatile markOop _mark; | 61 volatile markOop _mark; |
65 union _metadata { | 62 union _metadata { |
66 wideKlassOop _klass; | 63 Klass* _klass; |
67 narrowOop _compressed_klass; | 64 narrowOop _compressed_klass; |
68 } _metadata; | 65 } _metadata; |
69 | 66 |
70 // Fast access to barrier set. Must be initialized. | 67 // Fast access to barrier set. Must be initialized. |
71 static BarrierSet* _bs; | 68 static BarrierSet* _bs; |
72 | 69 |
73 public: | 70 public: |
74 enum ConcSafeType { | |
75 IsUnsafeConc = false, | |
76 IsSafeConc = true | |
77 }; | |
78 | |
79 markOop mark() const { return _mark; } | 71 markOop mark() const { return _mark; } |
80 markOop* mark_addr() const { return (markOop*) &_mark; } | 72 markOop* mark_addr() const { return (markOop*) &_mark; } |
81 | 73 |
82 void set_mark(volatile markOop m) { _mark = m; } | 74 void set_mark(volatile markOop m) { _mark = m; } |
83 | 75 |
86 | 78 |
87 // Used only to re-initialize the mark word (e.g., of promoted | 79 // Used only to re-initialize the mark word (e.g., of promoted |
88 // objects during a GC) -- requires a valid klass pointer | 80 // objects during a GC) -- requires a valid klass pointer |
89 void init_mark(); | 81 void init_mark(); |
90 | 82 |
91 klassOop klass() const; | 83 Klass* klass() const; |
92 klassOop klass_or_null() const volatile; | 84 Klass* klass_or_null() const volatile; |
93 oop* klass_addr(); | 85 Klass** klass_addr(); |
94 narrowOop* compressed_klass_addr(); | 86 narrowOop* compressed_klass_addr(); |
95 | 87 |
96 void set_klass(klassOop k); | 88 void set_klass(Klass* k); |
97 | 89 |
98 // For klass field compression | 90 // For klass field compression |
99 int klass_gap() const; | 91 int klass_gap() const; |
100 void set_klass_gap(int z); | 92 void set_klass_gap(int z); |
101 // For when the klass pointer is being used as a linked list "next" field. | 93 // For when the klass pointer is being used as a linked list "next" field. |
102 void set_klass_to_list_ptr(oop k); | 94 void set_klass_to_list_ptr(oop k); |
95 oop list_ptr_from_klass(); | |
103 | 96 |
104 // size of object header, aligned to platform wordSize | 97 // size of object header, aligned to platform wordSize |
105 static int header_size() { return sizeof(oopDesc)/HeapWordSize; } | 98 static int header_size() { return sizeof(oopDesc)/HeapWordSize; } |
106 | 99 |
107 Klass* blueprint() const; | |
108 | |
109 // Returns whether this is an instance of k or an instance of a subclass of k | 100 // Returns whether this is an instance of k or an instance of a subclass of k |
110 bool is_a(klassOop k) const; | 101 bool is_a(Klass* k) const; |
111 | 102 |
112 // Returns the actual oop size of the object | 103 // Returns the actual oop size of the object |
113 int size(); | 104 int size(); |
114 | 105 |
115 // Sometimes (for complicated concurrency-related reasons), it is useful | 106 // Sometimes (for complicated concurrency-related reasons), it is useful |
116 // to be able to figure out the size of an object knowing its klass. | 107 // to be able to figure out the size of an object knowing its klass. |
117 int size_given_klass(Klass* klass); | 108 int size_given_klass(Klass* klass); |
118 | |
119 // Some perm gen objects are not parseble immediately after | |
120 // installation of their klass pointer. | |
121 bool is_parsable(); | |
122 | |
123 // Some perm gen objects that have been allocated and initialized | |
124 // can be changed by the VM when not at a safe point (class rededfinition | |
125 // is an example). Such objects should not be examined by the | |
126 // concurrent processing of a garbage collector if is_conc_safe() | |
127 // returns false. | |
128 bool is_conc_safe(); | |
129 | 109 |
130 // type test operations (inlined in oop.inline.h) | 110 // type test operations (inlined in oop.inline.h) |
131 bool is_instance() const; | 111 bool is_instance() const; |
132 bool is_instanceMirror() const; | 112 bool is_instanceMirror() const; |
133 bool is_instanceRef() const; | 113 bool is_instanceRef() const; |
134 bool is_array() const; | 114 bool is_array() const; |
135 bool is_objArray() const; | 115 bool is_objArray() const; |
136 bool is_klass() const; | |
137 bool is_thread() const; | |
138 bool is_method() const; | |
139 bool is_constMethod() const; | |
140 bool is_methodData() const; | |
141 bool is_constantPool() const; | |
142 bool is_constantPoolCache() const; | |
143 bool is_typeArray() const; | 116 bool is_typeArray() const; |
144 bool is_javaArray() const; | |
145 bool is_compiledICHolder() const; | |
146 | 117 |
147 private: | 118 private: |
148 // field addresses in oop | 119 // field addresses in oop |
149 void* field_base(int offset) const; | 120 void* field_base(int offset) const; |
150 | 121 |
154 jint* int_field_addr(int offset) const; | 125 jint* int_field_addr(int offset) const; |
155 jshort* short_field_addr(int offset) const; | 126 jshort* short_field_addr(int offset) const; |
156 jlong* long_field_addr(int offset) const; | 127 jlong* long_field_addr(int offset) const; |
157 jfloat* float_field_addr(int offset) const; | 128 jfloat* float_field_addr(int offset) const; |
158 jdouble* double_field_addr(int offset) const; | 129 jdouble* double_field_addr(int offset) const; |
159 address* address_field_addr(int offset) const; | 130 Metadata** metadata_field_addr(int offset) const; |
160 | 131 |
161 public: | 132 public: |
162 // Need this as public for garbage collection. | 133 // Need this as public for garbage collection. |
163 template <class T> T* obj_field_addr(int offset) const; | 134 template <class T> T* obj_field_addr(int offset) const; |
164 | 135 |
136 // Needed for javaClasses | |
137 address* address_field_addr(int offset) const; | |
138 | |
165 static bool is_null(oop obj); | 139 static bool is_null(oop obj); |
166 static bool is_null(narrowOop obj); | 140 static bool is_null(narrowOop obj); |
141 static bool is_null(Klass* obj); | |
167 | 142 |
168 // Decode an oop pointer from a narrowOop if compressed. | 143 // Decode an oop pointer from a narrowOop if compressed. |
169 // These are overloaded for oop and narrowOop as are the other functions | 144 // These are overloaded for oop and narrowOop as are the other functions |
170 // below so that they can be called in template functions. | 145 // below so that they can be called in template functions. |
171 static oop decode_heap_oop_not_null(oop v); | 146 static oop decode_heap_oop_not_null(oop v); |
208 static void release_encode_store_heap_oop(volatile oop* p, oop v); | 183 static void release_encode_store_heap_oop(volatile oop* p, oop v); |
209 | 184 |
210 static oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest); | 185 static oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest); |
211 static oop atomic_compare_exchange_oop(oop exchange_value, | 186 static oop atomic_compare_exchange_oop(oop exchange_value, |
212 volatile HeapWord *dest, | 187 volatile HeapWord *dest, |
213 oop compare_value); | 188 oop compare_value, |
189 bool prebarrier = false); | |
190 | |
191 // klass encoding for klass pointer in objects. | |
192 static narrowOop encode_klass_not_null(Klass* v); | |
193 static narrowOop encode_klass(Klass* v); | |
194 | |
195 static Klass* decode_klass_not_null(narrowOop v); | |
196 static Klass* decode_klass(narrowOop v); | |
214 | 197 |
215 // Access to fields in a instanceOop through these methods. | 198 // Access to fields in a instanceOop through these methods. |
216 oop obj_field(int offset) const; | 199 oop obj_field(int offset) const; |
217 volatile oop obj_field_volatile(int offset) const; | 200 volatile oop obj_field_volatile(int offset) const; |
218 void obj_field_put(int offset, oop value); | 201 void obj_field_put(int offset, oop value); |
219 void obj_field_put_raw(int offset, oop value); | 202 void obj_field_put_raw(int offset, oop value); |
220 void obj_field_put_volatile(int offset, oop value); | 203 void obj_field_put_volatile(int offset, oop value); |
221 | 204 |
205 Metadata* metadata_field(int offset) const; | |
206 void metadata_field_put(int offset, Metadata* value); | |
207 | |
222 jbyte byte_field(int offset) const; | 208 jbyte byte_field(int offset) const; |
223 void byte_field_put(int offset, jbyte contents); | 209 void byte_field_put(int offset, jbyte contents); |
224 | 210 |
225 jchar char_field(int offset) const; | 211 jchar char_field(int offset) const; |
226 void char_field_put(int offset, jchar contents); | 212 void char_field_put(int offset, jchar contents); |
291 char* print_value_string(); | 277 char* print_value_string(); |
292 | 278 |
293 // verification operations | 279 // verification operations |
294 void verify_on(outputStream* st); | 280 void verify_on(outputStream* st); |
295 void verify(); | 281 void verify(); |
296 | |
297 // tells whether this oop is partially constructed (gc during class loading) | |
298 bool partially_loaded(); | |
299 void set_partially_loaded(); | |
300 | 282 |
301 // locking operations | 283 // locking operations |
302 bool is_locked() const; | 284 bool is_locked() const; |
303 bool is_unlocked() const; | 285 bool is_unlocked() const; |
304 bool has_bias_pattern() const; | 286 bool has_bias_pattern() const; |
313 // garbage collection | 295 // garbage collection |
314 bool is_gc_marked() const; | 296 bool is_gc_marked() const; |
315 // Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL | 297 // Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL |
316 // reference field in "this". | 298 // reference field in "this". |
317 void follow_contents(void); | 299 void follow_contents(void); |
318 void follow_header(void); | |
319 | 300 |
320 #ifndef SERIALGC | 301 #ifndef SERIALGC |
321 // Parallel Scavenge | 302 // Parallel Scavenge |
322 void push_contents(PSPromotionManager* pm); | 303 void push_contents(PSPromotionManager* pm); |
323 | 304 |
324 // Parallel Old | 305 // Parallel Old |
325 void update_contents(ParCompactionManager* cm); | 306 void update_contents(ParCompactionManager* cm); |
326 | 307 |
327 void follow_contents(ParCompactionManager* cm); | 308 void follow_contents(ParCompactionManager* cm); |
328 void follow_header(ParCompactionManager* cm); | |
329 #endif // SERIALGC | 309 #endif // SERIALGC |
330 | 310 |
331 bool is_perm() const; | |
332 bool is_perm_or_null() const; | |
333 bool is_scavengable() const; | 311 bool is_scavengable() const; |
334 bool is_shared() const; | |
335 bool is_shared_readonly() const; | |
336 bool is_shared_readwrite() const; | |
337 | 312 |
338 // Forward pointer operations for scavenge | 313 // Forward pointer operations for scavenge |
339 bool is_forwarded() const; | 314 bool is_forwarded() const; |
340 | 315 |
341 void forward_to(oop p); | 316 void forward_to(oop p); |
356 void incr_age(); | 331 void incr_age(); |
357 | 332 |
358 // Adjust all pointers in this object to point at it's forwarded location and | 333 // Adjust all pointers in this object to point at it's forwarded location and |
359 // return the size of this oop. This is used by the MarkSweep collector. | 334 // return the size of this oop. This is used by the MarkSweep collector. |
360 int adjust_pointers(); | 335 int adjust_pointers(); |
361 void adjust_header(); | |
362 | 336 |
363 #ifndef SERIALGC | 337 #ifndef SERIALGC |
364 // Parallel old | 338 // Parallel old |
365 void update_header(); | 339 void update_header(ParCompactionManager* cm); |
366 #endif // SERIALGC | 340 #endif // SERIALGC |
367 | 341 |
368 // mark-sweep support | 342 // mark-sweep support |
369 void follow_body(int begin, int end); | 343 void follow_body(int begin, int end); |
370 | 344 |
387 | 361 |
388 ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DECL) | 362 ALL_OOP_OOP_ITERATE_CLOSURES_1(OOP_ITERATE_BACKWARDS_DECL) |
389 ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DECL) | 363 ALL_OOP_OOP_ITERATE_CLOSURES_2(OOP_ITERATE_BACKWARDS_DECL) |
390 #endif | 364 #endif |
391 | 365 |
392 void oop_iterate_header(OopClosure* blk); | 366 int oop_iterate_no_header(OopClosure* bk); |
393 void oop_iterate_header(OopClosure* blk, MemRegion mr); | 367 int oop_iterate_no_header(OopClosure* bk, MemRegion mr); |
394 | 368 |
395 // identity hash; returns the identity hash key (computes it if necessary) | 369 // identity hash; returns the identity hash key (computes it if necessary) |
396 // NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a | 370 // NOTE with the introduction of UseBiasedLocking that identity_hash() might reach a |
397 // safepoint if called on a biased object. Calling code must be aware of that. | 371 // safepoint if called on a biased object. Calling code must be aware of that. |
398 intptr_t identity_hash(); | 372 intptr_t identity_hash(); |
399 intptr_t slow_identity_hash(); | 373 intptr_t slow_identity_hash(); |
400 | 374 |
375 // Alternate hashing code if string table is rehashed | |
376 unsigned int new_hash(jint seed); | |
377 | |
401 // marks are forwarded to stack when object is locked | 378 // marks are forwarded to stack when object is locked |
402 bool has_displaced_mark() const; | 379 bool has_displaced_mark() const; |
403 markOop displaced_mark() const; | 380 markOop displaced_mark() const; |
404 void set_displaced_mark(markOop m); | 381 void set_displaced_mark(markOop m); |
405 | 382 |