< prev index next >

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

Print this page




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




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


< prev index next >