Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6427586

Browse files
committedAug 18, 2023
8307356: Metaspace: simplify BinList handling
Reviewed-by: rkennke, coleenp
1 parent 1485e7f commit 6427586

File tree

4 files changed

+20
-38
lines changed

4 files changed

+20
-38
lines changed
 

‎test/hotspot/gtest/metaspace/test_binlist.cpp

+15-24
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ using metaspace::MemRangeCounter;
4646
template <class BINLISTTYPE>
4747
struct BinListBasicTest {
4848

49-
static const size_t minws;
5049
static const size_t maxws;
5150

5251
static void basic_test() {
@@ -57,7 +56,7 @@ struct BinListBasicTest {
5756

5857
MetaWord arr[1000];
5958

60-
size_t innocous_size = minws + ((maxws - minws) / 2);
59+
size_t innocous_size = MAX2((size_t)1, maxws / 2);
6160

6261
// Try to get a block from an empty list.
6362
size_t real_size = 4711;
@@ -88,8 +87,8 @@ struct BinListBasicTest {
8887

8988
MetaWord arr[1000];
9089

91-
for (size_t s1 = minws; s1 <= maxws; s1++) {
92-
for (size_t s2 = minws; s2 <= maxws; s2++) {
90+
for (size_t s1 = 1; s1 <= maxws; s1++) {
91+
for (size_t s2 = 1; s2 <= maxws; s2++) {
9392

9493
bl.add_block(arr, s1);
9594
CHECK_BL_CONTENT(bl, 1, s1);
@@ -108,7 +107,7 @@ struct BinListBasicTest {
108107
CHECK_BL_CONTENT(bl, 1, s1);
109108
DEBUG_ONLY(bl.verify();)
110109
// drain bl
111-
p = bl.remove_block(minws, &real_size);
110+
p = bl.remove_block(1, &real_size);
112111
EXPECT_EQ(p, arr);
113112
EXPECT_EQ((size_t)s1, real_size);
114113
CHECK_BL_CONTENT(bl, 0, 0);
@@ -129,7 +128,7 @@ struct BinListBasicTest {
129128
ASSERT_EQ(cnt[1].total_size(), bl[1].total_size());
130129

131130
FeederBuffer fb(1024);
132-
RandSizeGenerator rgen(minws, maxws + 1);
131+
RandSizeGenerator rgen(1, maxws + 1);
133132

134133
// feed all
135134
int which = 0;
@@ -184,10 +183,10 @@ struct BinListBasicTest {
184183
while (bl[which].is_empty() == false) {
185184

186185
size_t real_size = 4711;
187-
MetaWord* p = bl[which].remove_block(minws, &real_size);
186+
MetaWord* p = bl[which].remove_block(1, &real_size);
188187

189188
ASSERT_NE(p, (MetaWord*) NULL);
190-
ASSERT_GE(real_size, minws);
189+
ASSERT_GE(real_size, (size_t)1);
191190
ASSERT_TRUE(fb.is_valid_range(p, real_size));
192191

193192
// This must hold true since we always return the smallest fit.
@@ -205,24 +204,16 @@ struct BinListBasicTest {
205204
}
206205
};
207206

208-
template <typename BINLISTTYPE> const size_t BinListBasicTest<BINLISTTYPE>::minws = BINLISTTYPE::MinWordSize;
209207
template <typename BINLISTTYPE> const size_t BinListBasicTest<BINLISTTYPE>::maxws = BINLISTTYPE::MaxWordSize;
210208

211-
TEST_VM(metaspace, BinList_basic_8) { BinListBasicTest< BinListImpl<2, 8> >::basic_test(); }
212-
TEST_VM(metaspace, BinList_basic_16) { BinListBasicTest< BinListImpl<2, 16> >::basic_test(); }
209+
TEST_VM(metaspace, BinList_basic_1) { BinListBasicTest< BinListImpl<1> >::basic_test(); }
210+
TEST_VM(metaspace, BinList_basic_8) { BinListBasicTest< BinListImpl<8> >::basic_test(); }
213211
TEST_VM(metaspace, BinList_basic_32) { BinListBasicTest<BinList32>::basic_test(); }
214-
TEST_VM(metaspace, BinList_basic_1331) { BinListBasicTest< BinListImpl<13, 31> >::basic_test(); }
215-
TEST_VM(metaspace, BinList_basic_131) { BinListBasicTest< BinListImpl<13, 1> >::basic_test(); }
216212

217-
TEST_VM(metaspace, BinList_basic2_8) { BinListBasicTest< BinListImpl<2, 8> >::basic_test_2(); }
218-
TEST_VM(metaspace, BinList_basic2_16) { BinListBasicTest< BinListImpl<2, 16> >::basic_test_2(); }
219-
TEST_VM(metaspace, BinList_basic2_32) { BinListBasicTest<BinList32 >::basic_test_2(); }
220-
TEST_VM(metaspace, BinList_basic2_1331) { BinListBasicTest< BinListImpl<13, 31> >::basic_test_2(); }
221-
TEST_VM(metaspace, BinList_basic2_131) { BinListBasicTest< BinListImpl<13, 1> >::basic_test_2(); }
222-
223-
TEST_VM(metaspace, BinList_random_test_8) { BinListBasicTest< BinListImpl<2, 8> >::random_test(); }
224-
TEST_VM(metaspace, BinList_random_test_16) { BinListBasicTest< BinListImpl<2, 16> >::random_test(); }
225-
TEST_VM(metaspace, BinList_random_test_32) { BinListBasicTest<BinList32>::random_test(); }
226-
TEST_VM(metaspace, BinList_random_test_1331) { BinListBasicTest< BinListImpl<13, 31> >::random_test(); }
227-
TEST_VM(metaspace, BinList_random_test_131) { BinListBasicTest< BinListImpl<13, 1> >::random_test(); }
213+
TEST_VM(metaspace, BinList_basic_2_1) { BinListBasicTest< BinListImpl<1> >::basic_test_2(); }
214+
TEST_VM(metaspace, BinList_basic_2_8) { BinListBasicTest< BinListImpl<8> >::basic_test_2(); }
215+
TEST_VM(metaspace, BinList_basic_2_32) { BinListBasicTest<BinList32>::basic_test_2(); }
228216

217+
TEST_VM(metaspace, BinList_basic_rand_1) { BinListBasicTest< BinListImpl<1> >::random_test(); }
218+
TEST_VM(metaspace, BinList_basic_rand_8) { BinListBasicTest< BinListImpl<8> >::random_test(); }
219+
TEST_VM(metaspace, BinList_basic_rand_32) { BinListBasicTest<BinList32>::random_test(); }

‎test/hotspot/gtest/metaspace/test_metaspacearena.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "metaspaceGtestContexts.hpp"
4242
#include "metaspaceGtestRangeHelpers.hpp"
4343

44+
using metaspace::AllocationAlignmentByteSize;
4445
using metaspace::ArenaGrowthPolicy;
4546
using metaspace::CommitLimiter;
4647
using metaspace::InternalStats;
@@ -50,11 +51,6 @@ using metaspace::SizeAtomicCounter;
5051
using metaspace::Settings;
5152
using metaspace::ArenaStats;
5253

53-
// See metaspaceArena.cpp : needed for predicting commit sizes.
54-
namespace metaspace {
55-
extern size_t get_raw_word_size_for_requested_word_size(size_t net_word_size);
56-
}
57-
5854
class MetaspaceArenaTestHelper {
5955

6056
MetaspaceGtestContext& _context;
@@ -179,7 +175,7 @@ class MetaspaceArenaTestHelper {
179175
ASSERT_EQ(capacity, capacity2);
180176
} else {
181177
// Allocation succeeded. Should be correctly aligned.
182-
ASSERT_TRUE(is_aligned(p, sizeof(MetaWord)));
178+
ASSERT_TRUE(is_aligned(p, AllocationAlignmentByteSize));
183179
// used: may go up or may not (since our request may have been satisfied from the freeblocklist
184180
// whose content already counts as used).
185181
// committed: may go up, may not

‎test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "metaspaceGtestContexts.hpp"
3939
#include "metaspaceGtestSparseArray.hpp"
4040

41+
using metaspace::AllocationAlignmentByteSize;
4142
using metaspace::ArenaGrowthPolicy;
4243
using metaspace::ChunkManager;
4344
using metaspace::IntCounter;
@@ -52,11 +53,6 @@ static bool fifty_fifty() {
5253
return IntRange(100).random_value() < 50;
5354
}
5455

55-
// See metaspaceArena.cpp : needed for predicting commit sizes.
56-
namespace metaspace {
57-
extern size_t get_raw_word_size_for_requested_word_size(size_t net_word_size);
58-
}
59-
6056
// A MetaspaceArenaTestBed contains a single MetaspaceArena and its lock.
6157
// It keeps track of allocations done from this MetaspaceArena.
6258
class MetaspaceArenaTestBed : public CHeapObj<mtInternal> {
@@ -179,7 +175,8 @@ class MetaspaceArenaTestBed : public CHeapObj<mtInternal> {
179175
size_t word_size = 1 + _allocation_range.random_value();
180176
MetaWord* p = _arena->allocate(word_size);
181177
if (p != NULL) {
182-
EXPECT_TRUE(is_aligned(p, sizeof(MetaWord)));
178+
EXPECT_TRUE(is_aligned(p, AllocationAlignmentByteSize));
179+
183180
allocation_t* a = NEW_C_HEAP_OBJ(allocation_t, mtInternal);
184181
a->word_size = word_size;
185182
a->p = p;

‎test/hotspot/jtreg/TEST.groups

-2
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,6 @@ tier1_runtime = \
384384
-runtime/memory/ReserveMemory.java \
385385
-runtime/Metaspace/FragmentMetaspace.java \
386386
-runtime/Metaspace/FragmentMetaspaceSimple.java \
387-
-runtime/Metaspace/elastic/TestMetaspaceAllocationMT1.java \
388-
-runtime/Metaspace/elastic/TestMetaspaceAllocationMT2.java \
389387
-runtime/MirrorFrame/Test8003720.java \
390388
-runtime/modules/LoadUnloadModuleStress.java \
391389
-runtime/modules/ModuleStress/ExportModuleStressTest.java \

0 commit comments

Comments
 (0)
Please sign in to comment.