< prev index next >

src/hotspot/share/classfile/javaClasses.cpp

Print this page




1104         break;
1105       case T_ARRAY:
1106       case T_OBJECT: {
1107         // It might be useful to cache the String field, but
1108         // for now just clear out any reference field
1109         oop o = _m()->obj_field(fd->offset());
1110         _m()->obj_field_put(fd->offset(), NULL);
1111         break;
1112       }
1113       default:
1114         ShouldNotReachHere();
1115         break;
1116      }
1117   }
1118 };
1119 
1120 void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
1121   assert(HeapShared::is_heap_object_archiving_allowed(),
1122          "HeapShared::is_heap_object_archiving_allowed() must be true");
1123 
1124   for (int t = T_BOOLEAN; t < T_VOID+1; t++) {
1125     BasicType bt = (BasicType)t;
1126     oop m = Universe::_mirrors[t].resolve();
1127     if (m != NULL) {
1128       // Update the field at _array_klass_offset to point to the relocated array klass.
1129       oop archived_m = HeapShared::archive_heap_object(m, THREAD);
1130       assert(archived_m != NULL, "sanity");
1131       Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
1132       assert(ak != NULL || t == T_VOID, "should not be NULL");
1133       if (ak != NULL) {
1134         Klass *reloc_ak = MetaspaceShared::get_relocated_klass(ak, true);
1135         archived_m->metadata_field_put(_array_klass_offset, reloc_ak);
1136       }
1137 
1138       // Clear the fields. Just to be safe
1139       Klass *k = m->klass();
1140       Handle archived_mirror_h(THREAD, archived_m);
1141       ResetMirrorField reset(archived_mirror_h);
1142       InstanceKlass::cast(k)->do_nonstatic_fields(&reset);
1143 
1144       log_trace(cds, heap, mirror)(
1145         "Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
1146         type2name(bt), p2i(m), p2i(archived_m));
1147 
1148       Universe::replace_mirror(bt, archived_m);
1149     }
1150   }




















1151 }

1152 //
1153 // After the mirror object is successfully archived, the archived
1154 // klass is set with _has_archived_raw_mirror flag.
1155 //
1156 // The _has_archived_raw_mirror flag is cleared at runtime when the
1157 // archived mirror is restored. If archived java heap data cannot
1158 // be used at runtime, new mirror object is created for the shared
1159 // class. The _has_archived_raw_mirror is cleared also during the process.
1160 oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
1161   assert(HeapShared::is_heap_object_archiving_allowed(),
1162          "HeapShared::is_heap_object_archiving_allowed() must be true");
1163 
1164   // Mirror is already archived
1165   if (k->has_raw_archived_mirror()) {
1166     assert(k->archived_java_mirror_raw() != NULL, "no archived mirror");
1167     return k->archived_java_mirror_raw();
1168   }
1169 
1170   // No mirror
1171   oop mirror = k->java_mirror();




1104         break;
1105       case T_ARRAY:
1106       case T_OBJECT: {
1107         // It might be useful to cache the String field, but
1108         // for now just clear out any reference field
1109         oop o = _m()->obj_field(fd->offset());
1110         _m()->obj_field_put(fd->offset(), NULL);
1111         break;
1112       }
1113       default:
1114         ShouldNotReachHere();
1115         break;
1116      }
1117   }
1118 };
1119 
1120 void java_lang_Class::archive_basic_type_mirrors(TRAPS) {
1121   assert(HeapShared::is_heap_object_archiving_allowed(),
1122          "HeapShared::is_heap_object_archiving_allowed() must be true");
1123 
1124   for (int t = 0; t <= T_VOID; t++) {
1125     oop m = Universe::_mirrors[t];

1126     if (m != NULL) {
1127       // Update the field at _array_klass_offset to point to the relocated array klass.
1128       oop archived_m = HeapShared::archive_heap_object(m, THREAD);
1129       assert(archived_m != NULL, "sanity");
1130       Klass *ak = (Klass*)(archived_m->metadata_field(_array_klass_offset));
1131       assert(ak != NULL || t == T_VOID, "should not be NULL");
1132       if (ak != NULL) {
1133         Klass *reloc_ak = MetaspaceShared::get_relocated_klass(ak, true);
1134         archived_m->metadata_field_put(_array_klass_offset, reloc_ak);
1135       }
1136 
1137       // Clear the fields. Just to be safe
1138       Klass *k = m->klass();
1139       Handle archived_mirror_h(THREAD, archived_m);
1140       ResetMirrorField reset(archived_mirror_h);
1141       InstanceKlass::cast(k)->do_nonstatic_fields(&reset);
1142 
1143       log_trace(cds, heap, mirror)(
1144         "Archived %s mirror object from " PTR_FORMAT " ==> " PTR_FORMAT,
1145         type2name((BasicType)t), p2i(Universe::_mirrors[t]), p2i(archived_m));
1146 
1147       Universe::_mirrors[t] = archived_m;
1148     }
1149   }
1150 
1151   assert(Universe::_mirrors[T_INT] != NULL &&
1152          Universe::_mirrors[T_FLOAT] != NULL &&
1153          Universe::_mirrors[T_DOUBLE] != NULL &&
1154          Universe::_mirrors[T_BYTE] != NULL &&
1155          Universe::_mirrors[T_BOOLEAN] != NULL &&
1156          Universe::_mirrors[T_CHAR] != NULL &&
1157          Universe::_mirrors[T_LONG] != NULL &&
1158          Universe::_mirrors[T_SHORT] != NULL &&
1159          Universe::_mirrors[T_VOID] != NULL, "sanity");
1160 
1161   Universe::set_int_mirror(Universe::_mirrors[T_INT]);
1162   Universe::set_float_mirror(Universe::_mirrors[T_FLOAT]);
1163   Universe::set_double_mirror(Universe::_mirrors[T_DOUBLE]);
1164   Universe::set_byte_mirror(Universe::_mirrors[T_BYTE]);
1165   Universe::set_bool_mirror(Universe::_mirrors[T_BOOLEAN]);
1166   Universe::set_char_mirror(Universe::_mirrors[T_CHAR]);
1167   Universe::set_long_mirror(Universe::_mirrors[T_LONG]);
1168   Universe::set_short_mirror(Universe::_mirrors[T_SHORT]);
1169   Universe::set_void_mirror(Universe::_mirrors[T_VOID]);
1170 }
1171 
1172 //
1173 // After the mirror object is successfully archived, the archived
1174 // klass is set with _has_archived_raw_mirror flag.
1175 //
1176 // The _has_archived_raw_mirror flag is cleared at runtime when the
1177 // archived mirror is restored. If archived java heap data cannot
1178 // be used at runtime, new mirror object is created for the shared
1179 // class. The _has_archived_raw_mirror is cleared also during the process.
1180 oop java_lang_Class::archive_mirror(Klass* k, TRAPS) {
1181   assert(HeapShared::is_heap_object_archiving_allowed(),
1182          "HeapShared::is_heap_object_archiving_allowed() must be true");
1183 
1184   // Mirror is already archived
1185   if (k->has_raw_archived_mirror()) {
1186     assert(k->archived_java_mirror_raw() != NULL, "no archived mirror");
1187     return k->archived_java_mirror_raw();
1188   }
1189 
1190   // No mirror
1191   oop mirror = k->java_mirror();


< prev index next >