Skip to content

Commit

Permalink
new check
Browse files Browse the repository at this point in the history
  • Loading branch information
kimbarrett committed Nov 1, 2020
1 parent fe7672b commit cc583d7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/hotspot/share/gc/g1/g1ParScanThreadState.cpp
Expand Up @@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc/g1/g1Allocator.inline.hpp"
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/g1CollectionSet.hpp"
Expand Down Expand Up @@ -75,10 +76,17 @@ G1ParScanThreadState::G1ParScanThreadState(G1CollectedHeap* g1h,
_old_gen_is_full(false),
_partial_objarray_chunk_size(ParGCArrayScanChunk),
_partial_array_stepper(n_workers),
_string_klass_or_null(G1StringDedup::is_enabled()
? SystemDictionary::String_klass()
: nullptr),
_num_optional_regions(optional_cset_length),
_numa(g1h->numa()),
_obj_alloc_stat(NULL)
{
// Verify klass comparison with _string_klass_or_null is sufficient
// to determine whether dedup is enabled and the object is a String.
assert(SystemDictionary::String_klass()->is_final(), "precondition");

// We allocate number of young gen regions in the collection set plus one
// entries, since entry 0 keeps track of surviving bytes for non-young regions.
// We also add a few elements at the beginning and at the end in
Expand Down Expand Up @@ -510,7 +518,7 @@ oop G1ParScanThreadState::do_copy_to_survivor_space(G1HeapRegionAttr const regio
return obj;
}

if (G1StringDedup::is_enabled()) {
if (klass == _string_klass_or_null) {
const bool is_from_young = region_attr.is_young();
const bool is_to_young = dest_attr.is_young();
assert(is_from_young == from_region->is_young(),
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/gc/g1/g1ParScanThreadState.hpp
Expand Up @@ -42,6 +42,7 @@ class G1OopStarChunkedList;
class G1PLABAllocator;
class G1EvacuationRootClosures;
class HeapRegion;
class Klass;
class outputStream;

class G1ParScanThreadState : public CHeapObj<mtGC> {
Expand Down Expand Up @@ -83,6 +84,8 @@ class G1ParScanThreadState : public CHeapObj<mtGC> {
// Size (in elements) of a partial objArray task chunk.
int _partial_objarray_chunk_size;
PartialArrayTaskStepper _partial_array_stepper;
// Used to check whether string dedup should be applied to an object.
Klass* _string_klass_or_null;

G1RedirtyCardsQueue& redirty_cards_queue() { return _rdcq; }
G1CardTable* ct() { return _ct; }
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/g1/g1StringDedup.cpp
Expand Up @@ -63,7 +63,7 @@ void G1StringDedup::enqueue_from_mark(oop java_string, uint worker_id) {
}

bool G1StringDedup::is_candidate_from_evacuation(bool from_young, bool to_young, oop obj) {
if (from_young && java_lang_String::is_instance_inlined(obj)) {
if (from_young) {
if (to_young && obj->age() == StringDeduplicationAgeThreshold) {
// Candidate found. String is being evacuated from young to young and just
// reached the deduplication age threshold.
Expand All @@ -83,6 +83,7 @@ bool G1StringDedup::is_candidate_from_evacuation(bool from_young, bool to_young,

void G1StringDedup::enqueue_from_evacuation(bool from_young, bool to_young, uint worker_id, oop java_string) {
assert(is_enabled(), "String deduplication not enabled");
assert(java_lang_String::is_instance(java_string), "not a String");
if (is_candidate_from_evacuation(from_young, to_young, java_string)) {
G1StringDedupQueue::push(worker_id, java_string);
}
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/g1/g1StringDedup.hpp
Expand Up @@ -75,7 +75,8 @@ class G1StringDedup : public StringDedup {
// Enqueues a deduplication candidate for later processing by the deduplication
// thread. Before enqueuing, these functions apply the appropriate candidate
// selection policy to filters out non-candidates.
static void enqueue_from_mark(oop java_string, uint worker_id);
static void enqueue_from_mark(oop obj, uint worker_id);
// precondition: java_string is a String.
static void enqueue_from_evacuation(bool from_young, bool to_young,
unsigned int queue, oop java_string);
};
Expand Down

0 comments on commit cc583d7

Please sign in to comment.