< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

 234   ShouldNotReachHere();
 235   return nullptr;
 236 }
 237 
 238 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
 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 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
 251   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
 252 }
 253 










 254 Klass::Klass() : _kind(UnknownKlassKind) {
 255   assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
 256 }
 257 
 258 // "Normal" instantiation is preceded by a MetaspaceObj allocation
 259 // which zeros out memory - calloc equivalent.
 260 // The constructor is also used from CppVtableCloner,
 261 // which doesn't zero out the memory before calling the constructor.
 262 Klass::Klass(KlassKind kind) : _kind(kind),

 263                            _shared_class_path_index(-1) {
 264   CDS_ONLY(_shared_class_flags = 0;)
 265   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
 266   _primary_supers[0] = this;
 267   set_super_check_offset(in_bytes(primary_supers_offset()));
 268 }
 269 
 270 jint Klass::array_layout_helper(BasicType etype) {
 271   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 272   // Note that T_ARRAY is not allowed here.
 273   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 274   int  esize = type2aelembytes(etype);
 275   bool isobj = (etype == T_OBJECT);
 276   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 277   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
 278 
 279   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 280   assert(layout_helper_is_array(lh), "correct kind");
 281   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
 282   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

 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   }
 971 
 972   // print class
 973   st->print(BULLET"klass: ");
 974   obj->klass()->print_value_on(st);
 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 
 989   // This can be expensive, but it is worth checking that this klass is actually

 234   ShouldNotReachHere();
 235   return nullptr;
 236 }
 237 
 238 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
 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 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
 251   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
 252 }
 253 
 254 static markWord make_prototype(Klass* kls) {
 255   markWord prototype = markWord::prototype();
 256 #ifdef _LP64
 257   if (UseCompactObjectHeaders) {
 258     prototype = prototype.set_klass(kls);
 259   }
 260 #endif
 261   return prototype;
 262 }
 263 
 264 Klass::Klass() : _kind(UnknownKlassKind) {
 265   assert(CDSConfig::is_dumping_static_archive() || CDSConfig::is_using_archive(), "only for cds");
 266 }
 267 
 268 // "Normal" instantiation is preceded by a MetaspaceObj allocation
 269 // which zeros out memory - calloc equivalent.
 270 // The constructor is also used from CppVtableCloner,
 271 // which doesn't zero out the memory before calling the constructor.
 272 Klass::Klass(KlassKind kind) : _kind(kind),
 273                            _prototype_header(make_prototype(this)),
 274                            _shared_class_path_index(-1) {
 275   CDS_ONLY(_shared_class_flags = 0;)
 276   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
 277   _primary_supers[0] = this;
 278   set_super_check_offset(in_bytes(primary_supers_offset()));
 279 }
 280 
 281 jint Klass::array_layout_helper(BasicType etype) {
 282   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 283   // Note that T_ARRAY is not allowed here.
 284   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 285   int  esize = type2aelembytes(etype);
 286   bool isobj = (etype == T_OBJECT);
 287   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
 288   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
 289 
 290   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
 291   assert(layout_helper_is_array(lh), "correct kind");
 292   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
 293   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

 961 void Klass::print_on(outputStream* st) const {
 962   ResourceMark rm;
 963   // print title
 964   st->print("%s", internal_name());
 965   print_address_on(st);
 966   st->cr();
 967 }
 968 
 969 #define BULLET  " - "
 970 
 971 // Caller needs ResourceMark
 972 void Klass::oop_print_on(oop obj, outputStream* st) {
 973   // print title
 974   st->print_cr("%s ", internal_name());
 975   obj->print_address_on(st);
 976 
 977   if (WizardMode) {
 978      // print header
 979      obj->mark().print_on(st);
 980      st->cr();
 981      if (UseCompactObjectHeaders) {
 982        st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
 983        st->cr();
 984      }
 985   }
 986 
 987   // print class
 988   st->print(BULLET"klass: ");
 989   obj->klass()->print_value_on(st);
 990   st->cr();
 991 }
 992 
 993 void Klass::oop_print_value_on(oop obj, outputStream* st) {
 994   // print title
 995   ResourceMark rm;              // Cannot print in debug mode without this
 996   st->print("%s", internal_name());
 997   obj->print_address_on(st);
 998 }
 999 
1000 // Verification
1001 
1002 void Klass::verify_on(outputStream* st) {
1003 
1004   // This can be expensive, but it is worth checking that this klass is actually
< prev index next >