22 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_UNIVERSE_HPP
26 #define SHARE_VM_MEMORY_UNIVERSE_HPP
27
28 #include "oops/array.hpp"
29 #include "runtime/handles.hpp"
30 #include "utilities/growableArray.hpp"
31
32 // Universe is a name space holding known system classes and objects in the VM.
33 //
34 // Loaded classes are accessible through the SystemDictionary.
35 //
36 // The object heap is allocated and accessed through Universe, and various allocation
37 // support is provided. Allocation by the interpreter and compiled code is done inline
38 // and bails out to Scavenge::invoke_and_allocate.
39
40 class CollectedHeap;
41 class DeferredObjAllocEvent;
42
43
44 // A helper class for caching a Method* when the user of the cache
45 // only cares about the latest version of the Method*. This cache safely
46 // interacts with the RedefineClasses API.
47
48 class LatestMethodCache : public CHeapObj<mtClass> {
49 // We save the Klass* and the idnum of Method* in order to get
50 // the current cached Method*.
51 private:
52 Klass* _klass;
53 int _method_idnum;
54
55 public:
56 LatestMethodCache() { _klass = NULL; _method_idnum = -1; }
57 ~LatestMethodCache() { _klass = NULL; _method_idnum = -1; }
58
59 void init(Klass* k, Method* m);
60 Klass* klass() const { return _klass; }
61 int method_idnum() const { return _method_idnum; }
107
108 friend jint universe_init();
109 friend void universe2_init();
110 friend bool universe_post_init();
111 friend void universe_post_module_init();
112
113 private:
114 // Known classes in the VM
115 static Klass* _boolArrayKlassObj;
116 static Klass* _byteArrayKlassObj;
117 static Klass* _charArrayKlassObj;
118 static Klass* _intArrayKlassObj;
119 static Klass* _shortArrayKlassObj;
120 static Klass* _longArrayKlassObj;
121 static Klass* _singleArrayKlassObj;
122 static Klass* _doubleArrayKlassObj;
123 static Klass* _typeArrayKlassObjs[T_VOID+1];
124
125 static Klass* _objectArrayKlassObj;
126
127 // Known objects in the VM
128
129 // Primitive objects
130 static oop _int_mirror;
131 static oop _float_mirror;
132 static oop _double_mirror;
133 static oop _byte_mirror;
134 static oop _bool_mirror;
135 static oop _char_mirror;
136 static oop _long_mirror;
137 static oop _short_mirror;
138 static oop _void_mirror;
139
140 static oop _main_thread_group; // Reference to the main thread group object
141 static oop _system_thread_group; // Reference to the system thread group object
142
143 static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class
144 static oop _the_null_sentinel; // A unique object pointer unused except as a sentinel for null.
145 static oop _the_null_string; // A cache of "null" as a Java string
146 static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string
212 // the array of preallocated errors with backtraces
213 static objArrayOop preallocated_out_of_memory_errors() { return _preallocated_out_of_memory_error_array; }
214
215 // generate an out of memory error; if possible using an error with preallocated backtrace;
216 // otherwise return the given default error.
217 static oop gen_out_of_memory_error(oop default_err);
218
219 // Historic gc information
220 static size_t _heap_capacity_at_last_gc;
221 static size_t _heap_used_at_last_gc;
222
223 static CollectedHeap* create_heap();
224 static jint initialize_heap();
225 static void initialize_basic_type_mirrors(TRAPS);
226 static void fixup_mirrors(TRAPS);
227
228 static void reinitialize_vtable_of(Klass* k, TRAPS);
229 static void reinitialize_itables(TRAPS);
230 static void compute_base_vtable_size(); // compute vtable size of class Object
231
232 static void genesis(TRAPS); // Create the initial world
233
234 // Mirrors for primitive classes (created eagerly)
235 static oop check_mirror(oop m) {
236 assert(m != NULL, "mirror not initialized");
237 return m;
238 }
239
240 static void set_narrow_oop_base(address base) {
241 assert(UseCompressedOops, "no compressed oops?");
242 _narrow_oop._base = base;
243 }
244 static void set_narrow_klass_base(address base) {
245 assert(UseCompressedClassPointers, "no compressed klass ptrs?");
246 _narrow_klass._base = base;
247 }
248 static void set_narrow_klass_range(uint64_t range) {
249 assert(UseCompressedClassPointers, "no compressed klass ptrs?");
250 _narrow_klass_range = range;
251 }
270 public:
271 // Known classes in the VM
272 static Klass* boolArrayKlassObj() { return _boolArrayKlassObj; }
273 static Klass* byteArrayKlassObj() { return _byteArrayKlassObj; }
274 static Klass* charArrayKlassObj() { return _charArrayKlassObj; }
275 static Klass* intArrayKlassObj() { return _intArrayKlassObj; }
276 static Klass* shortArrayKlassObj() { return _shortArrayKlassObj; }
277 static Klass* longArrayKlassObj() { return _longArrayKlassObj; }
278 static Klass* singleArrayKlassObj() { return _singleArrayKlassObj; }
279 static Klass* doubleArrayKlassObj() { return _doubleArrayKlassObj; }
280
281 static Klass* objectArrayKlassObj() {
282 return _objectArrayKlassObj;
283 }
284
285 static Klass* typeArrayKlassObj(BasicType t) {
286 assert((uint)t < T_VOID+1, "range check for type: %s", type2name(t));
287 assert(_typeArrayKlassObjs[t] != NULL, "domain check");
288 return _typeArrayKlassObjs[t];
289 }
290
291 // Known objects in the VM
292 static oop int_mirror() { return check_mirror(_int_mirror); }
293 static oop float_mirror() { return check_mirror(_float_mirror); }
294 static oop double_mirror() { return check_mirror(_double_mirror); }
295 static oop byte_mirror() { return check_mirror(_byte_mirror); }
296 static oop bool_mirror() { return check_mirror(_bool_mirror); }
297 static oop char_mirror() { return check_mirror(_char_mirror); }
298 static oop long_mirror() { return check_mirror(_long_mirror); }
299 static oop short_mirror() { return check_mirror(_short_mirror); }
300 static oop void_mirror() { return check_mirror(_void_mirror); }
301
302 static void set_int_mirror(oop m) { _int_mirror = m; }
303 static void set_float_mirror(oop m) { _float_mirror = m; }
304 static void set_double_mirror(oop m) { _double_mirror = m; }
305 static void set_byte_mirror(oop m) { _byte_mirror = m; }
306 static void set_bool_mirror(oop m) { _bool_mirror = m; }
307 static void set_char_mirror(oop m) { _char_mirror = m; }
308 static void set_long_mirror(oop m) { _long_mirror = m; }
309 static void set_short_mirror(oop m) { _short_mirror = m; }
|
22 *
23 */
24
25 #ifndef SHARE_VM_MEMORY_UNIVERSE_HPP
26 #define SHARE_VM_MEMORY_UNIVERSE_HPP
27
28 #include "oops/array.hpp"
29 #include "runtime/handles.hpp"
30 #include "utilities/growableArray.hpp"
31
32 // Universe is a name space holding known system classes and objects in the VM.
33 //
34 // Loaded classes are accessible through the SystemDictionary.
35 //
36 // The object heap is allocated and accessed through Universe, and various allocation
37 // support is provided. Allocation by the interpreter and compiled code is done inline
38 // and bails out to Scavenge::invoke_and_allocate.
39
40 class CollectedHeap;
41 class DeferredObjAllocEvent;
42 class OopStorage;
43
44
45 // A helper class for caching a Method* when the user of the cache
46 // only cares about the latest version of the Method*. This cache safely
47 // interacts with the RedefineClasses API.
48
49 class LatestMethodCache : public CHeapObj<mtClass> {
50 // We save the Klass* and the idnum of Method* in order to get
51 // the current cached Method*.
52 private:
53 Klass* _klass;
54 int _method_idnum;
55
56 public:
57 LatestMethodCache() { _klass = NULL; _method_idnum = -1; }
58 ~LatestMethodCache() { _klass = NULL; _method_idnum = -1; }
59
60 void init(Klass* k, Method* m);
61 Klass* klass() const { return _klass; }
62 int method_idnum() const { return _method_idnum; }
108
109 friend jint universe_init();
110 friend void universe2_init();
111 friend bool universe_post_init();
112 friend void universe_post_module_init();
113
114 private:
115 // Known classes in the VM
116 static Klass* _boolArrayKlassObj;
117 static Klass* _byteArrayKlassObj;
118 static Klass* _charArrayKlassObj;
119 static Klass* _intArrayKlassObj;
120 static Klass* _shortArrayKlassObj;
121 static Klass* _longArrayKlassObj;
122 static Klass* _singleArrayKlassObj;
123 static Klass* _doubleArrayKlassObj;
124 static Klass* _typeArrayKlassObjs[T_VOID+1];
125
126 static Klass* _objectArrayKlassObj;
127
128 // VM weak OopStorage object.
129 static OopStorage* _vm_weak_oop_storage;
130
131 // Known objects in the VM
132
133 // Primitive objects
134 static oop _int_mirror;
135 static oop _float_mirror;
136 static oop _double_mirror;
137 static oop _byte_mirror;
138 static oop _bool_mirror;
139 static oop _char_mirror;
140 static oop _long_mirror;
141 static oop _short_mirror;
142 static oop _void_mirror;
143
144 static oop _main_thread_group; // Reference to the main thread group object
145 static oop _system_thread_group; // Reference to the system thread group object
146
147 static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class
148 static oop _the_null_sentinel; // A unique object pointer unused except as a sentinel for null.
149 static oop _the_null_string; // A cache of "null" as a Java string
150 static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string
216 // the array of preallocated errors with backtraces
217 static objArrayOop preallocated_out_of_memory_errors() { return _preallocated_out_of_memory_error_array; }
218
219 // generate an out of memory error; if possible using an error with preallocated backtrace;
220 // otherwise return the given default error.
221 static oop gen_out_of_memory_error(oop default_err);
222
223 // Historic gc information
224 static size_t _heap_capacity_at_last_gc;
225 static size_t _heap_used_at_last_gc;
226
227 static CollectedHeap* create_heap();
228 static jint initialize_heap();
229 static void initialize_basic_type_mirrors(TRAPS);
230 static void fixup_mirrors(TRAPS);
231
232 static void reinitialize_vtable_of(Klass* k, TRAPS);
233 static void reinitialize_itables(TRAPS);
234 static void compute_base_vtable_size(); // compute vtable size of class Object
235
236 static void initialize_oop_storage();
237
238 static void genesis(TRAPS); // Create the initial world
239
240 // Mirrors for primitive classes (created eagerly)
241 static oop check_mirror(oop m) {
242 assert(m != NULL, "mirror not initialized");
243 return m;
244 }
245
246 static void set_narrow_oop_base(address base) {
247 assert(UseCompressedOops, "no compressed oops?");
248 _narrow_oop._base = base;
249 }
250 static void set_narrow_klass_base(address base) {
251 assert(UseCompressedClassPointers, "no compressed klass ptrs?");
252 _narrow_klass._base = base;
253 }
254 static void set_narrow_klass_range(uint64_t range) {
255 assert(UseCompressedClassPointers, "no compressed klass ptrs?");
256 _narrow_klass_range = range;
257 }
276 public:
277 // Known classes in the VM
278 static Klass* boolArrayKlassObj() { return _boolArrayKlassObj; }
279 static Klass* byteArrayKlassObj() { return _byteArrayKlassObj; }
280 static Klass* charArrayKlassObj() { return _charArrayKlassObj; }
281 static Klass* intArrayKlassObj() { return _intArrayKlassObj; }
282 static Klass* shortArrayKlassObj() { return _shortArrayKlassObj; }
283 static Klass* longArrayKlassObj() { return _longArrayKlassObj; }
284 static Klass* singleArrayKlassObj() { return _singleArrayKlassObj; }
285 static Klass* doubleArrayKlassObj() { return _doubleArrayKlassObj; }
286
287 static Klass* objectArrayKlassObj() {
288 return _objectArrayKlassObj;
289 }
290
291 static Klass* typeArrayKlassObj(BasicType t) {
292 assert((uint)t < T_VOID+1, "range check for type: %s", type2name(t));
293 assert(_typeArrayKlassObjs[t] != NULL, "domain check");
294 return _typeArrayKlassObjs[t];
295 }
296
297 static OopStorage* vm_weak_oop_storage();
298
299 // Known objects in the VM
300 static oop int_mirror() { return check_mirror(_int_mirror); }
301 static oop float_mirror() { return check_mirror(_float_mirror); }
302 static oop double_mirror() { return check_mirror(_double_mirror); }
303 static oop byte_mirror() { return check_mirror(_byte_mirror); }
304 static oop bool_mirror() { return check_mirror(_bool_mirror); }
305 static oop char_mirror() { return check_mirror(_char_mirror); }
306 static oop long_mirror() { return check_mirror(_long_mirror); }
307 static oop short_mirror() { return check_mirror(_short_mirror); }
308 static oop void_mirror() { return check_mirror(_void_mirror); }
309
310 static void set_int_mirror(oop m) { _int_mirror = m; }
311 static void set_float_mirror(oop m) { _float_mirror = m; }
312 static void set_double_mirror(oop m) { _double_mirror = m; }
313 static void set_byte_mirror(oop m) { _byte_mirror = m; }
314 static void set_bool_mirror(oop m) { _bool_mirror = m; }
315 static void set_char_mirror(oop m) { _char_mirror = m; }
316 static void set_long_mirror(oop m) { _long_mirror = m; }
317 static void set_short_mirror(oop m) { _short_mirror = m; }
|