< prev index next >

src/share/vm/memory/heap.hpp

Print this page
rev 13455 : 8187091: ReturnBlobToWrongHeapTest fails because of problems in CodeHeap::contains_blob()


 137   void on_code_mapping(char* base, size_t size);
 138   void clear();                                 // clears all heap contents
 139 
 140  public:
 141   CodeHeap(const char* name, const int code_blob_type);
 142 
 143   // Heap extents
 144   bool  reserve(ReservedSpace rs, size_t committed_size, size_t segment_size);
 145   bool  expand_by(size_t size);                  // expands committed memory by size
 146 
 147   // Memory allocation
 148   void* allocate (size_t size); // Allocate 'size' bytes in the code cache or return NULL
 149   void  deallocate(void* p);    // Deallocate memory
 150 
 151   // Attributes
 152   char* low_boundary() const                     { return _memory.low_boundary(); }
 153   char* high() const                             { return _memory.high(); }
 154   char* high_boundary() const                    { return _memory.high_boundary(); }
 155 
 156   bool contains(const void* p) const             { return low_boundary() <= p && p < high(); }
 157   bool contains_blob(const CodeBlob* blob) const { return contains(blob->code_begin()); }











 158 
 159   virtual void* find_start(void* p)     const;   // returns the block containing p or NULL
 160   virtual CodeBlob* find_blob_unsafe(void* start) const;
 161   size_t alignment_unit()       const;           // alignment of any block
 162   size_t alignment_offset()     const;           // offset of first byte of any block, within the enclosing alignment unit
 163   static size_t header_size();                   // returns the header size for each heap block
 164 
 165   size_t allocated_in_freelist() const           { return _freelist_segments * CodeCacheSegmentSize; }
 166   int    freelist_length()       const           { return _freelist_length; } // number of elements in the freelist
 167 
 168   // returns the first block or NULL
 169   virtual void* first() const                    { return next_used(first_block()); }
 170   // returns the next block given a block p or NULL
 171   virtual void* next(void* p) const              { return next_used(next_block(block_start(p))); }
 172 
 173   // Statistics
 174   size_t capacity() const;
 175   size_t max_capacity() const;
 176   int    allocated_segments() const;
 177   size_t allocated_capacity() const;




 137   void on_code_mapping(char* base, size_t size);
 138   void clear();                                 // clears all heap contents
 139 
 140  public:
 141   CodeHeap(const char* name, const int code_blob_type);
 142 
 143   // Heap extents
 144   bool  reserve(ReservedSpace rs, size_t committed_size, size_t segment_size);
 145   bool  expand_by(size_t size);                  // expands committed memory by size
 146 
 147   // Memory allocation
 148   void* allocate (size_t size); // Allocate 'size' bytes in the code cache or return NULL
 149   void  deallocate(void* p);    // Deallocate memory
 150 
 151   // Attributes
 152   char* low_boundary() const                     { return _memory.low_boundary(); }
 153   char* high() const                             { return _memory.high(); }
 154   char* high_boundary() const                    { return _memory.high_boundary(); }
 155 
 156   bool contains(const void* p) const             { return low_boundary() <= p && p < high(); }
 157   bool contains_blob(const CodeBlob* blob) const {
 158     // AOT CodeBlobs (i.e. AOTCompiledMethod) objects aren't allocated in the AOTCodeHeap but on the C-Heap.
 159     // Only the code they are pointing to is located in the AOTCodeHeap. All other CodeBlobs are allocated
 160     // directly in their corresponding CodeHeap with their code appended to the actual C++ object.
 161     // So all CodeBlobs except AOTCompiledMethod are continuous in memory with their data and code while
 162     // AOTCompiledMethod and their code/data is distributed in the C-Heap. This means we can use the
 163     // address of a CodeBlob object in order to locate it in its heap while we have to use the address
 164     // of the actual code an AOTCompiledMethod object is pointing to in order to locate it.
 165     // Notice that for an ordinary CodeBlob with code size zero, code_begin() may point beyond the object!
 166     const void* start = (code_blob_type() == CodeBlobType::AOT) ? blob->code_begin() : (void*)blob;
 167     return contains(start);
 168   }
 169 
 170   virtual void* find_start(void* p)     const;   // returns the block containing p or NULL
 171   virtual CodeBlob* find_blob_unsafe(void* start) const;
 172   size_t alignment_unit()       const;           // alignment of any block
 173   size_t alignment_offset()     const;           // offset of first byte of any block, within the enclosing alignment unit
 174   static size_t header_size();                   // returns the header size for each heap block
 175 
 176   size_t allocated_in_freelist() const           { return _freelist_segments * CodeCacheSegmentSize; }
 177   int    freelist_length()       const           { return _freelist_length; } // number of elements in the freelist
 178 
 179   // returns the first block or NULL
 180   virtual void* first() const                    { return next_used(first_block()); }
 181   // returns the next block given a block p or NULL
 182   virtual void* next(void* p) const              { return next_used(next_block(block_start(p))); }
 183 
 184   // Statistics
 185   size_t capacity() const;
 186   size_t max_capacity() const;
 187   int    allocated_segments() const;
 188   size_t allocated_capacity() const;


< prev index next >