39 |
39 |
40 class CollectedHeap; |
40 class CollectedHeap; |
41 class DeferredObjAllocEvent; |
41 class DeferredObjAllocEvent; |
42 |
42 |
43 |
43 |
44 // Common parts of a Method* cache. This cache safely interacts with |
44 // A helper class for caching a Method* when the user of the cache |
45 // the RedefineClasses API. |
45 // only cares about the latest version of the Method*. This cache safely |
46 // |
46 // interacts with the RedefineClasses API. |
47 class CommonMethodOopCache : public CHeapObj<mtClass> { |
47 |
|
48 class LatestMethodCache : public CHeapObj<mtClass> { |
48 // We save the Klass* and the idnum of Method* in order to get |
49 // We save the Klass* and the idnum of Method* in order to get |
49 // the current cached Method*. |
50 // the current cached Method*. |
50 private: |
51 private: |
51 Klass* _klass; |
52 Klass* _klass; |
52 int _method_idnum; |
53 int _method_idnum; |
53 |
54 |
54 public: |
55 public: |
55 CommonMethodOopCache() { _klass = NULL; _method_idnum = -1; } |
56 LatestMethodCache() { _klass = NULL; _method_idnum = -1; } |
56 ~CommonMethodOopCache() { _klass = NULL; _method_idnum = -1; } |
57 ~LatestMethodCache() { _klass = NULL; _method_idnum = -1; } |
57 |
58 |
58 void init(Klass* k, Method* m, TRAPS); |
59 void init(Klass* k, Method* m); |
59 Klass* klass() const { return _klass; } |
60 Klass* klass() const { return _klass; } |
60 int method_idnum() const { return _method_idnum; } |
61 int method_idnum() const { return _method_idnum; } |
|
62 |
|
63 Method* get_method(); |
61 |
64 |
62 // Enhanced Class Redefinition support |
65 // Enhanced Class Redefinition support |
63 void classes_do(void f(Klass*)) { |
66 void classes_do(void f(Klass*)) { |
64 f(_klass); |
67 f(_klass); |
65 } |
68 } |
69 void serialize(SerializeClosure* f) { |
72 void serialize(SerializeClosure* f) { |
70 f->do_ptr((void**)&_klass); |
73 f->do_ptr((void**)&_klass); |
71 } |
74 } |
72 }; |
75 }; |
73 |
76 |
74 |
|
75 // A helper class for caching a Method* when the user of the cache |
|
76 // cares about all versions of the Method*. |
|
77 // |
|
78 class ActiveMethodOopsCache : public CommonMethodOopCache { |
|
79 // This subclass adds weak references to older versions of the |
|
80 // Method* and a query method for a Method*. |
|
81 |
|
82 private: |
|
83 // If the cached Method* has not been redefined, then |
|
84 // _prev_methods will be NULL. If all of the previous |
|
85 // versions of the method have been collected, then |
|
86 // _prev_methods can have a length of zero. |
|
87 GrowableArray<Method*>* _prev_methods; |
|
88 |
|
89 public: |
|
90 ActiveMethodOopsCache() { _prev_methods = NULL; } |
|
91 ~ActiveMethodOopsCache(); |
|
92 |
|
93 void add_previous_version(Method* method); |
|
94 bool is_same_method(const Method* method) const; |
|
95 }; |
|
96 |
|
97 |
|
98 // A helper class for caching a Method* when the user of the cache |
|
99 // only cares about the latest version of the Method*. |
|
100 // |
|
101 class LatestMethodOopCache : public CommonMethodOopCache { |
|
102 // This subclass adds a getter method for the latest Method*. |
|
103 |
|
104 public: |
|
105 Method* get_Method(); |
|
106 }; |
|
107 |
77 |
108 // For UseCompressedOops and UseCompressedKlassPointers. |
78 // For UseCompressedOops and UseCompressedKlassPointers. |
109 struct NarrowPtrStruct { |
79 struct NarrowPtrStruct { |
110 // Base address for oop/klass-within-java-object materialization. |
80 // Base address for oop/klass-within-java-object materialization. |
111 // NULL if using wide oops/klasses or zero based narrow oops/klasses. |
81 // NULL if using wide oops/klasses or zero based narrow oops/klasses. |
172 static oop _system_thread_group; // Reference to the system thread group object |
142 static oop _system_thread_group; // Reference to the system thread group object |
173 |
143 |
174 static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class |
144 static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class |
175 static oop _the_null_string; // A cache of "null" as a Java string |
145 static oop _the_null_string; // A cache of "null" as a Java string |
176 static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string |
146 static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string |
177 static LatestMethodOopCache* _finalizer_register_cache; // static method for registering finalizable objects |
147 static LatestMethodCache* _finalizer_register_cache; // static method for registering finalizable objects |
178 static LatestMethodOopCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector |
148 static LatestMethodCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector |
179 static LatestMethodOopCache* _pd_implies_cache; // method for checking protection domain attributes |
149 static LatestMethodCache* _pd_implies_cache; // method for checking protection domain attributes |
180 static ActiveMethodOopsCache* _reflect_invoke_cache; // method for security checks |
150 |
181 // preallocated error objects (no backtrace) |
151 // preallocated error objects (no backtrace) |
182 static oop _out_of_memory_error_java_heap; |
152 static oop _out_of_memory_error_java_heap; |
183 static oop _out_of_memory_error_metaspace; |
153 static oop _out_of_memory_error_metaspace; |
184 static oop _out_of_memory_error_class_metaspace; |
154 static oop _out_of_memory_error_class_metaspace; |
185 static oop _out_of_memory_error_array_size; |
155 static oop _out_of_memory_error_array_size; |
332 |
302 |
333 static objArrayOop the_empty_class_klass_array () { return _the_empty_class_klass_array; } |
303 static objArrayOop the_empty_class_klass_array () { return _the_empty_class_klass_array; } |
334 static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; } |
304 static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; } |
335 static oop the_null_string() { return _the_null_string; } |
305 static oop the_null_string() { return _the_null_string; } |
336 static oop the_min_jint_string() { return _the_min_jint_string; } |
306 static oop the_min_jint_string() { return _the_min_jint_string; } |
337 static Method* finalizer_register_method() { return _finalizer_register_cache->get_Method(); } |
307 |
338 static Method* loader_addClass_method() { return _loader_addClass_cache->get_Method(); } |
308 static Method* finalizer_register_method() { return _finalizer_register_cache->get_method(); } |
339 |
309 static Method* loader_addClass_method() { return _loader_addClass_cache->get_method(); } |
340 static Method* protection_domain_implies_method() { return _pd_implies_cache->get_Method(); } |
310 |
341 static ActiveMethodOopsCache* reflect_invoke_cache() { return _reflect_invoke_cache; } |
311 static Method* protection_domain_implies_method() { return _pd_implies_cache->get_method(); } |
342 |
312 |
343 static oop null_ptr_exception_instance() { return _null_ptr_exception_instance; } |
313 static oop null_ptr_exception_instance() { return _null_ptr_exception_instance; } |
344 static oop arithmetic_exception_instance() { return _arithmetic_exception_instance; } |
314 static oop arithmetic_exception_instance() { return _arithmetic_exception_instance; } |
345 static oop virtual_machine_error_instance() { return _virtual_machine_error_instance; } |
315 static oop virtual_machine_error_instance() { return _virtual_machine_error_instance; } |
346 static oop vm_exception() { return _vm_exception; } |
316 static oop vm_exception() { return _vm_exception; } |