< prev index next >

src/hotspot/share/memory/allocation.cpp

Print this page

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








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

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