32 #include "gc/parallel/spaceCounters.hpp"
33 #include "runtime/safepoint.hpp"
34
35 class PSOldGen : public CHeapObj<mtGC> {
36 friend class VMStructs;
37 friend class PSPromotionManager; // Uses the cas_allocate methods
38 friend class ParallelScavengeHeap;
39 friend class AdjoiningGenerations;
40
41 private:
42 MemRegion _reserved; // Used for simple containment tests
43 PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem
44 ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block
45 MutableSpace* _object_space; // Where all the objects live
46
47 // Performance Counters
48 PSGenerationCounters* _gen_counters;
49 SpaceCounters* _space_counters;
50
51 // Sizing information, in bytes, set in constructor
52 const size_t _init_gen_size;
53 const size_t _min_gen_size;
54 const size_t _max_gen_size;
55
56 #ifdef ASSERT
57 void assert_block_in_covered_region(MemRegion new_memregion) {
58 // Explictly capture current covered_region in a local
59 MemRegion covered_region = this->start_array()->covered_region();
60 assert(covered_region.contains(new_memregion),
61 "new region is not in covered_region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
62 "new region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
63 "object space [ " PTR_FORMAT ", " PTR_FORMAT " ]",
64 p2i(covered_region.start()),
65 p2i(covered_region.end()),
66 p2i(new_memregion.start()),
67 p2i(new_memregion.end()),
68 p2i(this->object_space()->used_region().start()),
69 p2i(this->object_space()->used_region().end()));
70 }
71 #endif
72
93 }
94 return res;
95 }
96
97 // Support for MT garbage collection. See above comment.
98 HeapWord* cas_allocate(size_t word_size) {
99 HeapWord* res = cas_allocate_noexpand(word_size);
100 return (res == NULL) ? expand_and_cas_allocate(word_size) : res;
101 }
102
103 HeapWord* expand_and_allocate(size_t word_size);
104 HeapWord* expand_and_cas_allocate(size_t word_size);
105 void expand(size_t bytes);
106 bool expand_by(size_t bytes);
107 bool expand_to_reserved();
108
109 void shrink(size_t bytes);
110
111 void post_resize();
112
113 void initialize(ReservedSpace rs, size_t alignment,
114 const char* perf_data_name, int level);
115 void initialize_virtual_space(ReservedSpace rs, size_t alignment);
116 void initialize_work(const char* perf_data_name, int level);
117 void initialize_performance_counters(const char* perf_data_name, int level);
118
119 public:
120 // Initialize the generation.
121 PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
122 size_t max_size, const char* perf_data_name, int level);
123
124 MemRegion reserved() const { return _reserved; }
125 size_t max_gen_size() const { return _max_gen_size; }
126 size_t min_gen_size() const { return _min_gen_size; }
127
128 bool is_in(const void* p) const {
129 return _virtual_space->contains((void *)p);
130 }
131
132 bool is_in_reserved(const void* p) const {
133 return reserved().contains(p);
134 }
135
|
32 #include "gc/parallel/spaceCounters.hpp"
33 #include "runtime/safepoint.hpp"
34
35 class PSOldGen : public CHeapObj<mtGC> {
36 friend class VMStructs;
37 friend class PSPromotionManager; // Uses the cas_allocate methods
38 friend class ParallelScavengeHeap;
39 friend class AdjoiningGenerations;
40
41 private:
42 MemRegion _reserved; // Used for simple containment tests
43 PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem
44 ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block
45 MutableSpace* _object_space; // Where all the objects live
46
47 // Performance Counters
48 PSGenerationCounters* _gen_counters;
49 SpaceCounters* _space_counters;
50
51 // Sizing information, in bytes, set in constructor
52 const size_t _min_gen_size;
53 const size_t _max_gen_size;
54
55 #ifdef ASSERT
56 void assert_block_in_covered_region(MemRegion new_memregion) {
57 // Explictly capture current covered_region in a local
58 MemRegion covered_region = this->start_array()->covered_region();
59 assert(covered_region.contains(new_memregion),
60 "new region is not in covered_region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
61 "new region [ " PTR_FORMAT ", " PTR_FORMAT " ], "
62 "object space [ " PTR_FORMAT ", " PTR_FORMAT " ]",
63 p2i(covered_region.start()),
64 p2i(covered_region.end()),
65 p2i(new_memregion.start()),
66 p2i(new_memregion.end()),
67 p2i(this->object_space()->used_region().start()),
68 p2i(this->object_space()->used_region().end()));
69 }
70 #endif
71
92 }
93 return res;
94 }
95
96 // Support for MT garbage collection. See above comment.
97 HeapWord* cas_allocate(size_t word_size) {
98 HeapWord* res = cas_allocate_noexpand(word_size);
99 return (res == NULL) ? expand_and_cas_allocate(word_size) : res;
100 }
101
102 HeapWord* expand_and_allocate(size_t word_size);
103 HeapWord* expand_and_cas_allocate(size_t word_size);
104 void expand(size_t bytes);
105 bool expand_by(size_t bytes);
106 bool expand_to_reserved();
107
108 void shrink(size_t bytes);
109
110 void post_resize();
111
112 void initialize(ReservedSpace rs, size_t initial_size, size_t alignment,
113 const char* perf_data_name, int level);
114 void initialize_virtual_space(ReservedSpace rs, size_t initial_size, size_t alignment);
115 void initialize_work(const char* perf_data_name, int level);
116 void initialize_performance_counters(const char* perf_data_name, int level);
117
118 public:
119 // Initialize the generation.
120 PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
121 size_t max_size, const char* perf_data_name, int level);
122
123 MemRegion reserved() const { return _reserved; }
124 size_t max_gen_size() const { return _max_gen_size; }
125 size_t min_gen_size() const { return _min_gen_size; }
126
127 bool is_in(const void* p) const {
128 return _virtual_space->contains((void *)p);
129 }
130
131 bool is_in_reserved(const void* p) const {
132 return reserved().contains(p);
133 }
134
|