590 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN |
590 #undef ContigSpace_OOP_SINCE_SAVE_MARKS_DEFN |
591 |
591 |
592 // Very general, slow implementation. |
592 // Very general, slow implementation. |
593 HeapWord* ContiguousSpace::block_start_const(const void* p) const { |
593 HeapWord* ContiguousSpace::block_start_const(const void* p) const { |
594 assert(MemRegion(bottom(), end()).contains(p), |
594 assert(MemRegion(bottom(), end()).contains(p), |
595 err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", |
595 "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", |
596 p2i(p), p2i(bottom()), p2i(end()))); |
596 p2i(p), p2i(bottom()), p2i(end())); |
597 if (p >= top()) { |
597 if (p >= top()) { |
598 return top(); |
598 return top(); |
599 } else { |
599 } else { |
600 HeapWord* last = bottom(); |
600 HeapWord* last = bottom(); |
601 HeapWord* cur = last; |
601 HeapWord* cur = last; |
602 while (cur <= p) { |
602 while (cur <= p) { |
603 last = cur; |
603 last = cur; |
604 cur += oop(cur)->size(); |
604 cur += oop(cur)->size(); |
605 } |
605 } |
606 assert(oop(last)->is_oop(), |
606 assert(oop(last)->is_oop(), PTR_FORMAT " should be an object start", p2i(last)); |
607 err_msg(PTR_FORMAT " should be an object start", p2i(last))); |
|
608 return last; |
607 return last; |
609 } |
608 } |
610 } |
609 } |
611 |
610 |
612 size_t ContiguousSpace::block_size(const HeapWord* p) const { |
611 size_t ContiguousSpace::block_size(const HeapWord* p) const { |
613 assert(MemRegion(bottom(), end()).contains(p), |
612 assert(MemRegion(bottom(), end()).contains(p), |
614 err_msg("p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", |
613 "p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")", |
615 p2i(p), p2i(bottom()), p2i(end()))); |
614 p2i(p), p2i(bottom()), p2i(end())); |
616 HeapWord* current_top = top(); |
615 HeapWord* current_top = top(); |
617 assert(p <= current_top, |
616 assert(p <= current_top, |
618 err_msg("p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT, |
617 "p > current top - p: " PTR_FORMAT ", current top: " PTR_FORMAT, |
619 p2i(p), p2i(current_top))); |
618 p2i(p), p2i(current_top)); |
620 assert(p == current_top || oop(p)->is_oop(), |
619 assert(p == current_top || oop(p)->is_oop(), |
621 err_msg("p (" PTR_FORMAT ") is not a block start - " |
620 "p (" PTR_FORMAT ") is not a block start - " |
622 "current_top: " PTR_FORMAT ", is_oop: %s", |
621 "current_top: " PTR_FORMAT ", is_oop: %s", |
623 p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop()))); |
622 p2i(p), p2i(current_top), BOOL_TO_STR(oop(p)->is_oop())); |
624 if (p < current_top) { |
623 if (p < current_top) { |
625 return oop(p)->size(); |
624 return oop(p)->size(); |
626 } else { |
625 } else { |
627 assert(p == current_top, "just checking"); |
626 assert(p == current_top, "just checking"); |
628 return pointer_delta(end(), (HeapWord*) p); |
627 return pointer_delta(end(), (HeapWord*) p); |