void klassKlass::oop_verify_on(oop obj, outputStream* st) { Klass::oop_verify_on(obj, st); guarantee(obj->is_perm(), "should be in permspace"); guarantee(obj->is_klass(), "should be klass"); Klass* k = Klass::cast(klassOop(obj)); if (k->super() != NULL) { guarantee(k->super()->is_perm(), "should be in permspace"); guarantee(k->super()->is_klass(), "should be klass"); } klassOop ko = k->secondary_super_cache(); if( ko != NULL ) { guarantee(ko->is_perm(), "should be in permspace"); guarantee(ko->is_klass(), "should be klass"); } for( uint i = 0; i < primary_super_limit(); i++ ) { oop ko = k->adr_primary_supers()[i]; // Cannot use normal accessor because it asserts if( ko != NULL ) { guarantee(ko->is_perm(), "should be in permspace"); guarantee(ko->is_klass(), "should be klass"); } } if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) { guarantee(k->java_mirror() != NULL, "should be allocated"); guarantee(k->java_mirror()->is_perm(), "should be in permspace"); guarantee(k->java_mirror()->is_instance(), "should be instance"); } if (k->name() != NULL) { guarantee(Universe::heap()->is_in_permanent(k->name()), "should be in permspace"); guarantee(k->name()->is_symbol(), "should be symbol"); } }
void ClassLoaderData::dump(outputStream * const out) { ResourceMark rm; out->print("ClassLoaderData CLD: "PTR_FORMAT", loader: "PTR_FORMAT", loader_klass: "PTR_FORMAT" %s {", p2i(this), p2i((void *)class_loader()), p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name()); if (claimed()) out->print(" claimed "); if (is_unloading()) out->print(" unloading "); out->print(" handles " INTPTR_FORMAT, p2i(handles())); out->cr(); if (metaspace_or_null() != NULL) { out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null())); metaspace_or_null()->dump(out); } else { out->print_cr("metaspace: NULL"); } #ifdef CLD_DUMP_KLASSES if (Verbose) { ResourceMark rm; Klass* k = _klasses; while (k != NULL) { out->print_cr("klass "PTR_FORMAT", %s, CT: %d, MUT: %d", k, k->name()->as_C_string(), k->has_modified_oops(), k->has_accumulated_modified_oops()); assert(k != k->next_link(), "no loops!"); k = k->next_link(); } } #endif // CLD_DUMP_KLASSES #undef CLD_DUMP_KLASSES if (_jmethod_ids != NULL) { Method::print_jmethod_ids(this, out); } out->print_cr("}"); }
// ------------------------------------------------------------------ // ciKlass::ciKlass ciKlass::ciKlass(KlassHandle h_k) : ciType(h_k) { assert(get_Klass()->is_klass(), "wrong type"); Klass* k = get_Klass(); _layout_helper = k->layout_helper(); Symbol* klass_name = k->name(); assert(klass_name != NULL, "wrong ciKlass constructor"); _name = CURRENT_ENV->get_symbol(klass_name); }
virtual void do_object(oop obj) { if (obj->is_klass()) { Klass* k = klassOop(obj)->klass_part(); if (k->name() != NULL) { ResourceMark rm; const char* ext = k->external_name(); if ( strcmp(_target, ext) == 0 ) { tty->print_cr("Found " INTPTR_FORMAT, obj); obj->print(); } } } }
void ClassifyInstanceKlassClosure::do_object(oop obj) { int type = classify_object(obj, false); if (type == instanceKlass_type || type == klass_type) { Klass* k = ((klassOop)obj)->klass_part(); if (k->alloc_count() > 0) { ResourceMark rm; const char *name; if (k->name() == NULL) { if (obj == Universe::klassKlassObj()) { name = "_klassKlassObj"; } else if (obj == Universe::arrayKlassKlassObj()) { name = "_arrayKlassKlassObj"; } else if (obj == Universe::objArrayKlassKlassObj()) { name = "_objArrayKlassKlassObj"; } else if (obj == Universe::typeArrayKlassKlassObj()) { name = "_typeArrayKlassKlassObj"; } else if (obj == Universe::instanceKlassKlassObj()) { name = "_instanceKlassKlassObj"; } else if (obj == Universe::symbolKlassObj()) { name = "_symbolKlassObj"; } else if (obj == Universe::methodKlassObj()) { name = "_methodKlassObj"; } else if (obj == Universe::constMethodKlassObj()) { name = "_constMethodKlassObj"; } else if (obj == Universe::constantPoolKlassObj()) { name = "_constantPoolKlassObj"; } else if (obj == Universe::constantPoolCacheKlassObj()) { name = "_constantPoolCacheKlassObj"; } else if (obj == Universe::compiledICHolderKlassObj()) { name = "_compiledICHolderKlassObj"; } else if (obj == Universe::systemObjArrayKlassObj()) { name = "_systemObjArrayKlassObj"; } else { name = "[unnamed]"; } } else { name = k->external_name(); } tty->print_cr("% 8d instances of %s", k->alloc_count(), name); } total_instances += k->alloc_count(); } }
// ------------------------------------------------------------------ // ciEnv::get_klass_by_name_impl ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, constantPoolHandle cpool, ciSymbol* name, bool require_local) { ASSERT_IN_VM; EXCEPTION_CONTEXT; // Now we need to check the SystemDictionary Symbol* sym = name->get_symbol(); if (sym->byte_at(0) == 'L' && sym->byte_at(sym->utf8_length()-1) == ';') { // This is a name from a signature. Strip off the trimmings. // Call recursive to keep scope of strippedsym. TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, sym->utf8_length()-2, KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass)); ciSymbol* strippedname = get_symbol(strippedsym); return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local); } // Check for prior unloaded klass. The SystemDictionary's answers // can vary over time but the compiler needs consistency. ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name); if (unloaded_klass != NULL) { if (require_local) return NULL; return unloaded_klass; } Handle loader(THREAD, (oop)NULL); Handle domain(THREAD, (oop)NULL); if (accessing_klass != NULL) { loader = Handle(THREAD, accessing_klass->loader()); domain = Handle(THREAD, accessing_klass->protection_domain()); } // setup up the proper type to return on OOM ciKlass* fail_type; if (sym->byte_at(0) == '[') { fail_type = _unloaded_ciobjarrayklass; } else { fail_type = _unloaded_ciinstance_klass; } KlassHandle found_klass; { ttyUnlocker ttyul; // release tty lock to avoid ordering problems MutexLocker ml(Compile_lock); Klass* kls; if (!require_local) { kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, KILL_COMPILE_ON_FATAL_(fail_type)); } else { kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, KILL_COMPILE_ON_FATAL_(fail_type)); } found_klass = KlassHandle(THREAD, kls); } // If we fail to find an array klass, look again for its element type. // The element type may be available either locally or via constraints. // In either case, if we can find the element type in the system dictionary, // we must build an array type around it. The CI requires array klasses // to be loaded if their element klasses are loaded, except when memory // is exhausted. if (sym->byte_at(0) == '[' && (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { // We have an unloaded array. // Build it on the fly if the element class exists. TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, sym->utf8_length()-1, KILL_COMPILE_ON_FATAL_(fail_type)); // Get element ciKlass recursively. ciKlass* elem_klass = get_klass_by_name_impl(accessing_klass, cpool, get_symbol(elem_sym), require_local); if (elem_klass != NULL && elem_klass->is_loaded()) { // Now make an array for it return ciObjArrayKlass::make_impl(elem_klass); } } if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) { // Look inside the constant pool for pre-resolved class entries. for (int i = cpool->length() - 1; i >= 1; i--) { if (cpool->tag_at(i).is_klass()) { Klass* kls = cpool->resolved_klass_at(i); if (kls->name() == sym) { found_klass = KlassHandle(THREAD, kls); break; } } } } if (found_klass() != NULL) { // Found it. Build a CI handle. return get_klass(found_klass()); } if (require_local) return NULL; // Not yet loaded into the VM, or not governed by loader constraints. // Make a CI representative for it. return get_unloaded_klass(accessing_klass, name); }
void ciMethodData::dump_replay_data(outputStream* out) { ResourceMark rm; MethodData* mdo = get_MethodData(); Method* method = mdo->method(); Klass* holder = method->method_holder(); out->print("ciMethodData %s %s %s %d %d", holder->name()->as_quoted_ascii(), method->name()->as_quoted_ascii(), method->signature()->as_quoted_ascii(), _state, current_mileage()); // dump the contents of the MDO header as raw data unsigned char* orig = (unsigned char*)&_orig; int length = sizeof(_orig); out->print(" orig %d", length); for (int i = 0; i < length; i++) { out->print(" %d", orig[i]); } // dump the MDO data as raw data int elements = (data_size() + extra_data_size()) / sizeof(intptr_t); out->print(" data %d", elements); for (int i = 0; i < elements; i++) { // We could use INTPTR_FORMAT here but that's a zero justified // which makes comparing it with the SA version of this output // harder. #ifdef _LP64 out->print(" 0x%" FORMAT64_MODIFIER "x", data()[i]); #else out->print(" 0x%x", data()[i]); #endif } // The MDO contained oop references as ciObjects, so scan for those // and emit pairs of offset and klass name so that they can be // reconstructed at runtime. The first round counts the number of // oop references and the second actually emits them. ciParametersTypeData* parameters = parameters_type_data(); for (int count = 0, round = 0; round < 2; round++) { if (round == 1) out->print(" oops %d", count); ProfileData* pdata = first_data(); for ( ; is_valid(pdata); pdata = next_data(pdata)) { if (pdata->is_VirtualCallData()) { ciVirtualCallData* vdata = (ciVirtualCallData*)pdata; dump_replay_data_receiver_type_helper<ciVirtualCallData>(out, round, count, vdata); if (pdata->is_VirtualCallTypeData()) { ciVirtualCallTypeData* call_type_data = (ciVirtualCallTypeData*)pdata; dump_replay_data_call_type_helper<ciVirtualCallTypeData>(out, round, count, call_type_data); } } else if (pdata->is_ReceiverTypeData()) { ciReceiverTypeData* vdata = (ciReceiverTypeData*)pdata; dump_replay_data_receiver_type_helper<ciReceiverTypeData>(out, round, count, vdata); } else if (pdata->is_CallTypeData()) { ciCallTypeData* call_type_data = (ciCallTypeData*)pdata; dump_replay_data_call_type_helper<ciCallTypeData>(out, round, count, call_type_data); } } if (parameters != NULL) { for (int i = 0; i < parameters->number_of_parameters(); i++) { dump_replay_data_type_helper(out, round, count, parameters, ParametersTypeData::type_offset(i), parameters->valid_parameter_type(i)); } } } for (int count = 0, round = 0; round < 2; round++) { if (round == 1) out->print(" methods %d", count); dump_replay_data_extra_data_helper(out, round, count); } out->cr(); }