239 OverpassLookupMode overpass_mode,
240 PrivateLookupMode private_mode) const {
241 #ifdef ASSERT
242 tty->print_cr("Error: uncached_lookup_method called on a klass oop."
243 " Likely error: reflection method does not correctly"
244 " wrap return value in a mirror object.");
245 #endif
246 ShouldNotReachHere();
247 return nullptr;
248 }
249
250 Klass::Klass() : _kind(UnknownKlassKind) {
251 assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
252 }
253
254 // "Normal" instantiation is preceded by a MetaspaceObj allocation
255 // which zeros out memory - calloc equivalent.
256 // The constructor is also used from CppVtableCloner,
257 // which doesn't zero out the memory before calling the constructor.
258 Klass::Klass(KlassKind kind) : _kind(kind),
259 _shared_class_path_index(-1) {
260 CDS_ONLY(_shared_class_flags = 0;)
261 CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
262 _primary_supers[0] = this;
263 set_super_check_offset(in_bytes(primary_supers_offset()));
264 }
265
266 jint Klass::array_layout_helper(BasicType etype) {
267 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
268 // Note that T_ARRAY is not allowed here.
269 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
270 int esize = type2aelembytes(etype);
271 bool isobj = (etype == T_OBJECT);
272 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
273 int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
274
275 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
276 assert(layout_helper_is_array(lh), "correct kind");
277 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
278 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
279 assert(layout_helper_header_size(lh) == hsize, "correct decode");
280 assert(layout_helper_element_type(lh) == etype, "correct decode");
281 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
282
283 return lh;
284 }
285
286 bool Klass::can_be_primary_super_slow() const {
287 if (super() == nullptr)
288 return true;
289 else if (super()->super_depth() >= primary_super_limit()-1)
290 return false;
291 else
292 return true;
293 }
949 void Klass::print_on(outputStream* st) const {
950 ResourceMark rm;
951 // print title
952 st->print("%s", internal_name());
953 print_address_on(st);
954 st->cr();
955 }
956
957 #define BULLET " - "
958
959 // Caller needs ResourceMark
960 void Klass::oop_print_on(oop obj, outputStream* st) {
961 // print title
962 st->print_cr("%s ", internal_name());
963 obj->print_address_on(st);
964
965 if (WizardMode) {
966 // print header
967 obj->mark().print_on(st);
968 st->cr();
969 }
970
971 // print class
972 st->print(BULLET"klass: ");
973 obj->klass()->print_value_on(st);
974 st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
975 st->cr();
976 }
977
978 void Klass::oop_print_value_on(oop obj, outputStream* st) {
979 // print title
980 ResourceMark rm; // Cannot print in debug mode without this
981 st->print("%s", internal_name());
982 obj->print_address_on(st);
983 }
984
985 // Verification
986
987 void Klass::verify_on(outputStream* st) {
988
|
239 OverpassLookupMode overpass_mode,
240 PrivateLookupMode private_mode) const {
241 #ifdef ASSERT
242 tty->print_cr("Error: uncached_lookup_method called on a klass oop."
243 " Likely error: reflection method does not correctly"
244 " wrap return value in a mirror object.");
245 #endif
246 ShouldNotReachHere();
247 return nullptr;
248 }
249
250 Klass::Klass() : _kind(UnknownKlassKind) {
251 assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
252 }
253
254 // "Normal" instantiation is preceded by a MetaspaceObj allocation
255 // which zeros out memory - calloc equivalent.
256 // The constructor is also used from CppVtableCloner,
257 // which doesn't zero out the memory before calling the constructor.
258 Klass::Klass(KlassKind kind) : _kind(kind),
259 _prototype_header(markWord::prototype()),
260 _shared_class_path_index(-1) {
261 CDS_ONLY(_shared_class_flags = 0;)
262 CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
263 _primary_supers[0] = this;
264 set_super_check_offset(in_bytes(primary_supers_offset()));
265 }
266
267 jint Klass::array_layout_helper(BasicType etype) {
268 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
269 // Note that T_ARRAY is not allowed here.
270 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
271 int esize = type2aelembytes(etype);
272 bool isobj = (etype == T_OBJECT);
273 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
274 int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
275
276 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
277 assert(layout_helper_is_array(lh), "correct kind");
278 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
279 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
280 assert(layout_helper_header_size(lh) == hsize, "correct decode");
281 assert(layout_helper_element_type(lh) == etype, "correct decode");
282 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
283
284 return lh;
285 }
286
287 bool Klass::can_be_primary_super_slow() const {
288 if (super() == nullptr)
289 return true;
290 else if (super()->super_depth() >= primary_super_limit()-1)
291 return false;
292 else
293 return true;
294 }
950 void Klass::print_on(outputStream* st) const {
951 ResourceMark rm;
952 // print title
953 st->print("%s", internal_name());
954 print_address_on(st);
955 st->cr();
956 }
957
958 #define BULLET " - "
959
960 // Caller needs ResourceMark
961 void Klass::oop_print_on(oop obj, outputStream* st) {
962 // print title
963 st->print_cr("%s ", internal_name());
964 obj->print_address_on(st);
965
966 if (WizardMode) {
967 // print header
968 obj->mark().print_on(st);
969 st->cr();
970 st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
971 st->cr();
972 }
973
974 // print class
975 st->print(BULLET"klass: ");
976 obj->klass()->print_value_on(st);
977 st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
978 st->cr();
979 }
980
981 void Klass::oop_print_value_on(oop obj, outputStream* st) {
982 // print title
983 ResourceMark rm; // Cannot print in debug mode without this
984 st->print("%s", internal_name());
985 obj->print_address_on(st);
986 }
987
988 // Verification
989
990 void Klass::verify_on(outputStream* st) {
991
|