< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

 266                                       OverpassLookupMode overpass_mode,
 267                                       PrivateLookupMode private_mode) const {
 268 #ifdef ASSERT
 269   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
 270                 " Likely error: reflection method does not correctly"
 271                 " wrap return value in a mirror object.");
 272 #endif
 273   ShouldNotReachHere();
 274   return nullptr;
 275 }
 276 
 277 Klass::Klass() : _kind(UnknownKlassKind) {
 278   assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
 279 }
 280 
 281 // "Normal" instantiation is preceded by a MetaspaceObj allocation
 282 // which zeros out memory - calloc equivalent.
 283 // The constructor is also used from CppVtableCloner,
 284 // which doesn't zero out the memory before calling the constructor.
 285 Klass::Klass(KlassKind kind) : _kind(kind),

 286                                _shared_class_path_index(-1) {
 287   CDS_ONLY(_shared_class_flags = 0;)
 288   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
 289   _primary_supers[0] = this;
 290   set_super_check_offset(in_bytes(primary_supers_offset()));
 291 }
 292 
 293 jint Klass::array_layout_helper(BasicType etype) {
 294   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 295   // Note that T_ARRAY is not allowed here.
 296   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 297   int  esize = type2aelembytes(etype);
 298   bool isobj = (etype == T_OBJECT);
 299   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 300   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
 301 
 302   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 303   assert(layout_helper_is_array(lh), "correct kind");
 304   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
 305   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
 306   assert(layout_helper_header_size(lh) == hsize, "correct decode");
 307   assert(layout_helper_element_type(lh) == etype, "correct decode");
 308   assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
 309 
 310   return lh;
 311 }
 312 
 313 bool Klass::can_be_primary_super_slow() const {
 314   if (super() == nullptr)
 315     return true;
 316   else if (super()->super_depth() >= primary_super_limit()-1)
 317     return false;
 318   else
 319     return true;
 320 }

 968 void Klass::print_on(outputStream* st) const {
 969   ResourceMark rm;
 970   // print title
 971   st->print("%s", internal_name());
 972   print_address_on(st);
 973   st->cr();
 974 }
 975 
 976 #define BULLET  " - "
 977 
 978 // Caller needs ResourceMark
 979 void Klass::oop_print_on(oop obj, outputStream* st) {
 980   // print title
 981   st->print_cr("%s ", internal_name());
 982   obj->print_address_on(st);
 983 
 984   if (WizardMode) {
 985      // print header
 986      obj->mark().print_on(st);
 987      st->cr();


 988   }
 989 
 990   // print class
 991   st->print(BULLET"klass: ");
 992   obj->klass()->print_value_on(st);
 993   st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
 994   st->cr();
 995 }
 996 
 997 void Klass::oop_print_value_on(oop obj, outputStream* st) {
 998   // print title
 999   ResourceMark rm;              // Cannot print in debug mode without this
1000   st->print("%s", internal_name());
1001   obj->print_address_on(st);
1002 }
1003 
1004 // Verification
1005 
1006 void Klass::verify_on(outputStream* st) {
1007 

 266                                       OverpassLookupMode overpass_mode,
 267                                       PrivateLookupMode private_mode) const {
 268 #ifdef ASSERT
 269   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
 270                 " Likely error: reflection method does not correctly"
 271                 " wrap return value in a mirror object.");
 272 #endif
 273   ShouldNotReachHere();
 274   return nullptr;
 275 }
 276 
 277 Klass::Klass() : _kind(UnknownKlassKind) {
 278   assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
 279 }
 280 
 281 // "Normal" instantiation is preceded by a MetaspaceObj allocation
 282 // which zeros out memory - calloc equivalent.
 283 // The constructor is also used from CppVtableCloner,
 284 // which doesn't zero out the memory before calling the constructor.
 285 Klass::Klass(KlassKind kind) : _kind(kind),
 286                                _prototype_header(markWord::prototype()),
 287                                _shared_class_path_index(-1) {
 288   CDS_ONLY(_shared_class_flags = 0;)
 289   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
 290   _primary_supers[0] = this;
 291   set_super_check_offset(in_bytes(primary_supers_offset()));
 292 }
 293 
 294 jint Klass::array_layout_helper(BasicType etype) {
 295   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 296   // Note that T_ARRAY is not allowed here.
 297   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 298   int  esize = type2aelembytes(etype);
 299   bool isobj = (etype == T_OBJECT);
 300   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 301   int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
 302 
 303   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 304   assert(layout_helper_is_array(lh), "correct kind");
 305   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
 306   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
 307   assert(layout_helper_header_size(lh) == hsize, "correct decode");
 308   assert(layout_helper_element_type(lh) == etype, "correct decode");
 309   assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
 310 
 311   return lh;
 312 }
 313 
 314 bool Klass::can_be_primary_super_slow() const {
 315   if (super() == nullptr)
 316     return true;
 317   else if (super()->super_depth() >= primary_super_limit()-1)
 318     return false;
 319   else
 320     return true;
 321 }

 969 void Klass::print_on(outputStream* st) const {
 970   ResourceMark rm;
 971   // print title
 972   st->print("%s", internal_name());
 973   print_address_on(st);
 974   st->cr();
 975 }
 976 
 977 #define BULLET  " - "
 978 
 979 // Caller needs ResourceMark
 980 void Klass::oop_print_on(oop obj, outputStream* st) {
 981   // print title
 982   st->print_cr("%s ", internal_name());
 983   obj->print_address_on(st);
 984 
 985   if (WizardMode) {
 986      // print header
 987      obj->mark().print_on(st);
 988      st->cr();
 989      st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
 990      st->cr();
 991   }
 992 
 993   // print class
 994   st->print(BULLET"klass: ");
 995   obj->klass()->print_value_on(st);
 996   st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
 997   st->cr();
 998 }
 999 
1000 void Klass::oop_print_value_on(oop obj, outputStream* st) {
1001   // print title
1002   ResourceMark rm;              // Cannot print in debug mode without this
1003   st->print("%s", internal_name());
1004   obj->print_address_on(st);
1005 }
1006 
1007 // Verification
1008 
1009 void Klass::verify_on(outputStream* st) {
1010 
< prev index next >