< prev index next >

src/hotspot/share/memory/heap.hpp

Print this page
rev 47399 : 8187091: ReturnBlobToWrongHeapTest fails because of problems in CodeHeap::contains_blob()
Reviewed-by: kvn


 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   // Free the tail of segments allocated by the last call to 'allocate()' which exceed 'used_size'.
 151   // ATTENTION: this is only safe to use if there was no other call to 'allocate()' after
 152   //            'p' was allocated. Only intended for freeing memory which would be otherwise
 153   //            wasted after the interpreter generation because we don't know the interpreter size
 154   //            beforehand and we also can't easily relocate the interpreter to a new location.
 155   void  deallocate_tail(void* p, size_t used_size);
 156 
 157   // Attributes
 158   char* low_boundary() const                     { return _memory.low_boundary(); }
 159   char* high() const                             { return _memory.high(); }
 160   char* high_boundary() const                    { return _memory.high_boundary(); }
 161 
 162   bool contains(const void* p) const             { return low_boundary() <= p && p < high(); }
 163   bool contains_blob(const CodeBlob* blob) const { return contains(blob->code_begin()); }











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




 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   // Free the tail of segments allocated by the last call to 'allocate()' which exceed 'used_size'.
 151   // ATTENTION: this is only safe to use if there was no other call to 'allocate()' after
 152   //            'p' was allocated. Only intended for freeing memory which would be otherwise
 153   //            wasted after the interpreter generation because we don't know the interpreter size
 154   //            beforehand and we also can't easily relocate the interpreter to a new location.
 155   void  deallocate_tail(void* p, size_t used_size);
 156 
 157   // Attributes
 158   char* low_boundary() const                     { return _memory.low_boundary(); }
 159   char* high() const                             { return _memory.high(); }
 160   char* high_boundary() const                    { return _memory.high_boundary(); }
 161 
 162   bool contains(const void* p) const             { return low_boundary() <= p && p < high(); }
 163   bool contains_blob(const CodeBlob* blob) const {
 164     // AOT CodeBlobs (i.e. AOTCompiledMethod) objects aren't allocated in the AOTCodeHeap but on the C-Heap.
 165     // Only the code they are pointing to is located in the AOTCodeHeap. All other CodeBlobs are allocated
 166     // directly in their corresponding CodeHeap with their code appended to the actual C++ object.
 167     // So all CodeBlobs except AOTCompiledMethod are continuous in memory with their data and code while
 168     // AOTCompiledMethod and their code/data is distributed in the C-Heap. This means we can use the
 169     // address of a CodeBlob object in order to locate it in its heap while we have to use the address
 170     // of the actual code an AOTCompiledMethod object is pointing to in order to locate it.
 171     // Notice that for an ordinary CodeBlob with code size zero, code_begin() may point beyond the object!
 172     const void* start = AOT_ONLY( (code_blob_type() == CodeBlobType::AOT) ? blob->code_begin() : ) (void*)blob;
 173     return contains(start);
 174   }
 175 
 176   virtual void* find_start(void* p)     const;   // returns the block containing p or NULL
 177   virtual CodeBlob* find_blob_unsafe(void* start) const;
 178   size_t alignment_unit()       const;           // alignment of any block
 179   size_t alignment_offset()     const;           // offset of first byte of any block, within the enclosing alignment unit
 180   static size_t header_size();                   // returns the header size for each heap block
 181 
 182   size_t allocated_in_freelist() const           { return _freelist_segments * CodeCacheSegmentSize; }
 183   int    freelist_length()       const           { return _freelist_length; } // number of elements in the freelist
 184 
 185   // returns the first block or NULL
 186   virtual void* first() const                    { return next_used(first_block()); }
 187   // returns the next block given a block p or NULL
 188   virtual void* next(void* p) const              { return next_used(next_block(block_start(p))); }
 189 
 190   // Statistics
 191   size_t capacity() const;
 192   size_t max_capacity() const;
 193   int    allocated_segments() const;
 194   size_t allocated_capacity() const;


< prev index next >