src/share/vm/memory/allocation.hpp

changeset 7074
833b0f92429a
parent 6507
752ba2e5f6d0
child 7089
6e0cb14ce59b
     1.1 --- a/src/share/vm/memory/allocation.hpp	Wed Aug 27 09:36:55 2014 +0200
     1.2 +++ b/src/share/vm/memory/allocation.hpp	Wed Aug 27 08:19:12 2014 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -133,51 +133,34 @@
    1.11  
    1.12  
    1.13  /*
    1.14 - * MemoryType bitmap layout:
    1.15 - * | 16 15 14 13 12 11 10 09 | 08 07 06 05 | 04 03 02 01 |
    1.16 - * |      memory type        |   object    | reserved    |
    1.17 - * |                         |     type    |             |
    1.18 + * Memory types
    1.19   */
    1.20  enum MemoryType {
    1.21    // Memory type by sub systems. It occupies lower byte.
    1.22 -  mtNone              = 0x0000,  // undefined
    1.23 -  mtClass             = 0x0100,  // memory class for Java classes
    1.24 -  mtThread            = 0x0200,  // memory for thread objects
    1.25 -  mtThreadStack       = 0x0300,
    1.26 -  mtCode              = 0x0400,  // memory for generated code
    1.27 -  mtGC                = 0x0500,  // memory for GC
    1.28 -  mtCompiler          = 0x0600,  // memory for compiler
    1.29 -  mtInternal          = 0x0700,  // memory used by VM, but does not belong to
    1.30 +  mtJavaHeap          = 0x00,  // Java heap
    1.31 +  mtClass             = 0x01,  // memory class for Java classes
    1.32 +  mtThread            = 0x02,  // memory for thread objects
    1.33 +  mtThreadStack       = 0x03,
    1.34 +  mtCode              = 0x04,  // memory for generated code
    1.35 +  mtGC                = 0x05,  // memory for GC
    1.36 +  mtCompiler          = 0x06,  // memory for compiler
    1.37 +  mtInternal          = 0x07,  // memory used by VM, but does not belong to
    1.38                                   // any of above categories, and not used for
    1.39                                   // native memory tracking
    1.40 -  mtOther             = 0x0800,  // memory not used by VM
    1.41 -  mtSymbol            = 0x0900,  // symbol
    1.42 -  mtNMT               = 0x0A00,  // memory used by native memory tracking
    1.43 -  mtChunk             = 0x0B00,  // chunk that holds content of arenas
    1.44 -  mtJavaHeap          = 0x0C00,  // Java heap
    1.45 -  mtClassShared       = 0x0D00,  // class data sharing
    1.46 -  mtTest              = 0x0E00,  // Test type for verifying NMT
    1.47 -  mtTracing           = 0x0F00,  // memory used for Tracing
    1.48 -  mt_number_of_types  = 0x000F,  // number of memory types (mtDontTrack
    1.49 +  mtOther             = 0x08,  // memory not used by VM
    1.50 +  mtSymbol            = 0x09,  // symbol
    1.51 +  mtNMT               = 0x0A,  // memory used by native memory tracking
    1.52 +  mtClassShared       = 0x0B,  // class data sharing
    1.53 +  mtChunk             = 0x0C,  // chunk that holds content of arenas
    1.54 +  mtTest              = 0x0D,  // Test type for verifying NMT
    1.55 +  mtTracing           = 0x0E,  // memory used for Tracing
    1.56 +  mtNone              = 0x0F,  // undefined
    1.57 +  mt_number_of_types  = 0x10   // number of memory types (mtDontTrack
    1.58                                   // is not included as validate type)
    1.59 -  mtDontTrack         = 0x0F00,  // memory we do not or cannot track
    1.60 -  mt_masks            = 0x7F00,
    1.61 -
    1.62 -  // object type mask
    1.63 -  otArena             = 0x0010, // an arena object
    1.64 -  otNMTRecorder       = 0x0020, // memory recorder object
    1.65 -  ot_masks            = 0x00F0
    1.66  };
    1.67  
    1.68 -#define IS_MEMORY_TYPE(flags, type) ((flags & mt_masks) == type)
    1.69 -#define HAS_VALID_MEMORY_TYPE(flags)((flags & mt_masks) != mtNone)
    1.70 -#define FLAGS_TO_MEMORY_TYPE(flags) (flags & mt_masks)
    1.71 +typedef MemoryType MEMFLAGS;
    1.72  
    1.73 -#define IS_ARENA_OBJ(flags)         ((flags & ot_masks) == otArena)
    1.74 -#define IS_NMT_RECORDER(flags)      ((flags & ot_masks) == otNMTRecorder)
    1.75 -#define NMT_CAN_TRACK(flags)        (!IS_NMT_RECORDER(flags) && !(IS_MEMORY_TYPE(flags, mtDontTrack)))
    1.76 -
    1.77 -typedef unsigned short MEMFLAGS;
    1.78  
    1.79  #if INCLUDE_NMT
    1.80  
    1.81 @@ -189,27 +172,23 @@
    1.82  
    1.83  #endif // INCLUDE_NMT
    1.84  
    1.85 -// debug build does not inline
    1.86 -#if defined(_NMT_NOINLINE_)
    1.87 -  #define CURRENT_PC       (NMT_track_callsite ? os::get_caller_pc(1) : 0)
    1.88 -  #define CALLER_PC        (NMT_track_callsite ? os::get_caller_pc(2) : 0)
    1.89 -  #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(3) : 0)
    1.90 -#else
    1.91 -  #define CURRENT_PC      (NMT_track_callsite? os::get_caller_pc(0) : 0)
    1.92 -  #define CALLER_PC       (NMT_track_callsite ? os::get_caller_pc(1) : 0)
    1.93 -  #define CALLER_CALLER_PC (NMT_track_callsite ? os::get_caller_pc(2) : 0)
    1.94 -#endif
    1.95 -
    1.96 +class NativeCallStack;
    1.97  
    1.98  
    1.99  template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
   1.100   public:
   1.101 -  _NOINLINE_ void* operator new(size_t size, address caller_pc = 0) throw();
   1.102 +  _NOINLINE_ void* operator new(size_t size, const NativeCallStack& stack) throw();
   1.103 +  _NOINLINE_ void* operator new(size_t size) throw();
   1.104    _NOINLINE_ void* operator new (size_t size, const std::nothrow_t&  nothrow_constant,
   1.105 -                               address caller_pc = 0) throw();
   1.106 -  _NOINLINE_ void* operator new [](size_t size, address caller_pc = 0) throw();
   1.107 +                               const NativeCallStack& stack) throw();
   1.108 +  _NOINLINE_ void* operator new (size_t size, const std::nothrow_t&  nothrow_constant)
   1.109 +                               throw();
   1.110 +  _NOINLINE_ void* operator new [](size_t size, const NativeCallStack& stack) throw();
   1.111 +  _NOINLINE_ void* operator new [](size_t size) throw();
   1.112    _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t&  nothrow_constant,
   1.113 -                               address caller_pc = 0) throw();
   1.114 +                               const NativeCallStack& stack) throw();
   1.115 +  _NOINLINE_ void* operator new [](size_t size, const std::nothrow_t&  nothrow_constant)
   1.116 +                               throw();
   1.117    void  operator delete(void* p);
   1.118    void  operator delete [] (void* p);
   1.119  };
   1.120 @@ -384,13 +363,15 @@
   1.121  
   1.122  //------------------------------Arena------------------------------------------
   1.123  // Fast allocation of memory
   1.124 -class Arena : public CHeapObj<mtNone|otArena> {
   1.125 +class Arena : public CHeapObj<mtNone> {
   1.126  protected:
   1.127    friend class ResourceMark;
   1.128    friend class HandleMark;
   1.129    friend class NoHandleMark;
   1.130    friend class VMStructs;
   1.131  
   1.132 +  MEMFLAGS    _flags;           // Memory tracking flags
   1.133 +
   1.134    Chunk *_first;                // First chunk
   1.135    Chunk *_chunk;                // current chunk
   1.136    char *_hwm, *_max;            // High water mark and max in current chunk
   1.137 @@ -418,8 +399,8 @@
   1.138   }
   1.139  
   1.140   public:
   1.141 -  Arena();
   1.142 -  Arena(size_t init_size);
   1.143 +  Arena(MEMFLAGS memflag);
   1.144 +  Arena(MEMFLAGS memflag, size_t init_size);
   1.145    ~Arena();
   1.146    void  destruct_contents();
   1.147    char* hwm() const             { return _hwm; }
   1.148 @@ -518,8 +499,6 @@
   1.149    static void free_malloced_objects(Chunk* chunk, char* hwm, char* max, char* hwm2)  PRODUCT_RETURN;
   1.150    static void free_all(char** start, char** end)                                     PRODUCT_RETURN;
   1.151  
   1.152 -  // how many arena instances
   1.153 -  NOT_PRODUCT(static volatile jint _instance_count;)
   1.154  private:
   1.155    // Reset this Arena to empty, access will trigger grow if necessary
   1.156    void   reset(void) {
   1.157 @@ -681,7 +660,7 @@
   1.158    NEW_C_HEAP_ARRAY3(type, (size), memflags, pc, AllocFailStrategy::RETURN_NULL)
   1.159  
   1.160  #define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\
   1.161 -  NEW_C_HEAP_ARRAY3(type, (size), memflags, (address)0, AllocFailStrategy::RETURN_NULL)
   1.162 +  NEW_C_HEAP_ARRAY3(type, (size), memflags, CURRENT_PC, AllocFailStrategy::RETURN_NULL)
   1.163  
   1.164  #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
   1.165    (type*) (ReallocateHeap((char*)(old), (size) * sizeof(type), memflags))

mercurial