146 GenerationIsInClosure(const void* p) : _p(p), sp(NULL) {}
147 };
148
149 bool Generation::is_in(const void* p) const {
150 GenerationIsInClosure blk(p);
151 ((Generation*)this)->space_iterate(&blk);
152 return blk.sp != NULL;
153 }
154
155 DefNewGeneration* Generation::as_DefNewGeneration() {
156 assert((kind() == Generation::DefNew) ||
157 (kind() == Generation::ParNew),
158 "Wrong youngest generation type");
159 return (DefNewGeneration*) this;
160 }
161
162 Generation* Generation::next_gen() const {
163 GenCollectedHeap* gch = GenCollectedHeap::heap();
164 int next = level() + 1;
165 if (next < gch->_n_gens) {
166 return gch->_gens[next];
167 } else {
168 return NULL;
169 }
170 }
171
172 size_t Generation::max_contiguous_available() const {
173 // The largest number of contiguous free words in this or any higher generation.
174 size_t max = 0;
175 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
176 size_t avail = gen->contiguous_available();
177 if (avail > max) {
178 max = avail;
179 }
180 }
181 return max;
182 }
183
184 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
185 size_t available = max_contiguous_available();
186 bool res = (available >= max_promotion_in_bytes);
|
146 GenerationIsInClosure(const void* p) : _p(p), sp(NULL) {}
147 };
148
149 bool Generation::is_in(const void* p) const {
150 GenerationIsInClosure blk(p);
151 ((Generation*)this)->space_iterate(&blk);
152 return blk.sp != NULL;
153 }
154
155 DefNewGeneration* Generation::as_DefNewGeneration() {
156 assert((kind() == Generation::DefNew) ||
157 (kind() == Generation::ParNew),
158 "Wrong youngest generation type");
159 return (DefNewGeneration*) this;
160 }
161
162 Generation* Generation::next_gen() const {
163 GenCollectedHeap* gch = GenCollectedHeap::heap();
164 int next = level() + 1;
165 if (next < gch->_n_gens) {
166 return gch->get_gen(next);
167 } else {
168 return NULL;
169 }
170 }
171
172 size_t Generation::max_contiguous_available() const {
173 // The largest number of contiguous free words in this or any higher generation.
174 size_t max = 0;
175 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
176 size_t avail = gen->contiguous_available();
177 if (avail > max) {
178 max = avail;
179 }
180 }
181 return max;
182 }
183
184 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
185 size_t available = max_contiguous_available();
186 bool res = (available >= max_promotion_in_bytes);
|