diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index a3d45a98354..3eab4a2e5fe 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -267,7 +267,6 @@ DefNewGeneration::DefNewGeneration(ReservedSpace rs, update_counters(); _old_gen = nullptr; _tenuring_threshold = MaxTenuringThreshold; - _pretenure_size_threshold_words = PretenureSizeThreshold >> LogHeapWordSize; _ref_processor = nullptr; diff --git a/src/hotspot/share/gc/serial/defNewGeneration.hpp b/src/hotspot/share/gc/serial/defNewGeneration.hpp index c5e1c2b152e..7f4077873b2 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.hpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.hpp @@ -55,8 +55,6 @@ class DefNewGeneration: public Generation { uint _tenuring_threshold; // Tenuring threshold for next collection. AgeTable _age_table; - // Size of object to pretenure in words; command line provides bytes - size_t _pretenure_size_threshold_words; // ("Weak") Reference processing support SpanSubjectToDiscoveryClosure _span_based_discoverer; @@ -185,24 +183,6 @@ class DefNewGeneration: public Generation { HeapWord* block_start(const void* p) const; - // Allocation support - bool should_allocate(size_t word_size, bool is_tlab) { - assert(UseTLAB || !is_tlab, "Should not allocate tlab"); - assert(word_size != 0, "precondition"); - - size_t overflow_limit = (size_t)1 << (BitsPerSize_t - LogHeapWordSize); - - const bool overflows = word_size >= overflow_limit; - const bool check_too_big = _pretenure_size_threshold_words > 0; - const bool not_too_big = word_size < _pretenure_size_threshold_words; - const bool size_ok = is_tlab || !check_too_big || not_too_big; - - bool result = !overflows && - size_ok; - - return result; - } - // Allocate requested size or return null; single-threaded and lock-free versions. HeapWord* allocate(size_t word_size); HeapWord* par_allocate(size_t word_size); diff --git a/src/hotspot/share/gc/serial/serialHeap.cpp b/src/hotspot/share/gc/serial/serialHeap.cpp index 72f8ad85a4e..6bb1183aa56 100644 --- a/src/hotspot/share/gc/serial/serialHeap.cpp +++ b/src/hotspot/share/gc/serial/serialHeap.cpp @@ -283,16 +283,12 @@ size_t SerialHeap::max_capacity() const { } HeapWord* SerialHeap::expand_heap_and_allocate(size_t size, bool is_tlab) { - HeapWord* result = nullptr; - if (_old_gen->should_allocate(size, is_tlab)) { + HeapWord* result = _young_gen->allocate(size); + + if (result == nullptr) { result = _old_gen->expand_and_allocate(size); } - if (result == nullptr) { - if (_young_gen->should_allocate(size, is_tlab)) { - // Young-gen is not expanded. - result = _young_gen->allocate(size); - } - } + assert(result == nullptr || is_in_reserved(result), "result not in heap"); return result; } @@ -301,11 +297,9 @@ HeapWord* SerialHeap::mem_allocate_work(size_t size, bool is_tlab) { HeapWord* result = nullptr; for (uint try_count = 1; /* break */; try_count++) { - if (_young_gen->should_allocate(size, is_tlab)) { - result = _young_gen->par_allocate(size); - if (result != nullptr) { - break; - } + result = _young_gen->par_allocate(size); + if (result != nullptr) { + break; } // Try old-gen allocation for non-TLAB. if (!is_tlab) { @@ -342,25 +336,6 @@ HeapWord* SerialHeap::mem_allocate_work(size_t size, bool is_tlab) { return result; } -HeapWord* SerialHeap::attempt_allocation(size_t size, - bool is_tlab, - bool first_only) { - HeapWord* res = nullptr; - - if (_young_gen->should_allocate(size, is_tlab)) { - res = _young_gen->allocate(size); - if (res != nullptr || first_only) { - return res; - } - } - - if (_old_gen->should_allocate(size, is_tlab)) { - res = _old_gen->allocate(size); - } - - return res; -} - HeapWord* SerialHeap::mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) { return mem_allocate_work(size, @@ -459,15 +434,10 @@ HeapWord* SerialHeap::satisfy_failed_allocation(size_t size, bool is_tlab) { HeapWord* result = nullptr; // If young-gen can handle this allocation, attempt young-gc firstly. - bool should_run_young_gc = _young_gen->should_allocate(size, is_tlab); + bool should_run_young_gc = is_tlab || size <= _young_gen->eden()->capacity(); collect_at_safepoint(!should_run_young_gc); - result = attempt_allocation(size, is_tlab, false /*first_only*/); - if (result != nullptr) { - return result; - } - - // OK, collection failed, try expansion. + // Just finished a GC, try to satisfy this allocation, using expansion if needed. result = expand_heap_and_allocate(size, is_tlab); if (result != nullptr) { return result; @@ -484,10 +454,6 @@ HeapWord* SerialHeap::satisfy_failed_allocation(size_t size, bool is_tlab) { do_full_collection(clear_all_soft_refs); } - result = attempt_allocation(size, is_tlab, false /* first_only */); - if (result != nullptr) { - return result; - } // The previous full-gc can shrink the heap, so re-expand it. result = expand_heap_and_allocate(size, is_tlab); if (result != nullptr) { diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp index b89edb33307..f0194f1a4a2 100644 --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -102,11 +102,6 @@ private: // old-gen. bool _is_heap_almost_full; - // Helper functions for allocation - HeapWord* attempt_allocation(size_t size, - bool is_tlab, - bool first_only); - void do_full_collection(bool clear_all_soft_refs) override; // Does the "cause" of GC indicate that diff --git a/src/hotspot/share/gc/serial/tenuredGeneration.hpp b/src/hotspot/share/gc/serial/tenuredGeneration.hpp index 1225005aff4..038038f6808 100644 --- a/src/hotspot/share/gc/serial/tenuredGeneration.hpp +++ b/src/hotspot/share/gc/serial/tenuredGeneration.hpp @@ -135,15 +135,6 @@ public: void gc_prologue(); void gc_epilogue(); - bool should_allocate(size_t word_size, bool is_tlab) { - bool result = false; - size_t overflow_limit = (size_t)1 << (BitsPerSize_t - LogHeapWordSize); - if (!is_tlab) { - result = (word_size > 0) && (word_size < overflow_limit); - } - return result; - } - // Performance Counter support void update_counters(); diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index 7f46f449085..240068f10c0 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -484,11 +484,6 @@ "OS specific low limit for heap base address") \ constraint(HeapBaseMinAddressConstraintFunc,AfterErgo) \ \ - product(size_t, PretenureSizeThreshold, 0, \ - "Maximum size in bytes of objects allocated in DefNew " \ - "generation; zero means no maximum") \ - range(0, max_uintx) \ - \ product(uintx, SurvivorRatio, 8, \ "Ratio of eden/survivor space size") \ range(1, max_uintx-2) \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 063090b93c9..0d4adc7f587 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -567,6 +567,8 @@ static SpecialFlag const special_jvm_flags[] = { { "UseAdaptiveSizePolicyWithSystemGC", JDK_Version::undefined(), JDK_Version::jdk(26), JDK_Version::jdk(27) }, { "UsePSAdaptiveSurvivorSizePolicy", JDK_Version::undefined(), JDK_Version::jdk(26), JDK_Version::jdk(27) }, + { "PretenureSizeThreshold", JDK_Version::undefined(), JDK_Version::jdk(26), JDK_Version::jdk(27) }, + #ifdef ASSERT { "DummyObsoleteTestFlag", JDK_Version::undefined(), JDK_Version::jdk(18), JDK_Version::undefined() }, #endif