170 }
171 }
172
173 size_t Generation::max_contiguous_available() const {
174 // The largest number of contiguous free words in this or any higher generation.
175 size_t max = 0;
176 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
177 size_t avail = gen->contiguous_available();
178 if (avail > max) {
179 max = avail;
180 }
181 }
182 return max;
183 }
184
185 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
186 size_t available = max_contiguous_available();
187 bool res = (available >= max_promotion_in_bytes);
188 if (PrintGC && Verbose) {
189 gclog_or_tty->print_cr(
190 "Generation: promo attempt is%s safe: available("SIZE_FORMAT") %s max_promo("SIZE_FORMAT")",
191 res? "":" not", available, res? ">=":"<",
192 max_promotion_in_bytes);
193 }
194 return res;
195 }
196
197 // Ignores "ref" and calls allocate().
198 oop Generation::promote(oop obj, size_t obj_size) {
199 assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
200
201 #ifndef PRODUCT
202 if (Universe::heap()->promotion_should_fail()) {
203 return NULL;
204 }
205 #endif // #ifndef PRODUCT
206
207 HeapWord* result = allocate(obj_size, false);
208 if (result != NULL) {
209 Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size);
210 return oop(result);
|
170 }
171 }
172
173 size_t Generation::max_contiguous_available() const {
174 // The largest number of contiguous free words in this or any higher generation.
175 size_t max = 0;
176 for (const Generation* gen = this; gen != NULL; gen = gen->next_gen()) {
177 size_t avail = gen->contiguous_available();
178 if (avail > max) {
179 max = avail;
180 }
181 }
182 return max;
183 }
184
185 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
186 size_t available = max_contiguous_available();
187 bool res = (available >= max_promotion_in_bytes);
188 if (PrintGC && Verbose) {
189 gclog_or_tty->print_cr(
190 "Generation: promo attempt is%s safe: available(" SIZE_FORMAT ") %s max_promo(" SIZE_FORMAT ")",
191 res? "":" not", available, res? ">=":"<",
192 max_promotion_in_bytes);
193 }
194 return res;
195 }
196
197 // Ignores "ref" and calls allocate().
198 oop Generation::promote(oop obj, size_t obj_size) {
199 assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
200
201 #ifndef PRODUCT
202 if (Universe::heap()->promotion_should_fail()) {
203 return NULL;
204 }
205 #endif // #ifndef PRODUCT
206
207 HeapWord* result = allocate(obj_size, false);
208 if (result != NULL) {
209 Copy::aligned_disjoint_words((HeapWord*)obj, result, obj_size);
210 return oop(result);
|