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");
283 assert(layout_helper_header_size(lh) == hsize, "correct decode");
284 assert(layout_helper_element_type(lh) == etype, "correct decode");
285 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
286
287 return lh;
288 }
289
290 bool Klass::can_be_primary_super_slow() const {
291 if (super() == nullptr)
292 return true;
293 else if (super()->super_depth() >= primary_super_limit()-1)
294 return false;
295 else
296 return true;
297 }
953 void Klass::print_on(outputStream* st) const {
954 ResourceMark rm;
955 // print title
956 st->print("%s", internal_name());
957 print_address_on(st);
958 st->cr();
959 }
960
961 #define BULLET " - "
962
963 // Caller needs ResourceMark
964 void Klass::oop_print_on(oop obj, outputStream* st) {
965 // print title
966 st->print_cr("%s ", internal_name());
967 obj->print_address_on(st);
968
969 if (WizardMode) {
970 // print header
971 obj->mark().print_on(st);
972 st->cr();
973 }
974
975 // print class
976 st->print(BULLET"klass: ");
977 obj->klass()->print_value_on(st);
978 st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
979 st->cr();
980 }
981
982 void Klass::oop_print_value_on(oop obj, outputStream* st) {
983 // print title
984 ResourceMark rm; // Cannot print in debug mode without this
985 st->print("%s", internal_name());
986 obj->print_address_on(st);
987 }
988
989 // Verification
990
991 void Klass::verify_on(outputStream* st) {
992
|
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 _prototype_header(markWord::prototype()),
264 _shared_class_path_index(-1) {
265 CDS_ONLY(_shared_class_flags = 0;)
266 CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
267 _primary_supers[0] = this;
268 set_super_check_offset(in_bytes(primary_supers_offset()));
269 }
270
271 jint Klass::array_layout_helper(BasicType etype) {
272 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
273 // Note that T_ARRAY is not allowed here.
274 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
275 int esize = type2aelembytes(etype);
276 bool isobj = (etype == T_OBJECT);
277 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
278 int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
279
280 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
281 assert(layout_helper_is_array(lh), "correct kind");
282 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
283 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
284 assert(layout_helper_header_size(lh) == hsize, "correct decode");
285 assert(layout_helper_element_type(lh) == etype, "correct decode");
286 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
287
288 return lh;
289 }
290
291 bool Klass::can_be_primary_super_slow() const {
292 if (super() == nullptr)
293 return true;
294 else if (super()->super_depth() >= primary_super_limit()-1)
295 return false;
296 else
297 return true;
298 }
954 void Klass::print_on(outputStream* st) const {
955 ResourceMark rm;
956 // print title
957 st->print("%s", internal_name());
958 print_address_on(st);
959 st->cr();
960 }
961
962 #define BULLET " - "
963
964 // Caller needs ResourceMark
965 void Klass::oop_print_on(oop obj, outputStream* st) {
966 // print title
967 st->print_cr("%s ", internal_name());
968 obj->print_address_on(st);
969
970 if (WizardMode) {
971 // print header
972 obj->mark().print_on(st);
973 st->cr();
974 st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
975 st->cr();
976 }
977
978 // print class
979 st->print(BULLET"klass: ");
980 obj->klass()->print_value_on(st);
981 st->print(BULLET"flags: "); _misc_flags.print_on(st); st->cr();
982 st->cr();
983 }
984
985 void Klass::oop_print_value_on(oop obj, outputStream* st) {
986 // print title
987 ResourceMark rm; // Cannot print in debug mode without this
988 st->print("%s", internal_name());
989 obj->print_address_on(st);
990 }
991
992 // Verification
993
994 void Klass::verify_on(outputStream* st) {
995
|