180 ShouldNotReachHere();
181 return NULL;
182 }
183
184 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
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, 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");
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 st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
748 st->cr();
749 }
750
751 // print class
752 st->print(BULLET"klass: ");
753 obj->klass()->print_value_on(st);
754 st->cr();
755 }
756
757 void Klass::oop_print_value_on(oop obj, outputStream* st) {
758 // print title
759 ResourceMark rm; // Cannot print in debug mode without this
760 st->print("%s", internal_name());
761 obj->print_address_on(st);
762 }
763
764 // Verification
765
766 void Klass::verify_on(outputStream* st) {
767
768 // This can be expensive, but it is worth checking that this klass is actually
|
180 ShouldNotReachHere();
181 return NULL;
182 }
183
184 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
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 static markWord make_prototype(Klass* kls) {
201 markWord prototype = markWord::prototype();
202 #ifdef _LP64
203 if (UseCompactObjectHeaders) {
204 prototype = prototype.set_klass(kls);
205 }
206 #endif
207 return prototype;
208 }
209
210 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
211 // which zeros out memory - calloc equivalent.
212 // The constructor is also used from CppVtableCloner,
213 // which doesn't zero out the memory before calling the constructor.
214 Klass::Klass(KlassID id) : _id(id),
215 _prototype_header(make_prototype(this)),
216 _shared_class_path_index(-1) {
217 CDS_ONLY(_shared_class_flags = 0;)
218 CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
219 _primary_supers[0] = this;
220 set_super_check_offset(in_bytes(primary_supers_offset()));
221 }
222
223 jint Klass::array_layout_helper(BasicType etype) {
224 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
225 // Note that T_ARRAY is not allowed here.
226 int hsize = arrayOopDesc::base_offset_in_bytes(etype);
227 int esize = type2aelembytes(etype);
228 bool isobj = (etype == T_OBJECT);
229 int tag = isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
230 int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
231
232 assert(lh < (int)_lh_neutral_value, "must look like an array layout");
233 assert(layout_helper_is_array(lh), "correct kind");
234 assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
235 assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
737 void Klass::print_on(outputStream* st) const {
738 ResourceMark rm;
739 // print title
740 st->print("%s", internal_name());
741 print_address_on(st);
742 st->cr();
743 }
744
745 #define BULLET " - "
746
747 // Caller needs ResourceMark
748 void Klass::oop_print_on(oop obj, outputStream* st) {
749 // print title
750 st->print_cr("%s ", internal_name());
751 obj->print_address_on(st);
752
753 if (WizardMode) {
754 // print header
755 obj->mark().print_on(st);
756 st->cr();
757 if (UseCompactObjectHeaders) {
758 st->print(BULLET"prototype_header: " INTPTR_FORMAT, _prototype_header.value());
759 st->cr();
760 }
761 }
762
763 // print class
764 st->print(BULLET"klass: ");
765 obj->klass()->print_value_on(st);
766 st->cr();
767 }
768
769 void Klass::oop_print_value_on(oop obj, outputStream* st) {
770 // print title
771 ResourceMark rm; // Cannot print in debug mode without this
772 st->print("%s", internal_name());
773 obj->print_address_on(st);
774 }
775
776 // Verification
777
778 void Klass::verify_on(outputStream* st) {
779
780 // This can be expensive, but it is worth checking that this klass is actually
|