< prev index next >

src/share/vm/memory/allocation.hpp

Print this page
   1 /*
   2  * Copyright (c) 1997, 2016, 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  *


 217 // be defined as a an empty string "".
 218 //
 219 class _ValueObj {
 220  private:
 221   void* operator new(size_t size) throw();
 222   void  operator delete(void* p);
 223   void* operator new [](size_t size) throw();
 224   void  operator delete [](void* p);
 225 };
 226 
 227 
 228 // Base class for objects stored in Metaspace.
 229 // Calling delete will result in fatal error.
 230 //
 231 // Do not inherit from something with a vptr because this class does
 232 // not introduce one.  This class is used to allocate both shared read-only
 233 // and shared read-write classes.
 234 //
 235 
 236 class ClassLoaderData;

 237 
 238 class MetaspaceObj {
 239  public:
 240   bool is_metaspace_object() const;
 241   bool is_shared() const;
 242   void print_address_on(outputStream* st) const;  // nonvirtual address printing
 243 
 244 #define METASPACE_OBJ_TYPES_DO(f) \
 245   f(Unknown) \
 246   f(Class) \
 247   f(Symbol) \
 248   f(TypeArrayU1) \
 249   f(TypeArrayU2) \
 250   f(TypeArrayU4) \
 251   f(TypeArrayU8) \
 252   f(TypeArrayOther) \
 253   f(Method) \
 254   f(ConstMethod) \
 255   f(MethodData) \
 256   f(ConstantPool) \
 257   f(ConstantPoolCache) \
 258   f(Annotation) \
 259   f(MethodCounters) \
 260   f(Deallocated)
 261 
 262 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
 263 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
 264 
 265   enum Type {
 266     // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
 267     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
 268     _number_of_types
 269   };
 270 
 271   static const char * type_name(Type type) {
 272     switch(type) {
 273     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
 274     default:
 275       ShouldNotReachHere();
 276       return NULL;
 277     }
 278   }
 279 
 280   static MetaspaceObj::Type array_type(size_t elem_size) {
 281     switch (elem_size) {
 282     case 1: return TypeArrayU1Type;
 283     case 2: return TypeArrayU2Type;
 284     case 4: return TypeArrayU4Type;
 285     case 8: return TypeArrayU8Type;
 286     default:
 287       return TypeArrayOtherType;
 288     }
 289   }
 290 
 291   void* operator new(size_t size, ClassLoaderData* loader_data,
 292                      size_t word_size, bool read_only,
 293                      Type type, Thread* thread) throw();
 294                      // can't use TRAPS from this header file.
 295   void operator delete(void* p) { ShouldNotCallThis(); }





 296 };
 297 
 298 // Base class for classes that constitute name spaces.
 299 
 300 class AllStatic {
 301  public:
 302   AllStatic()  { ShouldNotCallThis(); }
 303   ~AllStatic() { ShouldNotCallThis(); }
 304 };
 305 
 306 
 307 //------------------------------Chunk------------------------------------------
 308 // Linked list of raw memory chunks
 309 class Chunk: CHeapObj<mtChunk> {
 310   friend class VMStructs;
 311 
 312  protected:
 313   Chunk*       _next;     // Next Chunk in list
 314   const size_t _len;      // Size of this Chunk
 315  public:


   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  *


 217 // be defined as a an empty string "".
 218 //
 219 class _ValueObj {
 220  private:
 221   void* operator new(size_t size) throw();
 222   void  operator delete(void* p);
 223   void* operator new [](size_t size) throw();
 224   void  operator delete [](void* p);
 225 };
 226 
 227 
 228 // Base class for objects stored in Metaspace.
 229 // Calling delete will result in fatal error.
 230 //
 231 // Do not inherit from something with a vptr because this class does
 232 // not introduce one.  This class is used to allocate both shared read-only
 233 // and shared read-write classes.
 234 //
 235 
 236 class ClassLoaderData;
 237 class MetaspaceClosure;
 238 
 239 class MetaspaceObj {
 240  public:
 241   bool is_metaspace_object() const;
 242   bool is_shared() const;
 243   void print_address_on(outputStream* st) const;  // nonvirtual address printing
 244 
 245 #define METASPACE_OBJ_TYPES_DO(f) \
 246   f(Unknown) \
 247   f(Class) \
 248   f(Symbol) \
 249   f(TypeArrayU1) \
 250   f(TypeArrayU2) \
 251   f(TypeArrayU4) \
 252   f(TypeArrayU8) \
 253   f(TypeArrayOther) \
 254   f(Method) \
 255   f(ConstMethod) \
 256   f(MethodData) \
 257   f(ConstantPool) \
 258   f(ConstantPoolCache) \
 259   f(Annotations) \
 260   f(MethodCounters)

 261 
 262 #define METASPACE_OBJ_TYPE_DECLARE(name) name ## Type,
 263 #define METASPACE_OBJ_TYPE_NAME_CASE(name) case name ## Type: return #name;
 264 
 265   enum Type {
 266     // Types are MetaspaceObj::ClassType, MetaspaceObj::SymbolType, etc
 267     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_DECLARE)
 268     _number_of_types
 269   };
 270 
 271   static const char * type_name(Type type) {
 272     switch(type) {
 273     METASPACE_OBJ_TYPES_DO(METASPACE_OBJ_TYPE_NAME_CASE)
 274     default:
 275       ShouldNotReachHere();
 276       return NULL;
 277     }
 278   }
 279 
 280   static MetaspaceObj::Type array_type(size_t elem_size) {
 281     switch (elem_size) {
 282     case 1: return TypeArrayU1Type;
 283     case 2: return TypeArrayU2Type;
 284     case 4: return TypeArrayU4Type;
 285     case 8: return TypeArrayU8Type;
 286     default:
 287       return TypeArrayOtherType;
 288     }
 289   }
 290 
 291   void* operator new(size_t size, ClassLoaderData* loader_data,
 292                      size_t word_size,
 293                      Type type, Thread* thread) throw();
 294                      // can't use TRAPS from this header file.
 295   void operator delete(void* p) { ShouldNotCallThis(); }
 296 
 297   // Declare a *static* method with the same signature in any subclass of MetaspaceObj
 298   // that should be read-only by default. See symbol.hpp for an example. This function
 299   // is used by the templates in metaspaceClosure.hpp
 300   static bool is_read_only_by_default() { return false; }
 301 };
 302 
 303 // Base class for classes that constitute name spaces.
 304 
 305 class AllStatic {
 306  public:
 307   AllStatic()  { ShouldNotCallThis(); }
 308   ~AllStatic() { ShouldNotCallThis(); }
 309 };
 310 
 311 
 312 //------------------------------Chunk------------------------------------------
 313 // Linked list of raw memory chunks
 314 class Chunk: CHeapObj<mtChunk> {
 315   friend class VMStructs;
 316 
 317  protected:
 318   Chunk*       _next;     // Next Chunk in list
 319   const size_t _len;      // Size of this Chunk
 320  public:


< prev index next >