< 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 // "Normal" instantiation is preceded by a MetaspaceObj allocation
195 // which zeros out memory - calloc equivalent.
196 // The constructor is also used from CppVtableCloner,
197 // which doesn't zero out the memory before calling the constructor.
198 Klass::Klass(KlassKind kind) : _kind(kind),

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

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




743   }
744 
745   // print class
746   st->print(BULLET"klass: ");
747   obj->klass()->print_value_on(st);
748   st->cr();
749 }
750 
751 void Klass::oop_print_value_on(oop obj, outputStream* st) {
752   // print title
753   ResourceMark rm;              // Cannot print in debug mode without this
754   st->print("%s", internal_name());
755   obj->print_address_on(st);
756 }
757 
758 // Verification
759 
760 void Klass::verify_on(outputStream* st) {
761 
762   // 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 // "Normal" instantiation is preceded by a MetaspaceObj allocation
205 // which zeros out memory - calloc equivalent.
206 // The constructor is also used from CppVtableCloner,
207 // which doesn't zero out the memory before calling the constructor.
208 Klass::Klass(KlassKind kind) : _kind(kind),
209                            _prototype_header(make_prototype(this)),
210                            _shared_class_path_index(-1) {
211   CDS_ONLY(_shared_class_flags = 0;)
212   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
213   _primary_supers[0] = this;
214   set_super_check_offset(in_bytes(primary_supers_offset()));
215 }
216 
217 jint Klass::array_layout_helper(BasicType etype) {
218   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
219   // Note that T_ARRAY is not allowed here.
220   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
221   int  esize = type2aelembytes(etype);
222   bool isobj = (etype == T_OBJECT);
223   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
224   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
225 
226   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
227   assert(layout_helper_is_array(lh), "correct kind");
228   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
229   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

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