Skip to content

Commit 45a145e

Browse files
author
Afshin Zafari
committed
8299915: Remove ArrayAllocatorMallocLimit and associated code
Reviewed-by: dholmes, coleenp
1 parent 50a7a04 commit 45a145e

File tree

8 files changed

+11
-211
lines changed

8 files changed

+11
-211
lines changed

src/hotspot/share/gc/shared/taskqueue.inline.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ inline void GenericTaskQueueSet<T, F>::print_and_reset_taskqueue_stats(const cha
9999

100100
template<class E, MEMFLAGS F, unsigned int N>
101101
inline GenericTaskQueue<E, F, N>::GenericTaskQueue() :
102-
_elems(ArrayAllocator<E>::allocate(N, F)),
102+
_elems(MallocArrayAllocator<E>::allocate(N, F)),
103103
_last_stolen_queue_id(InvalidQueueId),
104104
_seed(17 /* random number */) {}
105105

106106
template<class E, MEMFLAGS F, unsigned int N>
107107
inline GenericTaskQueue<E, F, N>::~GenericTaskQueue() {
108-
ArrayAllocator<E>::free(_elems, N);
108+
MallocArrayAllocator<E>::free(_elems);
109109
}
110110

111111
template<class E, MEMFLAGS F, unsigned int N> inline bool

src/hotspot/share/memory/allocation.hpp

-26
Original file line numberDiff line numberDiff line change
@@ -616,32 +616,6 @@ class ReallocMark: public StackObj {
616616
void check() PRODUCT_RETURN;
617617
};
618618

619-
// Helper class to allocate arrays that may become large.
620-
// Uses the OS malloc for allocations smaller than ArrayAllocatorMallocLimit
621-
// and uses mapped memory for larger allocations.
622-
// Most OS mallocs do something similar but Solaris malloc does not revert
623-
// to mapped memory for large allocations. By default ArrayAllocatorMallocLimit
624-
// is set so that we always use malloc except for Solaris where we set the
625-
// limit to get mapped memory.
626-
template <class E>
627-
class ArrayAllocator : public AllStatic {
628-
private:
629-
static bool should_use_malloc(size_t length);
630-
631-
static E* allocate_malloc(size_t length, MEMFLAGS flags);
632-
static E* allocate_mmap(size_t length, MEMFLAGS flags);
633-
634-
static E* reallocate_malloc(E* addr, size_t new_length, MEMFLAGS flags);
635-
636-
static void free_malloc(E* addr, size_t length);
637-
static void free_mmap(E* addr, size_t length);
638-
639-
public:
640-
static E* allocate(size_t length, MEMFLAGS flags);
641-
static E* reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags);
642-
static void free(E* addr, size_t length);
643-
};
644-
645619
// Uses mmapped memory for all allocations. All allocations are initially
646620
// zero-filled. No pre-touching.
647621
template <class E>

src/hotspot/share/memory/allocation.inline.hpp

-71
Original file line numberDiff line numberDiff line change
@@ -111,75 +111,4 @@ void MallocArrayAllocator<E>::free(E* addr) {
111111
FreeHeap(addr);
112112
}
113113

114-
template <class E>
115-
bool ArrayAllocator<E>::should_use_malloc(size_t length) {
116-
return MallocArrayAllocator<E>::size_for(length) < ArrayAllocatorMallocLimit;
117-
}
118-
119-
template <class E>
120-
E* ArrayAllocator<E>::allocate_malloc(size_t length, MEMFLAGS flags) {
121-
return MallocArrayAllocator<E>::allocate(length, flags);
122-
}
123-
124-
template <class E>
125-
E* ArrayAllocator<E>::allocate_mmap(size_t length, MEMFLAGS flags) {
126-
return MmapArrayAllocator<E>::allocate(length, flags);
127-
}
128-
129-
template <class E>
130-
E* ArrayAllocator<E>::allocate(size_t length, MEMFLAGS flags) {
131-
if (should_use_malloc(length)) {
132-
return allocate_malloc(length, flags);
133-
}
134-
135-
return allocate_mmap(length, flags);
136-
}
137-
138-
template <class E>
139-
E* ArrayAllocator<E>::reallocate_malloc(E* addr, size_t new_length, MEMFLAGS flags) {
140-
return MallocArrayAllocator<E>::reallocate(addr, new_length, flags);
141-
}
142-
143-
template <class E>
144-
E* ArrayAllocator<E>::reallocate(E* old_addr, size_t old_length, size_t new_length, MEMFLAGS flags) {
145-
if (should_use_malloc(old_length) && should_use_malloc(new_length)) {
146-
return reallocate_malloc(old_addr, new_length, flags);
147-
}
148-
149-
E* new_addr = (new_length > 0)
150-
? allocate(new_length, flags)
151-
: nullptr;
152-
153-
if (new_addr != nullptr && old_addr != nullptr) {
154-
memcpy(new_addr, old_addr, MIN2(old_length, new_length) * sizeof(E));
155-
}
156-
157-
if (old_addr != nullptr) {
158-
free(old_addr, old_length);
159-
}
160-
161-
return new_addr;
162-
}
163-
164-
template <class E>
165-
void ArrayAllocator<E>::free_malloc(E* addr, size_t length) {
166-
MallocArrayAllocator<E>::free(addr);
167-
}
168-
169-
template <class E>
170-
void ArrayAllocator<E>::free_mmap(E* addr, size_t length) {
171-
MmapArrayAllocator<E>::free(addr, length);
172-
}
173-
174-
template <class E>
175-
void ArrayAllocator<E>::free(E* addr, size_t length) {
176-
if (addr != nullptr) {
177-
if (should_use_malloc(length)) {
178-
free_malloc(addr, length);
179-
} else {
180-
free_mmap(addr, length);
181-
}
182-
}
183-
}
184-
185114
#endif // SHARE_MEMORY_ALLOCATION_INLINE_HPP

