本文整理汇总了C++中Klass::super_depth方法的典型用法代码示例。如果您正苦于以下问题:C++ Klass::super_depth方法的具体用法?C++ Klass::super_depth怎么用?C++ Klass::super_depth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Klass
的用法示例。
在下文中一共展示了Klass::super_depth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialize_supers
void Klass::initialize_supers(klassOop k, TRAPS) {
if (FastSuperclassLimit == 0) {
// None of the other machinery matters.
set_super(k);
return;
}
if (k == NULL) {
set_super(NULL);
oop_store_without_check((oop*) &_primary_supers[0], (oop) this->as_klassOop());
assert(super_depth() == 0, "Object must already be initialized properly");
} else if (k != super() || k == SystemDictionary::Object_klass()) {
assert(super() == NULL || super() == SystemDictionary::Object_klass(),
"initialize this only once to a non-trivial value");
set_super(k);
Klass* sup = k->klass_part();
int sup_depth = sup->super_depth();
juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
if (!can_be_primary_super_slow())
my_depth = primary_super_limit();
for (juint i = 0; i < my_depth; i++) {
oop_store_without_check((oop*) &_primary_supers[i], (oop) sup->_primary_supers[i]);
}
klassOop *super_check_cell;
if (my_depth < primary_super_limit()) {
oop_store_without_check((oop*) &_primary_supers[my_depth], (oop) this->as_klassOop());
super_check_cell = &_primary_supers[my_depth];
} else {
// Overflow of the primary_supers array forces me to be secondary.
super_check_cell = &_secondary_super_cache;
}
set_super_check_offset((address)super_check_cell - (address) this->as_klassOop());
#ifdef ASSERT
{
juint j = super_depth();
assert(j == my_depth, "computed accessor gets right answer");
klassOop t = as_klassOop();
while (!Klass::cast(t)->can_be_primary_super()) {
t = Klass::cast(t)->super();
j = Klass::cast(t)->super_depth();
}
for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
assert(primary_super_of_depth(j1) == NULL, "super list padding");
}
while (t != NULL) {
assert(primary_super_of_depth(j) == t, "super list initialization");
t = Klass::cast(t)->super();
--j;
}
assert(j == (juint)-1, "correct depth count");
}
#endif
}
if (secondary_supers() == NULL) {
KlassHandle this_kh (THREAD, this);
// Now compute the list of secondary supertypes.
// Secondaries can occasionally be on the super chain,
// if the inline "_primary_supers" array overflows.
int extras = 0;
klassOop p;
for (p = super(); !(p == NULL || p->klass_part()->can_be_primary_super()); p = p->klass_part()->super()) {
++extras;
}
// Compute the "real" non-extra secondaries.
objArrayOop secondary_oops = compute_secondary_supers(extras, CHECK);
objArrayHandle secondaries (THREAD, secondary_oops);
// Store the extra secondaries in the first array positions:
int fillp = extras;
for (p = this_kh->super(); !(p == NULL || p->klass_part()->can_be_primary_super()); p = p->klass_part()->super()) {
int i; // Scan for overflow primaries being duplicates of 2nd'arys
// This happens frequently for very deeply nested arrays: the
// primary superclass chain overflows into the secondary. The
// secondary list contains the element_klass's secondaries with
// an extra array dimension added. If the element_klass's
// secondary list already contains some primary overflows, they
// (with the extra level of array-ness) will collide with the
// normal primary superclass overflows.
for( i = extras; i < secondaries->length(); i++ )
if( secondaries->obj_at(i) == p )
break;
if( i < secondaries->length() )
continue; // It's a dup, don't put it in
secondaries->obj_at_put(--fillp, p);
}
// See if we had some dup's, so the array has holes in it.
if( fillp > 0 ) {
// Pack the array. Drop the old secondaries array on the floor
// and let GC reclaim it.
objArrayOop s2 = oopFactory::new_system_objArray(secondaries->length() - fillp, CHECK);
for( int i = 0; i < s2->length(); i++ )
s2->obj_at_put( i, secondaries->obj_at(i+fillp) );
secondaries = objArrayHandle(THREAD, s2);
}
#ifdef ASSERT
//.........这里部分代码省略.........
示例2: initialize_supers
void Klass::initialize_supers(Klass* k, TRAPS) {
if (FastSuperclassLimit == 0) {
// None of the other machinery matters.
set_super(k);
return;
}
if (k == NULL) {
set_super(NULL);
_primary_supers[0] = this;
assert(super_depth() == 0, "Object must already be initialized properly");
} else if (k != super() || k == SystemDictionary::Object_klass()) {
assert(super() == NULL || super() == SystemDictionary::Object_klass(),
"initialize this only once to a non-trivial value");
set_super(k);
Klass* sup = k;
int sup_depth = sup->super_depth();
juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
if (!can_be_primary_super_slow())
my_depth = primary_super_limit();
for (juint i = 0; i < my_depth; i++) {
_primary_supers[i] = sup->_primary_supers[i];
}
Klass* *super_check_cell;
if (my_depth < primary_super_limit()) {
_primary_supers[my_depth] = this;
super_check_cell = &_primary_supers[my_depth];
} else {
// Overflow of the primary_supers array forces me to be secondary.
super_check_cell = &_secondary_super_cache;
}
set_super_check_offset((address)super_check_cell - (address) this);
#ifdef ASSERT
{
juint j = super_depth();
assert(j == my_depth, "computed accessor gets right answer");
Klass* t = this;
while (!t->can_be_primary_super()) {
t = t->super();
j = t->super_depth();
}
for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
assert(primary_super_of_depth(j1) == NULL, "super list padding");
}
while (t != NULL) {
assert(primary_super_of_depth(j) == t, "super list initialization");
t = t->super();
--j;
}
assert(j == (juint)-1, "correct depth count");
}
#endif
}
if (secondary_supers() == NULL) {
KlassHandle this_kh (THREAD, this);
// Now compute the list of secondary supertypes.
// Secondaries can occasionally be on the super chain,
// if the inline "_primary_supers" array overflows.
int extras = 0;
Klass* p;
for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
++extras;
}
ResourceMark rm(THREAD); // need to reclaim GrowableArrays allocated below
// Compute the "real" non-extra secondaries.
GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
if (secondaries == NULL) {
// secondary_supers set by compute_secondary_supers
return;
}
GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
for (p = this_kh->super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
int i; // Scan for overflow primaries being duplicates of 2nd'arys
// This happens frequently for very deeply nested arrays: the
// primary superclass chain overflows into the secondary. The
// secondary list contains the element_klass's secondaries with
// an extra array dimension added. If the element_klass's
// secondary list already contains some primary overflows, they
// (with the extra level of array-ness) will collide with the
// normal primary superclass overflows.
for( i = 0; i < secondaries->length(); i++ ) {
if( secondaries->at(i) == p )
break;
}
if( i < secondaries->length() )
continue; // It's a dup, don't put it in
primaries->push(p);
}
// Combine the two arrays into a metadata object to pack the array.
// The primaries are added in the reverse order, then the secondaries.
int new_length = primaries->length() + secondaries->length();
Array<Klass*>* s2 = MetadataFactory::new_array<Klass*>(
class_loader_data(), new_length, CHECK);
//.........这里部分代码省略.........