8344363: FullGCForwarding::initialize_flags is called after ObjLayout::initialize

Reviewed-by: stefank, shade, ayang
This commit is contained in:
Roman Kennke 2024-11-25 13:48:02 +00:00
parent c6b14c62f6
commit cb1c73663e
11 changed files with 23 additions and 25 deletions

View File

@ -244,10 +244,7 @@ void G1Arguments::initialize() {
if (max_parallel_refinement_threads > UINT_MAX / divisor) {
vm_exit_during_initialization("Too large parallelism for remembered sets.");
}
}
void G1Arguments::initialize_heap_flags_and_sizes() {
GCArguments::initialize_heap_flags_and_sizes();
FullGCForwarding::initialize_flags(heap_reserved_size_bytes());
}

View File

@ -39,7 +39,6 @@ class G1Arguments : public GCArguments {
static void parse_verification_type(const char* type);
virtual void initialize_alignments();
virtual void initialize_heap_flags_and_sizes();
virtual void initialize();
virtual size_t conservative_max_heap_alignment();

View File

@ -83,6 +83,8 @@ void ParallelArguments::initialize() {
if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) {
FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
}
FullGCForwarding::initialize_flags(heap_reserved_size_bytes());
}
// The alignment used for boundary between young gen and old gen
@ -128,7 +130,6 @@ void ParallelArguments::initialize_heap_flags_and_sizes() {
// Redo everything from the start
initialize_heap_flags_and_sizes_one_pass();
}
FullGCForwarding::initialize_flags(heap_reserved_size_bytes());
}
size_t ParallelArguments::heap_reserved_size_bytes() {

View File

@ -24,12 +24,12 @@
#include "precompiled.hpp"
#include "gc/shared/fullGCForwarding.hpp"
#include "gc/shared/genArguments.hpp"
#include "gc/shared/gcArguments.hpp"
#include "gc/serial/serialArguments.hpp"
#include "gc/serial/serialHeap.hpp"
void SerialArguments::initialize_heap_flags_and_sizes() {
GenArguments::initialize_heap_flags_and_sizes();
void SerialArguments::initialize() {
GCArguments::initialize();
FullGCForwarding::initialize_flags(MaxHeapSize);
}

View File

@ -31,8 +31,8 @@ class CollectedHeap;
class SerialArguments : public GenArguments {
private:
virtual void initialize();
virtual CollectedHeap* create_heap();
virtual void initialize_heap_flags_and_sizes();
};
#endif // SHARE_GC_SERIAL_SERIALARGUMENTS_HPP

View File

@ -176,6 +176,8 @@ void ShenandoahArguments::initialize() {
if (FLAG_IS_DEFAULT(TLABAllocationWeight)) {
FLAG_SET_DEFAULT(TLABAllocationWeight, 90);
}
FullGCForwarding::initialize_flags(MaxHeapSize);
}
size_t ShenandoahArguments::conservative_max_heap_alignment() {
@ -199,11 +201,6 @@ void ShenandoahArguments::initialize_alignments() {
HeapAlignment = align;
}
void ShenandoahArguments::initialize_heap_flags_and_sizes() {
GCArguments::initialize_heap_flags_and_sizes();
FullGCForwarding::initialize_flags(MaxHeapSize);
}
CollectedHeap* ShenandoahArguments::create_heap() {
return new ShenandoahHeap(new ShenandoahCollectorPolicy());
}

View File

@ -35,7 +35,6 @@ private:
virtual void initialize();
virtual size_t conservative_max_heap_alignment();
virtual void initialize_heap_flags_and_sizes();
virtual CollectedHeap* create_heap();
};

View File

@ -62,6 +62,7 @@
#include "oops/instanceMirrorKlass.hpp"
#include "oops/klass.inline.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/objLayout.hpp"
#include "oops/oop.inline.hpp"
#include "oops/oopHandle.inline.hpp"
#include "oops/typeArrayKlass.hpp"
@ -868,6 +869,8 @@ jint universe_init() {
// Initialize CPUTimeCounters object, which must be done before creation of the heap.
CPUTimeCounters::initialize();
ObjLayout::initialize();
#ifdef _LP64
MetaspaceShared::adjust_heap_sizes_for_dumping();
#endif // _LP64

View File

@ -3654,14 +3654,15 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
Arguments::print_on(&st);
}
return JNI_OK;
}
void Arguments::set_compact_headers_flags() {
#ifdef _LP64
if (UseCompactObjectHeaders && FLAG_IS_CMDLINE(UseCompressedClassPointers) && !UseCompressedClassPointers) {
warning("Compact object headers require compressed class pointers. Disabling compact object headers.");
FLAG_SET_DEFAULT(UseCompactObjectHeaders, false);
}
if (UseCompactObjectHeaders && LockingMode != LM_LIGHTWEIGHT) {
FLAG_SET_DEFAULT(LockingMode, LM_LIGHTWEIGHT);
}
if (UseCompactObjectHeaders && !UseObjectMonitorTable) {
// If UseCompactObjectHeaders is on the command line, turn on UseObjectMonitorTable.
if (FLAG_IS_CMDLINE(UseCompactObjectHeaders)) {
@ -3675,12 +3676,13 @@ jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) {
FLAG_SET_DEFAULT(UseObjectMonitorTable, true);
}
}
if (UseCompactObjectHeaders && LockingMode != LM_LIGHTWEIGHT) {
FLAG_SET_DEFAULT(LockingMode, LM_LIGHTWEIGHT);
}
if (UseCompactObjectHeaders && !UseCompressedClassPointers) {
FLAG_SET_DEFAULT(UseCompressedClassPointers, true);
}
#endif
return JNI_OK;
}
jint Arguments::apply_ergo() {
@ -3693,6 +3695,8 @@ jint Arguments::apply_ergo() {
GCConfig::arguments()->initialize();
set_compact_headers_flags();
if (UseCompressedClassPointers) {
CompressedKlassPointers::pre_initialize();
}

View File

@ -264,6 +264,7 @@ class Arguments : AllStatic {
static void set_conservative_max_heap_alignment();
static void set_use_compressed_oops();
static jint set_ergonomics_flags();
static void set_compact_headers_flags();
// Limits the given heap size by the maximum amount of virtual
// memory this process is currently allowed to use. It also takes
// the virtual-to-physical ratio of the current GC into account.

View File

@ -497,9 +497,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
// Timing (must come after argument parsing)
TraceTime timer("Create VM", TRACETIME_LOG(Info, startuptime));
// Initialize object layout after parsing the args
ObjLayout::initialize();
// Initialize the os module after parsing the args
jint os_init_2_result = os::init_2();
if (os_init_2_result != JNI_OK) return os_init_2_result;