< prev index next >

src/hotspot/share/memory/heap.cpp

Print this page
rev 47398 : 8166317: InterpreterCodeSize should be computed
Reviewed-by: kvn, coleenp


 205   number_of_segments = MAX2((int)CodeCacheMinBlockLength, (int)number_of_segments);
 206 
 207   if (_next_segment + number_of_segments <= _number_of_committed_segments) {
 208     mark_segmap_as_used(_next_segment, _next_segment + number_of_segments);
 209     HeapBlock* b =  block_at(_next_segment);
 210     b->initialize(number_of_segments);
 211     _next_segment += number_of_segments;
 212     guarantee((char*) b >= _memory.low_boundary() && (char*) block < _memory.high(),
 213               "The newly allocated block " INTPTR_FORMAT " is not within the heap "
 214               "starting with "  INTPTR_FORMAT " and ending with " INTPTR_FORMAT,
 215               p2i(b), p2i(_memory.low_boundary()), p2i(_memory.high()));
 216     DEBUG_ONLY(memset((void *)b->allocated_space(), badCodeHeapNewVal, instance_size));
 217     _max_allocated_capacity = MAX2(_max_allocated_capacity, allocated_capacity());
 218     _blob_count++;
 219     return b->allocated_space();
 220   } else {
 221     return NULL;
 222   }
 223 }
 224 














 225 
 226 void CodeHeap::deallocate(void* p) {
 227   assert(p == find_start(p), "illegal deallocation");
 228   // Find start of HeapBlock
 229   HeapBlock* b = (((HeapBlock *)p) - 1);
 230   assert(b->allocated_space() == p, "sanity check");
 231   guarantee((char*) b >= _memory.low_boundary() && (char*) b < _memory.high(),
 232             "The block to be deallocated " INTPTR_FORMAT " is not within the heap "
 233             "starting with "  INTPTR_FORMAT " and ending with " INTPTR_FORMAT,
 234             p2i(b), p2i(_memory.low_boundary()), p2i(_memory.high()));
 235   DEBUG_ONLY(memset((void *)b->allocated_space(), badCodeHeapFreeVal,
 236              segments_to_size(b->length()) - sizeof(HeapBlock)));
 237   add_to_freelist(b);
 238   NOT_PRODUCT(verify());
 239 }
 240 
 241 /**
 242  * Uses segment map to find the the start (header) of a nmethod. This works as follows:
 243  * The memory of the code cache is divided into 'segments'. The size of a segment is
 244  * determined by -XX:CodeCacheSegmentSize=XX. Allocation in the code cache can only




 205   number_of_segments = MAX2((int)CodeCacheMinBlockLength, (int)number_of_segments);
 206 
 207   if (_next_segment + number_of_segments <= _number_of_committed_segments) {
 208     mark_segmap_as_used(_next_segment, _next_segment + number_of_segments);
 209     HeapBlock* b =  block_at(_next_segment);
 210     b->initialize(number_of_segments);
 211     _next_segment += number_of_segments;
 212     guarantee((char*) b >= _memory.low_boundary() && (char*) block < _memory.high(),
 213               "The newly allocated block " INTPTR_FORMAT " is not within the heap "
 214               "starting with "  INTPTR_FORMAT " and ending with " INTPTR_FORMAT,
 215               p2i(b), p2i(_memory.low_boundary()), p2i(_memory.high()));
 216     DEBUG_ONLY(memset((void *)b->allocated_space(), badCodeHeapNewVal, instance_size));
 217     _max_allocated_capacity = MAX2(_max_allocated_capacity, allocated_capacity());
 218     _blob_count++;
 219     return b->allocated_space();
 220   } else {
 221     return NULL;
 222   }
 223 }
 224 
 225 void CodeHeap::deallocate_tail(void* p, size_t used_size) {
 226   assert(p == find_start(p), "illegal deallocation");
 227   // Find start of HeapBlock
 228   HeapBlock* b = (((HeapBlock *)p) - 1);
 229   assert(b->allocated_space() == p, "sanity check");
 230   size_t used_number_of_segments = size_to_segments(used_size + header_size());
 231   size_t actual_number_of_segments = b->length();
 232   guarantee(used_number_of_segments <= actual_number_of_segments, "Must be!");
 233   guarantee(b == block_at(_next_segment - actual_number_of_segments), "Intermediate allocation!");
 234   size_t number_of_segments_to_deallocate = actual_number_of_segments - used_number_of_segments;
 235   _next_segment -= number_of_segments_to_deallocate;
 236   mark_segmap_as_free(_next_segment, _next_segment + number_of_segments_to_deallocate);
 237   b->initialize(used_number_of_segments);
 238 }
 239 
 240 void CodeHeap::deallocate(void* p) {
 241   assert(p == find_start(p), "illegal deallocation");
 242   // Find start of HeapBlock
 243   HeapBlock* b = (((HeapBlock *)p) - 1);
 244   assert(b->allocated_space() == p, "sanity check");
 245   guarantee((char*) b >= _memory.low_boundary() && (char*) b < _memory.high(),
 246             "The block to be deallocated " INTPTR_FORMAT " is not within the heap "
 247             "starting with "  INTPTR_FORMAT " and ending with " INTPTR_FORMAT,
 248             p2i(b), p2i(_memory.low_boundary()), p2i(_memory.high()));
 249   DEBUG_ONLY(memset((void *)b->allocated_space(), badCodeHeapFreeVal,
 250              segments_to_size(b->length()) - sizeof(HeapBlock)));
 251   add_to_freelist(b);
 252   NOT_PRODUCT(verify());
 253 }
 254 
 255 /**
 256  * Uses segment map to find the the start (header) of a nmethod. This works as follows:
 257  * The memory of the code cache is divided into 'segments'. The size of a segment is
 258  * determined by -XX:CodeCacheSegmentSize=XX. Allocation in the code cache can only


< prev index next >