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, bool is_value, TRAPS) throw() { 174 // Pad size in case need adjust to even/odd klass ptr 175 uintptr_t addr = (uintptr_t) Metaspace::allocate(loader_data, word_size + (1 << LogKlassAlignment), MetaspaceObj::ClassType, THREAD); 176 // values are odd, otherwise make even (and vice versa) 177 if (is_value ^ (((addr & KlassPtrEvenOddMask) >> LogKlassAlignmentInBytes) != 0)) { 178 addr += (1 << LogKlassAlignmentInBytes); 179 } 180 assert(is_aligned(addr, (1 << LogKlassAlignmentInBytes)), "Klass base alignment incorrect"); 181 assert(is_value || ((addr & KlassPtrEvenOddMask) == 0), "Klass even alignment incorrect"); 182 assert((!is_value) || ((addr & KlassPtrEvenOddMask) != 0), "Klass odd alignment incorrect"); 183 return (void*) addr; 184 } 185 186 187 // "Normal" instantiation is preceeded by a MetaspaceObj allocation 188 // which zeros out memory - calloc equivalent. 189 // The constructor is also used from CppVtableCloner, 190 // which doesn't zero out the memory before calling the constructor. 191 // Need to set the _java_mirror field explicitly to not hit an assert that the field 192 // should be NULL before setting it. 193 Klass::Klass() : _prototype_header(markOopDesc::prototype()), 194 _shared_class_path_index(-1), 195 _java_mirror(NULL) { 196 197 _primary_supers[0] = this; 198 set_super_check_offset(in_bytes(primary_supers_offset())); 199 } 200 201 jint Klass::array_layout_helper(BasicType etype) { 202 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype"); | 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, bool is_value, TRAPS) throw() { 174 // Pad size in case need adjust to even/odd klass ptr 175 uintptr_t addr = (uintptr_t) Metaspace::allocate(loader_data, word_size + (1 << LogKlassAlignment), MetaspaceObj::ClassType, THREAD); 176 // values are odd, otherwise make even (and vice versa) 177 if (is_value ^ (((addr & KlassPtrEvenOddMask) >> LogKlassAlignmentInBytes) != 0)) { 178 addr += (1 << LogKlassAlignmentInBytes); 179 } 180 assert(is_aligned(addr, (1 << LogKlassAlignmentInBytes)), "Klass base alignment incorrect"); 181 assert( is_value || ((addr & KlassPtrEvenOddMask) == 0), "Klass even alignment incorrect"); 182 assert(!is_value || ((addr & KlassPtrEvenOddMask) != 0), "Klass odd alignment incorrect"); 183 return (void*) addr; 184 } 185 186 187 // "Normal" instantiation is preceeded by a MetaspaceObj allocation 188 // which zeros out memory - calloc equivalent. 189 // The constructor is also used from CppVtableCloner, 190 // which doesn't zero out the memory before calling the constructor. 191 // Need to set the _java_mirror field explicitly to not hit an assert that the field 192 // should be NULL before setting it. 193 Klass::Klass() : _prototype_header(markOopDesc::prototype()), 194 _shared_class_path_index(-1), 195 _java_mirror(NULL) { 196 197 _primary_supers[0] = this; 198 set_super_check_offset(in_bytes(primary_supers_offset())); 199 } 200 201 jint Klass::array_layout_helper(BasicType etype) { 202 assert(etype >= T_BOOLEAN && etype <= T_OBJECT, "valid etype"); |