639 return obj;
640 }
641 } else {
642 return NULL;
643 }
644 } while (true);
645 }
646
647 HeapWord* ContiguousSpace::allocate_aligned(size_t size) {
648 assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked");
649 HeapWord* end_value = end();
650
651 HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes);
652 if (obj == NULL) {
653 return NULL;
654 }
655
656 if (pointer_delta(end_value, obj) >= size) {
657 HeapWord* new_top = obj + size;
658 set_top(new_top);
659 assert(is_ptr_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top),
660 "checking alignment");
661 return obj;
662 } else {
663 set_top(obj);
664 return NULL;
665 }
666 }
667
668 // Requires locking.
669 HeapWord* ContiguousSpace::allocate(size_t size) {
670 return allocate_impl(size);
671 }
672
673 // Lock-free.
674 HeapWord* ContiguousSpace::par_allocate(size_t size) {
675 return par_allocate_impl(size);
676 }
677
678 void ContiguousSpace::allocate_temporary_filler(int factor) {
679 // allocate temporary type array decreasing free size with factor 'factor'
|
639 return obj;
640 }
641 } else {
642 return NULL;
643 }
644 } while (true);
645 }
646
647 HeapWord* ContiguousSpace::allocate_aligned(size_t size) {
648 assert(Heap_lock->owned_by_self() || (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), "not locked");
649 HeapWord* end_value = end();
650
651 HeapWord* obj = CollectedHeap::align_allocation_or_fail(top(), end_value, SurvivorAlignmentInBytes);
652 if (obj == NULL) {
653 return NULL;
654 }
655
656 if (pointer_delta(end_value, obj) >= size) {
657 HeapWord* new_top = obj + size;
658 set_top(new_top);
659 assert(::is_aligned(obj, SurvivorAlignmentInBytes) && is_aligned(new_top),
660 "checking alignment");
661 return obj;
662 } else {
663 set_top(obj);
664 return NULL;
665 }
666 }
667
668 // Requires locking.
669 HeapWord* ContiguousSpace::allocate(size_t size) {
670 return allocate_impl(size);
671 }
672
673 // Lock-free.
674 HeapWord* ContiguousSpace::par_allocate(size_t size) {
675 return par_allocate_impl(size);
676 }
677
678 void ContiguousSpace::allocate_temporary_filler(int factor) {
679 // allocate temporary type array decreasing free size with factor 'factor'
|