1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
210 private:
211 void* operator new(size_t size) throw();
212 void operator delete(void* p);
213 void* operator new [](size_t size) throw();
214 void operator delete [](void* p);
215 };
216
217
218 // Base class for objects stored in Metaspace.
219 // Calling delete will result in fatal error.
220 //
221 // Do not inherit from something with a vptr because this class does
222 // not introduce one. This class is used to allocate both shared read-only
223 // and shared read-write classes.
224 //
225
226 class ClassLoaderData;
227 class MetaspaceClosure;
228
229 class MetaspaceObj {
230 public:
231 bool is_metaspace_object() const;
232 bool is_shared() const;
233 void print_address_on(outputStream* st) const; // nonvirtual address printing
234
235 #define METASPACE_OBJ_TYPES_DO(f) \
236 f(Class) \
237 f(Symbol) \
238 f(TypeArrayU1) \
239 f(TypeArrayU2) \
240 f(TypeArrayU4) \
241 f(TypeArrayU8) \
242 f(TypeArrayOther) \
243 f(Method) \
244 f(ConstMethod) \
245 f(MethodData) \
246 f(ConstantPool) \
247 f(ConstantPoolCache) \
248 f(Annotations) \
249 f(MethodCounters)
250
251 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
252 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
210 private:
211 void* operator new(size_t size) throw();
212 void operator delete(void* p);
213 void* operator new [](size_t size) throw();
214 void operator delete [](void* p);
215 };
216
217
218 // Base class for objects stored in Metaspace.
219 // Calling delete will result in fatal error.
220 //
221 // Do not inherit from something with a vptr because this class does
222 // not introduce one. This class is used to allocate both shared read-only
223 // and shared read-write classes.
224 //
225
226 class ClassLoaderData;
227 class MetaspaceClosure;
228
229 class MetaspaceObj {
230 friend class MetaspaceShared;
231 static void* _shared_metaspace_base;
232 static void* _shared_metaspace_top;
233
234 public:
235 bool is_metaspace_object() const;
236 bool is_shared() const {
237 // If no shared metaspace regions are mapped, _shared_metaspace_{base,top} will
238 // both be NULL and all values of p will be rejected quickly.
239 return (((void*)this) < _shared_metaspace_top && ((void*)this) >= _shared_metaspace_base);
240 }
241 void print_address_on(outputStream* st) const; // nonvirtual address printing
242
243 #define METASPACE_OBJ_TYPES_DO(f) \
244 f(Class) \
245 f(Symbol) \
246 f(TypeArrayU1) \
247 f(TypeArrayU2) \
248 f(TypeArrayU4) \
249 f(TypeArrayU8) \
250 f(TypeArrayOther) \
251 f(Method) \
252 f(ConstMethod) \
253 f(MethodData) \
254 f(ConstantPool) \
255 f(ConstantPoolCache) \
256 f(Annotations) \
257 f(MethodCounters)
258
259 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
260 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
|