8202095: JFR TestBiasedLockRevocationEvents should cope with multiple events during a single safepoint
Reviewed-by: mgronlun, egahlin
This commit is contained in:
parent
4ed3a3f4fa
commit
33724f098f
@ -33,9 +33,7 @@ import jdk.test.lib.jfr.EventNames;
|
|||||||
import jdk.test.lib.jfr.Events;
|
import jdk.test.lib.jfr.Events;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -275,12 +273,20 @@ public class TestBiasedLockRevocationEvents {
|
|||||||
recording.stop();
|
recording.stop();
|
||||||
List<RecordedEvent> events = Events.fromRecording(recording);
|
List<RecordedEvent> events = Events.fromRecording(recording);
|
||||||
|
|
||||||
// Find all biased locking related VMOperation events
|
// Determine which safepoints included single and bulk revocation VM operations
|
||||||
HashMap<Integer, RecordedEvent> vmOperations = new HashMap<Integer, RecordedEvent>();
|
Set<Integer> vmOperationsSingle = new HashSet<>();
|
||||||
|
Set<Integer> vmOperationsBulk = new HashSet<>();
|
||||||
|
|
||||||
for (RecordedEvent event : events) {
|
for (RecordedEvent event : events) {
|
||||||
if ((event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) &&
|
if (event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) {
|
||||||
(event.getValue("operation").toString().contains("Bias"))) {
|
String operation = event.getValue("operation");
|
||||||
vmOperations.put(event.getValue("safepointId"), event);
|
Integer safepointId = event.getValue("safepointId");
|
||||||
|
|
||||||
|
if (operation.equals("RevokeBias")) {
|
||||||
|
vmOperationsSingle.add(safepointId);
|
||||||
|
} else if (operation.equals("BulkRevokeBias")) {
|
||||||
|
vmOperationsBulk.add(safepointId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,23 +296,22 @@ public class TestBiasedLockRevocationEvents {
|
|||||||
// Match all revoke events to a corresponding VMOperation event
|
// Match all revoke events to a corresponding VMOperation event
|
||||||
for (RecordedEvent event : events) {
|
for (RecordedEvent event : events) {
|
||||||
if (event.getEventType().getName().equals(EventNames.BiasedLockRevocation)) {
|
if (event.getEventType().getName().equals(EventNames.BiasedLockRevocation)) {
|
||||||
RecordedEvent vmOpEvent = vmOperations.remove(event.getValue("safepointId"));
|
Integer safepointId = event.getValue("safepointId");
|
||||||
if (event.getValue("safepointId").toString().equals("-1")) {
|
String lockClass = ((RecordedClass)event.getValue("lockClass")).getName();
|
||||||
Asserts.assertEquals(vmOpEvent, null);
|
if (lockClass.equals(MyLock.class.getName())) {
|
||||||
} else {
|
Asserts.assertTrue(vmOperationsSingle.contains(safepointId));
|
||||||
Events.assertField(vmOpEvent, "operation").equal("RevokeBias");
|
|
||||||
revokeCount++;
|
revokeCount++;
|
||||||
}
|
}
|
||||||
} else if (event.getEventType().getName().equals(EventNames.BiasedLockClassRevocation)) {
|
} else if (event.getEventType().getName().equals(EventNames.BiasedLockClassRevocation)) {
|
||||||
RecordedEvent vmOpEvent = vmOperations.remove(event.getValue("safepointId"));
|
Integer safepointId = event.getValue("safepointId");
|
||||||
Events.assertField(vmOpEvent, "operation").equal("BulkRevokeBias");
|
String lockClass = ((RecordedClass)event.getValue("revokedClass")).getName();
|
||||||
bulkRevokeCount++;
|
if (lockClass.toString().equals(MyLock.class.getName())) {
|
||||||
|
Asserts.assertTrue(vmOperationsBulk.contains(safepointId));
|
||||||
|
bulkRevokeCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All VMOperations should have had a matching revoke event
|
|
||||||
Asserts.assertEQ(vmOperations.size(), 0);
|
|
||||||
|
|
||||||
Asserts.assertGT(bulkRevokeCount, 0);
|
Asserts.assertGT(bulkRevokeCount, 0);
|
||||||
Asserts.assertGT(revokeCount, bulkRevokeCount);
|
Asserts.assertGT(revokeCount, bulkRevokeCount);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user