Skip to content

Commit

Permalink
8314329: AgeTable: add is_clear() & allocation spec, and relax assert…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Y. Srinivas Ramakrishna committed Jan 22, 2024
1 parent 0d8543d commit df370d7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/hotspot/share/gc/shared/ageTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ void AgeTable::clear() {
}
}

#ifndef PRODUCT
bool AgeTable::is_clear() const {
for (const size_t* p = sizes; p < sizes + table_size; ++p) {
if (*p != 0) return false;
}
return true;
}
#endif // !PRODUCT

void AgeTable::merge(const AgeTable* subTable) {
for (int i = 0; i < table_size; i++) {
sizes[i]+= subTable->sizes[i];
Expand Down
13 changes: 9 additions & 4 deletions src/hotspot/share/gc/shared/ageTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#ifndef SHARE_GC_SHARED_AGETABLE_HPP
#define SHARE_GC_SHARED_AGETABLE_HPP

#include "memory/allocation.hpp"
#include "oops/markWord.hpp"
#include "oops/oop.hpp"
#include "runtime/perfDataTypes.hpp"
Expand All @@ -36,7 +37,7 @@
//
// Note: all sizes are in oops

class AgeTable {
class AgeTable: public CHeapObj<mtGC> {
friend class VMStructs;

public:
Expand All @@ -53,16 +54,20 @@ class AgeTable {
// clear table
void clear();

#ifndef PRODUCT
// check whether it's clear
bool is_clear() const;
#endif // !PRODUCT

// add entry
inline void add(oop p, size_t oop_size);

void add(uint age, size_t oop_size) {
assert(age > 0 && age < table_size, "invalid age of object");
assert(age < table_size, "invalid age of object");
sizes[age] += oop_size;
}

// Merge another age table with the current one. Used
// for parallel young generation gc.
// Merge another age table with the current one.
void merge(const AgeTable* subTable);

// Calculate new tenuring threshold based on age information.
Expand Down

1 comment on commit df370d7

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.