Skip to content
Permalink
Browse files
8272327: Shenandoah: Avoid enqueuing duplicate string candidates
Reviewed-by: rkennke
  • Loading branch information
zhengyu123 committed Aug 17, 2021
1 parent 3fb1927 commit ee8bf10d321da8a261ff4eda705cef753b4a7014
@@ -261,7 +261,9 @@ inline void ShenandoahMark::mark_through_ref(T* p, ShenandoahObjToScanQueue* q,
if ((STRING_DEDUP == ENQUEUE_DEDUP) && ShenandoahStringDedup::is_candidate(obj)) {
assert(ShenandoahStringDedup::is_enabled(), "Must be enabled");
req->add(obj);
} else if ((STRING_DEDUP == ALWAYS_DEDUP) && ShenandoahStringDedup::is_string_candidate(obj)) {
} else if ((STRING_DEDUP == ALWAYS_DEDUP) &&
ShenandoahStringDedup::is_string_candidate(obj) &&
!ShenandoahStringDedup::dedup_requested(obj)) {
assert(ShenandoahStringDedup::is_enabled(), "Must be enabled");
req->add(obj);
}
@@ -31,6 +31,7 @@ class ShenandoahStringDedup : public StringDedup {
public:
static inline bool is_string_candidate(oop obj);
static inline bool is_candidate(oop obj);
static inline bool dedup_requested(oop obj);
};

#endif // SHARE_GC_SHENANDOAH_SHENANDOAHSTRINGDEDUP_HPP
@@ -36,6 +36,10 @@ bool ShenandoahStringDedup::is_string_candidate(oop obj) {
java_lang_String::value(obj) != nullptr;
}

bool ShenandoahStringDedup::dedup_requested(oop obj) {
return java_lang_String::test_and_set_deduplication_requested(obj);
}

bool ShenandoahStringDedup::is_candidate(oop obj) {
if (!is_string_candidate(obj)) {
return false;
@@ -51,7 +55,8 @@ bool ShenandoahStringDedup::is_candidate(oop obj) {
// Increase string age and enqueue it when it rearches age threshold
markWord new_mark = mark.incr_age();
if (mark == obj->cas_set_mark(new_mark, mark)) {
return StringDedup::is_threshold_age(new_mark.age());
return StringDedup::is_threshold_age(new_mark.age()) &&
!dedup_requested(obj);
}
}
return false;

1 comment on commit ee8bf10

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on ee8bf10 Aug 17, 2021

Please sign in to comment.