Skip to content

Commit d554f2b

Browse files
committed
8316885: jcmd: Compiler.CodeHeap_Analytics cmd does not inform about missing aggregate
Backport-of: 1230aed61d286fe9c09f46e2bab626d0e8fe0273
1 parent 990859c commit d554f2b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/hotspot/share/code/codeHeapState.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,13 +1216,15 @@ void CodeHeapState::aggregate(outputStream* out, CodeHeap* heap, size_t granular
12161216

12171217
void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) {
12181218
if (!initialization_complete) {
1219+
print_aggregate_missing(out, nullptr);
12191220
return;
12201221
}
12211222

12221223
const char* heapName = get_heapName(heap);
12231224
get_HeapStatGlobals(out, heapName);
12241225

12251226
if ((StatArray == nullptr) || (TopSizeArray == nullptr) || (used_topSizeBlocks == 0)) {
1227+
print_aggregate_missing(out, heapName);
12261228
return;
12271229
}
12281230
BUFFEREDSTREAM_DECL(ast, out)
@@ -1426,13 +1428,15 @@ void CodeHeapState::print_usedSpace(outputStream* out, CodeHeap* heap) {
14261428

14271429
void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) {
14281430
if (!initialization_complete) {
1431+
print_aggregate_missing(out, nullptr);
14291432
return;
14301433
}
14311434

14321435
const char* heapName = get_heapName(heap);
14331436
get_HeapStatGlobals(out, heapName);
14341437

14351438
if ((StatArray == nullptr) || (FreeArray == nullptr) || (alloc_granules == 0)) {
1439+
print_aggregate_missing(out, heapName);
14361440
return;
14371441
}
14381442
BUFFEREDSTREAM_DECL(ast, out)
@@ -1600,13 +1604,15 @@ void CodeHeapState::print_freeSpace(outputStream* out, CodeHeap* heap) {
16001604

16011605
void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) {
16021606
if (!initialization_complete) {
1607+
print_aggregate_missing(out, nullptr);
16031608
return;
16041609
}
16051610

16061611
const char* heapName = get_heapName(heap);
16071612
get_HeapStatGlobals(out, heapName);
16081613

16091614
if ((StatArray == nullptr) || (alloc_granules == 0)) {
1615+
print_aggregate_missing(out, heapName);
16101616
return;
16111617
}
16121618
BUFFEREDSTREAM_DECL(ast, out)
@@ -1758,13 +1764,15 @@ void CodeHeapState::print_count(outputStream* out, CodeHeap* heap) {
17581764

17591765
void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) {
17601766
if (!initialization_complete) {
1767+
print_aggregate_missing(out, nullptr);
17611768
return;
17621769
}
17631770

17641771
const char* heapName = get_heapName(heap);
17651772
get_HeapStatGlobals(out, heapName);
17661773

17671774
if ((StatArray == nullptr) || (alloc_granules == 0)) {
1775+
print_aggregate_missing(out, heapName);
17681776
return;
17691777
}
17701778
BUFFEREDSTREAM_DECL(ast, out)
@@ -1927,13 +1935,15 @@ void CodeHeapState::print_space(outputStream* out, CodeHeap* heap) {
19271935

19281936
void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) {
19291937
if (!initialization_complete) {
1938+
print_aggregate_missing(out, nullptr);
19301939
return;
19311940
}
19321941

19331942
const char* heapName = get_heapName(heap);
19341943
get_HeapStatGlobals(out, heapName);
19351944

19361945
if ((StatArray == nullptr) || (alloc_granules == 0)) {
1946+
print_aggregate_missing(out, heapName);
19371947
return;
19381948
}
19391949
BUFFEREDSTREAM_DECL(ast, out)
@@ -2039,13 +2049,15 @@ void CodeHeapState::print_age(outputStream* out, CodeHeap* heap) {
20392049

20402050
void CodeHeapState::print_names(outputStream* out, CodeHeap* heap) {
20412051
if (!initialization_complete) {
2052+
print_aggregate_missing(out, nullptr);
20422053
return;
20432054
}
20442055

20452056
const char* heapName = get_heapName(heap);
20462057
get_HeapStatGlobals(out, heapName);
20472058

20482059
if ((StatArray == nullptr) || (alloc_granules == 0)) {
2060+
print_aggregate_missing(out, heapName);
20492061
return;
20502062
}
20512063
BUFFEREDSTREAM_DECL(ast, out)
@@ -2343,6 +2355,14 @@ void CodeHeapState::print_line_delim(outputStream* out, bufferedStream* ast, cha
23432355
}
23442356
}
23452357

2358+
void CodeHeapState::print_aggregate_missing(outputStream* out, const char* heapName) {
2359+
if (heapName == nullptr) {
2360+
out->print_cr("No aggregated code heap data available. Run function aggregate first.");
2361+
} else {
2362+
out->print_cr("No aggregated data available for heap %s. Run function aggregate first.", heapName);
2363+
}
2364+
}
2365+
23462366
// Find out which blob type we have at hand.
23472367
// Return "noType" if anything abnormal is detected.
23482368
CodeHeapState::blobType CodeHeapState::get_cbType(CodeBlob* cb) {

src/hotspot/share/code/codeHeapState.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class CodeHeapState : public CHeapObj<mtCode> {
9191
static void print_age_single(outputStream *ast, int age);
9292
static void print_line_delim(outputStream* out, bufferedStream *sst, char* low_bound, unsigned int ix, unsigned int gpl);
9393
static void print_line_delim(outputStream* out, outputStream *sst, char* low_bound, unsigned int ix, unsigned int gpl);
94+
static void print_aggregate_missing(outputStream* out, const char* heapName);
9495
static blobType get_cbType(CodeBlob* cb);
9596
static bool blob_access_is_safe(CodeBlob* this_blob);
9697
static bool nmethod_access_is_safe(nmethod* nm);

0 commit comments

Comments
 (0)