< prev index next >

src/hotspot/share/oops/klass.cpp

Print this page
rev 48545 : Value-based classes (vbc) / Oop value test via metadata ptr


 153 Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
 154 #ifdef ASSERT
 155   tty->print_cr("Error: find_field called on a klass oop."
 156                 " Likely error: reflection method does not correctly"
 157                 " wrap return value in a mirror object.");
 158 #endif
 159   ShouldNotReachHere();
 160   return NULL;
 161 }
 162 
 163 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode) const {
 164 #ifdef ASSERT
 165   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
 166                 " Likely error: reflection method does not correctly"
 167                 " wrap return value in a mirror object.");
 168 #endif
 169   ShouldNotReachHere();
 170   return NULL;
 171 }
 172 













 173 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
 174   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);

 175 }

 176 
 177 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
 178 // which zeros out memory - calloc equivalent.
 179 // The constructor is also used from CppVtableCloner,
 180 // which doesn't zero out the memory before calling the constructor.
 181 // Need to set the _java_mirror field explicitly to not hit an assert that the field
 182 // should be NULL before setting it.
 183 Klass::Klass() : _prototype_header(markOopDesc::prototype()),
 184                  _shared_class_path_index(-1),
 185                  _java_mirror(NULL) {
 186 
 187   _primary_supers[0] = this;
 188   set_super_check_offset(in_bytes(primary_supers_offset()));
 189 }
 190 
 191 jint Klass::array_layout_helper(BasicType etype) {
 192   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 193   // Note that T_ARRAY is not allowed here.
 194   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 195   int  esize = type2aelembytes(etype);




 153 Klass* Klass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
 154 #ifdef ASSERT
 155   tty->print_cr("Error: find_field called on a klass oop."
 156                 " Likely error: reflection method does not correctly"
 157                 " wrap return value in a mirror object.");
 158 #endif
 159   ShouldNotReachHere();
 160   return NULL;
 161 }
 162 
 163 Method* Klass::uncached_lookup_method(const Symbol* name, const Symbol* signature, OverpassLookupMode overpass_mode) const {
 164 #ifdef ASSERT
 165   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
 166                 " Likely error: reflection method does not correctly"
 167                 " wrap return value in a mirror object.");
 168 #endif
 169   ShouldNotReachHere();
 170   return NULL;
 171 }
 172 
 173 #if INCLUDE_VBC
 174 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, bool is_value, TRAPS) throw() {
 175   // Pad size in case need adjust to even/odd klass ptr
 176   uintptr_t addr = (uintptr_t) Metaspace::allocate(loader_data, word_size + (1 << LogKlassAlignment), MetaspaceObj::ClassType, THREAD);
 177   // values are odd, otherwise make even (and vice versa)
 178   if (is_value ^ ((addr & KlassPtrEvenOddMask) >> LogKlassAlignmentInBytes)) {
 179           addr += (1 << LogKlassAlignmentInBytes);
 180   }
 181   assert(is_aligned(addr, (1 << LogKlassAlignmentInBytes)), "Klass base alignment incorrect");
 182   assert(is_value || (addr & KlassPtrEvenOddMask) == 0,     "Klass even alignment incorrect");
 183   assert((!is_value) || (addr & KlassPtrEvenOddMask),       "Klass odd alignment incorrect");
 184   return (void*) addr;
 185 #else
 186 void* Klass::operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw() {
 187   return Metaspace::allocate(loader_data, word_size, MetaspaceObj::ClassType, THREAD);
 188 #endif
 189 }
 190 
 191 
 192 // "Normal" instantiation is preceeded by a MetaspaceObj allocation
 193 // which zeros out memory - calloc equivalent.
 194 // The constructor is also used from CppVtableCloner,
 195 // which doesn't zero out the memory before calling the constructor.
 196 // Need to set the _java_mirror field explicitly to not hit an assert that the field
 197 // should be NULL before setting it.
 198 Klass::Klass() : _prototype_header(markOopDesc::prototype()),
 199                  _shared_class_path_index(-1),
 200                  _java_mirror(NULL) {
 201 
 202   _primary_supers[0] = this;
 203   set_super_check_offset(in_bytes(primary_supers_offset()));
 204 }
 205 
 206 jint Klass::array_layout_helper(BasicType etype) {
 207   assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype");
 208   // Note that T_ARRAY is not allowed here.
 209   int  hsize = arrayOopDesc::base_offset_in_bytes(etype);
 210   int  esize = type2aelembytes(etype);


< prev index next >