本文整理汇总了C++中Klass::as_klassOop方法的典型用法代码示例。如果您正苦于以下问题:C++ Klass::as_klassOop方法的具体用法?C++ Klass::as_klassOop怎么用?C++ Klass::as_klassOop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Klass
的用法示例。
在下文中一共展示了Klass::as_klassOop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj_new
Expr* PrimInliner::obj_new() {
// replace generic allocation primitive by size-specific primitive, if possible
Expr* rcvr = parameter(0);
if (!rcvr->isConstantExpr() || !rcvr->constant()->is_klass()) return NULL;
Klass* klass = klassOop(rcvr->constant())->klass_part(); // class being instantiated
if (klass->oop_is_indexable()) return NULL; // would fail (extremely unlikely)
int size = klass->non_indexable_size(); // size in words
if (klass->can_inline_allocation()) {
// These special compiler primitives only work for memOop klasses
int number_of_instance_variables = size - memOopDesc::header_size();
switch (number_of_instance_variables) {
case 0: _pdesc = primitives::new0(); break;
case 1: _pdesc = primitives::new1(); break;
case 2: _pdesc = primitives::new2(); break;
case 3: _pdesc = primitives::new3(); break;
case 4: _pdesc = primitives::new4(); break;
case 5: _pdesc = primitives::new5(); break;
case 6: _pdesc = primitives::new6(); break;
case 7: _pdesc = primitives::new7(); break;
case 8: _pdesc = primitives::new8(); break;
case 9: _pdesc = primitives::new9(); break;
default: ; // use generic primitives
}
}
Expr* u = genCall(true);
return new KlassExpr(klass->as_klassOop(), u->preg(), u->node());
}
示例2: assert
// ------------------------------------------------------------------
// ciKlass::least_common_ancestor
//
// Get the shared parent of two klasses.
//
// Implementation note: this method currently goes "over the wall"
// and does all of the work on the VM side. It could be rewritten
// to use the super() method and do all of the work (aside from the
// lazy computation of super()) in native mode. This may be
// worthwhile if the compiler is repeatedly requesting the same lca
// computation or possibly if most of the superklasses have already
// been created as ciObjects anyway. Something to think about...
ciKlass*
ciKlass::least_common_ancestor(ciKlass* that) {
assert(is_loaded() && that->is_loaded(), "must be loaded");
assert(is_java_klass() && that->is_java_klass(), "must be java klasses");
// Check to see if the klasses are identical.
if (this == that) {
return this;
}
VM_ENTRY_MARK;
Klass* this_klass = get_Klass();
Klass* that_klass = that->get_Klass();
Klass* lca = this_klass->LCA(that_klass);
// Many times the LCA will be either this_klass or that_klass.
// Treat these as special cases.
if (lca == that_klass) {
return that;
}
if (this_klass == lca) {
return this;
}
// Create the ciInstanceKlass for the lca.
ciKlass* result =
CURRENT_THREAD_ENV->get_object(lca->as_klassOop())->as_klass();
return result;
}
示例3: classify_object
object_type ClassifyObjectClosure::classify_object(oop obj, bool count) {
object_type type = unknown_type;
Klass* k = obj->blueprint();
if (k->as_klassOop() == SystemDictionary::Object_klass()) {
tty->print_cr("Found the class!");
}
if (count) {
k->set_alloc_count(k->alloc_count() + 1);
}
if (obj->is_instance()) {
if (k->oop_is_instanceRef()) {
type = instanceRef_type;
} else {
type = instance_type;
}
} else if (obj->is_typeArray()) {
type = typeArray_type;
} else if (obj->is_objArray()) {
type = objArray_type;
} else if (obj->is_symbol()) {
type = symbol_type;
} else if (obj->is_klass()) {
Klass* k = ((klassOop)obj)->klass_part();
if (k->oop_is_instance()) {
type = instanceKlass_type;
} else {
type = klass_type;
}
} else if (obj->is_method()) {
type = method_type;
} else if (obj->is_constMethod()) {
type = constMethod_type;
} else if (obj->is_methodData()) {
ShouldNotReachHere();
} else if (obj->is_constantPool()) {
type = constantPool_type;
} else if (obj->is_constantPoolCache()) {
type = constantPoolCache_type;
} else if (obj->is_compiledICHolder()) {
type = compiledICHolder_type;
} else {
ShouldNotReachHere();
}
assert(type != unknown_type, "found object of unknown type.");
return type;
}
示例4: process_interface
void CHA::process_interface(instanceKlassHandle r, GrowableArray<KlassHandle>* receivers, GrowableArray<methodHandle>* methods,
symbolHandle name, symbolHandle signature) {
// recursively add non-abstract implementors of interface r to receivers list
assert(r->is_interface(), "should call process_class instead");
// We only store the implementors for an interface, if there is exactly one implementor
klassOop k = r->implementor();
assert(k == NULL || r->nof_implementors() == 1, "inconsistent implementor list");
if (k != NULL && !methods->is_full()) {
instanceKlass* kl = instanceKlass::cast(k);
assert(kl->oop_is_instance(), "primitive klasses don't implement interfaces");
assert(!kl->is_interface(), "must be a real klass");
process_class(kl, receivers, methods, name, signature);
}
// now process all subinterfaces
for (Klass* s = r->subklass(); s != NULL && !methods->is_full(); s = s->next_sibling()) {
assert(s->is_interface(), "must be an interface");
instanceKlassHandle sub(s->as_klassOop());
process_interface(sub, receivers, methods, name, signature);
if (methods->is_full()) break; // give up -- too many overriding methods
}
}
示例5: base_create_klass_oop
klassOop Klass::base_create_klass_oop(KlassHandle& klass, int size,
const Klass_vtbl& vtbl, TRAPS) {
size = align_object_size(size);
// allocate and initialize vtable
Klass* kl = (Klass*) vtbl.allocate_permanent(klass, size, CHECK_NULL);
klassOop k = kl->as_klassOop();
{ // Preinitialize supertype information.
// A later call to initialize_supers() may update these settings:
kl->set_super(NULL);
for (juint i = 0; i < Klass::primary_super_limit(); i++) {
kl->_primary_supers[i] = NULL;
}
kl->set_secondary_supers(NULL);
oop_store_without_check((oop*) &kl->_primary_supers[0], k);
kl->set_super_check_offset(in_bytes(primary_supers_offset()));
}
kl->set_java_mirror(NULL);
kl->set_modifier_flags(0);
kl->set_layout_helper(Klass::_lh_neutral_value);
kl->set_name(NULL);
AccessFlags af;
af.set_flags(0);
kl->set_access_flags(af);
kl->set_subklass(NULL);
kl->set_next_sibling(NULL);
kl->set_alloc_count(0);
kl->set_alloc_size(0);
TRACE_SET_KLASS_TRACE_ID(kl, 0);
kl->set_prototype_header(markOopDesc::prototype());
kl->set_biased_lock_revocation_count(0);
kl->set_last_biased_lock_bulk_revocation_time(0);
return k;
}
示例6: oop_verify_on
void instanceKlassKlass::oop_verify_on(oop obj, outputStream* st) {
klassKlass::oop_verify_on(obj, st);
if (!obj->partially_loaded()) {
Thread *thread = Thread::current();
instanceKlass* ik = instanceKlass::cast(klassOop(obj));
// Avoid redundant verifies
if (ik->_verify_count == Universe::verify_count()) return;
ik->_verify_count = Universe::verify_count();
// Verify that klass is present in SystemDictionary
if (ik->is_loaded()) {
symbolHandle h_name (thread, ik->name());
Handle h_loader (thread, ik->class_loader());
SystemDictionary::verify_obj_klass_present(obj, h_name, h_loader);
}
// Verify static fields
VerifyFieldClosure blk;
ik->iterate_static_fields(&blk);
// Verify vtables
if (ik->is_linked()) {
ResourceMark rm(thread);
// $$$ This used to be done only for m/s collections. Doing it
// always seemed a valid generalization. (DLD -- 6/00)
ik->vtable()->verify(st);
}
// Verify oop map cache
if (ik->oop_map_cache() != NULL) {
ik->oop_map_cache()->verify();
}
// Verify first subklass
if (ik->subklass_oop() != NULL) {
guarantee(ik->subklass_oop()->is_perm(), "should be in permspace");
guarantee(ik->subklass_oop()->is_klass(), "should be klass");
}
// Verify siblings
klassOop super = ik->super();
Klass* sib = ik->next_sibling();
int sib_count = 0;
while (sib != NULL) {
if (sib == ik) {
fatal1("subclass cycle of length %d", sib_count);
}
if (sib_count >= 100000) {
fatal1("suspiciously long subclass list %d", sib_count);
}
guarantee(sib->as_klassOop()->is_klass(), "should be klass");
guarantee(sib->as_klassOop()->is_perm(), "should be in permspace");
guarantee(sib->super() == super, "siblings should have same superklass");
sib = sib->next_sibling();
}
// Verify implementor field
if (ik->implementor() != NULL) {
guarantee(ik->is_interface(), "only interfaces should have implementor set");
guarantee(ik->nof_implementors() == 1, "should only have one implementor");
klassOop im = ik->implementor();
guarantee(im->is_perm(), "should be in permspace");
guarantee(im->is_klass(), "should be klass");
guarantee(!Klass::cast(klassOop(im))->is_interface(), "implementors cannot be interfaces");
}
// Verify local interfaces
objArrayOop local_interfaces = ik->local_interfaces();
guarantee(local_interfaces->is_perm(), "should be in permspace");
guarantee(local_interfaces->is_objArray(), "should be obj array");
int j;
for (j = 0; j < local_interfaces->length(); j++) {
oop e = local_interfaces->obj_at(j);
guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid local interface");
}
// Verify transitive interfaces
objArrayOop transitive_interfaces = ik->transitive_interfaces();
guarantee(transitive_interfaces->is_perm(), "should be in permspace");
guarantee(transitive_interfaces->is_objArray(), "should be obj array");
for (j = 0; j < transitive_interfaces->length(); j++) {
oop e = transitive_interfaces->obj_at(j);
guarantee(e->is_klass() && Klass::cast(klassOop(e))->is_interface(), "invalid transitive interface");
}
// Verify methods
objArrayOop methods = ik->methods();
guarantee(methods->is_perm(), "should be in permspace");
guarantee(methods->is_objArray(), "should be obj array");
for (j = 0; j < methods->length(); j++) {
guarantee(methods->obj_at(j)->is_method(), "non-method in methods array");
}
for (j = 0; j < methods->length() - 1; j++) {
methodOop m1 = methodOop(methods->obj_at(j));
methodOop m2 = methodOop(methods->obj_at(j + 1));
guarantee(m1->name()->fast_compare(m2->name()) <= 0, "methods not sorted correctly");
}
// Verify method ordering
//.........这里部分代码省略.........
示例7: oop_print_on
void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) {
assert(obj->is_klass(), "must be klass");
instanceKlass* ik = instanceKlass::cast(klassOop(obj));
klassKlass::oop_print_on(obj, st);
st->print(" - instance size: %d", ik->size_helper()); st->cr();
st->print(" - klass size: %d", ik->object_size()); st->cr();
st->print(" - access: "); ik->access_flags().print_on(st); st->cr();
st->print(" - state: "); st->print_cr(state_names[ik->_init_state]);
st->print(" - name: "); ik->name()->print_value_on(st); st->cr();
st->print(" - super: "); ik->super()->print_value_on(st); st->cr();
st->print(" - sub: ");
Klass* sub = ik->subklass();
int n;
for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) {
if (n < MaxSubklassPrintSize) {
sub->as_klassOop()->print_value_on(st);
st->print(" ");
}
}
if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize);
st->cr();
if (ik->is_interface()) {
st->print_cr(" - nof implementors: %d", ik->nof_implementors());
if (ik->nof_implementors() == 1) {
st->print_cr(" - implementor: "); ik->implementor()->print_value_on(st);st->cr();
}
}
st->print(" - arrays: "); ik->array_klasses()->print_value_on(st); st->cr();
st->print(" - methods: "); ik->methods()->print_value_on(st); st->cr();
if (Verbose) {
objArrayOop methods = ik->methods();
for(int i = 0; i < methods->length(); i++) {
tty->print("%d : ", i); methods->obj_at(i)->print_value(); tty->cr();
}
}
st->print(" - method ordering: "); ik->method_ordering()->print_value_on(st); st->cr();
st->print(" - local interfaces: "); ik->local_interfaces()->print_value_on(st); st->cr();
st->print(" - trans. interfaces: "); ik->transitive_interfaces()->print_value_on(st); st->cr();
st->print(" - constants: "); ik->constants()->print_value_on(st); st->cr();
st->print(" - class loader: "); ik->class_loader()->print_value_on(st); st->cr();
st->print(" - protection domain: "); ik->protection_domain()->print_value_on(st); st->cr();
st->print(" - signers: "); ik->signers()->print_value_on(st); st->cr();
if (ik->source_file_name() != NULL) {
st->print(" - source file: ");
ik->source_file_name()->print_value_on(st);
st->cr();
}
if (ik->source_debug_extension() != NULL) {
st->print(" - source debug extension: ");
ik->source_debug_extension()->print_value_on(st);
st->cr();
}
if (ik->has_previous_version()) {
st->print_cr(" - previous version: ");
ik->previous_version()->print_value_on(st);
st->cr();
}
st->print(" - inner classes: "); ik->inner_classes()->print_value_on(st); st->cr();
st->print(" - java mirror: "); ik->java_mirror()->print_value_on(st); st->cr();
st->print(" - vtable length %d (start addr: " INTPTR_FORMAT ")", ik->vtable_length(), ik->start_of_vtable()); st->cr();
st->print(" - itable length %d (start addr: " INTPTR_FORMAT ")", ik->itable_length(), ik->start_of_itable()); st->cr();
st->print_cr(" - static fields:");
printing_stream = st;
ik->do_local_static_fields(print_static_field, obj);
st->print_cr(" - non-static fields:");
ik->do_nonstatic_fields(print_nonstatic_field, NULL);
printing_stream = NULL;
st->print(" - static oop maps: ");
if (ik->static_oop_field_size() > 0) {
int first_offset = ik->offset_of_static_fields();
st->print("%d-%d", first_offset, first_offset + ik->static_oop_field_size() - 1);
}
st->cr();
st->print(" - non-static oop maps: ");
OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
OopMapBlock* end_map = map + ik->nonstatic_oop_map_size();
while (map < end_map) {
st->print("%d-%d ", map->offset(), map->offset() + map->length() - 1);
map++;
}
st->cr();
}
示例8: oop_print_on
void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) {
assert(obj->is_klass(), "must be klass");
instanceKlass* ik = instanceKlass::cast(klassOop(obj));
klassKlass::oop_print_on(obj, st);
st->print(BULLET"instance size: %d", ik->size_helper()); st->cr();
st->print(BULLET"klass size: %d", ik->object_size()); st->cr();
st->print(BULLET"access: "); ik->access_flags().print_on(st); st->cr();
st->print(BULLET"state: "); st->print_cr(state_names[ik->_init_state]);
st->print(BULLET"name: "); ik->name()->print_value_on(st); st->cr();
st->print(BULLET"super: "); ik->super()->print_value_on(st); st->cr();
st->print(BULLET"sub: ");
Klass* sub = ik->subklass();
int n;
for (n = 0; sub != NULL; n++, sub = sub->next_sibling()) {
if (n < MaxSubklassPrintSize) {
sub->as_klassOop()->print_value_on(st);
st->print(" ");
}
}
if (n >= MaxSubklassPrintSize) st->print("(%d more klasses...)", n - MaxSubklassPrintSize);
st->cr();
if (ik->is_interface()) {
st->print_cr(BULLET"nof implementors: %d", ik->nof_implementors());
if (ik->nof_implementors() == 1) {
st->print_cr(BULLET"implementor: ");
st->print(" ");
ik->implementor()->print_value_on(st);
st->cr();
}
}
st->print(BULLET"arrays: "); ik->array_klasses()->print_value_on(st); st->cr();
st->print(BULLET"methods: "); ik->methods()->print_value_on(st); st->cr();
if (Verbose) {
objArrayOop methods = ik->methods();
for(int i = 0; i < methods->length(); i++) {
tty->print("%d : ", i); methods->obj_at(i)->print_value(); tty->cr();
}
}
st->print(BULLET"method ordering: "); ik->method_ordering()->print_value_on(st); st->cr();
st->print(BULLET"local interfaces: "); ik->local_interfaces()->print_value_on(st); st->cr();
st->print(BULLET"trans. interfaces: "); ik->transitive_interfaces()->print_value_on(st); st->cr();
st->print(BULLET"constants: "); ik->constants()->print_value_on(st); st->cr();
st->print(BULLET"class loader: "); ik->class_loader()->print_value_on(st); st->cr();
st->print(BULLET"protection domain: "); ik->protection_domain()->print_value_on(st); st->cr();
if (ik->host_klass() != NULL) {
st->print(BULLET"host class: "); ik->host_klass()->print_value_on(st); st->cr();
}
st->print(BULLET"signers: "); ik->signers()->print_value_on(st); st->cr();
if (ik->source_file_name() != NULL) {
st->print(BULLET"source file: ");
ik->source_file_name()->print_value_on(st);
st->cr();
}
if (ik->source_debug_extension() != NULL) {
st->print(BULLET"source debug extension: ");
st->print_cr("%s", ik->source_debug_extension());
st->cr();
}
{
ResourceMark rm;
// PreviousVersionInfo objects returned via PreviousVersionWalker
// contain a GrowableArray of handles. We have to clean up the
// GrowableArray _after_ the PreviousVersionWalker destructor
// has destroyed the handles.
{
bool have_pv = false;
PreviousVersionWalker pvw(ik);
for (PreviousVersionInfo * pv_info = pvw.next_previous_version();
pv_info != NULL; pv_info = pvw.next_previous_version()) {
if (!have_pv)
st->print(BULLET"previous version: ");
have_pv = true;
pv_info->prev_constant_pool_handle()()->print_value_on(st);
}
if (have_pv) st->cr();
} // pvw is cleaned up
} // rm is cleaned up
if (ik->generic_signature() != NULL) {
st->print(BULLET"generic signature: ");
ik->generic_signature()->print_value_on(st);
st->cr();
}
st->print(BULLET"inner classes: "); ik->inner_classes()->print_value_on(st); st->cr();
st->print(BULLET"java mirror: "); ik->java_mirror()->print_value_on(st); st->cr();
st->print(BULLET"vtable length %d (start addr: " INTPTR_FORMAT ")", ik->vtable_length(), ik->start_of_vtable()); st->cr();
st->print(BULLET"itable length %d (start addr: " INTPTR_FORMAT ")", ik->itable_length(), ik->start_of_itable()); st->cr();
st->print_cr(BULLET"---- static fields (%d words):", ik->static_field_size());
FieldPrinter print_static_field(st);
ik->do_local_static_fields(&print_static_field);
st->print_cr(BULLET"---- non-static fields (%d words):", ik->nonstatic_field_size());
FieldPrinter print_nonstatic_field(st);
ik->do_nonstatic_fields(&print_nonstatic_field);
st->print(BULLET"non-static oop maps: ");
OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
//.........这里部分代码省略.........