Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "gc/shared/gcInitLogger.hpp"
#include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/scavengableNMethods.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
#include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspaceCounters.hpp"
Expand Down Expand Up @@ -162,6 +163,17 @@ void ParallelScavengeHeap::initialize_serviceability() {

}

void ParallelScavengeHeap::safepoint_synchronize_begin() {
if (UseStringDeduplication) {
SuspendibleThreadSet::synchronize();
}
}

void ParallelScavengeHeap::safepoint_synchronize_end() {
if (UseStringDeduplication) {
SuspendibleThreadSet::desynchronize();
}
}
class PSIsScavengable : public BoolObjectClosure {
bool do_object_b(oop obj) {
return ParallelScavengeHeap::heap()->is_in_young(obj);
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ class ParallelScavengeHeap : public CollectedHeap {
// Returns JNI_OK on success
virtual jint initialize();

virtual void safepoint_synchronize_begin();
virtual void safepoint_synchronize_end();

void post_initialize();
void update_counters();

Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/gc/parallel/psCompactionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ void ParCompactionManager::reset_all_bitmap_query_caches() {
}
}

void ParCompactionManager::flush_all_string_dedup_requests() {
uint parallel_gc_threads = ParallelScavengeHeap::heap()->workers().total_workers();
for (uint i=0; i<=parallel_gc_threads; i++) {
_manager_array[i]->flush_string_dedup_requests();
}
}

ParCompactionManager*
ParCompactionManager::gc_thread_compaction_manager(uint index) {
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/gc/parallel/psCompactionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define SHARE_GC_PARALLEL_PSCOMPACTIONMANAGER_HPP

#include "gc/parallel/psParallelCompact.hpp"
#include "gc/shared/stringdedup/stringDedup.hpp"
#include "gc/shared/taskqueue.hpp"
#include "gc/shared/taskTerminator.hpp"
#include "memory/allocation.hpp"
Expand Down Expand Up @@ -88,6 +89,8 @@ class ParCompactionManager : public CHeapObj<mtGC> {
oop _last_query_obj;
size_t _last_query_ret;

StringDedup::Requests _string_dedup_requests;

static PSOldGen* old_gen() { return _old_gen; }
static ObjectStartArray* start_array() { return _start_array; }
static OopTaskQueueSet* oop_task_queues() { return _oop_task_queues; }
Expand Down Expand Up @@ -125,6 +128,10 @@ class ParCompactionManager : public CHeapObj<mtGC> {
_last_query_ret = 0;
}

void flush_string_dedup_requests() {
_string_dedup_requests.flush();
}

// Bitmap query support, cache last query and result
HeapWord* last_query_begin() { return _last_query_beg; }
oop last_query_object() { return _last_query_obj; }
Expand All @@ -136,6 +143,8 @@ class ParCompactionManager : public CHeapObj<mtGC> {

static void reset_all_bitmap_query_caches();

static void flush_all_string_dedup_requests();

RegionTaskQueue* region_stack() { return &_region_stack; }

static ParCompactionManager* get_vmthread_cm() { return _manager_array[ParallelGCThreads]; }
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "classfile/javaClasses.inline.hpp"
#include "gc/parallel/parMarkBitMap.hpp"
#include "gc/parallel/psParallelCompact.inline.hpp"
#include "gc/parallel/psStringDedup.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "oops/access.inline.hpp"
#include "oops/arrayOop.hpp"
Expand Down Expand Up @@ -108,6 +109,12 @@ inline void ParCompactionManager::mark_and_push(T* p) {

if (mark_bitmap()->is_unmarked(obj) && PSParallelCompact::mark_obj(obj)) {
push(obj);

if (StringDedup::is_enabled() &&
java_lang_String::is_instance_inlined(obj) &&
psStringDedup::is_candidate_from_mark(obj)) {
_string_dedup_requests.add(obj);
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "gc/parallel/psPromotionManager.inline.hpp"
#include "gc/parallel/psRootType.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/psStringDedup.hpp"
#include "gc/parallel/psYoungGen.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcHeapSummary.hpp"
Expand Down Expand Up @@ -1021,6 +1022,8 @@ void PSParallelCompact::post_compact()
_space_info[id].publish_new_top();
}

ParCompactionManager::flush_all_string_dedup_requests();

MutableSpace* const eden_space = _space_info[eden_space_id].space();
MutableSpace* const from_space = _space_info[from_space_id].space();
MutableSpace* const to_space = _space_info[to_space_id].space();
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/parallel/psPromotionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ bool PSPromotionManager::post_scavenge(YoungGCTracer& gc_tracer) {
promotion_failure_occurred = true;
}
manager->flush_labs();
manager->flush_string_dedup_requests();
}
if (!promotion_failure_occurred) {
// If there was no promotion failure, the preserved mark stacks
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/gc/parallel/psPromotionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "gc/shared/copyFailedInfo.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/preservedMarks.hpp"
#include "gc/shared/stringdedup/stringDedup.hpp"
#include "gc/shared/taskqueue.hpp"
#include "memory/padded.hpp"
#include "utilities/globalDefinitions.hpp"
Expand Down Expand Up @@ -92,6 +93,8 @@ class PSPromotionManager {
PreservedMarks* _preserved_marks;
PromotionFailedInfo _promotion_failed_info;

StringDedup::Requests _string_dedup_requests;

// Accessors
static PSOldGen* old_gen() { return _old_gen; }
static MutableSpace* young_space() { return _young_space; }
Expand Down Expand Up @@ -146,6 +149,8 @@ class PSPromotionManager {
static void restore_preserved_marks();

void flush_labs();
void flush_string_dedup_requests() { _string_dedup_requests.flush(); }

void drain_stacks(bool totally_drain) {
drain_stacks_depth(totally_drain);
}
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "gc/parallel/psOldGen.hpp"
#include "gc/parallel/psPromotionLAB.inline.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
#include "gc/parallel/psStringDedup.hpp"
#include "gc/shared/taskqueue.inline.hpp"
#include "gc/shared/tlab_globals.hpp"
#include "logging/log.hpp"
Expand Down Expand Up @@ -284,6 +285,12 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
} else {
// we'll just push its contents
push_contents(new_obj);

if (StringDedup::is_enabled() &&
java_lang_String::is_instance_inlined(new_obj) &&
psStringDedup::is_candidate_from_evacuation(new_obj, new_obj_is_tenured)) {
_string_dedup_requests.add(o);
}
}
return new_obj;
} else {
Expand Down
50 changes: 50 additions & 0 deletions src/hotspot/share/gc/parallel/psStringDedup.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/

#ifndef SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP
#define SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP

#include "gc/parallel/psScavenge.hpp"
#include "gc/shared/stringdedup/stringDedup.hpp"
#include "memory/allStatic.hpp"
#include "oops/oopsHierarchy.hpp"

class psStringDedup : AllStatic {
public:
static bool is_candidate_from_mark(oop java_string) {
// Candidate if string is being evacuated from young to old but has not
// reached the deduplication age threshold, i.e. has not previously been a
// candidate during its life in the young generation.
return PSScavenge::is_obj_in_young(java_string) &&
StringDedup::is_below_threshold_age(java_string->age());
}

static bool is_candidate_from_evacuation(oop obj,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was just copied from G1 and isn't right for this implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from an earlier version, fixed.

bool obj_is_tenured) {
return obj_is_tenured ?
StringDedup::is_below_threshold_age(obj->age()) :
StringDedup::is_threshold_age(obj->age());
}
};
#endif // SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ size_t StringDedup::Config::desired_table_size(size_t entry_count) {
bool StringDedup::Config::ergo_initialize() {
if (!UseStringDeduplication) {
return true;
} else if (!UseG1GC && !UseShenandoahGC && !UseZGC) {
} else if (!UseG1GC && !UseShenandoahGC && !UseZGC && !UseParallelGC) {
// String deduplication requested but not supported by the selected GC.
// Warn and force disable, but don't error except in debug build with
// incorrect default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
* @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold G1
*/

/*
* @test TestStringDeduplicationAgeThreshold
* @summary Test string deduplication age threshold
* @bug 8029075
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc:open
* @modules java.base/java.lang:open
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold Parallel
*/

/*
* @test TestStringDeduplicationAgeThreshold
* @summary Test string deduplication age threshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
* @run driver gc.stringdedup.TestStringDeduplicationFullGC G1
*/

/*
* @test TestStringDeduplicationFullGC
* @summary Test string deduplication during full GC
* @bug 8029075
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc:open
* @modules java.base/java.lang:open
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationFullGC Parallel
*/

/*
* @test TestStringDeduplicationFullGC
* @summary Test string deduplication during full GC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
* @run driver gc.stringdedup.TestStringDeduplicationInterned G1
*/

/*
* @test TestStringDeduplicationInterned
* @summary Test string deduplication of interned strings
* @bug 8029075
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc:open
* @modules java.base/java.lang:open
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationInterned Parallel
*/

/*
* @test TestStringDeduplicationInterned
* @summary Test string deduplication of interned strings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
* @run driver gc.stringdedup.TestStringDeduplicationPrintOptions G1
*/

/*
* @test TestStringDeduplicationPrintOptions
* @summary Test string deduplication print options
* @bug 8029075
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc:open
* @modules java.base/java.lang:open
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationPrintOptions Parallel
*/

/*
* @test TestStringDeduplicationPrintOptions
* @summary Test string deduplication print options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
* @run driver gc.stringdedup.TestStringDeduplicationTableResize G1
*/

/*
* @test TestStringDeduplicationTableResize
* @summary Test string deduplication table resize
* @bug 8029075
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc:open
* @modules java.base/java.lang:open
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationTableResize Parallel
*/

/*
* @test TestStringDeduplicationTableResize
* @summary Test string deduplication table resize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@
* @run driver gc.stringdedup.TestStringDeduplicationYoungGC G1
*/

/*
* @test TestStringDeduplicationYoungGC
* @summary Test string deduplication during young GC
* @bug 8029075
* @requires vm.gc.Parallel
* @library /test/lib
* @library /
* @modules java.base/jdk.internal.misc:open
* @modules java.base/java.lang:open
* java.management
* @run driver gc.stringdedup.TestStringDeduplicationYoungGC Parallel
*/

/*
* @test TestStringDeduplicationYoungGC
* @summary Test string deduplication during young GC
Expand Down