< prev index next >

src/hotspot/share/gc/serial/defNewGeneration.cpp

Print this page

684 
685   _promotion_failed = true;
686   _promotion_failed_info.register_copy_failure(old->size());
687   _preserved_marks_set.get()->push_if_necessary(old, old->mark());
688   // forward to self
689   old->forward_to(old);
690 
691   _promo_failure_scan_stack.push(old);
692 
693   if (!_promo_failure_drain_in_progress) {
694     // prevent recursion in copy_to_survivor_space()
695     _promo_failure_drain_in_progress = true;
696     drain_promo_failure_scan_stack();
697     _promo_failure_drain_in_progress = false;
698   }
699 }
700 
701 oop DefNewGeneration::copy_to_survivor_space(oop old) {
702   assert(is_in_reserved(old) && !old->is_forwarded(),
703          "shouldn't be scavenging this oop");
704   size_t s = old->size();
705   oop obj = NULL;
706 
707   // Try allocating obj in to-space (unless too old)
708   if (old->age() < tenuring_threshold()) {
709     obj = cast_to_oop(to()->allocate(s));
710   }
711 
712   bool new_obj_is_tenured = false;
713   // Otherwise try allocating obj tenured
714   if (obj == NULL) {
715     obj = _old_gen->promote(old, s);
716     if (obj == NULL) {
717       handle_promotion_failure(old);
718       return old;
719     }
720     new_obj_is_tenured = true;
721   } else {
722     // Prefetch beyond obj
723     const intx interval = PrefetchCopyIntervalInBytes;
724     Prefetch::write(obj, interval);
725 
726     // Copy obj
727     Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(old), cast_from_oop<HeapWord*>(obj), s);
728 
729     // Increment age if obj still in new generation
730     obj->incr_age();
731     age_table()->add(obj, s);
732   }
733 
734   // Done, insert forward pointer to obj in this header
735   old->forward_to(obj);
736 
737   if (SerialStringDedup::is_candidate_from_evacuation(obj, new_obj_is_tenured)) {
738     // Record old; request adds a new weak reference, which reference
739     // processing expects to refer to a from-space object.
740     _string_dedup_requests.add(old);
741   }
742   return obj;
743 }
744 
745 void DefNewGeneration::drain_promo_failure_scan_stack() {
746   while (!_promo_failure_scan_stack.is_empty()) {
747      oop obj = _promo_failure_scan_stack.pop();

684 
685   _promotion_failed = true;
686   _promotion_failed_info.register_copy_failure(old->size());
687   _preserved_marks_set.get()->push_if_necessary(old, old->mark());
688   // forward to self
689   old->forward_to(old);
690 
691   _promo_failure_scan_stack.push(old);
692 
693   if (!_promo_failure_drain_in_progress) {
694     // prevent recursion in copy_to_survivor_space()
695     _promo_failure_drain_in_progress = true;
696     drain_promo_failure_scan_stack();
697     _promo_failure_drain_in_progress = false;
698   }
699 }
700 
701 oop DefNewGeneration::copy_to_survivor_space(oop old) {
702   assert(is_in_reserved(old) && !old->is_forwarded(),
703          "shouldn't be scavenging this oop");
704   size_t s = old->compact_size();
705   oop obj = NULL;
706 
707   // Try allocating obj in to-space (unless too old)
708   if (old->age() < tenuring_threshold()) {
709     obj = cast_to_oop(to()->allocate(s));
710   }
711 
712   bool new_obj_is_tenured = false;
713   // Otherwise try allocating obj tenured
714   if (obj == NULL) {
715     obj = _old_gen->promote(old, s);
716     if (obj == NULL) {
717       handle_promotion_failure(old);
718       return old;
719     }
720     new_obj_is_tenured = true;
721   } else {
722     // Prefetch beyond obj
723     const intx interval = PrefetchCopyIntervalInBytes;
724     Prefetch::write(obj, interval);
725 
726     // Copy obj
727     old->copy_disjoint_compact(cast_from_oop<HeapWord*>(obj), s);
728 
729     // Increment age if obj still in new generation
730     obj->incr_age();
731     age_table()->add(obj, s);
732   }
733 
734   // Done, insert forward pointer to obj in this header
735   old->forward_to(obj);
736 
737   if (SerialStringDedup::is_candidate_from_evacuation(obj, new_obj_is_tenured)) {
738     // Record old; request adds a new weak reference, which reference
739     // processing expects to refer to a from-space object.
740     _string_dedup_requests.add(old);
741   }
742   return obj;
743 }
744 
745 void DefNewGeneration::drain_promo_failure_scan_stack() {
746   while (!_promo_failure_scan_stack.is_empty()) {
747      oop obj = _promo_failure_scan_stack.pop();
< prev index next >