Skip to content

Commit df370d7

Browse files
author
Y. Srinivas Ramakrishna
committed
8314329: AgeTable: add is_clear() & allocation spec, and relax assert to allow use of 0-index slot
AgeTable changes: 1. add CHeap allocation spec 2. add a non-product const is_clear() method to check if the age table has only zero entries 3. relax the assertion that the 0th index of the age table is never used, to allow use of that slot Reviewed-by: wkemper, kdnilsen, ayang, shade
1 parent 0d8543d commit df370d7

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/hotspot/share/gc/shared/ageTable.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ void AgeTable::clear() {
7171
}
7272
}
7373

74+
#ifndef PRODUCT
75+
bool AgeTable::is_clear() const {
76+
for (const size_t* p = sizes; p < sizes + table_size; ++p) {
77+
if (*p != 0) return false;
78+
}
79+
return true;
80+
}
81+
#endif // !PRODUCT
82+
7483
void AgeTable::merge(const AgeTable* subTable) {
7584
for (int i = 0; i < table_size; i++) {
7685
sizes[i]+= subTable->sizes[i];

src/hotspot/share/gc/shared/ageTable.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifndef SHARE_GC_SHARED_AGETABLE_HPP
2626
#define SHARE_GC_SHARED_AGETABLE_HPP
2727

28+
#include "memory/allocation.hpp"
2829
#include "oops/markWord.hpp"
2930
#include "oops/oop.hpp"
3031
#include "runtime/perfDataTypes.hpp"
@@ -36,7 +37,7 @@
3637
//
3738
// Note: all sizes are in oops
3839

39-
class AgeTable {
40+
class AgeTable: public CHeapObj<mtGC> {
4041
friend class VMStructs;
4142

4243
public:
@@ -53,16 +54,20 @@ class AgeTable {
5354
// clear table
5455
void clear();
5556

57+
#ifndef PRODUCT
58+
// check whether it's clear
59+
bool is_clear() const;
60+
#endif // !PRODUCT
61+
5662
// add entry
5763
inline void add(oop p, size_t oop_size);
5864

5965
void add(uint age, size_t oop_size) {
60-
assert(age > 0 && age < table_size, "invalid age of object");
66+
assert(age < table_size, "invalid age of object");
6167
sizes[age] += oop_size;
6268
}
6369

64-
// Merge another age table with the current one. Used
65-
// for parallel young generation gc.
70+
// Merge another age table with the current one.
6671
void merge(const AgeTable* subTable);
6772

6873
// Calculate new tenuring threshold based on age information.

0 commit comments

Comments
 (0)