< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

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

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




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

178   ShouldNotReachHere();
179   return nullptr;
180 }
181 
182 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
183                                       OverpassLookupMode overpass_mode,
184                                       PrivateLookupMode private_mode) const {
185 #ifdef ASSERT
186   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
187                 " Likely error: reflection method does not correctly"
188                 " wrap return value in a mirror object.");
189 #endif
190   ShouldNotReachHere();
191   return nullptr;
192 }
193 
194 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
195   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
196 }
197 
198 static markWord make_prototype(Klass* kls) {
199   markWord prototype = markWord::prototype();
200 #ifdef _LP64
201   if (UseCompactObjectHeaders) {
202     prototype = prototype.set_klass(kls);
203   }
204 #endif
205   return prototype;
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");

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