Skip to content

Commit 80d3bb4

Browse files
committedNov 6, 2023
8289745: JfrStructCopyFailed uses heap words instead of bytes for object sizes
Reviewed-by: phh Backport-of: 7f0e9bd632198c7fd34d27b85ca51ea0e2442e4d
1 parent 1f67ffb commit 80d3bb4

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
 

‎src/hotspot/share/gc/shared/gcTraceSend.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void OldGCTracer::send_old_gc_event() const {
161161
static JfrStructCopyFailed to_struct(const CopyFailedInfo& cf_info) {
162162
JfrStructCopyFailed failed_info;
163163
failed_info.set_objectCount(cf_info.failed_count());
164-
failed_info.set_firstSize(cf_info.first_size());
165-
failed_info.set_smallestSize(cf_info.smallest_size());
166-
failed_info.set_totalSize(cf_info.total_size());
164+
failed_info.set_firstSize(cf_info.first_size() * HeapWordSize);
165+
failed_info.set_smallestSize(cf_info.smallest_size() * HeapWordSize);
166+
failed_info.set_totalSize(cf_info.total_size() * HeapWordSize);
167167
return failed_info;
168168
}
169169

‎test/jdk/jdk/jfr/event/gc/detailed/PromotionFailedEvent.java

+4
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ public static void test(String testName, String[] vmFlags) throws Throwable {
5151
// This test can not always trigger the expected event.
5252
// Test is ok even if no events found.
5353
List<RecordedEvent> events = RecordingFile.readAllEvents(Paths.get(jfr_file));
54+
int minObjectAlignment = 8;
5455
for (RecordedEvent event : events) {
5556
System.out.println("Event: " + event);
5657
long smallestSize = Events.assertField(event, "promotionFailed.smallestSize").atLeast(1L).getValue();
58+
Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size.");
5759
long firstSize = Events.assertField(event, "promotionFailed.firstSize").atLeast(smallestSize).getValue();
60+
Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size.");
5861
long totalSize = Events.assertField(event, "promotionFailed.totalSize").atLeast(firstSize).getValue();
5962
long objectCount = Events.assertField(event, "promotionFailed.objectCount").atLeast(1L).getValue();
63+
Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size.");
6064
Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize");
6165
}
6266
}

‎test/jdk/jdk/jfr/event/gc/detailed/TestEvacuationFailedEvent.java

+4
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,17 @@ public static void main(String[] args) throws Exception {
6262
}
6363

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

6667
Events.hasEvents(events);
6768
for (RecordedEvent event : events) {
6869
long objectCount = Events.assertField(event, "evacuationFailed.objectCount").atLeast(1L).getValue();
6970
long smallestSize = Events.assertField(event, "evacuationFailed.smallestSize").atLeast(1L).getValue();
71+
Asserts.assertTrue((smallestSize % minObjectAlignment) == 0, "smallestSize " + smallestSize + " is not a valid size.");
7072
long firstSize = Events.assertField(event, "evacuationFailed.firstSize").atLeast(smallestSize).getValue();
73+
Asserts.assertTrue((firstSize % minObjectAlignment) == 0, "firstSize " + firstSize + " is not a valid size.");
7174
long totalSize = Events.assertField(event, "evacuationFailed.totalSize").atLeast(firstSize).getValue();
75+
Asserts.assertTrue((totalSize % minObjectAlignment) == 0, "totalSize " + totalSize + " is not a valid size.");
7276
Asserts.assertLessThanOrEqual(smallestSize * objectCount, totalSize, "smallestSize * objectCount <= totalSize");
7377
}
7478
}

0 commit comments

Comments
 (0)
Please sign in to comment.