2626#include " gc/serial/defNewGeneration.inline.hpp"
2727#include " gc/serial/serialGcRefProcProxyTask.hpp"
2828#include " gc/serial/serialHeap.inline.hpp"
29+ #include " gc/serial/serialStringDedup.inline.hpp"
2930#include " gc/serial/tenuredGeneration.hpp"
3031#include " gc/shared/adaptiveSizePolicy.hpp"
3132#include " gc/shared/ageTable.inline.hpp"
@@ -142,7 +143,8 @@ DefNewGeneration::DefNewGeneration(ReservedSpace rs,
142143 : Generation(rs, initial_size),
143144 _preserved_marks_set(false /* in_c_heap */ ),
144145 _promo_failure_drain_in_progress(false ),
145- _should_allocate_from_space(false )
146+ _should_allocate_from_space(false ),
147+ _string_dedup_requests()
146148{
147149 MemRegion cmr ((HeapWord*)_virtual_space.low (),
148150 (HeapWord*)_virtual_space.high ());
@@ -601,6 +603,8 @@ void DefNewGeneration::collect(bool full,
601603 // Verify that the usage of keep_alive didn't copy any objects.
602604 assert (heap->no_allocs_since_save_marks (), " save marks have not been newly set." );
603605
606+ _string_dedup_requests.flush ();
607+
604608 if (!_promotion_failed) {
605609 // Swap the survivor spaces.
606610 eden ()->clear (SpaceDecorator::Mangle);
@@ -705,13 +709,15 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
705709 obj = cast_to_oop (to ()->allocate (s));
706710 }
707711
712+ bool new_obj_is_tenured = false ;
708713 // Otherwise try allocating obj tenured
709714 if (obj == NULL ) {
710715 obj = _old_gen->promote (old, s);
711716 if (obj == NULL ) {
712717 handle_promotion_failure (old);
713718 return old;
714719 }
720+ new_obj_is_tenured = true ;
715721 } else {
716722 // Prefetch beyond obj
717723 const intx interval = PrefetchCopyIntervalInBytes;
@@ -728,6 +734,11 @@ oop DefNewGeneration::copy_to_survivor_space(oop old) {
728734 // Done, insert forward pointer to obj in this header
729735 old->forward_to (obj);
730736
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+ }
731742 return obj;
732743}
733744
0 commit comments