185 OverpassLookupMode overpass_mode,
186 PrivateLookupMode private_mode) const {
187 #ifdef ASSERT
188 tty->print_cr("Error: uncached_lookup_method called on a klass oop."
189 " Likely error: reflection method does not correctly"
190 " wrap return value in a mirror object.");
191 #endif
192 ShouldNotReachHere();
193 return NULL;
194 }
195
196 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
197 return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
198 }
199
200 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
201 // which zeros out memory - calloc equivalent.
202 // The constructor is also used from CppVtableCloner,
203 // which doesn't zero out the memory before calling the constructor.
204 Klass::Klass(KlassID id) : _id(id),
205 _shared_class_path_index(-1) {
206 CDS_ONLY(_shared_class_flags = 0;)
207 CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
208 _primary_supers[0] = this;
209 set_super_check_offset(in_bytes(primary_supers_offset()));
210 }
211
212 jint Klass::array_layout_helper(BasicType etype) {
213 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
214 // Note that T_ARRAY is not allowed here.
215 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
216 int esize = type2aelembytes(etype);
217 bool isobj = (etype == T_OBJECT);
218 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
219 int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
220
221 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
222 assert(layout_helper_is_array(lh), "correct kind");
223 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
224 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
225 assert(layout_helper_header_size(lh) == hsize, "correct decode");
226 assert(layout_helper_element_type(lh) == etype, "correct decode");
227 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
228
229 return lh;
230 }
231
232 bool Klass::can_be_primary_super_slow() const {
233 if (super() == NULL)
234 return true;
235 else if (super()->super_depth() >= primary_super_limit()-1)
236 return false;
237 else
238 return true;
239 }
727 void Klass::print_on(outputStream* st) const {
728 ResourceMark rm;
729 // print title
730 st->print("%s", internal_name());
731 print_address_on(st);
732 st->cr();
733 }
734
735 #define BULLET " - "
736
737 // Caller needs ResourceMark
738 void Klass::oop_print_on(oop obj, outputStream* st) {
739 // print title
740 st->print_cr("%s ", internal_name());
741 obj->print_address_on(st);
742
743 if (WizardMode) {
744 // print header
745 obj->mark().print_on(st);
746 st->cr();
747 }
748
749 // print class
750 st->print(BULLET"klass: ");
751 obj->klass()->print_value_on(st);
752 st->cr();
753 }
754
755 void Klass::oop_print_value_on(oop obj, outputStream* st) {
756 // print title
757 ResourceMark rm; // Cannot print in debug mode without this
758 st->print("%s", internal_name());
759 obj->print_address_on(st);
760 }
761
762 // Verification
763
764 void Klass::verify_on(outputStream* st) {
765
766 // This can be expensive, but it is worth checking that this klass is actually
|
185 OverpassLookupMode overpass_mode,
186 PrivateLookupMode private_mode) const {
187 #ifdef ASSERT
188 tty->print_cr("Error: uncached_lookup_method called on a klass oop."
189 " Likely error: reflection method does not correctly"
190 " wrap return value in a mirror object.");
191 #endif
192 ShouldNotReachHere();
193 return NULL;
194 }
195
196 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
197 return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
198 }
199
200 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
201 // which zeros out memory - calloc equivalent.
202 // The constructor is also used from CppVtableCloner,
203 // which doesn't zero out the memory before calling the constructor.
204 Klass::Klass(KlassID id) : _id(id),
205 _prototype_header(markWord::prototype()),
206 _shared_class_path_index(-1) {
207 CDS_ONLY(_shared_class_flags = 0;)
208 CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
209 _primary_supers[0] = this;
210 set_super_check_offset(in_bytes(primary_supers_offset()));
211 }
212
213 jint Klass::array_layout_helper(BasicType etype) {
214 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
215 // Note that T_ARRAY is not allowed here.
216 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
217 int esize = type2aelembytes(etype);
218 bool isobj = (etype == T_OBJECT);
219 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
220 int lh = array_layout_helper(tag, false, hsize, etype, exact_log2(esize));
221
222 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
223 assert(layout_helper_is_array(lh), "correct kind");
224 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
225 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
226 assert(layout_helper_header_size(lh) == hsize, "correct decode");
227 assert(layout_helper_element_type(lh) == etype, "correct decode");
228 assert(1 << layout_helper_log2_element_size(lh) == esize, "correct decode");
229
230 return lh;
231 }
232
233 bool Klass::can_be_primary_super_slow() const {
234 if (super() == NULL)
235 return true;
236 else if (super()->super_depth() >= primary_super_limit()-1)
237 return false;
238 else
239 return true;
240 }
728 void Klass::print_on(outputStream* st) const {
729 ResourceMark rm;
730 // print title
731 st->print("%s", internal_name());
732 print_address_on(st);
733 st->cr();
734 }
735
736 #define BULLET " - "
737
738 // Caller needs ResourceMark
739 void Klass::oop_print_on(oop obj, outputStream* st) {
740 // print title
741 st->print_cr("%s ", internal_name());
742 obj->print_address_on(st);
743
744 if (WizardMode) {
745 // print header
746 obj->mark().print_on(st);
747 st->cr();
748 st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
749 st->cr();
750 }
751
752 // print class
753 st->print(BULLET"klass: ");
754 obj->klass()->print_value_on(st);
755 st->cr();
756 }
757
758 void Klass::oop_print_value_on(oop obj, outputStream* st) {
759 // print title
760 ResourceMark rm; // Cannot print in debug mode without this
761 st->print("%s", internal_name());
762 obj->print_address_on(st);
763 }
764
765 // Verification
766
767 void Klass::verify_on(outputStream* st) {
768
769 // This can be expensive, but it is worth checking that this klass is actually
|