comparison src/share/vm/oops/oop.hpp @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children b7268662a986
comparison
equal deleted inserted replaced
110:a49a647afe9a 113:ba764ed4b6f2
28 // (see oopHierarchy for complete oop class hierarchy) 28 // (see oopHierarchy for complete oop class hierarchy)
29 // 29 //
30 // no virtual functions allowed 30 // no virtual functions allowed
31 31
32 // store into oop with store check 32 // store into oop with store check
33 void oop_store(oop* p, oop v); 33 template <class T> void oop_store(T* p, oop v);
34 void oop_store(volatile oop* p, oop v); 34 template <class T> void oop_store(volatile T* p, oop v);
35 35
36 // store into oop without store check 36 // store into oop without store check
37 void oop_store_without_check(oop* p, oop v); 37 template <class T> void oop_store_without_check(T* p, oop v);
38 void oop_store_without_check(volatile oop* p, oop v); 38 template <class T> void oop_store_without_check(volatile T* p, oop v);
39 39
40 40
41 extern bool always_do_update_barrier; 41 extern bool always_do_update_barrier;
42 42
43 // Forward declarations. 43 // Forward declarations.
53 53
54 class oopDesc { 54 class oopDesc {
55 friend class VMStructs; 55 friend class VMStructs;
56 private: 56 private:
57 volatile markOop _mark; 57 volatile markOop _mark;
58 klassOop _klass; 58 union _metadata {
59 wideKlassOop _klass;
60 narrowOop _compressed_klass;
61 } _metadata;
59 62
60 // Fast access to barrier set. Must be initialized. 63 // Fast access to barrier set. Must be initialized.
61 static BarrierSet* _bs; 64 static BarrierSet* _bs;
62 65
63 public: 66 public:
71 74
72 // Used only to re-initialize the mark word (e.g., of promoted 75 // Used only to re-initialize the mark word (e.g., of promoted
73 // objects during a GC) -- requires a valid klass pointer 76 // objects during a GC) -- requires a valid klass pointer
74 void init_mark(); 77 void init_mark();
75 78
76 klassOop klass() const { return _klass; } 79 klassOop klass() const;
77 oop* klass_addr() const { return (oop*) &_klass; } 80 oop* klass_addr();
81 narrowOop* compressed_klass_addr();
78 82
79 void set_klass(klassOop k); 83 void set_klass(klassOop k);
80 // For when the klass pointer is being used as a linked list "next" field. 84 // For when the klass pointer is being used as a linked list "next" field.
81 void set_klass_to_list_ptr(oop k); 85 void set_klass_to_list_ptr(oop k);
82 86
83 // size of object header 87 // size of object header, aligned to platform wordSize
84 static int header_size() { return sizeof(oopDesc)/HeapWordSize; } 88 static int header_size() { return sizeof(oopDesc)/HeapWordSize; }
85 static int header_size_in_bytes() { return sizeof(oopDesc); }
86 89
87 Klass* blueprint() const; 90 Klass* blueprint() const;
88 91
89 // Returns whether this is an instance of k or an instance of a subclass of k 92 // Returns whether this is an instance of k or an instance of a subclass of k
90 bool is_a(klassOop k) const; 93 bool is_a(klassOop k) const;
117 bool is_javaArray() const; 120 bool is_javaArray() const;
118 bool is_compiledICHolder() const; 121 bool is_compiledICHolder() const;
119 122
120 private: 123 private:
121 // field addresses in oop 124 // field addresses in oop
122 // byte/char/bool/short fields are always stored as full words
123 void* field_base(int offset) const; 125 void* field_base(int offset) const;
124 126
125 jbyte* byte_field_addr(int offset) const; 127 jbyte* byte_field_addr(int offset) const;
126 jchar* char_field_addr(int offset) const; 128 jchar* char_field_addr(int offset) const;
127 jboolean* bool_field_addr(int offset) const; 129 jboolean* bool_field_addr(int offset) const;
128 jint* int_field_addr(int offset) const; 130 jint* int_field_addr(int offset) const;
129 jshort* short_field_addr(int offset) const; 131 jshort* short_field_addr(int offset) const;
130 jlong* long_field_addr(int offset) const; 132 jlong* long_field_addr(int offset) const;
131 jfloat* float_field_addr(int offset) const; 133 jfloat* float_field_addr(int offset) const;
132 jdouble* double_field_addr(int offset) const; 134 jdouble* double_field_addr(int offset) const;
135 address* address_field_addr(int offset) const;
133 136
134 public: 137 public:
135 // need this as public for garbage collection 138 // Need this as public for garbage collection.
136 oop* obj_field_addr(int offset) const; 139 template <class T> T* obj_field_addr(int offset) const;
137 140
141 static bool is_null(oop obj);
142 static bool is_null(narrowOop obj);
143
144 // Decode an oop pointer from a narrowOop if compressed.
145 // These are overloaded for oop and narrowOop as are the other functions
146 // below so that they can be called in template functions.
147 static oop decode_heap_oop_not_null(oop v);
148 static oop decode_heap_oop_not_null(narrowOop v);
149 static oop decode_heap_oop(oop v);
150 static oop decode_heap_oop(narrowOop v);
151
152 // Encode an oop pointer to a narrow oop. The or_null versions accept
153 // null oop pointer, others do not in order to eliminate the
154 // null checking branches.
155 static narrowOop encode_heap_oop_not_null(oop v);
156 static narrowOop encode_heap_oop(oop v);
157
158 // Load an oop out of the Java heap
159 static narrowOop load_heap_oop(narrowOop* p);
160 static oop load_heap_oop(oop* p);
161
162 // Load an oop out of Java heap and decode it to an uncompressed oop.
163 static oop load_decode_heap_oop_not_null(narrowOop* p);
164 static oop load_decode_heap_oop_not_null(oop* p);
165 static oop load_decode_heap_oop(narrowOop* p);
166 static oop load_decode_heap_oop(oop* p);
167
168 // Store an oop into the heap.
169 static void store_heap_oop(narrowOop* p, narrowOop v);
170 static void store_heap_oop(oop* p, oop v);
171
172 // Encode oop if UseCompressedOops and store into the heap.
173 static void encode_store_heap_oop_not_null(narrowOop* p, oop v);
174 static void encode_store_heap_oop_not_null(oop* p, oop v);
175 static void encode_store_heap_oop(narrowOop* p, oop v);
176 static void encode_store_heap_oop(oop* p, oop v);
177
178 static void release_store_heap_oop(volatile narrowOop* p, narrowOop v);
179 static void release_store_heap_oop(volatile oop* p, oop v);
180
181 static void release_encode_store_heap_oop_not_null(volatile narrowOop* p, oop v);
182 static void release_encode_store_heap_oop_not_null(volatile oop* p, oop v);
183 static void release_encode_store_heap_oop(volatile narrowOop* p, oop v);
184 static void release_encode_store_heap_oop(volatile oop* p, oop v);
185
186 static oop atomic_exchange_oop(oop exchange_value, volatile HeapWord *dest);
187 static oop atomic_compare_exchange_oop(oop exchange_value,
188 volatile HeapWord *dest,
189 oop compare_value);
190
191 // Access to fields in a instanceOop through these methods.
138 oop obj_field(int offset) const; 192 oop obj_field(int offset) const;
139 void obj_field_put(int offset, oop value); 193 void obj_field_put(int offset, oop value);
194 void obj_field_raw_put(int offset, oop value);
140 195
141 jbyte byte_field(int offset) const; 196 jbyte byte_field(int offset) const;
142 void byte_field_put(int offset, jbyte contents); 197 void byte_field_put(int offset, jbyte contents);
143 198
144 jchar char_field(int offset) const; 199 jchar char_field(int offset) const;
159 jfloat float_field(int offset) const; 214 jfloat float_field(int offset) const;
160 void float_field_put(int offset, jfloat contents); 215 void float_field_put(int offset, jfloat contents);
161 216
162 jdouble double_field(int offset) const; 217 jdouble double_field(int offset) const;
163 void double_field_put(int offset, jdouble contents); 218 void double_field_put(int offset, jdouble contents);
219
220 address address_field(int offset) const;
221 void address_field_put(int offset, address contents);
164 222
165 oop obj_field_acquire(int offset) const; 223 oop obj_field_acquire(int offset) const;
166 void release_obj_field_put(int offset, oop value); 224 void release_obj_field_put(int offset, oop value);
167 225
168 jbyte byte_field_acquire(int offset) const; 226 jbyte byte_field_acquire(int offset) const;
205 263
206 // verification operations 264 // verification operations
207 void verify_on(outputStream* st); 265 void verify_on(outputStream* st);
208 void verify(); 266 void verify();
209 void verify_old_oop(oop* p, bool allow_dirty); 267 void verify_old_oop(oop* p, bool allow_dirty);
268 void verify_old_oop(narrowOop* p, bool allow_dirty);
210 269
211 // tells whether this oop is partially constructed (gc during class loading) 270 // tells whether this oop is partially constructed (gc during class loading)
212 bool partially_loaded(); 271 bool partially_loaded();
213 void set_partially_loaded(); 272 void set_partially_loaded();
214 273
226 285
227 // garbage collection 286 // garbage collection
228 bool is_gc_marked() const; 287 bool is_gc_marked() const;
229 // Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL 288 // Apply "MarkSweep::mark_and_push" to (the address of) every non-NULL
230 // reference field in "this". 289 // reference field in "this".
231 void follow_contents(); 290 void follow_contents(void);
232 void follow_header(); 291 void follow_header(void);
233 292
234 #ifndef SERIALGC 293 #ifndef SERIALGC
235 // Parallel Scavenge 294 // Parallel Scavenge
236 void copy_contents(PSPromotionManager* pm); 295 void copy_contents(PSPromotionManager* pm);
237 void push_contents(PSPromotionManager* pm); 296 void push_contents(PSPromotionManager* pm);
315 bool has_displaced_mark() const; 374 bool has_displaced_mark() const;
316 markOop displaced_mark() const; 375 markOop displaced_mark() const;
317 void set_displaced_mark(markOop m); 376 void set_displaced_mark(markOop m);
318 377
319 // for code generation 378 // for code generation
320 static int klass_offset_in_bytes() { return offset_of(oopDesc, _klass); }
321 static int mark_offset_in_bytes() { return offset_of(oopDesc, _mark); } 379 static int mark_offset_in_bytes() { return offset_of(oopDesc, _mark); }
380 static int klass_offset_in_bytes() { return offset_of(oopDesc, _metadata._klass); }
381 static int klass_gap_offset_in_bytes();
322 }; 382 };