< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page

176   ShouldNotReachHere();
177   return NULL;
178 }
179 
180 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
181                                       OverpassLookupMode overpass_mode,
182                                       PrivateLookupMode private_mode) const {
183 #ifdef ASSERT
184   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
185                 " Likely error: reflection method does not correctly"
186                 " wrap return value in a mirror object.");
187 #endif
188   ShouldNotReachHere();
189   return NULL;
190 }
191 
192 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
193   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
194 }
195 










196 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
197 // which zeros out memory - calloc equivalent.
198 // The constructor is also used from CppVtableCloner,
199 // which doesn't zero out the memory before calling the constructor.
200 Klass::Klass(KlassID id) : _id(id),
201                            _prototype_header(markWord::prototype()),
202                            _shared_class_path_index(-1) {
203   CDS_ONLY(_shared_class_flags = 0;)
204   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
205   _primary_supers[0] = this;
206   set_super_check_offset(in_bytes(primary_supers_offset()));
207 }
208 
209 jint Klass::array_layout_helper(BasicType etype) {
210   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
211   // Note that T_ARRAY is not allowed here.
212   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
213   int  esize = type2aelembytes(etype);
214   bool isobj = (etype == T_OBJECT);
215   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
216   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
217 
218   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
219   assert(layout_helper_is_array(lh), "correct kind");
220   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
221   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");

176   ShouldNotReachHere();
177   return NULL;
178 }
179 
180 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature,
181                                       OverpassLookupMode overpass_mode,
182                                       PrivateLookupMode private_mode) const {
183 #ifdef ASSERT
184   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
185                 " Likely error: reflection method does not correctly"
186                 " wrap return value in a mirror object.");
187 #endif
188   ShouldNotReachHere();
189   return NULL;
190 }
191 
192 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
193   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
194 }
195 
196 static markWord make_prototype(Klass* kls) {
197   markWord prototype = markWord::prototype();
198 #ifdef _LP64
199   if (UseCompactObjectHeaders) {
200     prototype = prototype.set_klass(kls);
201   }
202 #endif
203   return prototype;
204 }
205 
206 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
207 // which zeros out memory - calloc equivalent.
208 // The constructor is also used from CppVtableCloner,
209 // which doesn't zero out the memory before calling the constructor.
210 Klass::Klass(KlassID id) : _id(id),
211                            _prototype_header(make_prototype(this)),
212                            _shared_class_path_index(-1) {
213   CDS_ONLY(_shared_class_flags = 0;)
214   CDS_JAVA_HEAP_ONLY(_archived_mirror_index = -1;)
215   _primary_supers[0] = this;
216   set_super_check_offset(in_bytes(primary_supers_offset()));
217 }
218 
219 jint Klass::array_layout_helper(BasicType etype) {
220   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
221   // Note that T_ARRAY is not allowed here.
222   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
223   int  esize = type2aelembytes(etype);
224   bool isobj = (etype == T_OBJECT);
225   int  tag   =  isobj ? _lh_array_tag_obj_value : _lh_array_tag_type_value;
226   int lh = array_layout_helper(tag, hsize, etype, exact_log2(esize));
227 
228   assert(lh < (int)_lh_neutral_value, "must look like an array layout");
229   assert(layout_helper_is_array(lh), "correct kind");
230   assert(layout_helper_is_objArray(lh) == isobj, "correct kind");
231   assert(layout_helper_is_typeArray(lh) == !isobj, "correct kind");
< prev index next >