< prev index next >

src/hotspot/share/gc/shared/generation.cpp

Print this page

139 size_t Generation::max_contiguous_available() const {
140   // The largest number of contiguous free words in this or any higher generation.
141   size_t avail = contiguous_available();
142   size_t old_avail = 0;
143   if (GenCollectedHeap::heap()->is_young_gen(this)) {
144     old_avail = GenCollectedHeap::heap()->old_gen()->contiguous_available();
145   }
146   return MAX2(avail, old_avail);
147 }
148 
149 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
150   size_t available = max_contiguous_available();
151   bool   res = (available >= max_promotion_in_bytes);
152   log_trace(gc)("Generation: promo attempt is%s safe: available(" SIZE_FORMAT ") %s max_promo(" SIZE_FORMAT ")",
153                 res? "":" not", available, res? ">=":"<", max_promotion_in_bytes);
154   return res;
155 }
156 
157 // Ignores "ref" and calls allocate().
158 oop Generation::promote(oop obj, size_t obj_size) {
159   assert(obj_size == (size_t)obj->size(), "bad obj_size passed in");
160 
161 #ifndef PRODUCT
162   if (GenCollectedHeap::heap()->promotion_should_fail()) {
163     return NULL;
164   }
165 #endif  // #ifndef PRODUCT
166 
167   HeapWord* result = allocate(obj_size, false);
168   if (result != NULL) {
169     Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
170     return cast_to_oop(result);
171   } else {
172     GenCollectedHeap* gch = GenCollectedHeap::heap();
173     return gch->handle_failed_promotion(this, obj, obj_size);
174   }
175 }
176 
177 oop Generation::par_promote(int thread_num,
178                             oop obj, markWord m, size_t word_sz) {
179   // Could do a bad general impl here that gets a lock.  But no.
180   ShouldNotCallThis();
181   return NULL;
182 }
183 
184 Space* Generation::space_containing(const void* p) const {
185   GenerationIsInReservedClosure blk(p);
186   // Cast away const
187   ((Generation*)this)->space_iterate(&blk);
188   return blk.sp;
189 }

139 size_t Generation::max_contiguous_available() const {
140   // The largest number of contiguous free words in this or any higher generation.
141   size_t avail = contiguous_available();
142   size_t old_avail = 0;
143   if (GenCollectedHeap::heap()->is_young_gen(this)) {
144     old_avail = GenCollectedHeap::heap()->old_gen()->contiguous_available();
145   }
146   return MAX2(avail, old_avail);
147 }
148 
149 bool Generation::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
150   size_t available = max_contiguous_available();
151   bool   res = (available >= max_promotion_in_bytes);
152   log_trace(gc)("Generation: promo attempt is%s safe: available(" SIZE_FORMAT ") %s max_promo(" SIZE_FORMAT ")",
153                 res? "":" not", available, res? ">=":"<", max_promotion_in_bytes);
154   return res;
155 }
156 
157 // Ignores "ref" and calls allocate().
158 oop Generation::promote(oop obj, size_t obj_size) {
159   assert(obj_size == (size_t)obj->compact_size(), "bad obj_size passed in");
160 
161 #ifndef PRODUCT
162   if (GenCollectedHeap::heap()->promotion_should_fail()) {
163     return NULL;
164   }
165 #endif  // #ifndef PRODUCT
166 
167   HeapWord* result = allocate(obj_size, false);
168   if (result != NULL) {
169     obj->copy_disjoint_compact(result, obj_size);
170     return cast_to_oop(result);
171   } else {
172     GenCollectedHeap* gch = GenCollectedHeap::heap();
173     return gch->handle_failed_promotion(this, obj, obj_size);
174   }
175 }
176 
177 oop Generation::par_promote(int thread_num,
178                             oop obj, markWord m, size_t word_sz) {
179   // Could do a bad general impl here that gets a lock.  But no.
180   ShouldNotCallThis();
181   return NULL;
182 }
183 
184 Space* Generation::space_containing(const void* p) const {
185   GenerationIsInReservedClosure blk(p);
186   // Cast away const
187   ((Generation*)this)->space_iterate(&blk);
188   return blk.sp;
189 }
< prev index next >