2727
2828class ClassLoaderData ;
2929
30+ // The InstanceKlassFlags class contains the parse-time and writeable flags associated with
31+ // an InstanceKlass, and their associated accessors.
32+ // _flags are parse-time and constant in the InstanceKlass after that. _status are set at runtime and
33+ // require atomic access.
34+ // These flags are JVM internal and not part of the AccessFlags classfile specification.
35+
3036class InstanceKlassFlags {
3137 friend class VMStructs ;
3238 friend class JVMCIVMStructs ;
@@ -35,32 +41,45 @@ class InstanceKlassFlags {
3541 flag (rewritten , 1 << 0 ) /* methods rewritten. */ \
3642 flag (has_nonstatic_fields , 1 << 1 ) /* for sizing with UseCompressedOops */ \
3743 flag (should_verify_class , 1 << 2 ) /* allow caching of preverification */ \
38- flag (unused , 1 << 3 ) /* not currently used */ \
39- flag (is_contended , 1 << 4 ) /* marked with contended annotation */ \
40- flag (has_nonstatic_concrete_methods , 1 << 5 ) /* class/superclass/implemented interfaces has non-static, concrete methods */ \
41- flag (declares_nonstatic_concrete_methods, 1 << 6 ) /* directly declares non-static, concrete methods */ \
42- flag (has_been_redefined , 1 << 7 ) /* class has been redefined */ \
43- flag (shared_loading_failed , 1 << 8 ) /* class has been loaded from shared archive */ \
44- flag (is_scratch_class , 1 << 9 ) /* class is the redefined scratch class */ \
45- flag (is_shared_boot_class , 1 << 10 ) /* defining class loader is boot class loader */ \
46- flag (is_shared_platform_class , 1 << 11 ) /* defining class loader is platform class loader */ \
47- flag (is_shared_app_class , 1 << 12 ) /* defining class loader is app class loader */ \
48- flag (has_contended_annotations , 1 << 13 ) /* has @Contended annotation */ \
49- flag (has_localvariable_table , 1 << 14 ) /* has localvariable information */
44+ flag (is_contended , 1 << 3 ) /* marked with contended annotation */ \
45+ flag (has_nonstatic_concrete_methods , 1 << 4 ) /* class/superclass/implemented interfaces has non-static, concrete methods */ \
46+ flag (declares_nonstatic_concrete_methods, 1 << 5 ) /* directly declares non-static, concrete methods */ \
47+ flag (shared_loading_failed , 1 << 6 ) /* class has been loaded from shared archive */ \
48+ flag (is_shared_boot_class , 1 << 7 ) /* defining class loader is boot class loader */ \
49+ flag (is_shared_platform_class , 1 << 8 ) /* defining class loader is platform class loader */ \
50+ flag (is_shared_app_class , 1 << 9 ) /* defining class loader is app class loader */ \
51+ flag (has_contended_annotations , 1 << 10 ) /* has @Contended annotation */ \
52+ flag (has_localvariable_table , 1 << 11 ) /* has localvariable information */
5053
5154#define IK_FLAGS_ENUM_NAME (name, value ) _misc_##name = value,
5255 enum {
5356 IK_FLAGS_DO (IK_FLAGS_ENUM_NAME)
5457 };
5558#undef IK_FLAGS_ENUM_NAME
5659
60+ #define IK_STATUS_DO (status ) \
61+ status (is_being_redefined , 1 << 0 ) /* True if the klass is being redefined */ \
62+ status (has_resolved_methods , 1 << 1 ) /* True if the klass has resolved MethodHandle methods */ \
63+ status (has_been_redefined , 1 << 2 ) /* class has been redefined */ \
64+ status (is_scratch_class , 1 << 3 ) /* class is the redefined scratch class */ \
65+ status (is_marked_dependent , 1 << 4 ) /* class is the redefined scratch class */
66+
67+ #define IK_STATUS_ENUM_NAME (name, value ) _misc_##name = value,
68+ enum {
69+ IK_STATUS_DO (IK_STATUS_ENUM_NAME)
70+ };
71+ #undef IK_STATUS_ENUM_NAME
72+
5773 u2 shared_loader_type_bits () const {
5874 return _misc_is_shared_boot_class|_misc_is_shared_platform_class|_misc_is_shared_app_class;
5975 }
6076
6177 // These flags are write-once before the class is published and then read-only so don't require atomic updates.
6278 u2 _flags;
6379
80+ // These flags are written during execution so require atomic stores
81+ u1 _status;
82+
6483 public:
6584
6685 InstanceKlassFlags () : _flags(0 ) {}
@@ -87,6 +106,26 @@ class InstanceKlassFlags {
87106
88107 void assign_class_loader_type (const ClassLoaderData* cld);
89108 void assert_is_safe (bool set) NOT_DEBUG_RETURN;
109+
110+ // Create getters and setters for the status values.
111+ #define IK_STATUS_GET (name, ignore ) \
112+ bool name () const { return (_status & _misc_##name) != 0 ; }
113+ IK_STATUS_DO (IK_STATUS_GET)
114+ #undef IK_STATUS_GET
115+
116+ #define IK_STATUS_SET (name, ignore ) \
117+ void set_##name(bool b) { \
118+ if (b) { \
119+ atomic_set_bits (_misc_##name); \
120+ } else { \
121+ atomic_clear_bits (_misc_##name); \
122+ } \
123+ }
124+ IK_STATUS_DO (IK_STATUS_SET)
125+ #undef IK_STATUS_SET
126+
127+ void atomic_set_bits (u1 bits);
128+ void atomic_clear_bits (u1 bits);
90129};
91130
92131#endif // SHARE_OOPS_INSTANCEKLASSFLAGS_HPP
0 commit comments