8202647: Add deduplicate_string function to CollectedHeap
Reviewed-by: rehn, sjohanss
This commit is contained in:
parent
90a2a92fe3
commit
99072b90d7
src/hotspot/share
@ -28,12 +28,13 @@
|
||||
#include "classfile/javaClasses.inline.hpp"
|
||||
#include "classfile/stringTable.hpp"
|
||||
#include "classfile/systemDictionary.hpp"
|
||||
#include "gc/shared/collectedHeap.inline.hpp"
|
||||
#include "gc/shared/collectedHeap.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "memory/filemap.hpp"
|
||||
#include "memory/metaspaceShared.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
#include "oops/access.inline.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
#include "oops/typeArrayOop.inline.hpp"
|
||||
@ -44,9 +45,6 @@
|
||||
#include "services/diagnosticCommand.hpp"
|
||||
#include "utilities/hashtable.inline.hpp"
|
||||
#include "utilities/macros.hpp"
|
||||
#if INCLUDE_G1GC
|
||||
#include "gc/g1/g1StringDedup.hpp"
|
||||
#endif
|
||||
|
||||
// the number of buckets a thread claims
|
||||
const int ClaimChunkSize = 32;
|
||||
@ -260,14 +258,10 @@ oop StringTable::intern(Handle string_or_null, jchar* name,
|
||||
string = java_lang_String::create_from_unicode(name, len, CHECK_NULL);
|
||||
}
|
||||
|
||||
#if INCLUDE_G1GC
|
||||
if (G1StringDedup::is_enabled()) {
|
||||
// Deduplicate the string before it is interned. Note that we should never
|
||||
// deduplicate a string after it has been interned. Doing so will counteract
|
||||
// compiler optimizations done on e.g. interned string literals.
|
||||
G1StringDedup::deduplicate(string());
|
||||
}
|
||||
#endif
|
||||
// Deduplicate the string before it is interned. Note that we should never
|
||||
// deduplicate a string after it has been interned. Doing so will counteract
|
||||
// compiler optimizations done on e.g. interned string literals.
|
||||
Universe::heap()->deduplicate_string(string());
|
||||
|
||||
// Grab the StringTable_lock before getting the_table() because it could
|
||||
// change at safepoint.
|
||||
|
@ -2164,6 +2164,14 @@ jlong G1CollectedHeap::millis_since_last_gc() {
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void G1CollectedHeap::deduplicate_string(oop str) {
|
||||
assert(java_lang_String::is_instance(str), "invariant");
|
||||
|
||||
if (G1StringDedup::is_enabled()) {
|
||||
G1StringDedup::deduplicate(str);
|
||||
}
|
||||
}
|
||||
|
||||
void G1CollectedHeap::prepare_for_verify() {
|
||||
_verifier->prepare_for_verify();
|
||||
}
|
||||
|
@ -1338,6 +1338,9 @@ public:
|
||||
void redirty_logged_cards();
|
||||
// Verification
|
||||
|
||||
// Deduplicate the string
|
||||
virtual void deduplicate_string(oop str);
|
||||
|
||||
// Perform any cleanup actions necessary before allowing a verification.
|
||||
virtual void prepare_for_verify();
|
||||
|
||||
|
@ -652,3 +652,7 @@ oop CollectedHeap::pin_object(JavaThread* thread, oop obj) {
|
||||
void CollectedHeap::unpin_object(JavaThread* thread, oop obj) {
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
|
||||
void CollectedHeap::deduplicate_string(oop str) {
|
||||
// Do nothing, unless overridden in subclass.
|
||||
}
|
||||
|
@ -597,6 +597,9 @@ class CollectedHeap : public CHeapObj<mtInternal> {
|
||||
virtual oop pin_object(JavaThread* thread, oop obj);
|
||||
virtual void unpin_object(JavaThread* thread, oop obj);
|
||||
|
||||
// Deduplicate the string, iff the GC supports string deduplication.
|
||||
virtual void deduplicate_string(oop str);
|
||||
|
||||
virtual bool is_oop(oop object) const;
|
||||
|
||||
// Non product verification and debugging.
|
||||
|
Loading…
x
Reference in New Issue
Block a user