1.1 --- a/src/share/vm/memory/universe.hpp Fri Aug 31 16:39:35 2012 -0700 1.2 +++ b/src/share/vm/memory/universe.hpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -26,6 +26,7 @@ 1.4 #define SHARE_VM_MEMORY_UNIVERSE_HPP 1.5 1.6 #include "runtime/handles.hpp" 1.7 +#include "utilities/array.hpp" 1.8 #include "utilities/growableArray.hpp" 1.9 1.10 // Universe is a name space holding known system classes and objects in the VM. 1.11 @@ -40,60 +41,68 @@ 1.12 class DeferredObjAllocEvent; 1.13 1.14 1.15 -// Common parts of a methodOop cache. This cache safely interacts with 1.16 +// Common parts of a Method* cache. This cache safely interacts with 1.17 // the RedefineClasses API. 1.18 // 1.19 class CommonMethodOopCache : public CHeapObj<mtClass> { 1.20 - // We save the klassOop and the idnum of methodOop in order to get 1.21 - // the current cached methodOop. 1.22 + // We save the Klass* and the idnum of Method* in order to get 1.23 + // the current cached Method*. 1.24 private: 1.25 - klassOop _klass; 1.26 + Klass* _klass; 1.27 int _method_idnum; 1.28 1.29 public: 1.30 CommonMethodOopCache() { _klass = NULL; _method_idnum = -1; } 1.31 ~CommonMethodOopCache() { _klass = NULL; _method_idnum = -1; } 1.32 1.33 - void init(klassOop k, methodOop m, TRAPS); 1.34 - klassOop klass() const { return _klass; } 1.35 + void init(Klass* k, Method* m, TRAPS); 1.36 + Klass* klass() const { return _klass; } 1.37 int method_idnum() const { return _method_idnum; } 1.38 1.39 - // GC support 1.40 - void oops_do(OopClosure* f) { f->do_oop((oop*)&_klass); } 1.41 + // Enhanced Class Redefinition support 1.42 + void classes_do(void f(Klass*)) { 1.43 + f(_klass); 1.44 + } 1.45 + 1.46 + // CDS support. Replace the klass in this with the archive version 1.47 + // could use this for Enhanced Class Redefinition also. 1.48 + void serialize(SerializeClosure* f) { 1.49 + f->do_ptr((void**)&_klass); 1.50 + } 1.51 }; 1.52 1.53 1.54 -// A helper class for caching a methodOop when the user of the cache 1.55 -// cares about all versions of the methodOop. 1.56 +// A helper class for caching a Method* when the user of the cache 1.57 +// cares about all versions of the Method*. 1.58 // 1.59 class ActiveMethodOopsCache : public CommonMethodOopCache { 1.60 // This subclass adds weak references to older versions of the 1.61 - // methodOop and a query method for a methodOop. 1.62 + // Method* and a query method for a Method*. 1.63 1.64 private: 1.65 - // If the cached methodOop has not been redefined, then 1.66 + // If the cached Method* has not been redefined, then 1.67 // _prev_methods will be NULL. If all of the previous 1.68 // versions of the method have been collected, then 1.69 // _prev_methods can have a length of zero. 1.70 - GrowableArray<jweak>* _prev_methods; 1.71 + GrowableArray<Method*>* _prev_methods; 1.72 1.73 public: 1.74 ActiveMethodOopsCache() { _prev_methods = NULL; } 1.75 ~ActiveMethodOopsCache(); 1.76 1.77 - void add_previous_version(const methodOop method); 1.78 - bool is_same_method(const methodOop method) const; 1.79 + void add_previous_version(Method* const method); 1.80 + bool is_same_method(Method* const method) const; 1.81 }; 1.82 1.83 1.84 -// A helper class for caching a methodOop when the user of the cache 1.85 -// only cares about the latest version of the methodOop. 1.86 +// A helper class for caching a Method* when the user of the cache 1.87 +// only cares about the latest version of the Method*. 1.88 // 1.89 class LatestMethodOopCache : public CommonMethodOopCache { 1.90 - // This subclass adds a getter method for the latest methodOop. 1.91 + // This subclass adds a getter method for the latest Method*. 1.92 1.93 public: 1.94 - methodOop get_methodOop(); 1.95 + Method* get_Method(); 1.96 }; 1.97 1.98 // For UseCompressedOops. 1.99 @@ -126,7 +135,6 @@ 1.100 friend class Arguments; 1.101 friend class SystemDictionary; 1.102 friend class VMStructs; 1.103 - friend class CompactingPermGenGen; 1.104 friend class VM_PopulateDumpSharedSpace; 1.105 1.106 friend jint universe_init(); 1.107 @@ -135,30 +143,17 @@ 1.108 1.109 private: 1.110 // Known classes in the VM 1.111 - static klassOop _boolArrayKlassObj; 1.112 - static klassOop _byteArrayKlassObj; 1.113 - static klassOop _charArrayKlassObj; 1.114 - static klassOop _intArrayKlassObj; 1.115 - static klassOop _shortArrayKlassObj; 1.116 - static klassOop _longArrayKlassObj; 1.117 - static klassOop _singleArrayKlassObj; 1.118 - static klassOop _doubleArrayKlassObj; 1.119 - static klassOop _typeArrayKlassObjs[T_VOID+1]; 1.120 + static Klass* _boolArrayKlassObj; 1.121 + static Klass* _byteArrayKlassObj; 1.122 + static Klass* _charArrayKlassObj; 1.123 + static Klass* _intArrayKlassObj; 1.124 + static Klass* _shortArrayKlassObj; 1.125 + static Klass* _longArrayKlassObj; 1.126 + static Klass* _singleArrayKlassObj; 1.127 + static Klass* _doubleArrayKlassObj; 1.128 + static Klass* _typeArrayKlassObjs[T_VOID+1]; 1.129 1.130 - static klassOop _objectArrayKlassObj; 1.131 - 1.132 - static klassOop _methodKlassObj; 1.133 - static klassOop _constMethodKlassObj; 1.134 - static klassOop _methodDataKlassObj; 1.135 - static klassOop _klassKlassObj; 1.136 - static klassOop _arrayKlassKlassObj; 1.137 - static klassOop _objArrayKlassKlassObj; 1.138 - static klassOop _typeArrayKlassKlassObj; 1.139 - static klassOop _instanceKlassKlassObj; 1.140 - static klassOop _constantPoolKlassObj; 1.141 - static klassOop _constantPoolCacheKlassObj; 1.142 - static klassOop _compiledICHolderKlassObj; 1.143 - static klassOop _systemObjArrayKlassObj; 1.144 + static Klass* _objectArrayKlassObj; 1.145 1.146 // Known objects in the VM 1.147 1.148 @@ -176,22 +171,23 @@ 1.149 static oop _main_thread_group; // Reference to the main thread group object 1.150 static oop _system_thread_group; // Reference to the system thread group object 1.151 1.152 - static typeArrayOop _the_empty_byte_array; // Canonicalized byte array 1.153 - static typeArrayOop _the_empty_short_array; // Canonicalized short array 1.154 - static typeArrayOop _the_empty_int_array; // Canonicalized int array 1.155 - static objArrayOop _the_empty_system_obj_array; // Canonicalized system obj array 1.156 static objArrayOop _the_empty_class_klass_array; // Canonicalized obj array of type java.lang.Class 1.157 - static objArrayOop _the_array_interfaces_array; // Canonicalized 2-array of cloneable & serializable klasses 1.158 static oop _the_null_string; // A cache of "null" as a Java string 1.159 static oop _the_min_jint_string; // A cache of "-2147483648" as a Java string 1.160 static LatestMethodOopCache* _finalizer_register_cache; // static method for registering finalizable objects 1.161 - static LatestMethodOopCache* _loader_addClass_cache; // method for registering loaded classes in class loader vector 1.162 static ActiveMethodOopsCache* _reflect_invoke_cache; // method for security checks 1.163 static oop _out_of_memory_error_java_heap; // preallocated error object (no backtrace) 1.164 static oop _out_of_memory_error_perm_gen; // preallocated error object (no backtrace) 1.165 static oop _out_of_memory_error_array_size;// preallocated error object (no backtrace) 1.166 static oop _out_of_memory_error_gc_overhead_limit; // preallocated error object (no backtrace) 1.167 1.168 + static Array<int>* _the_empty_int_array; // Canonicalized int array 1.169 + static Array<u2>* _the_empty_short_array; // Canonicalized short array 1.170 + static Array<Klass*>* _the_empty_klass_array; // Canonicalized klass obj array 1.171 + static Array<Method*>* _the_empty_method_array; // Canonicalized method obj array 1.172 + 1.173 + static Array<Klass*>* _the_array_interfaces_array; 1.174 + 1.175 // array of preallocated error objects with backtrace 1.176 static objArrayOop _preallocated_out_of_memory_error_array; 1.177 1.178 @@ -250,6 +246,21 @@ 1.179 return m; 1.180 } 1.181 1.182 + // Narrow Oop encoding mode: 1.183 + // 0 - Use 32-bits oops without encoding when 1.184 + // NarrowOopHeapBaseMin + heap_size < 4Gb 1.185 + // 1 - Use zero based compressed oops with encoding when 1.186 + // NarrowOopHeapBaseMin + heap_size < 32Gb 1.187 + // 2 - Use compressed oops with heap base + encoding. 1.188 + enum NARROW_OOP_MODE { 1.189 + UnscaledNarrowOop = 0, 1.190 + ZeroBasedNarrowOop = 1, 1.191 + HeapBasedNarrowOop = 2 1.192 + }; 1.193 + static char* preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode); 1.194 + static void set_narrow_oop_base(address base) { _narrow_oop._base = base; } 1.195 + static void set_narrow_oop_use_implicit_null_checks(bool use) { _narrow_oop._use_implicit_null_checks = use; } 1.196 + 1.197 // Debugging 1.198 static int _verify_count; // number of verifies done 1.199 // True during call to verify(). Should only be set/cleared in verify(). 1.200 @@ -259,38 +270,25 @@ 1.201 1.202 public: 1.203 // Known classes in the VM 1.204 - static klassOop boolArrayKlassObj() { return _boolArrayKlassObj; } 1.205 - static klassOop byteArrayKlassObj() { return _byteArrayKlassObj; } 1.206 - static klassOop charArrayKlassObj() { return _charArrayKlassObj; } 1.207 - static klassOop intArrayKlassObj() { return _intArrayKlassObj; } 1.208 - static klassOop shortArrayKlassObj() { return _shortArrayKlassObj; } 1.209 - static klassOop longArrayKlassObj() { return _longArrayKlassObj; } 1.210 - static klassOop singleArrayKlassObj() { return _singleArrayKlassObj; } 1.211 - static klassOop doubleArrayKlassObj() { return _doubleArrayKlassObj; } 1.212 + static Klass* boolArrayKlassObj() { return _boolArrayKlassObj; } 1.213 + static Klass* byteArrayKlassObj() { return _byteArrayKlassObj; } 1.214 + static Klass* charArrayKlassObj() { return _charArrayKlassObj; } 1.215 + static Klass* intArrayKlassObj() { return _intArrayKlassObj; } 1.216 + static Klass* shortArrayKlassObj() { return _shortArrayKlassObj; } 1.217 + static Klass* longArrayKlassObj() { return _longArrayKlassObj; } 1.218 + static Klass* singleArrayKlassObj() { return _singleArrayKlassObj; } 1.219 + static Klass* doubleArrayKlassObj() { return _doubleArrayKlassObj; } 1.220 1.221 - static klassOop objectArrayKlassObj() { 1.222 + static Klass* objectArrayKlassObj() { 1.223 return _objectArrayKlassObj; 1.224 } 1.225 1.226 - static klassOop typeArrayKlassObj(BasicType t) { 1.227 + static Klass* typeArrayKlassObj(BasicType t) { 1.228 assert((uint)t < T_VOID+1, err_msg("range check for type: %s", type2name(t))); 1.229 assert(_typeArrayKlassObjs[t] != NULL, "domain check"); 1.230 return _typeArrayKlassObjs[t]; 1.231 } 1.232 1.233 - static klassOop methodKlassObj() { return _methodKlassObj; } 1.234 - static klassOop constMethodKlassObj() { return _constMethodKlassObj; } 1.235 - static klassOop methodDataKlassObj() { return _methodDataKlassObj; } 1.236 - static klassOop klassKlassObj() { return _klassKlassObj; } 1.237 - static klassOop arrayKlassKlassObj() { return _arrayKlassKlassObj; } 1.238 - static klassOop objArrayKlassKlassObj() { return _objArrayKlassKlassObj; } 1.239 - static klassOop typeArrayKlassKlassObj() { return _typeArrayKlassKlassObj; } 1.240 - static klassOop instanceKlassKlassObj() { return _instanceKlassKlassObj; } 1.241 - static klassOop constantPoolKlassObj() { return _constantPoolKlassObj; } 1.242 - static klassOop constantPoolCacheKlassObj() { return _constantPoolCacheKlassObj; } 1.243 - static klassOop compiledICHolderKlassObj() { return _compiledICHolderKlassObj; } 1.244 - static klassOop systemObjArrayKlassObj() { return _systemObjArrayKlassObj; } 1.245 - 1.246 // Known objects in the VM 1.247 static oop int_mirror() { return check_mirror(_int_mirror); } 1.248 static oop float_mirror() { return check_mirror(_float_mirror); } 1.249 @@ -315,22 +313,22 @@ 1.250 static oop system_thread_group() { return _system_thread_group; } 1.251 static void set_system_thread_group(oop group) { _system_thread_group = group;} 1.252 1.253 - static typeArrayOop the_empty_byte_array() { return _the_empty_byte_array; } 1.254 - static typeArrayOop the_empty_short_array() { return _the_empty_short_array; } 1.255 - static typeArrayOop the_empty_int_array() { return _the_empty_int_array; } 1.256 - static objArrayOop the_empty_system_obj_array () { return _the_empty_system_obj_array; } 1.257 static objArrayOop the_empty_class_klass_array () { return _the_empty_class_klass_array; } 1.258 - static objArrayOop the_array_interfaces_array() { return _the_array_interfaces_array; } 1.259 + static Array<Klass*>* the_array_interfaces_array() { return _the_array_interfaces_array; } 1.260 static oop the_null_string() { return _the_null_string; } 1.261 static oop the_min_jint_string() { return _the_min_jint_string; } 1.262 - static methodOop finalizer_register_method() { return _finalizer_register_cache->get_methodOop(); } 1.263 - static methodOop loader_addClass_method() { return _loader_addClass_cache->get_methodOop(); } 1.264 + static Method* finalizer_register_method() { return _finalizer_register_cache->get_Method(); } 1.265 static ActiveMethodOopsCache* reflect_invoke_cache() { return _reflect_invoke_cache; } 1.266 static oop null_ptr_exception_instance() { return _null_ptr_exception_instance; } 1.267 static oop arithmetic_exception_instance() { return _arithmetic_exception_instance; } 1.268 static oop virtual_machine_error_instance() { return _virtual_machine_error_instance; } 1.269 static oop vm_exception() { return _vm_exception; } 1.270 1.271 + static Array<int>* the_empty_int_array() { return _the_empty_int_array; } 1.272 + static Array<u2>* the_empty_short_array() { return _the_empty_short_array; } 1.273 + static Array<Method*>* the_empty_method_array() { return _the_empty_method_array; } 1.274 + static Array<Klass*>* the_empty_klass_array() { return _the_empty_klass_array; } 1.275 + 1.276 // OutOfMemoryError support. Returns an error with the required message. The returned error 1.277 // may or may not have a backtrace. If error has a backtrace then the stack trace is already 1.278 // filled in. 1.279 @@ -340,15 +338,15 @@ 1.280 static oop out_of_memory_error_gc_overhead_limit() { return gen_out_of_memory_error(_out_of_memory_error_gc_overhead_limit); } 1.281 1.282 // Accessors needed for fast allocation 1.283 - static klassOop* boolArrayKlassObj_addr() { return &_boolArrayKlassObj; } 1.284 - static klassOop* byteArrayKlassObj_addr() { return &_byteArrayKlassObj; } 1.285 - static klassOop* charArrayKlassObj_addr() { return &_charArrayKlassObj; } 1.286 - static klassOop* intArrayKlassObj_addr() { return &_intArrayKlassObj; } 1.287 - static klassOop* shortArrayKlassObj_addr() { return &_shortArrayKlassObj; } 1.288 - static klassOop* longArrayKlassObj_addr() { return &_longArrayKlassObj; } 1.289 - static klassOop* singleArrayKlassObj_addr() { return &_singleArrayKlassObj; } 1.290 - static klassOop* doubleArrayKlassObj_addr() { return &_doubleArrayKlassObj; } 1.291 - static klassOop* systemObjArrayKlassObj_addr() { return &_systemObjArrayKlassObj; } 1.292 + static Klass** boolArrayKlassObj_addr() { return &_boolArrayKlassObj; } 1.293 + static Klass** byteArrayKlassObj_addr() { return &_byteArrayKlassObj; } 1.294 + static Klass** charArrayKlassObj_addr() { return &_charArrayKlassObj; } 1.295 + static Klass** intArrayKlassObj_addr() { return &_intArrayKlassObj; } 1.296 + static Klass** shortArrayKlassObj_addr() { return &_shortArrayKlassObj; } 1.297 + static Klass** longArrayKlassObj_addr() { return &_longArrayKlassObj; } 1.298 + static Klass** singleArrayKlassObj_addr() { return &_singleArrayKlassObj; } 1.299 + static Klass** doubleArrayKlassObj_addr() { return &_doubleArrayKlassObj; } 1.300 + static Klass** objectArrayKlassObj_addr() { return &_objectArrayKlassObj; } 1.301 1.302 // The particular choice of collected heap. 1.303 static CollectedHeap* heap() { return _collectedHeap; } 1.304 @@ -358,22 +356,13 @@ 1.305 static address narrow_oop_base() { return _narrow_oop._base; } 1.306 static bool is_narrow_oop_base(void* addr) { return (narrow_oop_base() == (address)addr); } 1.307 static int narrow_oop_shift() { return _narrow_oop._shift; } 1.308 - static void set_narrow_oop_base(address base) { _narrow_oop._base = base; } 1.309 + static bool narrow_oop_use_implicit_null_checks() { return _narrow_oop._use_implicit_null_checks; } 1.310 + 1.311 + // this is set in vm_version on sparc (and then reset in universe afaict) 1.312 static void set_narrow_oop_shift(int shift) { _narrow_oop._shift = shift; } 1.313 - static bool narrow_oop_use_implicit_null_checks() { return _narrow_oop._use_implicit_null_checks; } 1.314 - static void set_narrow_oop_use_implicit_null_checks(bool use) { _narrow_oop._use_implicit_null_checks = use; } 1.315 - // Narrow Oop encoding mode: 1.316 - // 0 - Use 32-bits oops without encoding when 1.317 - // NarrowOopHeapBaseMin + heap_size < 4Gb 1.318 - // 1 - Use zero based compressed oops with encoding when 1.319 - // NarrowOopHeapBaseMin + heap_size < 32Gb 1.320 - // 2 - Use compressed oops with heap base + encoding. 1.321 - enum NARROW_OOP_MODE { 1.322 - UnscaledNarrowOop = 0, 1.323 - ZeroBasedNarrowOop = 1, 1.324 - HeapBasedNarrowOop = 2 1.325 - }; 1.326 - static char* preferred_heap_base(size_t heap_size, NARROW_OOP_MODE mode); 1.327 + 1.328 + // Reserve Java heap and determine CompressedOops mode 1.329 + static ReservedSpace reserve_heap(size_t heap_size, size_t alignment); 1.330 1.331 // Historic gc information 1.332 static size_t get_heap_capacity_at_last_gc() { return _heap_capacity_at_last_gc; } 1.333 @@ -400,12 +389,12 @@ 1.334 // as static fields of "Universe". 1.335 static void oops_do(OopClosure* f, bool do_all = false); 1.336 1.337 + // CDS support 1.338 + static void serialize(SerializeClosure* f, bool do_all = false); 1.339 + 1.340 // Apply "f" to all klasses for basic types (classes not present in 1.341 // SystemDictionary). 1.342 - static void basic_type_classes_do(void f(klassOop)); 1.343 - 1.344 - // Apply "f" to all system klasses (classes not present in SystemDictionary). 1.345 - static void system_classes_do(void f(klassOop)); 1.346 + static void basic_type_classes_do(void f(Klass*)); 1.347 1.348 // For sharing -- fill in a list of known vtable pointers. 1.349 static void init_self_patching_vtbl_list(void** list, int count); 1.350 @@ -438,8 +427,6 @@ 1.351 static uintptr_t verify_oop_bits() PRODUCT_RETURN0; 1.352 static uintptr_t verify_mark_bits() PRODUCT_RETURN0; 1.353 static uintptr_t verify_mark_mask() PRODUCT_RETURN0; 1.354 - static uintptr_t verify_klass_mask() PRODUCT_RETURN0; 1.355 - static uintptr_t verify_klass_bits() PRODUCT_RETURN0; 1.356 1.357 // Flushing and deoptimization 1.358 static void flush_dependents_on(instanceKlassHandle dependee);