@@ -1373,9 +1373,25 @@ size_t ZPageAllocator::unused() const {
1373
1373
return unused > 0 ? (size_t )unused : 0 ;
1374
1374
}
1375
1375
1376
- ZPageAllocatorStats ZPageAllocator::stats (ZGeneration* generation) const {
1377
- ZLocker<ZLock> locker (&_lock );
1376
+ void ZPageAllocator::update_collection_stats (ZGenerationId id) {
1377
+ assert ( SafepointSynchronize::is_at_safepoint (), " Should be at safepoint " );
1378
1378
1379
+ #ifdef ASSERT
1380
+ size_t total_used = 0 ;
1381
+
1382
+ ZPartitionIterator iter (&_partitions);
1383
+ for (ZPartition* partition; iter.next (&partition);) {
1384
+ total_used += partition->_used ;
1385
+ }
1386
+
1387
+ assert (total_used == _used, " Must be consistent %zu == %zu" , total_used, _used);
1388
+ #endif
1389
+
1390
+ _collection_stats[(int )id]._used_high = _used;
1391
+ _collection_stats[(int )id]._used_low = _used;
1392
+ }
1393
+
1394
+ ZPageAllocatorStats ZPageAllocator::stats_inner (ZGeneration* generation) const {
1379
1395
return ZPageAllocatorStats (_min_capacity,
1380
1396
_max_capacity,
1381
1397
soft_max_capacity (),
@@ -1390,29 +1406,16 @@ ZPageAllocatorStats ZPageAllocator::stats(ZGeneration* generation) const {
1390
1406
_stalled.size ());
1391
1407
}
1392
1408
1393
- void ZPageAllocator::reset_statistics (ZGenerationId id) {
1394
- assert (SafepointSynchronize::is_at_safepoint (), " Should be at safepoint" );
1395
- #ifdef ASSERT
1396
- {
1397
- // We may free without safepoint synchronization, take the lock to get
1398
- // consistent values.
1399
- ZLocker<ZLock> locker (&_lock);
1400
- size_t total_used = 0 ;
1401
-
1402
- ZPartitionIterator iter (&_partitions);
1403
- for (ZPartition* partition; iter.next (&partition);) {
1404
- total_used += partition->_used ;
1405
- }
1406
-
1407
- assert (total_used == _used, " Must be consistent at safepoint %zu == %zu" , total_used, _used);
1408
- }
1409
- #endif
1409
+ ZPageAllocatorStats ZPageAllocator::stats (ZGeneration* generation) const {
1410
+ ZLocker<ZLock> locker (&_lock);
1411
+ return stats_inner (generation);
1412
+ }
1410
1413
1411
- // Read once, we may have concurrent writers.
1412
- const size_t used = Atomic::load (&_used );
1414
+ ZPageAllocatorStats ZPageAllocator::update_and_stats (ZGeneration* generation) {
1415
+ ZLocker<ZLock> locker (&_lock );
1413
1416
1414
- _collection_stats[( int )id]. _used_high = used ;
1415
- _collection_stats[( int )id]. _used_low = used ;
1417
+ update_collection_stats (generation-> id ()) ;
1418
+ return stats_inner (generation) ;
1416
1419
}
1417
1420
1418
1421
void ZPageAllocator::increase_used_generation (ZGenerationId id, size_t size) {
0 commit comments