< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

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");
223   assert(layout_helper_header_size(lh) == hsize, "correct decode");
224   assert(layout_helper_element_type(lh) == etype, "correct decode");
225   assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
226 
227   return lh;
228 }
229 
230 bool Klass::can_be_primary_super_slow() const {
231   if (super() == nullptr)
232     return true;
233   else if (super()->super_depth() >= primary_super_limit()-1)
234     return false;
235   else
236     return true;
237 }

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

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                                _prototype_header(markWord::prototype()),
204                                _shared_class_path_index(-1) {
205   CDS_ONLY(_shared_class_flags = 0;)
206   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
207   _primary_supers[0] = this;
208   set_super_check_offset(in_bytes(primary_supers_offset()));
209 }
210 
211 jint Klass::array_layout_helper(BasicType etype) {
212   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
213   // Note that T_ARRAY is not allowed here.
214   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
215   int  esize = type2aelembytes(etype);
216   bool isobj = (etype == T_OBJECT);
217   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
218   int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
219 
220   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
221   assert(layout_helper_is_array(lh), "correct kind");
222   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
223   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
224   assert(layout_helper_header_size(lh) == hsize, "correct decode");
225   assert(layout_helper_element_type(lh) == etype, "correct decode");
226   assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
227 
228   return lh;
229 }
230 
231 bool Klass::can_be_primary_super_slow() const {
232   if (super() == nullptr)
233     return true;
234   else if (super()->super_depth() >= primary_super_limit()-1)
235     return false;
236   else
237     return true;
238 }

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