Skip to content

Commit

Permalink
8289745: JfrStructCopyFailed uses heap words instead of bytes for obj…
Browse files Browse the repository at this point in the history
…ect sizes

Reviewed-by: phh
Backport-of: 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d
  • Loading branch information
schmelter-sap committed Nov 6, 2023
1 parent 1f67ffb commit 80d3bb4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/shared/gcTraceSend.cpp
Expand Up @@ -161,9 +161,9 @@ void OldGCTracer::send_old_gc_event() const {
static JfrStructCopyFailed to_struct(const CopyFailedInfo& cf_info) {
JfrStructCopyFailed failed_info;
failed_info.set_objectCount(cf_info.failed_count());
failed_info.set_firstSize(cf_info.first_size());
failed_info.set_smallestSize(cf_info.smallest_size());
failed_info.set_totalSize(cf_info.total_size());
failed_info.set_firstSize(cf_info.first_size() * HeapWordSize);
failed_info.set_smallestSize(cf_info.smallest_size() * HeapWordSize);
failed_info.set_totalSize(cf_info.total_size() * HeapWordSize);
return failed_info;
}

Expand Down
4 changes: 4 additions & 0 deletions test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java
Expand Up @@ -51,12 +51,16 @@ public static void test(String testName, String[] vmFlags) throws Throwable {
// This test can not always trigger the expected event.
// Test is ok even if no events found.
List<RecordedEvent> events = RecordingFile.readAllEvents(Paths.get(jfr_file));
int minObjectAlignment = 8;
for (RecordedEvent event : events) {
System.out.println("Event: " + event);
long smallestSize = Events.assertField(event, "promotionFailed.smallestSize").atLeast(1L).getValue();
Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size.");
long firstSize = Events.assertField(event, "promotionFailed.firstSize").atLeast(smallestSize).getValue();
Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size.");
long totalSize = Events.assertField(event, "promotionFailed.totalSize").atLeast(firstSize).getValue();
long objectCount = Events.assertField(event, "promotionFailed.objectCount").atLeast(1L).getValue();
Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size.");
Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize");
}
}
Expand Down
Expand Up @@ -62,13 +62,17 @@ public static void main(String[] args) throws Exception {
}

List<RecordedEvent> events = RecordingFile.readAllEvents(Paths.get(JFR_FILE));
int minObjectAlignment = 8;

Events.hasEvents(events);
for (RecordedEvent event : events) {
long objectCount = Events.assertField(event, "evacuationFailed.objectCount").atLeast(1L).getValue();
long smallestSize = Events.assertField(event, "evacuationFailed.smallestSize").atLeast(1L).getValue();
Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size.");
long firstSize = Events.assertField(event, "evacuationFailed.firstSize").atLeast(smallestSize).getValue();
Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size.");
long totalSize = Events.assertField(event, "evacuationFailed.totalSize").atLeast(firstSize).getValue();
Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size.");
Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize");
}
}
Expand Down

1 comment on commit 80d3bb4

@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.