130 // Iteration helpers
131 void* next_used(HeapBlock* b) const;
132 HeapBlock* first_block() const;
133 HeapBlock* next_block(HeapBlock* b) const;
134 HeapBlock* block_start(void* p) const;
135
136 // to perform additional actions on creation of executable code
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()); }
|
130 // Iteration helpers
131 void* next_used(HeapBlock* b) const;
132 HeapBlock* first_block() const;
133 HeapBlock* next_block(HeapBlock* b) const;
134 HeapBlock* block_start(void* p) const;
135
136 // to perform additional actions on creation of executable code
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 // 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()); }
|