69 void* MetaspaceObj::_shared_metaspace_base = nullptr;
70 void* MetaspaceObj::_shared_metaspace_top = nullptr;
71
72 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
73 size_t word_size,
74 MetaspaceObj::Type type, TRAPS) throw() {
75 // Klass has its own operator new
76 assert(type != ClassType, "class has its own operator new");
77 return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false, THREAD);
78 }
79
80 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
81 size_t word_size,
82 MetaspaceObj::Type type) throw() {
83 assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread");
84 assert(type != ClassType, "class has its own operator new");
85 return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false);
86 }
87
88 // This is used for allocating training data. We are allocating training data in many cases where a GC cannot be triggered.
89 void* MetaspaceObj::operator new(size_t size, MemTag flags) throw() {
90 void* p = AllocateHeap(size, flags, CALLER_PC);
91 memset(p, 0, size);
92 return p;
93 }
94
95 bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
96 // Weed out obvious bogus values first without traversing metaspace
97 if ((size_t)p < os::min_page_size()) {
98 return false;
99 } else if (!is_aligned((address)p, sizeof(MetaWord))) {
100 return false;
101 }
102 return Metaspace::contains((void*)p);
103 }
104
105 void MetaspaceObj::print_address_on(outputStream* st) const {
106 st->print(" {" PTR_FORMAT "}", p2i(this));
107 }
108
109 //
|
69 void* MetaspaceObj::_shared_metaspace_base = nullptr;
70 void* MetaspaceObj::_shared_metaspace_top = nullptr;
71
72 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
73 size_t word_size,
74 MetaspaceObj::Type type, TRAPS) throw() {
75 // Klass has its own operator new
76 assert(type != ClassType, "class has its own operator new");
77 return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false, THREAD);
78 }
79
80 void* MetaspaceObj::operator new(size_t size, ClassLoaderData* loader_data,
81 size_t word_size,
82 MetaspaceObj::Type type) throw() {
83 assert(!Thread::current()->is_Java_thread(), "only allowed by non-Java thread");
84 assert(type != ClassType, "class has its own operator new");
85 return Metaspace::allocate(loader_data, word_size, type, /*use_class_space*/ false);
86 }
87
88 // This is used for allocating training data. We are allocating training data in many cases where a GC cannot be triggered.
89 void* MetaspaceObj::operator new(size_t size, MemTag flags) {
90 void* p = AllocateHeap(size, flags, CALLER_PC);
91 memset(p, 0, size);
92 return p;
93 }
94
95 bool MetaspaceObj::is_valid(const MetaspaceObj* p) {
96 // Weed out obvious bogus values first without traversing metaspace
97 if ((size_t)p < os::min_page_size()) {
98 return false;
99 } else if (!is_aligned((address)p, sizeof(MetaWord))) {
100 return false;
101 }
102 return Metaspace::contains((void*)p);
103 }
104
105 void MetaspaceObj::print_address_on(outputStream* st) const {
106 st->print(" {" PTR_FORMAT "}", p2i(this));
107 }
108
109 //
|