src/hotspot/share/runtime/globals.hpp

-4
Original file line numberDiff line numberDiff line change
@@ -1888,10 +1888,6 @@ const int ObjectAlignmentInBytes = 8;
18881888
product(bool, WhiteBoxAPI, false, DIAGNOSTIC, \
18891889
"Enable internal testing APIs") \
18901890
\
1891-
product(size_t, ArrayAllocatorMallocLimit, SIZE_MAX, EXPERIMENTAL, \
1892-
"Allocation less than this value will be allocated " \
1893-
"using malloc. Larger allocations will use mmap.") \
1894-
\
18951891
product(bool, AlwaysAtomicAccesses, false, EXPERIMENTAL, \
18961892
"Accesses to all variables should always be atomic") \
18971893
\

src/hotspot/share/utilities/bitMap.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,17 @@ CHeapBitMap::~CHeapBitMap() {
135135
}
136136

137137
bm_word_t* CHeapBitMap::allocate(idx_t size_in_words) const {
138-
return ArrayAllocator<bm_word_t>::allocate(size_in_words, _flags);
138+
return MallocArrayAllocator<bm_word_t>::allocate(size_in_words, _flags);
139139
}
140140

141+
// GrowableBitMap<T>::resize uses free(ptr, size) for T as CHeapBitMap, ArenaBitMap and ResourceBitMap allocators.
142+
// The free(ptr, size) signature is kept but the size parameter is ignored.
141143
void CHeapBitMap::free(bm_word_t* map, idx_t size_in_words) const {
142-
ArrayAllocator<bm_word_t>::free(map, size_in_words);
144+
MallocArrayAllocator<bm_word_t>::free(map);
143145
}
144146

145147
bm_word_t* CHeapBitMap::reallocate(bm_word_t* map, size_t old_size_in_words, size_t new_size_in_words) const {
146-
return ArrayAllocator<bm_word_t>::reallocate(map, old_size_in_words, new_size_in_words, _flags);
148+
return MallocArrayAllocator<bm_word_t>::reallocate(map, new_size_in_words, _flags);
147149
}
148150

149151
#ifdef ASSERT

test/hotspot/jtreg/gc/arguments/TestArrayAllocatorMallocLimit.java

-100
This file was deleted.

test/hotspot/jtreg/serviceability/attach/AttachSetGetFlag.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,8 +59,7 @@ public static void main(String... args) throws Exception {
5959

6060
// Test a non-manageable size_t flag.
6161
// Since it is not manageable, we can't test the setFlag functionality.
62-
testGetFlag("ArrayAllocatorMallocLimit", "128");
63-
// testSetFlag("ArrayAllocatorMallocLimit", "64", "128");
62+
testGetFlag("MetaspaceSize", "65536");
6463

6564
// Test a uint flag.
6665
testGetFlag("ParallelGCThreads", "10");

test/lib-test/jdk/test/whitebox/vm_flags/SizeTTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
3535
import jdk.test.lib.Platform;
3636

3737
public class SizeTTest {
38-
private static final String FLAG_NAME = "ArrayAllocatorMallocLimit";
38+
private static final String FLAG_NAME = "LargePageSizeInBytes";
3939
private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE,
4040
(1L << 32L) - 1L, 1L << 32L};
4141
private static final Long[] EXPECTED_64 = TESTS;

0 commit comments

Comments
 (0)