Mercurial > hg > truffle
comparison src/share/vm/oops/instanceKlass.hpp @ 4737:75c0a73eee98
7102776: Pack instanceKlass boolean fields into single u1 field
Summary: Reduce class runtime memory usage by packing 4 instanceKlass boolean fields into single u1 field. Save 4-byte for each loaded class.
Reviewed-by: dholmes, bobv, phh, twisti, never, coleenp
Contributed-by: Jiangli Zhou <jiangli.zhou@oracle.com>
author | coleenp |
---|---|
date | Thu, 17 Nov 2011 12:53:59 -0500 |
parents | f6f3bb0ee072 |
children | 52b5d32fbfaf |
comparison
equal
deleted
inserted
replaced
4038:869804b759e7 | 4737:75c0a73eee98 |
---|---|
228 int _nonstatic_field_size; | 228 int _nonstatic_field_size; |
229 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass | 229 int _static_field_size; // number words used by static fields (oop and non-oop) in this klass |
230 int _static_oop_field_count;// number of static oop fields in this klass | 230 int _static_oop_field_count;// number of static oop fields in this klass |
231 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks | 231 int _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks |
232 int _java_fields_count; // The number of declared Java fields | 232 int _java_fields_count; // The number of declared Java fields |
233 bool _is_marked_dependent; // used for marking during flushing and deoptimization | 233 |
234 bool _rewritten; // methods rewritten. | |
235 bool _has_nonstatic_fields; // for sizing with UseCompressedOops | |
236 bool _should_verify_class; // allow caching of preverification | |
237 u2 _minor_version; // minor version number of class file | 234 u2 _minor_version; // minor version number of class file |
238 u2 _major_version; // major version number of class file | 235 u2 _major_version; // major version number of class file |
239 ClassState _init_state; // state of class | 236 ClassState _init_state; // state of class |
240 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) | 237 Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) |
241 int _vtable_len; // length of Java vtable (in words) | 238 int _vtable_len; // length of Java vtable (in words) |
258 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH | 255 unsigned char * _cached_class_file_bytes; // JVMTI: cached class file, before retransformable agent modified it in CFLH |
259 jint _cached_class_file_len; // JVMTI: length of above | 256 jint _cached_class_file_len; // JVMTI: length of above |
260 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration | 257 JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration |
261 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change | 258 volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change |
262 | 259 |
260 // Compact the following four boolean flags into 1-bit each. These four flags | |
261 // were defined as separate boolean fields and each was 1-byte before. Since | |
262 // there are 2 bytes unused after the _idnum_allocated_count field, place the | |
263 // _misc_flags field after _idnum_allocated_count to utilize the unused bits | |
264 // and save total 4-bytes. | |
265 enum { | |
266 IS_MARKED_DEPENDENT = 0x1, // used for marking during flushing and deoptimization | |
267 REWRITTEN = 0x2, // methods rewritten. | |
268 HAS_NONSTATIC_FIELDS = 0x4, // for sizing with UseCompressedOops | |
269 SHOULD_VERIFY_CLASS = 0x8 // allow caching of preverification | |
270 }; | |
271 u1 _misc_flags; | |
272 | |
263 // embedded Java vtable follows here | 273 // embedded Java vtable follows here |
264 // embedded Java itables follows here | 274 // embedded Java itables follows here |
265 // embedded static fields follows here | 275 // embedded static fields follows here |
266 // embedded nonstatic oop-map blocks follows here | 276 // embedded nonstatic oop-map blocks follows here |
267 | 277 |
268 friend class instanceKlassKlass; | 278 friend class instanceKlassKlass; |
269 friend class SystemDictionary; | 279 friend class SystemDictionary; |
270 | 280 |
271 public: | 281 public: |
272 bool has_nonstatic_fields() const { return _has_nonstatic_fields; } | 282 bool has_nonstatic_fields() const { return (_misc_flags & HAS_NONSTATIC_FIELDS) != 0; } |
273 void set_has_nonstatic_fields(bool b) { _has_nonstatic_fields = b; } | 283 void set_has_nonstatic_fields(bool b) { |
284 if (b) { | |
285 _misc_flags |= HAS_NONSTATIC_FIELDS; | |
286 } else { | |
287 _misc_flags &= ~HAS_NONSTATIC_FIELDS; | |
288 } | |
289 } | |
274 | 290 |
275 // field sizes | 291 // field sizes |
276 int nonstatic_field_size() const { return _nonstatic_field_size; } | 292 int nonstatic_field_size() const { return _nonstatic_field_size; } |
277 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; } | 293 void set_nonstatic_field_size(int size) { _nonstatic_field_size = size; } |
278 | 294 |
376 bool is_not_initialized() const { return _init_state < being_initialized; } | 392 bool is_not_initialized() const { return _init_state < being_initialized; } |
377 bool is_being_initialized() const { return _init_state == being_initialized; } | 393 bool is_being_initialized() const { return _init_state == being_initialized; } |
378 bool is_in_error_state() const { return _init_state == initialization_error; } | 394 bool is_in_error_state() const { return _init_state == initialization_error; } |
379 bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; } | 395 bool is_reentrant_initialization(Thread *thread) { return thread == _init_thread; } |
380 int get_init_state() { return _init_state; } // Useful for debugging | 396 int get_init_state() { return _init_state; } // Useful for debugging |
381 bool is_rewritten() const { return _rewritten; } | 397 bool is_rewritten() const { return (_misc_flags & REWRITTEN) != 0; } |
382 | 398 |
383 // defineClass specified verification | 399 // defineClass specified verification |
384 bool should_verify_class() const { return _should_verify_class; } | 400 bool should_verify_class() const { return (_misc_flags & SHOULD_VERIFY_CLASS) != 0; } |
385 void set_should_verify_class(bool value) { _should_verify_class = value; } | 401 void set_should_verify_class(bool value) { |
402 if (value) { | |
403 _misc_flags |= SHOULD_VERIFY_CLASS; | |
404 } else { | |
405 _misc_flags &= ~SHOULD_VERIFY_CLASS; | |
406 } | |
407 } | |
408 | |
386 | 409 |
387 // marking | 410 // marking |
388 bool is_marked_dependent() const { return _is_marked_dependent; } | 411 bool is_marked_dependent() const { return (_misc_flags & IS_MARKED_DEPENDENT) != 0; } |
389 void set_is_marked_dependent(bool value) { _is_marked_dependent = value; } | 412 void set_is_marked_dependent() { _misc_flags |= IS_MARKED_DEPENDENT; } |
413 void clear_is_marked_dependent() { _misc_flags &= ~IS_MARKED_DEPENDENT; } | |
390 | 414 |
391 // initialization (virtuals from Klass) | 415 // initialization (virtuals from Klass) |
392 bool should_be_initialized() const; // means that initialize should be called | 416 bool should_be_initialized() const; // means that initialize should be called |
393 void initialize(TRAPS); | 417 void initialize(TRAPS); |
394 void link_class(TRAPS); | 418 void link_class(TRAPS); |
754 #ifdef ASSERT | 778 #ifdef ASSERT |
755 void set_init_state(ClassState state); | 779 void set_init_state(ClassState state); |
756 #else | 780 #else |
757 void set_init_state(ClassState state) { _init_state = state; } | 781 void set_init_state(ClassState state) { _init_state = state; } |
758 #endif | 782 #endif |
759 void set_rewritten() { _rewritten = true; } | 783 void set_rewritten() { _misc_flags |= REWRITTEN; } |
760 void set_init_thread(Thread *thread) { _init_thread = thread; } | 784 void set_init_thread(Thread *thread) { _init_thread = thread; } |
761 | 785 |
762 u2 idnum_allocated_count() const { return _idnum_allocated_count; } | 786 u2 idnum_allocated_count() const { return _idnum_allocated_count; } |
763 // The RedefineClasses() API can cause new method idnums to be needed | 787 // The RedefineClasses() API can cause new method idnums to be needed |
764 // which will cause the caches to grow. Safety requires different | 788 // which will cause the caches to grow. Safety requires different |