2525#ifndef SHARE_GC_PARALLEL_MUTABLESPACE_HPP
2626#define SHARE_GC_PARALLEL_MUTABLESPACE_HPP
2727
28- #include " gc/parallel/immutableSpace.hpp"
28+ #include " memory/allocation.hpp"
29+ #include " memory/iterator.hpp"
2930#include " memory/memRegion.hpp"
3031#include " utilities/copy.hpp"
32+ #include " utilities/globalDefinitions.hpp"
33+ #include " utilities/macros.hpp"
3134
3235class WorkGang ;
3336
34- // A MutableSpace is a subtype of ImmutableSpace that supports the
35- // concept of allocation. This includes the concepts that a space may
36- // be only partially full, and the query methods that go with such
37- // an assumption. MutableSpace is also responsible for minimizing the
37+ // A MutableSpace supports the concept of allocation. This includes the
38+ // concepts that a space may be only partially full, and the query methods
39+ // that go with such an assumption.
40+ //
41+ // MutableSpace is also responsible for minimizing the
3842// page allocation time by having the memory pretouched (with
3943// AlwaysPretouch) and for optimizing page placement on NUMA systems
4044// by make the underlying region interleaved (with UseNUMA).
4145//
42- // Invariant: (ImmutableSpace +) bottom() <= top() <= end()
43- // top() is inclusive and end() is exclusive.
46+ // Invariant: bottom() <= top() <= end()
47+ // top() and end() are exclusive.
4448
4549class MutableSpaceMangler ;
4650
47- class MutableSpace : public ImmutableSpace {
51+ class MutableSpace : public CHeapObj <mtGC> {
4852 friend class VMStructs ;
4953
5054 // Helper for mangling unused space in debug builds
5155 MutableSpaceMangler* _mangler;
5256 // The last region which page had been setup to be interleaved.
5357 MemRegion _last_setup_region;
5458 size_t _alignment;
55- protected:
59+ HeapWord* _bottom;
5660 HeapWord* volatile _top;
61+ HeapWord* _end;
5762
5863 MutableSpaceMangler* mangler () { return _mangler; }
5964
@@ -67,17 +72,25 @@ class MutableSpace: public ImmutableSpace {
6772 MutableSpace (size_t page_size);
6873
6974 // Accessors
75+ HeapWord* bottom () const { return _bottom; }
7076 HeapWord* top () const { return _top; }
77+ HeapWord* end () const { return _end; }
78+
79+ void set_bottom (HeapWord* value) { _bottom = value; }
7180 virtual void set_top (HeapWord* value) { _top = value; }
81+ void set_end (HeapWord* value) { _end = value; }
7282
7383 HeapWord* volatile * top_addr () { return &_top; }
7484 HeapWord** end_addr () { return &_end; }
7585
76- virtual void set_bottom (HeapWord* value) { _bottom = value; }
77- virtual void set_end (HeapWord* value) { _end = value; }
78-
7986 size_t alignment () { return _alignment; }
8087
88+ MemRegion region () const { return MemRegion (bottom (), end ()); }
89+
90+ size_t capacity_in_bytes () const { return capacity_in_words () * HeapWordSize; }
91+ size_t capacity_in_words () const { return pointer_delta (end (), bottom ()); }
92+ virtual size_t capacity_in_words (Thread*) const { return capacity_in_words (); }
93+
8194 // Returns a subregion containing all objects in this space.
8295 MemRegion used_region () { return MemRegion (bottom (), top ()); }
8396
@@ -92,10 +105,6 @@ class MutableSpace: public ImmutableSpace {
92105 WorkGang* pretouch_gang = NULL );
93106
94107 virtual void clear (bool mangle_space);
95- // Does the usual initialization but optionally resets top to bottom.
96- #if 0 // MANGLE_SPACE
97- void initialize(MemRegion mr, bool clear_space, bool reset_top);
98- #endif
99108 virtual void update () { }
100109 virtual void accumulate_statistics () { }
101110
0 commit comments