@@ -58,7 +58,6 @@ chunklevel_t MetaspaceArena::next_chunk_level() const {
58
58
59
59
// Given a chunk, add its remaining free committed space to the free block list.
60
60
void MetaspaceArena::salvage_chunk (Metachunk* c) {
61
- assert_lock_strong (lock ());
62
61
size_t remaining_words = c->free_below_committed_words ();
63
62
if (remaining_words >= FreeBlocks::MinWordSize) {
64
63
@@ -80,8 +79,6 @@ void MetaspaceArena::salvage_chunk(Metachunk* c) {
80
79
// Allocate a new chunk from the underlying chunk manager able to hold at least
81
80
// requested word size.
82
81
Metachunk* MetaspaceArena::allocate_new_chunk (size_t requested_word_size) {
83
- assert_lock_strong (lock ());
84
-
85
82
// Should this ever happen, we need to increase the maximum possible chunk size.
86
83
guarantee (requested_word_size <= chunklevel::MAX_CHUNK_WORD_SIZE,
87
84
" Requested size too large (" SIZE_FORMAT " ) - max allowed size per allocation is " SIZE_FORMAT " ." ,
@@ -112,9 +109,8 @@ void MetaspaceArena::add_allocation_to_fbl(MetaWord* p, size_t word_size) {
112
109
}
113
110
114
111
MetaspaceArena::MetaspaceArena (ChunkManager* chunk_manager, const ArenaGrowthPolicy* growth_policy,
115
- Mutex* lock, SizeAtomicCounter* total_used_words_counter,
112
+ SizeAtomicCounter* total_used_words_counter,
116
113
const char * name) :
117
- _lock (lock),
118
114
_chunk_manager (chunk_manager),
119
115
_growth_policy (growth_policy),
120
116
_chunks (),
@@ -138,8 +134,6 @@ MetaspaceArena::~MetaspaceArena() {
138
134
verify_allocation_guards ();
139
135
}
140
136
#endif
141
-
142
- MutexLocker fcl (lock (), Mutex::_no_safepoint_check_flag);
143
137
MemRangeCounter return_counter;
144
138
145
139
Metachunk* c = _chunks.first ();
@@ -173,8 +167,6 @@ MetaspaceArena::~MetaspaceArena() {
173
167
//
174
168
// On success, true is returned, false otherwise.
175
169
bool MetaspaceArena::attempt_enlarge_current_chunk (size_t requested_word_size) {
176
- assert_lock_strong (lock ());
177
-
178
170
Metachunk* c = current_chunk ();
179
171
assert (c->free_words () < requested_word_size, " Sanity" );
180
172
@@ -224,7 +216,6 @@ bool MetaspaceArena::attempt_enlarge_current_chunk(size_t requested_word_size) {
224
216
// 4) Attempt to get a new chunk and allocate from that chunk.
225
217
// At any point, if we hit a commit limit, we return null.
226
218
MetaWord* MetaspaceArena::allocate (size_t requested_word_size) {
227
- MutexLocker cl (lock (), Mutex::_no_safepoint_check_flag);
228
219
UL2 (trace, " requested " SIZE_FORMAT " words." , requested_word_size);
229
220
230
221
MetaWord* p = nullptr ;
@@ -270,8 +261,6 @@ MetaWord* MetaspaceArena::allocate(size_t requested_word_size) {
270
261
271
262
// Allocate from the arena proper, once dictionary allocations and fencing are sorted out.
272
263
MetaWord* MetaspaceArena::allocate_inner (size_t word_size) {
273
-
274
- assert_lock_strong (lock ());
275
264
assert_is_aligned (word_size, metaspace::AllocationAlignmentWordSize);
276
265
277
266
MetaWord* p = nullptr ;
@@ -345,7 +334,7 @@ MetaWord* MetaspaceArena::allocate_inner(size_t word_size) {
345
334
_total_used_words_counter->increment_by (word_size);
346
335
}
347
336
348
- SOMETIMES (verify_locked ();)
337
+ SOMETIMES (verify ();)
349
338
350
339
if (p == nullptr ) {
351
340
UL (info, " allocation failed, returned null." );
@@ -362,8 +351,7 @@ MetaWord* MetaspaceArena::allocate_inner(size_t word_size) {
362
351
363
352
// Prematurely returns a metaspace allocation to the _block_freelists
364
353
// because it is not needed anymore (requires CLD lock to be active).
365
- void MetaspaceArena::deallocate_locked (MetaWord* p, size_t word_size) {
366
- assert_lock_strong (lock ());
354
+ void MetaspaceArena::deallocate (MetaWord* p, size_t word_size) {
367
355
// At this point a current chunk must exist since we only deallocate if we did allocate before.
368
356
assert (current_chunk () != nullptr , " stray deallocation?" );
369
357
assert (is_valid_area (p, word_size),
@@ -382,20 +370,11 @@ void MetaspaceArena::deallocate_locked(MetaWord* p, size_t word_size) {
382
370
383
371
add_allocation_to_fbl (p, raw_word_size);
384
372
385
- SOMETIMES (verify_locked ();)
386
- }
387
-
388
- // Prematurely returns a metaspace allocation to the _block_freelists because it is not
389
- // needed anymore.
390
- void MetaspaceArena::deallocate (MetaWord* p, size_t word_size) {
391
- MutexLocker cl (lock (), Mutex::_no_safepoint_check_flag);
392
- deallocate_locked (p, word_size);
373
+ SOMETIMES (verify ();)
393
374
}
394
375
395
376
// Update statistics. This walks all in-use chunks.
396
377
void MetaspaceArena::add_to_statistics (ArenaStats* out) const {
397
- MutexLocker cl (lock (), Mutex::_no_safepoint_check_flag);
398
-
399
378
for (const Metachunk* c = _chunks.first (); c != nullptr ; c = c->next ()) {
400
379
InUseChunkStats& ucs = out->_stats [c->level ()];
401
380
ucs._num ++;
@@ -421,7 +400,6 @@ void MetaspaceArena::add_to_statistics(ArenaStats* out) const {
421
400
// Convenience method to get the most important usage statistics.
422
401
// For deeper analysis use add_to_statistics().
423
402
void MetaspaceArena::usage_numbers (size_t * p_used_words, size_t * p_committed_words, size_t * p_capacity_words) const {
424
- MutexLocker cl (lock (), Mutex::_no_safepoint_check_flag);
425
403
size_t used = 0 , comm = 0 , cap = 0 ;
426
404
for (const Metachunk* c = _chunks.first (); c != nullptr ; c = c->next ()) {
427
405
used += c->used_words ();
@@ -441,8 +419,7 @@ void MetaspaceArena::usage_numbers(size_t* p_used_words, size_t* p_committed_wor
441
419
442
420
#ifdef ASSERT
443
421
444
- void MetaspaceArena::verify_locked () const {
445
- assert_lock_strong (lock ());
422
+ void MetaspaceArena::verify () const {
446
423
assert (_growth_policy != nullptr && _chunk_manager != nullptr , " Sanity" );
447
424
_chunks.verify ();
448
425
if (_fbl != nullptr ) {
@@ -462,11 +439,6 @@ void MetaspaceArena::verify_allocation_guards() const {
462
439
}
463
440
}
464
441
465
- void MetaspaceArena::verify () const {
466
- MutexLocker cl (lock (), Mutex::_no_safepoint_check_flag);
467
- verify_locked ();
468
- }
469
-
470
442
// Returns true if the area indicated by pointer and size have actually been allocated
471
443
// from this arena.
472
444
bool MetaspaceArena::is_valid_area (MetaWord* p, size_t word_size) const {
@@ -483,18 +455,12 @@ bool MetaspaceArena::is_valid_area(MetaWord* p, size_t word_size) const {
483
455
#endif // ASSERT
484
456
485
457
void MetaspaceArena::print_on (outputStream* st) const {
486
- MutexLocker fcl (_lock, Mutex::_no_safepoint_check_flag);
487
- print_on_locked (st);
488
- }
489
-
490
- void MetaspaceArena::print_on_locked (outputStream* st) const {
491
- assert_lock_strong (_lock);
492
458
st->print_cr (" sm %s: %d chunks, total word size: " SIZE_FORMAT " , committed word size: " SIZE_FORMAT, _name,
493
459
_chunks.count (), _chunks.calc_word_size (), _chunks.calc_committed_word_size ());
494
460
_chunks.print_on (st);
495
461
st->cr ();
496
- st->print_cr (" growth-policy " PTR_FORMAT " , lock " PTR_FORMAT " , cm " PTR_FORMAT " , fbl " PTR_FORMAT,
497
- p2i (_growth_policy), p2i (_lock), p2i ( _chunk_manager), p2i (_fbl));
462
+ st->print_cr (" growth-policy " PTR_FORMAT " , cm " PTR_FORMAT " , fbl " PTR_FORMAT,
463
+ p2i (_growth_policy), p2i (_chunk_manager), p2i (_fbl));
498
464
}
499
465
500
466
} // namespace metaspace
0 commit comments