Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/space.hpp @ 269:850fdf70db2b
Merge
author | jmasa |
---|---|
date | Mon, 28 Jul 2008 15:30:23 -0700 |
parents | d1605aabd0a1 12eea04c8b06 |
children | 1ee8caae33af |
comparison
equal
deleted
inserted
replaced
238:3df2fe7c4451 | 269:850fdf70db2b |
---|---|
129 // and after the call to save marks. | 129 // and after the call to save marks. |
130 virtual MemRegion used_region_at_save_marks() const { | 130 virtual MemRegion used_region_at_save_marks() const { |
131 return MemRegion(bottom(), saved_mark_word()); | 131 return MemRegion(bottom(), saved_mark_word()); |
132 } | 132 } |
133 | 133 |
134 // Initialization | 134 // Initialization. These may be run to reset an existing |
135 virtual void initialize(MemRegion mr, bool clear_space); | 135 // Space. |
136 virtual void clear(); | 136 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space); |
137 virtual void clear(bool mangle_space); | |
137 | 138 |
138 // For detecting GC bugs. Should only be called at GC boundaries, since | 139 // For detecting GC bugs. Should only be called at GC boundaries, since |
139 // some unused space may be used as scratch space during GC's. | 140 // some unused space may be used as scratch space during GC's. |
140 // Default implementation does nothing. We also call this when expanding | 141 // Default implementation does nothing. We also call this when expanding |
141 // a space to satisfy an allocation request. See bug #4668531 | 142 // a space to satisfy an allocation request. See bug #4668531 |
142 virtual void mangle_unused_area() {} | 143 virtual void mangle_unused_area() {} |
144 virtual void mangle_unused_area_complete() {} | |
143 virtual void mangle_region(MemRegion mr) {} | 145 virtual void mangle_region(MemRegion mr) {} |
144 | 146 |
145 // Testers | 147 // Testers |
146 bool is_empty() const { return used() == 0; } | 148 bool is_empty() const { return used() == 0; } |
147 bool not_empty() const { return used() > 0; } | 149 bool not_empty() const { return used() > 0; } |
352 private: | 354 private: |
353 HeapWord* _compaction_top; | 355 HeapWord* _compaction_top; |
354 CompactibleSpace* _next_compaction_space; | 356 CompactibleSpace* _next_compaction_space; |
355 | 357 |
356 public: | 358 public: |
357 virtual void initialize(MemRegion mr, bool clear_space); | 359 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space); |
358 | 360 |
359 // Used temporarily during a compaction phase to hold the value | 361 // Used temporarily during a compaction phase to hold the value |
360 // top should have when compaction is complete. | 362 // top should have when compaction is complete. |
361 HeapWord* compaction_top() const { return _compaction_top; } | 363 HeapWord* compaction_top() const { return _compaction_top; } |
362 | 364 |
722 /* space subtypes. For example, OffsetTableContigSpace's that were */ \ | 724 /* space subtypes. For example, OffsetTableContigSpace's that were */ \ |
723 /* compacted into will have had their offset table thresholds updated */ \ | 725 /* compacted into will have had their offset table thresholds updated */ \ |
724 /* continuously, but those that weren't need to have their thresholds */ \ | 726 /* continuously, but those that weren't need to have their thresholds */ \ |
725 /* re-initialized. Also mangles unused area for debugging. */ \ | 727 /* re-initialized. Also mangles unused area for debugging. */ \ |
726 if (is_empty()) { \ | 728 if (is_empty()) { \ |
727 clear(); \ | 729 clear(SpaceDecorator::Mangle); \ |
728 } else { \ | 730 } else { \ |
729 if (ZapUnusedHeapArea) mangle_unused_area(); \ | 731 if (ZapUnusedHeapArea) mangle_unused_area(); \ |
730 } \ | 732 } \ |
731 } | 733 } |
734 | |
735 class GenSpaceMangler; | |
732 | 736 |
733 // A space in which the free area is contiguous. It therefore supports | 737 // A space in which the free area is contiguous. It therefore supports |
734 // faster allocation, and compaction. | 738 // faster allocation, and compaction. |
735 class ContiguousSpace: public CompactibleSpace { | 739 class ContiguousSpace: public CompactibleSpace { |
736 friend class OneContigSpaceCardGeneration; | 740 friend class OneContigSpaceCardGeneration; |
737 friend class VMStructs; | 741 friend class VMStructs; |
738 protected: | 742 protected: |
739 HeapWord* _top; | 743 HeapWord* _top; |
740 HeapWord* _concurrent_iteration_safe_limit; | 744 HeapWord* _concurrent_iteration_safe_limit; |
745 // A helper for mangling the unused area of the space in debug builds. | |
746 GenSpaceMangler* _mangler; | |
747 | |
748 GenSpaceMangler* mangler() { return _mangler; } | |
741 | 749 |
742 // Allocation helpers (return NULL if full). | 750 // Allocation helpers (return NULL if full). |
743 inline HeapWord* allocate_impl(size_t word_size, HeapWord* end_value); | 751 inline HeapWord* allocate_impl(size_t word_size, HeapWord* end_value); |
744 inline HeapWord* par_allocate_impl(size_t word_size, HeapWord* end_value); | 752 inline HeapWord* par_allocate_impl(size_t word_size, HeapWord* end_value); |
745 | 753 |
746 public: | 754 public: |
747 virtual void initialize(MemRegion mr, bool clear_space); | 755 |
756 ContiguousSpace(); | |
757 ~ContiguousSpace(); | |
758 | |
759 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space); | |
748 | 760 |
749 // Accessors | 761 // Accessors |
750 HeapWord* top() const { return _top; } | 762 HeapWord* top() const { return _top; } |
751 void set_top(HeapWord* value) { _top = value; } | 763 void set_top(HeapWord* value) { _top = value; } |
752 | 764 |
753 void set_saved_mark() { _saved_mark_word = top(); } | 765 void set_saved_mark() { _saved_mark_word = top(); } |
754 void reset_saved_mark() { _saved_mark_word = bottom(); } | 766 void reset_saved_mark() { _saved_mark_word = bottom(); } |
755 | 767 |
756 virtual void clear(); | 768 virtual void clear(bool mangle_space); |
757 | 769 |
758 WaterMark bottom_mark() { return WaterMark(this, bottom()); } | 770 WaterMark bottom_mark() { return WaterMark(this, bottom()); } |
759 WaterMark top_mark() { return WaterMark(this, top()); } | 771 WaterMark top_mark() { return WaterMark(this, top()); } |
760 WaterMark saved_mark() { return WaterMark(this, saved_mark_word()); } | 772 WaterMark saved_mark() { return WaterMark(this, saved_mark_word()); } |
761 bool saved_mark_at_top() const { return saved_mark_word() == top(); } | 773 bool saved_mark_at_top() const { return saved_mark_word() == top(); } |
762 | 774 |
763 void mangle_unused_area(); | 775 // In debug mode mangle (write it with a particular bit |
764 void mangle_region(MemRegion mr); | 776 // pattern) the unused part of a space. |
777 | |
778 // Used to save the an address in a space for later use during mangling. | |
779 void set_top_for_allocations(HeapWord* v) PRODUCT_RETURN; | |
780 // Used to save the space's current top for later use during mangling. | |
781 void set_top_for_allocations() PRODUCT_RETURN; | |
782 | |
783 // Mangle regions in the space from the current top up to the | |
784 // previously mangled part of the space. | |
785 void mangle_unused_area() PRODUCT_RETURN; | |
786 // Mangle [top, end) | |
787 void mangle_unused_area_complete() PRODUCT_RETURN; | |
788 // Mangle the given MemRegion. | |
789 void mangle_region(MemRegion mr) PRODUCT_RETURN; | |
790 | |
791 // Do some sparse checking on the area that should have been mangled. | |
792 void check_mangled_unused_area(HeapWord* limit) PRODUCT_RETURN; | |
793 // Check the complete area that should have been mangled. | |
794 // This code may be NULL depending on the macro DEBUG_MANGLING. | |
795 void check_mangled_unused_area_complete() PRODUCT_RETURN; | |
765 | 796 |
766 // Size computations: sizes in bytes. | 797 // Size computations: sizes in bytes. |
767 size_t capacity() const { return byte_size(bottom(), end()); } | 798 size_t capacity() const { return byte_size(bottom(), end()); } |
768 size_t used() const { return byte_size(bottom(), top()); } | 799 size_t used() const { return byte_size(bottom(), top()); } |
769 size_t free() const { return byte_size(top(), end()); } | 800 size_t free() const { return byte_size(top(), end()); } |
954 HeapWord* soft_end() { return _soft_end; } | 985 HeapWord* soft_end() { return _soft_end; } |
955 HeapWord** soft_end_addr() { return &_soft_end; } | 986 HeapWord** soft_end_addr() { return &_soft_end; } |
956 void set_soft_end(HeapWord* value) { _soft_end = value; } | 987 void set_soft_end(HeapWord* value) { _soft_end = value; } |
957 | 988 |
958 // Override. | 989 // Override. |
959 void clear(); | 990 void clear(bool mangle_space); |
960 | 991 |
961 // Set both the 'hard' and 'soft' limits (_end and _soft_end). | 992 // Set both the 'hard' and 'soft' limits (_end and _soft_end). |
962 void set_end(HeapWord* value) { | 993 void set_end(HeapWord* value) { |
963 set_soft_end(value); | 994 set_soft_end(value); |
964 ContiguousSpace::set_end(value); | 995 ContiguousSpace::set_end(value); |
998 MemRegion mr); | 1029 MemRegion mr); |
999 | 1030 |
1000 void set_bottom(HeapWord* value); | 1031 void set_bottom(HeapWord* value); |
1001 void set_end(HeapWord* value); | 1032 void set_end(HeapWord* value); |
1002 | 1033 |
1003 void clear(); | 1034 void clear(bool mangle_space); |
1004 | 1035 |
1005 inline HeapWord* block_start(const void* p) const; | 1036 inline HeapWord* block_start(const void* p) const; |
1006 | 1037 |
1007 // Add offset table update. | 1038 // Add offset table update. |
1008 virtual inline HeapWord* allocate(size_t word_size); | 1039 virtual inline HeapWord* allocate(size_t word_size); |