src/share/vm/memory/heap.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8029799 Sdiff src/share/vm/memory

src/share/vm/memory/heap.hpp

Print this page




  76   FreeBlock* link() const                    { return _link; }
  77   void set_link(FreeBlock* link)             { _link = link; }
  78 };
  79 
  80 class CodeHeap : public CHeapObj<mtCode> {
  81   friend class VMStructs;
  82  private:
  83   VirtualSpace _memory;                          // the memory holding the blocks
  84   VirtualSpace _segmap;                          // the memory holding the segment map
  85 
  86   size_t       _number_of_committed_segments;
  87   size_t       _number_of_reserved_segments;
  88   size_t       _segment_size;
  89   int          _log2_segment_size;
  90 
  91   size_t       _next_segment;
  92 
  93   FreeBlock*   _freelist;
  94   size_t       _freelist_segments;               // No. of segments in freelist
  95 


  96   // Helper functions
  97   size_t   size_to_segments(size_t size) const { return (size + _segment_size - 1) >> _log2_segment_size; }
  98   size_t   segments_to_size(size_t number_of_segments) const { return number_of_segments << _log2_segment_size; }
  99 
 100   size_t   segment_for(void* p) const            { return ((char*)p - _memory.low()) >> _log2_segment_size; }

 101   HeapBlock* block_at(size_t i) const            { return (HeapBlock*)(_memory.low() + (i << _log2_segment_size)); }
 102 
 103   void  mark_segmap_as_free(size_t beg, size_t end);
 104   void  mark_segmap_as_used(size_t beg, size_t end);
 105 
 106   // Freelist management helpers
 107   FreeBlock* following_block(FreeBlock *b);
 108   void insert_after(FreeBlock* a, FreeBlock* b);
 109   void merge_right (FreeBlock* a);
 110 
 111   // Toplevel freelist management
 112   void add_to_freelist(HeapBlock *b);
 113   FreeBlock* search_freelist(size_t length, bool is_critical);
 114 
 115   // Iteration helpers
 116   void*      next_free(HeapBlock* b) const;
 117   HeapBlock* first_block() const;
 118   HeapBlock* next_block(HeapBlock* b) const;
 119   HeapBlock* block_start(void* p) const;
 120 
 121   // to perform additional actions on creation of executable code
 122   void on_code_mapping(char* base, size_t size);


 123 
 124  public:
 125   CodeHeap();
 126 
 127   // Heap extents
 128   bool  reserve(size_t reserved_size, size_t committed_size, size_t segment_size);
 129   void  release();                               // releases all allocated memory
 130   bool  expand_by(size_t size);                  // expands commited memory by size
 131   void  shrink_by(size_t size);                  // shrinks commited memory by size
 132   void  clear();                                 // clears all heap contents
 133 
 134   // Memory allocation
 135   void* allocate  (size_t size, bool is_critical);  // allocates a block of size or returns NULL
 136   void  deallocate(void* p);                     // deallocates a block
 137 
 138   // Attributes
 139   char* low_boundary() const                     { return _memory.low_boundary (); }
 140   char* high() const                             { return _memory.high(); }
 141   char* high_boundary() const                    { return _memory.high_boundary(); }
 142 
 143   bool  contains(const void* p) const            { return low_boundary() <= p && p < high(); }
 144   void* find_start(void* p) const;              // returns the block containing p or NULL
 145   size_t alignment_unit() const;                // alignment of any block
 146   size_t alignment_offset() const;              // offset of first byte of any block, within the enclosing alignment unit
 147   static size_t header_size();                  // returns the header size for each heap block
 148 
 149   // Iteration
 150 
 151   // returns the first block or NULL
 152   void* first() const       { return next_free(first_block()); }


  76   FreeBlock* link() const                    { return _link; }
  77   void set_link(FreeBlock* link)             { _link = link; }
  78 };
  79 
  80 class CodeHeap : public CHeapObj<mtCode> {
  81   friend class VMStructs;
  82  private:
  83   VirtualSpace _memory;                          // the memory holding the blocks
  84   VirtualSpace _segmap;                          // the memory holding the segment map
  85 
  86   size_t       _number_of_committed_segments;
  87   size_t       _number_of_reserved_segments;
  88   size_t       _segment_size;
  89   int          _log2_segment_size;
  90 
  91   size_t       _next_segment;
  92 
  93   FreeBlock*   _freelist;
  94   size_t       _freelist_segments;               // No. of segments in freelist
  95 
  96   enum { free_sentinel = 0xFF };
  97 
  98   // Helper functions
  99   size_t   size_to_segments(size_t size) const { return (size + _segment_size - 1) >> _log2_segment_size; }
 100   size_t   segments_to_size(size_t number_of_segments) const { return number_of_segments << _log2_segment_size; }
 101 
 102   size_t   segment_for(void* p) const            { return ((char*)p - _memory.low()) >> _log2_segment_size; }
 103   bool     is_segment_unused(int val) const      { return val == free_sentinel; }
 104   HeapBlock* block_at(size_t i) const            { return (HeapBlock*)(_memory.low() + (i << _log2_segment_size)); }
 105 
 106   void  mark_segmap_as_free(size_t beg, size_t end);
 107   void  mark_segmap_as_used(size_t beg, size_t end);
 108 
 109   // Freelist management helpers
 110   FreeBlock* following_block(FreeBlock* b);
 111   void insert_after(FreeBlock* a, FreeBlock* b);
 112   bool merge_right (FreeBlock* a);
 113 
 114   // Toplevel freelist management
 115   void add_to_freelist(HeapBlock* b);
 116   FreeBlock* search_freelist(size_t length, bool is_critical);
 117 
 118   // Iteration helpers
 119   void*      next_free(HeapBlock* b) const;
 120   HeapBlock* first_block() const;
 121   HeapBlock* next_block(HeapBlock* b) const;
 122   HeapBlock* block_start(void* p) const;
 123 
 124   // to perform additional actions on creation of executable code
 125   void on_code_mapping(char* base, size_t size);
 126   void clear();                                 // clears all heap contents
 127 
 128 
 129  public:
 130   CodeHeap();
 131 
 132   // Heap extents
 133   bool  reserve(size_t reserved_size, size_t committed_size, size_t segment_size);
 134   bool  expand_by(size_t size);                  // expands committed memory by size



 135 
 136   // Memory allocation
 137   void* allocate  (size_t size, bool is_critical);  // allocates a block of size or returns NULL
 138   void  deallocate(void* p);                        // deallocates a block
 139 
 140   // Attributes
 141   char* low_boundary() const                     { return _memory.low_boundary (); }
 142   char* high() const                             { return _memory.high(); }
 143   char* high_boundary() const                    { return _memory.high_boundary(); }
 144 
 145   bool  contains(const void* p) const            { return low_boundary() <= p && p < high(); }
 146   void* find_start(void* p) const;              // returns the block containing p or NULL
 147   size_t alignment_unit() const;                // alignment of any block
 148   size_t alignment_offset() const;              // offset of first byte of any block, within the enclosing alignment unit
 149   static size_t header_size();                  // returns the header size for each heap block
 150 
 151   // Iteration
 152 
 153   // returns the first block or NULL
 154   void* first() const       { return next_free(first_block()); }
src/share/vm/memory/heap.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File