575 do { \ 576 t = top(); \ 577 while (p < t) { \ 578 Prefetch::write(p, interval); \ 579 debug_only(HeapWord* prev = p); \ 580 oop m = oop(p); \ 581 p += m->oop_iterate_size(blk); \ 582 } \ 583 } while (t < top()); \ 584 \ 585 set_saved_mark_word(p); \ 586 } 587 588 ALL_SINCE_SAVE_MARKS_CLOSURES(ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN) 589 590 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN 591 592 // Very general, slow implementation. 593 HeapWord* ContiguousSpace::block_start_const(const void* p) const { 594 assert(MemRegion(bottom(), end()).contains(p), 595 err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", 596 p2i(p), p2i(bottom()), p2i(end()))); 597 if (p >= top()) { 598 return top(); 599 } else { 600 HeapWord* last = bottom(); 601 HeapWord* cur = last; 602 while (cur <= p) { 603 last = cur; 604 cur += oop(cur)->size(); 605 } 606 assert(oop(last)->is_oop(), 607 err_msg(PTR_FORMAT " should be an object start", p2i(last))); 608 return last; 609 } 610 } 611 612 size_t ContiguousSpace::block_size(const HeapWord* p) const { 613 assert(MemRegion(bottom(), end()).contains(p), 614 err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", 615 p2i(p), p2i(bottom()), p2i(end()))); 616 HeapWord* current_top = top(); 617 assert(p <= current_top, 618 err_msg("p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT, 619 p2i(p), p2i(current_top))); 620 assert(p == current_top || oop(p)->is_oop(), 621 err_msg("p (" PTR_FORMAT ") is not a block start - " 622 "current_top: " PTR_FORMAT ", is_oop: %s", 623 p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop()))); 624 if (p < current_top) { 625 return oop(p)->size(); 626 } else { 627 assert(p == current_top, "just checking"); 628 return pointer_delta(end(), (HeapWord*) p); 629 } 630 } 631 632 // This version requires locking. 633 inline HeapWord* ContiguousSpace::allocate_impl(size_t size) { 634 assert(Heap_lock->owned_by_self() || 635 (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), 636 "not locked"); 637 HeapWord* obj = top(); 638 if (pointer_delta(end(), obj) >= size) { 639 HeapWord* new_top = obj + size; 640 set_top(new_top); 641 assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); 642 return obj; 643 } else { | 575 do { \ 576 t = top(); \ 577 while (p < t) { \ 578 Prefetch::write(p, interval); \ 579 debug_only(HeapWord* prev = p); \ 580 oop m = oop(p); \ 581 p += m->oop_iterate_size(blk); \ 582 } \ 583 } while (t < top()); \ 584 \ 585 set_saved_mark_word(p); \ 586 } 587 588 ALL_SINCE_SAVE_MARKS_CLOSURES(ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN) 589 590 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN 591 592 // Very general, slow implementation. 593 HeapWord* ContiguousSpace::block_start_const(const void* p) const { 594 assert(MemRegion(bottom(), end()).contains(p), 595 "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", 596 p2i(p), p2i(bottom()), p2i(end())); 597 if (p >= top()) { 598 return top(); 599 } else { 600 HeapWord* last = bottom(); 601 HeapWord* cur = last; 602 while (cur <= p) { 603 last = cur; 604 cur += oop(cur)->size(); 605 } 606 assert(oop(last)->is_oop(), PTR_FORMAT " should be an object start", p2i(last)); 607 return last; 608 } 609 } 610 611 size_t ContiguousSpace::block_size(const HeapWord* p) const { 612 assert(MemRegion(bottom(), end()).contains(p), 613 "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", 614 p2i(p), p2i(bottom()), p2i(end())); 615 HeapWord* current_top = top(); 616 assert(p <= current_top, 617 "p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT, 618 p2i(p), p2i(current_top)); 619 assert(p == current_top || oop(p)->is_oop(), 620 "p (" PTR_FORMAT ") is not a block start - " 621 "current_top: " PTR_FORMAT ", is_oop: %s", 622 p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop())); 623 if (p < current_top) { 624 return oop(p)->size(); 625 } else { 626 assert(p == current_top, "just checking"); 627 return pointer_delta(end(), (HeapWord*) p); 628 } 629 } 630 631 // This version requires locking. 632 inline HeapWord* ContiguousSpace::allocate_impl(size_t size) { 633 assert(Heap_lock->owned_by_self() || 634 (SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread()), 635 "not locked"); 636 HeapWord* obj = top(); 637 if (pointer_delta(end(), obj) >= size) { 638 HeapWord* new_top = obj + size; 639 set_top(new_top); 640 assert(is_aligned(obj) && is_aligned(new_top), "checking alignment"); 641 return obj; 642 } else { |