本文整理汇总了C++中Klass类的典型用法代码示例。如果您正苦于以下问题:C++ Klass类的具体用法?C++ Klass怎么用?C++ Klass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Klass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: oop_pc_follow_contents
void InstanceMirrorKlass::oop_pc_follow_contents(oop obj, ParCompactionManager* cm) {
InstanceKlass::oop_pc_follow_contents(obj, cm);
// Follow the klass field in the mirror.
Klass* klass = java_lang_Class::as_Klass(obj);
if (klass != NULL) {
// An anonymous class doesn't have its own class loader, so the call
// to follow_klass will mark and push its java mirror instead of the
// class loader. When handling the java mirror for an anonymous class
// we need to make sure its class loader data is claimed, this is done
// by calling follow_class_loader explicitly. For non-anonymous classes
// the call to follow_class_loader is made when the class loader itself
// is handled.
if (klass->is_instance_klass() && InstanceKlass::cast(klass)->is_anonymous()) {
cm->follow_class_loader(klass->class_loader_data());
} else {
cm->follow_klass(klass);
}
} else {
// If klass is NULL then this a mirror for a primitive type.
// We don't have to follow them, since they are handled as strong
// roots in Universe::oops_do.
assert(java_lang_Class::is_primitive(obj), "Sanity check");
}
ParCompactionManager::MarkAndPushClosure cl(cm);
oop_oop_iterate_statics<true>(obj, &cl);
}
示例2: classes_do
void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
// Lock-free access requires load_ptr_acquire
for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
klass_closure->do_klass(k);
assert(k != k->next_link(), "no loops!");
}
}
示例3: method
void javaVFrame::print() {
ResourceMark rm;
vframe::print();
tty->print("\t");
method()->print_value();
tty->cr();
tty->print_cr("\tbci: %d", bci());
print_stack_values("locals", locals());
print_stack_values("expressions", expressions());
GrowableArray<MonitorInfo*>* list = monitors();
if (list->is_empty()) return;
tty->print_cr("\tmonitor list:");
for (int index = (list->length()-1); index >= 0; index--) {
MonitorInfo* monitor = list->at(index);
tty->print("\t obj\t");
if (monitor->owner_is_scalar_replaced()) {
Klass* k = java_lang_Class::as_Klass(monitor->owner_klass());
tty->print("( is scalar replaced %s)", k->external_name());
} else if (monitor->owner() == NULL) {
tty->print("( null )");
} else {
monitor->owner()->print_value();
tty->print("(" INTPTR_FORMAT ")", (address)monitor->owner());
}
if (monitor->eliminated() && is_compiled_frame())
tty->print(" ( lock is eliminated )");
tty->cr();
tty->print("\t ");
monitor->lock()->print_on(tty);
tty->cr();
}
}
示例4: dictionary
void Dictionary::print() {
ResourceMark rm;
HandleMark hm;
tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
table_size(), number_of_entries());
tty->print_cr("^ indicates that initiating loader is different from "
"defining loader");
for (int index = 0; index < table_size(); index++) {
for (DictionaryEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
if (Verbose) tty->print("%4d: ", index);
Klass* e = probe->klass();
ClassLoaderData* loader_data = probe->loader_data();
bool is_defining_class =
(loader_data == InstanceKlass::cast(e)->class_loader_data());
tty->print("%s%s", is_defining_class ? " " : "^",
e->external_name());
tty->print(", loader ");
loader_data->print_value();
tty->cr();
}
}
tty->cr();
_pd_cache_table->print();
tty->cr();
}
示例5: UNSAFE_ENTRY
} UNSAFE_END
UNSAFE_ENTRY(jclass, Unsafe_GetJavaMirror(JNIEnv *env, jobject unsafe, jlong metaspace_klass)) {
Klass* klass = (Klass*) (address) metaspace_klass;
return (jclass) JNIHandles::make_local(klass->java_mirror());
} UNSAFE_END
示例6: guarantee
void Dictionary::verify() {
guarantee(number_of_entries() >= 0, "Verify of system dictionary failed");
int element_count = 0;
for (int index = 0; index < table_size(); index++) {
for (DictionaryEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
Klass* e = probe->klass();
ClassLoaderData* loader_data = probe->loader_data();
guarantee(e->oop_is_instance(),
"Verify of system dictionary failed");
// class loader must be present; a null class loader is the
// boostrap loader
guarantee(loader_data != NULL || DumpSharedSpaces ||
loader_data->class_loader() == NULL ||
loader_data->class_loader()->is_instance(),
"checking type of class_loader");
e->verify();
probe->verify_protection_domain_set();
element_count++;
}
}
guarantee(number_of_entries() == element_count,
"Verify of system dictionary failed");
debug_only(verify_lookup_length((double)number_of_entries() / table_size()));
_pd_cache_table->verify();
}
示例7: build_u2_from
oop AOTCompiledMethod::oop_at(int index) const {
if (index == 0) { // 0 is reserved
return NULL;
}
Metadata** entry = _metadata_got + (index - 1);
intptr_t meta = (intptr_t)*entry;
if ((meta & 1) == 1) {
// already resolved
Klass* k = (Klass*)(meta & ~1);
return k->java_mirror();
}
// The entry is string which we need to resolve.
const char* meta_name = _heap->get_name_at((int)meta);
int klass_len = build_u2_from((address)meta_name);
const char* klass_name = meta_name + 2;
// Quick check the current method's holder.
Klass* k = _method->method_holder();
ResourceMark rm; // for signature_name()
if (strncmp(k->signature_name(), klass_name, klass_len) != 0) { // Does not match?
// Search klass in got cells in DSO which have this compiled method.
k = _heap->get_klass_from_got(klass_name, klass_len, _method);
}
int method_name_len = build_u2_from((address)klass_name + klass_len);
guarantee(method_name_len == 0, "only klass is expected here");
meta = ((intptr_t)k) | 1;
*entry = (Metadata*)meta; // Should be atomic on x64
return k->java_mirror();
}
示例8: increment_for_basic_type_arrays
// increment the count for the given basic type array class (and any
// multi-dimensional arrays). For example, for [B we check for
// [[B, [[[B, .. and the count is incremented for each one that exists.
static void increment_for_basic_type_arrays(Klass* k) {
JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
assert(that != NULL, "no JvmtiGetLoadedClassesClosure");
for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) {
that->set_count(that->get_count() + 1);
}
}
示例9: h_k
// ------------------------------------------------------------------
// ciObjectFactory::create_new_object
//
// Create a new ciObject from a Metadata*.
//
// Implementation note: this functionality could be virtual behavior
// of the oop itself. For now, we explicitly marshal the object.
ciMetadata* ciObjectFactory::create_new_object(Metadata* o) {
EXCEPTION_CONTEXT;
if (o->is_klass()) {
KlassHandle h_k(THREAD, (Klass*)o);
Klass* k = (Klass*)o;
if (k->oop_is_instance()) {
return new (arena()) ciInstanceKlass(h_k);
} else if (k->oop_is_objArray()) {
return new (arena()) ciObjArrayKlass(h_k);
} else if (k->oop_is_typeArray()) {
return new (arena()) ciTypeArrayKlass(h_k);
}
} else if (o->is_method()) {
methodHandle h_m(THREAD, (Method*)o);
return new (arena()) ciMethod(h_m);
} else if (o->is_methodData()) {
// Hold methodHandle alive - might not be necessary ???
methodHandle h_m(THREAD, ((MethodData*)o)->method());
return new (arena()) ciMethodData((MethodData*)o);
}
// The oop is of some type not supported by the compiler interface.
ShouldNotReachHere();
return NULL;
}
示例10: parameter
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());
}
示例11: do_object
void do_object(oop obj) {
if (obj->is_klass()) {
Klass* k = Klass::cast(klassOop(obj));
k->set_alloc_count(0);
k->set_alloc_size(0);
}
}
示例12: while
// Sets the do_print flag for every superclass and subclass of the specified class.
void KlassHierarchy::set_do_print_for_class_hierarchy(KlassInfoEntry* cie, KlassInfoTable* cit,
bool print_subclasses) {
// Set do_print for all superclasses of this class.
Klass* super = ((InstanceKlass*)cie->klass())->java_super();
while (super != NULL) {
KlassInfoEntry* super_cie = cit->lookup(super);
super_cie->set_do_print(true);
super = super->super();
}
// Set do_print for this class and all of its subclasses.
Stack <KlassInfoEntry*, mtClass> class_stack;
class_stack.push(cie);
while (!class_stack.is_empty()) {
KlassInfoEntry* curr_cie = class_stack.pop();
curr_cie->set_do_print(true);
if (print_subclasses && curr_cie->subclasses() != NULL) {
// Current class has subclasses, so push all of them onto the stack.
for (int i = 0; i < curr_cie->subclasses()->length(); i++) {
KlassInfoEntry* cie = curr_cie->subclasses()->at(i);
class_stack.push(cie);
}
}
}
}
示例13: 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;
}
示例14: compute_static_oop_field_count
int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
Klass* k = java_lang_Class::as_Klass(obj);
if (k != NULL && k->is_instance_klass()) {
return InstanceKlass::cast(k)->static_oop_field_count();
}
return 0;
}
示例15: f
void ClassLoaderData::methods_do(void f(Method*)) {
for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
if (k->is_instance_klass()) {
InstanceKlass::cast(k)->methods_do(f);
}
}
}