< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

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");

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");
< prev index next >