oop TenuredGeneration::par_promote(int thread_num, oop old, markOop m, size_t word_sz) { ParGCAllocBufferWithBOT* buf = _alloc_buffers[thread_num]; HeapWord* obj_ptr = buf->allocate(word_sz); bool is_lab = true; if (obj_ptr == NULL) { #ifndef PRODUCT if (Universe::heap()->promotion_should_fail()) { return NULL; } #endif // #ifndef PRODUCT // Slow path: if (word_sz * 100 < ParallelGCBufferWastePct * buf->word_sz()) { // Is small enough; abandon this buffer and start a new one. size_t buf_size = buf->word_sz(); HeapWord* buf_space = TenuredGeneration::par_allocate(buf_size, false); if (buf_space == NULL) { buf_space = expand_and_allocate(buf_size, false, true /* parallel*/); } if (buf_space != NULL) { buf->retire(false, false); buf->set_buf(buf_space); obj_ptr = buf->allocate(word_sz); assert(obj_ptr != NULL, "Buffer was definitely big enough..."); } }; // Otherwise, buffer allocation failed; try allocating object // individually. if (obj_ptr == NULL) { obj_ptr = TenuredGeneration::par_allocate(word_sz, false); if (obj_ptr == NULL) { obj_ptr = expand_and_allocate(word_sz, false, true /* parallel */); } } if (obj_ptr == NULL) return NULL; } assert(obj_ptr != NULL, "program logic"); Copy::aligned_disjoint_words((HeapWord*)old, obj_ptr, word_sz); oop obj = oop(obj_ptr); // Restore the mark word copied above. obj->set_mark(m); return obj; }
HeapWord* PSPermGen::allocate_permanent(size_t size) { assert_locked_or_safepoint(Heap_lock); HeapWord* obj = allocate_noexpand(size, false); if (obj == NULL) { obj = expand_and_allocate(size, false); } return obj; }
// Allocation. We report all successful allocations to the size policy // Note that the perm gen does not use this method, and should not! HeapWord* PSOldGen::allocate(size_t word_size, bool is_large_noref, bool is_tlab) { assert_locked_or_safepoint(Heap_lock); HeapWord* res = allocate_noexpand(word_size, is_large_noref, is_tlab); if (res == NULL) { res = expand_and_allocate(word_size, is_large_noref, is_tlab); } // Allocations in the old generation need to be reported if (res != NULL) { ParallelScavengeHeap::size_policy()->tenured_allocation(word_size); } return res; }