212 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
213 assert(layout_helper_is_array(lh), "correct kind");
214 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
215 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
216 assert(layout_helper_header_size(lh) == hsize, "correct decode");
217 assert(layout_helper_element_type(lh) == etype, "correct decode");
218 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
219
220 return lh;
221 }
222
223 bool Klass::can_be_primary_super_slow() const {
224 if (super() == NULL)
225 return true;
226 else if (super()->super_depth() >= primary_super_limit()-1)
227 return false;
228 else
229 return true;
230 }
231
232 void Klass::initialize_supers(Klass* k, Array<Klass*>* transitive_interfaces, TRAPS) {
233 if (FastSuperclassLimit == 0) {
234 // None of the other machinery matters.
235 set_super(k);
236 return;
237 }
238 if (k == NULL) {
239 set_super(NULL);
240 _primary_supers[0] = this;
241 assert(super_depth() == 0, "Object must already be initialized properly");
242 } else if (k != super() || k == SystemDictionary::Object_klass()) {
243 assert(super() == NULL || super() == SystemDictionary::Object_klass(),
244 "initialize this only once to a non-trivial value");
245 set_super(k);
246 Klass* sup = k;
247 int sup_depth = sup->super_depth();
248 juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
249 if (!can_be_primary_super_slow())
250 my_depth = primary_super_limit();
251 for (juint i = 0; i < my_depth; i++) {
252 _primary_supers[i] = sup->_primary_supers[i];
331 int fill_p = primaries->length();
332 for (int j = 0; j < fill_p; j++) {
333 s2->at_put(j, primaries->pop()); // add primaries in reverse order.
334 }
335 for( int j = 0; j < secondaries->length(); j++ ) {
336 s2->at_put(j+fill_p, secondaries->at(j)); // add secondaries on the end.
337 }
338
339 #ifdef ASSERT
340 // We must not copy any NULL placeholders left over from bootstrap.
341 for (int j = 0; j < s2->length(); j++) {
342 assert(s2->at(j) != NULL, "correct bootstrapping order");
343 }
344 #endif
345
346 set_secondary_supers(s2);
347 }
348 }
349
350 GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots,
351 Array<Klass*>* transitive_interfaces) {
352 assert(num_extra_slots == 0, "override for complex klasses");
353 assert(transitive_interfaces == NULL, "sanity");
354 set_secondary_supers(Universe::the_empty_klass_array());
355 return NULL;
356 }
357
358
359 InstanceKlass* Klass::superklass() const {
360 assert(super() == NULL || super()->is_instance_klass(), "must be instance klass");
361 return _super == NULL ? NULL : InstanceKlass::cast(_super);
362 }
363
364 void Klass::set_subklass(Klass* s) {
365 assert(s != this, "sanity check");
366 _subklass = s;
367 }
368
369 void Klass::set_next_sibling(Klass* s) {
370 assert(s != this, "sanity check");
371 _next_sibling = s;
745
746 Method* Klass::method_at_vtable(int index) {
747 #ifndef PRODUCT
748 assert(index >= 0, "valid vtable index");
749 if (DebugVtables) {
750 verify_vtable_index(index);
751 }
752 #endif
753 return start_of_vtable()[index].method();
754 }
755
756 ByteSize Klass::vtable_start_offset() {
757 return in_ByteSize(InstanceKlass::header_size() * wordSize);
758 }
759
760 #ifndef PRODUCT
761
762 bool Klass::verify_vtable_index(int i) {
763 int limit = vtable_length()/vtableEntry::size();
764 assert(i >= 0 && i < limit, "index %d out of bounds %d", i, limit);
765 return true;
766 }
767
768 bool Klass::verify_itable_index(int i) {
769 assert(is_instance_klass(), "");
770 int method_count = klassItable::method_count_for_interface(this);
771 assert(i >= 0 && i < method_count, "index out of bounds");
772 return true;
773 }
774
775 #endif // PRODUCT
776
777 // Caller needs ResourceMark
778 // joint_in_module_of_loader provides an optimization if 2 classes are in
779 // the same module to succinctly print out relevant information about their
780 // module name and class loader's name_and_id for error messages.
781 // Format:
782 // <fully-qualified-external-class-name1> and <fully-qualified-external-class-name2>
783 // are in module <module-name>[@<version>]
784 // of loader <loader-name_and_id>[, parent loader <parent-loader-name_and_id>]
785 const char* Klass::joint_in_module_of_loader(const Klass* class2, bool include_parent_loader) const {
786 assert(module() == class2->module(), "classes do not have the same module");
787 const char* class1_name = external_name();
788 size_t len = strlen(class1_name) + 1;
789
790 const char* class2_description = class2->class_in_module_of_loader(true, include_parent_loader);
791 len += strlen(class2_description);
|
212 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
213 assert(layout_helper_is_array(lh), "correct kind");
214 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
215 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
216 assert(layout_helper_header_size(lh) == hsize, "correct decode");
217 assert(layout_helper_element_type(lh) == etype, "correct decode");
218 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
219
220 return lh;
221 }
222
223 bool Klass::can_be_primary_super_slow() const {
224 if (super() == NULL)
225 return true;
226 else if (super()->super_depth() >= primary_super_limit()-1)
227 return false;
228 else
229 return true;
230 }
231
232 void Klass::initialize_supers(Klass* k, Array<InstanceKlass*>* transitive_interfaces, TRAPS) {
233 if (FastSuperclassLimit == 0) {
234 // None of the other machinery matters.
235 set_super(k);
236 return;
237 }
238 if (k == NULL) {
239 set_super(NULL);
240 _primary_supers[0] = this;
241 assert(super_depth() == 0, "Object must already be initialized properly");
242 } else if (k != super() || k == SystemDictionary::Object_klass()) {
243 assert(super() == NULL || super() == SystemDictionary::Object_klass(),
244 "initialize this only once to a non-trivial value");
245 set_super(k);
246 Klass* sup = k;
247 int sup_depth = sup->super_depth();
248 juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
249 if (!can_be_primary_super_slow())
250 my_depth = primary_super_limit();
251 for (juint i = 0; i < my_depth; i++) {
252 _primary_supers[i] = sup->_primary_supers[i];
331 int fill_p = primaries->length();
332 for (int j = 0; j < fill_p; j++) {
333 s2->at_put(j, primaries->pop()); // add primaries in reverse order.
334 }
335 for( int j = 0; j < secondaries->length(); j++ ) {
336 s2->at_put(j+fill_p, secondaries->at(j)); // add secondaries on the end.
337 }
338
339 #ifdef ASSERT
340 // We must not copy any NULL placeholders left over from bootstrap.
341 for (int j = 0; j < s2->length(); j++) {
342 assert(s2->at(j) != NULL, "correct bootstrapping order");
343 }
344 #endif
345
346 set_secondary_supers(s2);
347 }
348 }
349
350 GrowableArray<Klass*>* Klass::compute_secondary_supers(int num_extra_slots,
351 Array<InstanceKlass*>* transitive_interfaces) {
352 assert(num_extra_slots == 0, "override for complex klasses");
353 assert(transitive_interfaces == NULL, "sanity");
354 set_secondary_supers(Universe::the_empty_klass_array());
355 return NULL;
356 }
357
358
359 InstanceKlass* Klass::superklass() const {
360 assert(super() == NULL || super()->is_instance_klass(), "must be instance klass");
361 return _super == NULL ? NULL : InstanceKlass::cast(_super);
362 }
363
364 void Klass::set_subklass(Klass* s) {
365 assert(s != this, "sanity check");
366 _subklass = s;
367 }
368
369 void Klass::set_next_sibling(Klass* s) {
370 assert(s != this, "sanity check");
371 _next_sibling = s;
745
746 Method* Klass::method_at_vtable(int index) {
747 #ifndef PRODUCT
748 assert(index >= 0, "valid vtable index");
749 if (DebugVtables) {
750 verify_vtable_index(index);
751 }
752 #endif
753 return start_of_vtable()[index].method();
754 }
755
756 ByteSize Klass::vtable_start_offset() {
757 return in_ByteSize(InstanceKlass::header_size() * wordSize);
758 }
759
760 #ifndef PRODUCT
761
762 bool Klass::verify_vtable_index(int i) {
763 int limit = vtable_length()/vtableEntry::size();
764 assert(i >= 0 && i < limit, "index %d out of bounds %d", i, limit);
765 return true;
766 }
767
768 #endif // PRODUCT
769
770 // Caller needs ResourceMark
771 // joint_in_module_of_loader provides an optimization if 2 classes are in
772 // the same module to succinctly print out relevant information about their
773 // module name and class loader's name_and_id for error messages.
774 // Format:
775 // <fully-qualified-external-class-name1> and <fully-qualified-external-class-name2>
776 // are in module <module-name>[@<version>]
777 // of loader <loader-name_and_id>[, parent loader <parent-loader-name_and_id>]
778 const char* Klass::joint_in_module_of_loader(const Klass* class2, bool include_parent_loader) const {
779 assert(module() == class2->module(), "classes do not have the same module");
780 const char* class1_name = external_name();
781 size_t len = strlen(class1_name) + 1;
782
783 const char* class2_description = class2->class_in_module_of_loader(true, include_parent_loader);
784 len += strlen(class2_description);
|