< prev index next >

src/hotspot/share/memory/allocation.cpp

Print this page

 69 
 70 void* MetaspaceObj::_shared_metaspace_base = nullptr;
 71 void* MetaspaceObj::_shared_metaspace_top  = nullptr;
 72 
 73 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
 74                                  size_t word_size,
 75                                  MetaspaceObj::Type type, TRAPS) throw() {
 76   // Klass has its own operator new
 77   assert(type != ClassType, "class has its own operator new");
 78   return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false, THREAD);
 79 }
 80 
 81 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
 82                                  size_t word_size,
 83                                  MetaspaceObj::Type type) throw() {
 84   assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread");
 85   assert(type != ClassType, "class has its own operator new");
 86   return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false);
 87 }
 88 








 89 bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
 90   // Weed out obvious bogus values first without traversing metaspace
 91   if ((size_t)p < os::min_page_size()) {
 92     return false;
 93   } else if (!is_aligned((address)p, sizeof(MetaWord))) {
 94     return false;
 95   }
 96   return Metaspace::contains((void*)p);
 97 }
 98 
 99 void MetaspaceObj::print_address_on(outputStream* st) const {
100   st->print(" {" PTR_FORMAT "}", p2i(this));
101 }
102 
103 //
104 // ArenaObj
105 //
106 
107 void* ArenaObj::operator new(size_t size, Arena *arena) throw() {
108   return arena->Amalloc(size);

 69 
 70 void* MetaspaceObj::_shared_metaspace_base = nullptr;
 71 void* MetaspaceObj::_shared_metaspace_top  = nullptr;
 72 
 73 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
 74                                  size_t word_size,
 75                                  MetaspaceObj::Type type, TRAPS) throw() {
 76   // Klass has its own operator new
 77   assert(type != ClassType, "class has its own operator new");
 78   return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false, THREAD);
 79 }
 80 
 81 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
 82                                  size_t word_size,
 83                                  MetaspaceObj::Type type) throw() {
 84   assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread");
 85   assert(type != ClassType, "class has its own operator new");
 86   return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false);
 87 }
 88 
 89 
 90 // Work-around -- see JDK-8331086
 91 void* MetaspaceObj::operator new(size_t size, MemTag flags) throw() {
 92   void* p = AllocateHeap(size, flags, CALLER_PC);
 93   memset(p, 0, size);
 94   return p;
 95 }
 96 
 97 bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
 98   // Weed out obvious bogus values first without traversing metaspace
 99   if ((size_t)p < os::min_page_size()) {
100     return false;
101   } else if (!is_aligned((address)p, sizeof(MetaWord))) {
102     return false;
103   }
104   return Metaspace::contains((void*)p);
105 }
106 
107 void MetaspaceObj::print_address_on(outputStream* st) const {
108   st->print(" {" PTR_FORMAT "}", p2i(this));
109 }
110 
111 //
112 // ArenaObj
113 //
114 
115 void* ArenaObj::operator new(size_t size, Arena *arena) throw() {
116   return arena->Amalloc(size);
< prev index next >