< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

174   ShouldNotReachHere();
175   return nullptr;
176 }
177 
178 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
179                                       OverpassLookupMode overpass_mode,
180                                       PrivateLookupMode private_mode) const {
181 #ifdef ASSERT
182   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
183                 " Likely error: reflection method does not correctly"
184                 " wrap return value in a mirror object.");
185 #endif
186   ShouldNotReachHere();
187   return nullptr;
188 }
189 
190 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
191   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
192 }
193 










194 Klass::Klass() : _kind(UnknownKlassKind) {
195   assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for cds");
196 }
197 
198 // "Normal" instantiation is preceded by a MetaspaceObj allocation
199 // which zeros out memory - calloc equivalent.
200 // The constructor is also used from CppVtableCloner,
201 // which doesn't zero out the memory before calling the constructor.
202 Klass::Klass(KlassKind kind) : _kind(kind),

203                            _shared_class_path_index(-1) {
204   CDS_ONLY(_shared_class_flags = 0;)
205   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
206   _primary_supers[0] = this;
207   set_super_check_offset(in_bytes(primary_supers_offset()));
208 }
209 
210 jint Klass::array_layout_helper(BasicType etype) {
211   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
212   // Note that T_ARRAY is not allowed here.
213   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
214   int  esize = type2aelembytes(etype);
215   bool isobj = (etype == T_OBJECT);
216   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
217   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
218 
219   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
220   assert(layout_helper_is_array(lh), "correct kind");
221   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
222   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

729 void Klass::print_on(outputStream* st) const {
730   ResourceMark rm;
731   // print title
732   st->print("%s", internal_name());
733   print_address_on(st);
734   st->cr();
735 }
736 
737 #define BULLET  " - "
738 
739 // Caller needs ResourceMark
740 void Klass::oop_print_on(oop obj, outputStream* st) {
741   // print title
742   st->print_cr("%s ", internal_name());
743   obj->print_address_on(st);
744 
745   if (WizardMode) {
746      // print header
747      obj->mark().print_on(st);
748      st->cr();




749   }
750 
751   // print class
752   st->print(BULLET"klass: ");
753   obj->klass()->print_value_on(st);
754   st->cr();
755 }
756 
757 void Klass::oop_print_value_on(oop obj, outputStream* st) {
758   // print title
759   ResourceMark rm;              // Cannot print in debug mode without this
760   st->print("%s", internal_name());
761   obj->print_address_on(st);
762 }
763 
764 // Verification
765 
766 void Klass::verify_on(outputStream* st) {
767 
768   // This can be expensive, but it is worth checking that this klass is actually

174   ShouldNotReachHere();
175   return nullptr;
176 }
177 
178 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
179                                       OverpassLookupMode overpass_mode,
180                                       PrivateLookupMode private_mode) const {
181 #ifdef ASSERT
182   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
183                 " Likely error: reflection method does not correctly"
184                 " wrap return value in a mirror object.");
185 #endif
186   ShouldNotReachHere();
187   return nullptr;
188 }
189 
190 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
191   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
192 }
193 
194 static markWord make_prototype(Klass* kls) {
195   markWord prototype = markWord::prototype();
196 #ifdef _LP64
197   if (UseCompactObjectHeaders) {
198     prototype = prototype.set_klass(kls);
199   }
200 #endif
201   return prototype;
202 }
203 
204 Klass::Klass() : _kind(UnknownKlassKind) {
205   assert(CDSConfig::is_dumping_static_archive() || UseSharedSpaces, "only for cds");
206 }
207 
208 // "Normal" instantiation is preceded by a MetaspaceObj allocation
209 // which zeros out memory - calloc equivalent.
210 // The constructor is also used from CppVtableCloner,
211 // which doesn't zero out the memory before calling the constructor.
212 Klass::Klass(KlassKind kind) : _kind(kind),
213                            _prototype_header(make_prototype(this)),
214                            _shared_class_path_index(-1) {
215   CDS_ONLY(_shared_class_flags = 0;)
216   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
217   _primary_supers[0] = this;
218   set_super_check_offset(in_bytes(primary_supers_offset()));
219 }
220 
221 jint Klass::array_layout_helper(BasicType etype) {
222   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
223   // Note that T_ARRAY is not allowed here.
224   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
225   int  esize = type2aelembytes(etype);
226   bool isobj = (etype == T_OBJECT);
227   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
228   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
229 
230   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
231   assert(layout_helper_is_array(lh), "correct kind");
232   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
233   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

740 void Klass::print_on(outputStream* st) const {
741   ResourceMark rm;
742   // print title
743   st->print("%s", internal_name());
744   print_address_on(st);
745   st->cr();
746 }
747 
748 #define BULLET  " - "
749 
750 // Caller needs ResourceMark
751 void Klass::oop_print_on(oop obj, outputStream* st) {
752   // print title
753   st->print_cr("%s ", internal_name());
754   obj->print_address_on(st);
755 
756   if (WizardMode) {
757      // print header
758      obj->mark().print_on(st);
759      st->cr();
760      if (UseCompactObjectHeaders) {
761        st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
762        st->cr();
763      }
764   }
765 
766   // print class
767   st->print(BULLET"klass: ");
768   obj->klass()->print_value_on(st);
769   st->cr();
770 }
771 
772 void Klass::oop_print_value_on(oop obj, outputStream* st) {
773   // print title
774   ResourceMark rm;              // Cannot print in debug mode without this
775   st->print("%s", internal_name());
776   obj->print_address_on(st);
777 }
778 
779 // Verification
780 
781 void Klass::verify_on(outputStream* st) {
782 
783   // This can be expensive, but it is worth checking that this klass is actually
< prev index next >