61 #include "runtime/safepointVerifiers.hpp" |
61 #include "runtime/safepointVerifiers.hpp" |
62 #include "runtime/thread.inline.hpp" |
62 #include "runtime/thread.inline.hpp" |
63 #include "runtime/vframe.inline.hpp" |
63 #include "runtime/vframe.inline.hpp" |
64 #include "utilities/align.hpp" |
64 #include "utilities/align.hpp" |
65 #include "utilities/preserveException.hpp" |
65 #include "utilities/preserveException.hpp" |
66 |
|
67 #if INCLUDE_JVMCI |
66 #if INCLUDE_JVMCI |
68 #include "jvmci/jvmciJavaClasses.hpp" |
67 #include "jvmci/jvmciJavaClasses.hpp" |
69 #endif |
68 #endif |
70 |
69 |
71 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java) \ |
70 #define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java) \ |
796 if (!k->is_shared()) { |
795 if (!k->is_shared()) { |
797 if (k->is_instance_klass()) { |
796 if (k->is_instance_klass()) { |
798 // During bootstrap, java.lang.Class wasn't loaded so static field |
797 // During bootstrap, java.lang.Class wasn't loaded so static field |
799 // offsets were computed without the size added it. Go back and |
798 // offsets were computed without the size added it. Go back and |
800 // update all the static field offsets to included the size. |
799 // update all the static field offsets to included the size. |
801 for (JavaFieldStream fs(InstanceKlass::cast(k)); !fs.done(); fs.next()) { |
800 for (JavaFieldStream fs(InstanceKlass::cast(k)); !fs.done(); fs.next()) { |
802 if (fs.access_flags().is_static()) { |
801 if (fs.access_flags().is_static()) { |
803 int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); |
802 int real_offset = fs.offset() + InstanceMirrorKlass::offset_of_static_fields(); |
804 fs.set_offset(real_offset); |
803 fs.set_offset(real_offset); |
805 } |
804 } |
806 } |
805 } |
807 } |
806 } |
808 } |
807 } |
809 |
808 |
810 if (k->is_shared() && k->has_raw_archived_mirror()) { |
809 if (k->is_shared() && k->has_raw_archived_mirror()) { |
811 if (MetaspaceShared::open_archive_heap_region_mapped()) { |
810 if (MetaspaceShared::open_archive_heap_region_mapped()) { |
812 oop m = k->archived_java_mirror(); |
811 bool present = restore_archived_mirror(k, Handle(), Handle(), Handle(), CHECK); |
813 assert(m != NULL, "archived mirror is NULL"); |
812 assert(present, "Missing archived mirror for %s", k->external_name()); |
814 assert(MetaspaceShared::is_archive_object(m), "must be archived mirror object"); |
|
815 Handle m_h(THREAD, m); |
|
816 // restore_archived_mirror() clears the klass' _has_raw_archived_mirror flag |
|
817 restore_archived_mirror(k, m_h, Handle(), Handle(), Handle(), CHECK); |
|
818 return; |
813 return; |
819 } else { |
814 } else { |
820 k->set_java_mirror_handle(NULL); |
815 k->set_java_mirror_handle(NULL); |
821 k->clear_has_raw_archived_mirror(); |
816 k->clear_has_raw_archived_mirror(); |
822 } |
817 } |
1205 archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr); |
1200 archived_mirror->metadata_field_put(_array_klass_offset, reloc_arr); |
1206 } |
1201 } |
1207 return archived_mirror; |
1202 return archived_mirror; |
1208 } |
1203 } |
1209 |
1204 |
1210 // After the archived mirror object is restored, the shared klass' |
1205 // Returns true if the mirror is updated, false if no archived mirror |
1211 // _has_raw_archived_mirror flag is cleared |
1206 // data is present. After the archived mirror object is restored, the |
1212 void java_lang_Class::restore_archived_mirror(Klass *k, Handle mirror, |
1207 // shared klass' _has_raw_archived_mirror flag is cleared. |
|
1208 bool java_lang_Class::restore_archived_mirror(Klass *k, |
1213 Handle class_loader, Handle module, |
1209 Handle class_loader, Handle module, |
1214 Handle protection_domain, TRAPS) { |
1210 Handle protection_domain, TRAPS) { |
|
1211 oop m = MetaspaceShared::materialize_archived_object(k->archived_java_mirror_raw()); |
|
1212 |
|
1213 if (m == NULL) { |
|
1214 return false; |
|
1215 } |
|
1216 |
|
1217 log_debug(cds, mirror)("Archived mirror is: " PTR_FORMAT, p2i(m)); |
|
1218 |
|
1219 // mirror is archived, restore |
|
1220 assert(MetaspaceShared::is_archive_object(m), "must be archived mirror object"); |
|
1221 Handle mirror(THREAD, m); |
1215 |
1222 |
1216 // The java.lang.Class field offsets were archived and reloaded from archive. |
1223 // The java.lang.Class field offsets were archived and reloaded from archive. |
1217 // No need to put classes on the fixup_mirror_list before java.lang.Class |
1224 // No need to put classes on the fixup_mirror_list before java.lang.Class |
1218 // is loaded. |
1225 // is loaded. |
1219 |
1226 |
1220 if (!k->is_array_klass()) { |
1227 if (!k->is_array_klass()) { |
1221 // - local static final fields with initial values were initialized at dump time |
1228 // - local static final fields with initial values were initialized at dump time |
1222 |
1229 |
1223 // create the init_lock |
1230 // create the init_lock |
1224 typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK); |
1231 typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_(false)); |
1225 set_init_lock(mirror(), r); |
1232 set_init_lock(mirror(), r); |
1226 |
1233 |
1227 if (protection_domain.not_null()) { |
1234 if (protection_domain.not_null()) { |
1228 set_protection_domain(mirror(), protection_domain()); |
1235 set_protection_domain(mirror(), protection_domain()); |
1229 } |
1236 } |
1239 |
1246 |
1240 set_mirror_module_field(k, mirror, module, THREAD); |
1247 set_mirror_module_field(k, mirror, module, THREAD); |
1241 |
1248 |
1242 ResourceMark rm; |
1249 ResourceMark rm; |
1243 log_trace(cds, mirror)("Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror())); |
1250 log_trace(cds, mirror)("Restored %s archived mirror " PTR_FORMAT, k->external_name(), p2i(mirror())); |
|
1251 |
|
1252 return true; |
1244 } |
1253 } |
1245 #endif // INCLUDE_CDS_JAVA_HEAP |
1254 #endif // INCLUDE_CDS_JAVA_HEAP |
1246 |
1255 |
1247 void java_lang_Class::fixup_module_field(Klass* k, Handle module) { |
1256 void java_lang_Class::fixup_module_field(Klass* k, Handle module) { |
1248 assert(_module_offset != 0, "must have been computed already"); |
1257 assert(_module_offset != 0, "must have been computed already"); |