Skip to content

Commit dbf4fff

Browse files
committed
8366477: Refactor AOT-related flag bits in klass.hpp
Reviewed-by: liach, asmehra, kvn
1 parent cdc8b5e commit dbf4fff

File tree

7 files changed

+50
-40
lines changed

7 files changed

+50
-40
lines changed

src/hotspot/share/cds/archiveBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ void ArchiveBuilder::make_klasses_shareable() {
942942
old = " old";
943943
}
944944

945-
if (ik->is_generated_shared_class()) {
945+
if (ik->is_aot_generated_class()) {
946946
generated = " generated";
947947
}
948948
if (aotlinked) {

src/hotspot/share/cds/lambdaFormInvokers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) {
184184
klass->set_shared_classpath_index(0);
185185
// Set the "generated" bit, so it won't interfere with JVMTI.
186186
// See SystemDictionaryShared::find_builtin_class().
187-
klass->set_is_generated_shared_class();
187+
klass->set_is_aot_generated_class();
188188
}
189189
} else {
190190
int len = h_bytes->length();
@@ -222,7 +222,7 @@ void LambdaFormInvokers::regenerate_class(char* class_name, ClassFileStream& st,
222222
AOTMetaspace::try_link_class(THREAD, result);
223223
assert(!HAS_PENDING_EXCEPTION, "Invariant");
224224

225-
result->set_is_generated_shared_class();
225+
result->set_is_aot_generated_class();
226226
if (!klass->in_aot_cache()) {
227227
log_info(aot, lambda)("regenerate_class excluding klass %s %s", class_name, klass->name()->as_C_string());
228228
SystemDictionaryShared::set_excluded(InstanceKlass::cast(klass)); // exclude the existing class from dump

src/hotspot/share/classfile/systemDictionaryShared.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ InstanceKlass* SystemDictionaryShared::find_builtin_class(Symbol* name) {
11461146
DEBUG_ONLY(check_klass_after_loading(record->klass());)
11471147
// We did not save the classfile data of the generated LambdaForm invoker classes,
11481148
// so we cannot support CLFH for such classes.
1149-
if (record->klass()->is_generated_shared_class() && JvmtiExport::should_post_class_file_load_hook()) {
1149+
if (record->klass()->is_aot_generated_class() && JvmtiExport::should_post_class_file_load_hook()) {
11501150
return nullptr;
11511151
}
11521152
return record->klass();

src/hotspot/share/oops/instanceKlass.hpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,6 @@ class InstanceKlass: public Klass {
764764
bool has_final_method() const { return _misc_flags.has_final_method(); }
765765
void set_has_final_method() { _misc_flags.set_has_final_method(true); }
766766

767-
// Indicates presence of @AOTSafeClassInitializer. Also see AOTClassInitializer for more details.
768-
bool has_aot_safe_initializer() const { return _misc_flags.has_aot_safe_initializer(); }
769-
void set_has_aot_safe_initializer() { _misc_flags.set_has_aot_safe_initializer(true); }
770-
771-
// Indicates @AOTRuntimeSetup private static void runtimeSetup() presence.
772-
bool is_runtime_setup_required() const { return _misc_flags.is_runtime_setup_required(); }
773-
void set_is_runtime_setup_required() { _misc_flags.set_is_runtime_setup_required(true); }
774-
775767
// for adding methods, ConstMethod::UNSET_IDNUM means no more ids available
776768
inline u2 next_method_idnum();
777769
void set_initial_method_idnum(u2 value) { _idnum_allocated_count = value; }

src/hotspot/share/oops/instanceKlassFlags.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ class InstanceKlassFlags {
5454
flag(has_localvariable_table , 1 << 11) /* has localvariable information */ \
5555
flag(has_miranda_methods , 1 << 12) /* True if this class has miranda methods in it's vtable */ \
5656
flag(has_final_method , 1 << 13) /* True if klass has final method */ \
57-
flag(has_aot_safe_initializer , 1 << 14) /* has @AOTSafeClassInitializer annotation */ \
58-
flag(is_runtime_setup_required , 1 << 15) /* has a runtimeSetup method to be called */ \
5957
/* end of list */
6058

6159
#define IK_FLAGS_ENUM_NAME(name, value) _misc_##name = value,

src/hotspot/share/oops/klass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ Klass::Klass() : _kind(UnknownKlassKind) {
302302
Klass::Klass(KlassKind kind) : _kind(kind),
303303
_prototype_header(make_prototype(this)),
304304
_shared_class_path_index(-1) {
305-
CDS_ONLY(_shared_class_flags = 0;)
305+
CDS_ONLY(_aot_class_flags = 0;)
306306
CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
307307
_primary_supers[0] = this;
308308
set_super_check_offset(in_bytes(primary_supers_offset()));

src/hotspot/share/oops/klass.hpp

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,20 @@ class Klass : public Metadata {
174174

175175
#if INCLUDE_CDS
176176
// Various attributes for shared classes. Should be zero for a non-shared class.
177-
u2 _shared_class_flags;
178-
enum CDSSharedClassFlags {
177+
u2 _aot_class_flags;
178+
enum {
179179
_in_aot_cache = 1 << 0,
180180
_archived_lambda_proxy_is_available = 1 << 1,
181181
_has_value_based_class_annotation = 1 << 2,
182182
_verified_at_dump_time = 1 << 3,
183183
_has_archived_enum_objs = 1 << 4,
184-
// This class was not loaded from a classfile in the module image
185-
// or classpath.
186-
_is_generated_shared_class = 1 << 5,
187-
// archived mirror already initialized by AOT-cache assembly: no further need to call <clinit>
188-
_has_aot_initialized_mirror = 1 << 6,
184+
_is_aot_generated_class = 1 << 5, // this class was not loaded from a classfile in the module image
185+
// or classpath, but was generated during AOT cache assembly.
186+
_has_aot_initialized_mirror = 1 << 6, // archived mirror already initialized by AOT cache assembly.
187+
// no further need to call <clinit>
188+
_has_aot_safe_initializer = 1 << 7, // has @AOTSafeClassInitializer annotation
189+
_is_runtime_setup_required = 1 << 8, // has a runtimeSetup method to be called when
190+
// this class is loaded from AOT cache
189191
};
190192
#endif
191193

@@ -325,66 +327,84 @@ class Klass : public Metadata {
325327
void clear_archived_mirror_index() NOT_CDS_JAVA_HEAP_RETURN;
326328

327329
void set_lambda_proxy_is_available() {
328-
CDS_ONLY(_shared_class_flags |= _archived_lambda_proxy_is_available;)
330+
CDS_ONLY(_aot_class_flags |= _archived_lambda_proxy_is_available;)
329331
}
330332
void clear_lambda_proxy_is_available() {
331-
CDS_ONLY(_shared_class_flags &= (u2)(~_archived_lambda_proxy_is_available);)
333+
CDS_ONLY(_aot_class_flags &= (u2)(~_archived_lambda_proxy_is_available);)
332334
}
333335
bool lambda_proxy_is_available() const {
334-
CDS_ONLY(return (_shared_class_flags & _archived_lambda_proxy_is_available) != 0;)
336+
CDS_ONLY(return (_aot_class_flags & _archived_lambda_proxy_is_available) != 0;)
335337
NOT_CDS(return false;)
336338
}
337339

338340
void set_has_value_based_class_annotation() {
339-
CDS_ONLY(_shared_class_flags |= _has_value_based_class_annotation;)
341+
CDS_ONLY(_aot_class_flags |= _has_value_based_class_annotation;)
340342
}
341343
void clear_has_value_based_class_annotation() {
342-
CDS_ONLY(_shared_class_flags &= (u2)(~_has_value_based_class_annotation);)
344+
CDS_ONLY(_aot_class_flags &= (u2)(~_has_value_based_class_annotation);)
343345
}
344346
bool has_value_based_class_annotation() const {
345-
CDS_ONLY(return (_shared_class_flags & _has_value_based_class_annotation) != 0;)
347+
CDS_ONLY(return (_aot_class_flags & _has_value_based_class_annotation) != 0;)
346348
NOT_CDS(return false;)
347349
}
348350

349351
void set_verified_at_dump_time() {
350-
CDS_ONLY(_shared_class_flags |= _verified_at_dump_time;)
352+
CDS_ONLY(_aot_class_flags |= _verified_at_dump_time;)
351353
}
352354
bool verified_at_dump_time() const {
353-
CDS_ONLY(return (_shared_class_flags & _verified_at_dump_time) != 0;)
355+
CDS_ONLY(return (_aot_class_flags & _verified_at_dump_time) != 0;)
354356
NOT_CDS(return false;)
355357
}
356358

357359
void set_has_archived_enum_objs() {
358-
CDS_ONLY(_shared_class_flags |= _has_archived_enum_objs;)
360+
CDS_ONLY(_aot_class_flags |= _has_archived_enum_objs;)
359361
}
360362
bool has_archived_enum_objs() const {
361-
CDS_ONLY(return (_shared_class_flags & _has_archived_enum_objs) != 0;)
363+
CDS_ONLY(return (_aot_class_flags & _has_archived_enum_objs) != 0;)
362364
NOT_CDS(return false;)
363365
}
364366

365-
void set_is_generated_shared_class() {
366-
CDS_ONLY(_shared_class_flags |= _is_generated_shared_class;)
367+
void set_is_aot_generated_class() {
368+
CDS_ONLY(_aot_class_flags |= _is_aot_generated_class;)
367369
}
368-
bool is_generated_shared_class() const {
369-
CDS_ONLY(return (_shared_class_flags & _is_generated_shared_class) != 0;)
370+
bool is_aot_generated_class() const {
371+
CDS_ONLY(return (_aot_class_flags & _is_aot_generated_class) != 0;)
370372
NOT_CDS(return false;)
371373
}
372374

373375
void set_has_aot_initialized_mirror() {
374-
CDS_ONLY(_shared_class_flags |= _has_aot_initialized_mirror;)
376+
CDS_ONLY(_aot_class_flags |= _has_aot_initialized_mirror;)
375377
}
376378
bool has_aot_initialized_mirror() const {
377-
CDS_ONLY(return (_shared_class_flags & _has_aot_initialized_mirror) != 0;)
379+
CDS_ONLY(return (_aot_class_flags & _has_aot_initialized_mirror) != 0;)
380+
NOT_CDS(return false;)
381+
}
382+
383+
// Indicates presence of @AOTSafeClassInitializer. Also see AOTClassInitializer for more details.
384+
void set_has_aot_safe_initializer() {
385+
CDS_ONLY(_aot_class_flags |= _has_aot_safe_initializer;)
386+
}
387+
bool has_aot_safe_initializer() const {
388+
CDS_ONLY(return (_aot_class_flags & _has_aot_safe_initializer) != 0;)
389+
NOT_CDS(return false;)
390+
}
391+
392+
// Indicates @AOTRuntimeSetup private static void runtimeSetup() presence.
393+
void set_is_runtime_setup_required() {
394+
CDS_ONLY(_aot_class_flags |= _is_runtime_setup_required;)
395+
}
396+
bool is_runtime_setup_required() const {
397+
CDS_ONLY(return (_aot_class_flags & _is_runtime_setup_required) != 0;)
378398
NOT_CDS(return false;)
379399
}
380400

381401
bool in_aot_cache() const { // shadows MetaspaceObj::in_aot_cache)()
382-
CDS_ONLY(return (_shared_class_flags & _in_aot_cache) != 0;)
402+
CDS_ONLY(return (_aot_class_flags & _in_aot_cache) != 0;)
383403
NOT_CDS(return false;)
384404
}
385405

386406
void set_in_aot_cache() {
387-
CDS_ONLY(_shared_class_flags |= _in_aot_cache;)
407+
CDS_ONLY(_aot_class_flags |= _in_aot_cache;)
388408
}
389409

390410
// Obtain the module or package for this class

0 commit comments

Comments
 (0)