# HG changeset patch # User rwestberg # Date 1528122068 -7200 # Node ID 2bea53d7a27bfa37b15907c9b9ef24d139542b28 # Parent f4c4a86d1c12563df7bc1242e71a107df7b180da 8202095: JFR TestBiasedLockRevocationEvents should cope with multiple events during a single safepoint Reviewed-by: mgronlun, egahlin diff -r f4c4a86d1c12 -r 2bea53d7a27b test/jdk/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java --- a/test/jdk/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java Mon Jun 04 23:07:33 2018 +0200 +++ b/test/jdk/jdk/jfr/event/runtime/TestBiasedLockRevocationEvents.java Mon Jun 04 16:21:08 2018 +0200 @@ -33,9 +33,7 @@ import jdk.test.lib.jfr.Events; import jdk.test.lib.process.OutputAnalyzer; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; +import java.util.*; import java.util.concurrent.FutureTask; import java.util.stream.Collectors; @@ -275,12 +273,20 @@ recording.stop(); List events = Events.fromRecording(recording); - // Find all biased locking related VMOperation events - HashMap vmOperations = new HashMap(); + // Determine which safepoints included single and bulk revocation VM operations + Set vmOperationsSingle = new HashSet<>(); + Set vmOperationsBulk = new HashSet<>(); + for (RecordedEvent event : events) { - if ((event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) && - (event.getValue("operation").toString().contains("Bias"))) { - vmOperations.put(event.getValue("safepointId"), event); + if (event.getEventType().getName().equals(EventNames.ExecuteVMOperation)) { + String operation = event.getValue("operation"); + Integer safepointId = event.getValue("safepointId"); + + if (operation.equals("RevokeBias")) { + vmOperationsSingle.add(safepointId); + } else if (operation.equals("BulkRevokeBias")) { + vmOperationsBulk.add(safepointId); + } } } @@ -290,23 +296,22 @@ // Match all revoke events to a corresponding VMOperation event for (RecordedEvent event : events) { if (event.getEventType().getName().equals(EventNames.BiasedLockRevocation)) { - RecordedEvent vmOpEvent = vmOperations.remove(event.getValue("safepointId")); - if (event.getValue("safepointId").toString().equals("-1")) { - Asserts.assertEquals(vmOpEvent, null); - } else { - Events.assertField(vmOpEvent, "operation").equal("RevokeBias"); + Integer safepointId = event.getValue("safepointId"); + String lockClass = ((RecordedClass)event.getValue("lockClass")).getName(); + if (lockClass.equals(MyLock.class.getName())) { + Asserts.assertTrue(vmOperationsSingle.contains(safepointId)); revokeCount++; } } else if (event.getEventType().getName().equals(EventNames.BiasedLockClassRevocation)) { - RecordedEvent vmOpEvent = vmOperations.remove(event.getValue("safepointId")); - Events.assertField(vmOpEvent, "operation").equal("BulkRevokeBias"); - bulkRevokeCount++; + Integer safepointId = event.getValue("safepointId"); + String lockClass = ((RecordedClass)event.getValue("revokedClass")).getName(); + 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(revokeCount, bulkRevokeCount); }