Skip to content

Commit e07a5b6

Browse files
committed
8338512: JFR: Revert changes to TestCodeSweeper
Reviewed-by: mgronlun
1 parent 6d430f2 commit e07a5b6

File tree

2 files changed

+17
-38
lines changed

2 files changed

+17
-38
lines changed

test/jdk/ProblemList.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ jdk/incubator/vector/LoadJsvmlTest.java 8305390 windows-
743743

744744
# jdk_jfr
745745

746+
jdk/jfr/event/compiler/TestCodeSweeper.java 8338127 generic-all
746747
jdk/jfr/event/runtime/TestResidentSetSizeEvent.java 8309846 aix-ppc64
747748
jdk/jfr/jvm/TestWaste.java 8282427 generic-all
748749

test/jdk/jdk/jfr/event/compiler/TestCodeSweeper.java

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727
import java.lang.reflect.Method;
2828
import java.time.Instant;
2929
import java.util.ArrayList;
30-
import java.util.Collections;
3130
import java.util.List;
3231

33-
import jdk.jfr.Event;
34-
import jdk.jfr.consumer.RecordingStream;
32+
import jdk.jfr.Recording;
3533
import jdk.jfr.consumer.RecordedEvent;
3634
import jdk.test.lib.Asserts;
3735
import jdk.test.lib.jfr.EventNames;
@@ -41,7 +39,7 @@
4139
import jdk.test.whitebox.code.CodeBlob;
4240

4341
/**
44-
* Test for events: jdk.CodeCacheFull jdk.CompilationFailure
42+
* Test for events: vm/code_cache/full vm/compiler/failure
4543
*
4644
* We verify that we should get at least one of each of the events listed above.
4745
*
@@ -60,15 +58,13 @@
6058
*/
6159

6260
public class TestCodeSweeper {
63-
static class ProvocationEvent extends Event {
64-
}
6561
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
6662
private static final int COMP_LEVEL_SIMPLE = 1;
6763
private static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
6864
private static final int SIZE = 1;
6965
private static final String METHOD_NAME = "verifyFullEvent";
70-
private static final String EVENT_CODE_CACHE_FULL = EventNames.CodeCacheFull;
71-
private static final String EVENT_COMPILATION_FAILURE = EventNames.CompilationFailure;
66+
private static final String pathFull = EventNames.CodeCacheFull;
67+
private static final String pathFailure = EventNames.CompilationFailure;
7268
public static final long SEGMENT_SIZE = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheSegmentSize");
7369
public static final long MIN_BLOCK_LENGTH = WhiteBox.getWhiteBox().getUintxVMFlag("CodeCacheMinBlockLength");
7470
public static final long MIN_ALLOCATION = SEGMENT_SIZE * MIN_BLOCK_LENGTH;
@@ -81,41 +77,26 @@ public static void main(String[] args) throws Throwable {
8177
System.out.println("This test will warn that the code cache is full.");
8278
System.out.println("That is expected and is the purpose of the test.");
8379
System.out.println("************************************************");
84-
List<RecordedEvent> events = Collections.synchronizedList(new ArrayList<>());
85-
try (RecordingStream rs = new RecordingStream()) {
86-
rs.setReuse(false);
87-
rs.enable(EVENT_CODE_CACHE_FULL);
88-
rs.enable(EVENT_COMPILATION_FAILURE);
89-
rs.onEvent(EVENT_CODE_CACHE_FULL, events::add);
90-
rs.onEvent(EVENT_COMPILATION_FAILURE, events::add);
91-
rs.onEvent(ProvocationEvent.class.getName(), e -> {
92-
if (!events.isEmpty()) {
93-
rs.close();
94-
return;
95-
}
96-
// Retry if CodeCacheFull or CompilationFailure events weren't provoked
97-
try {
98-
provokeEvents();
99-
} catch (Exception ex) {
100-
ex.printStackTrace();
101-
rs.close();
102-
}
103-
});
104-
rs.startAsync();
105-
provokeEvents();
106-
rs.awaitTermination();
107-
}
80+
81+
Recording r = new Recording();
82+
r.enable(pathFull);
83+
r.enable(pathFailure);
84+
r.start();
85+
provokeEvents();
86+
r.stop();
10887

10988
int countEventFull = 0;
11089
int countEventFailure = 0;
90+
91+
List<RecordedEvent> events = Events.fromRecording(r);
11192
Events.hasEvents(events);
112-
for (RecordedEvent event : new ArrayList<>(events)) {
93+
for (RecordedEvent event : events) {
11394
switch (event.getEventType().getName()) {
114-
case EVENT_CODE_CACHE_FULL:
95+
case pathFull:
11596
countEventFull++;
11697
verifyFullEvent(event);
11798
break;
118-
case EVENT_COMPILATION_FAILURE:
99+
case pathFailure:
119100
countEventFailure++;
120101
verifyFailureEvent(event);
121102
break;
@@ -134,8 +115,6 @@ private static boolean canAllocate(double size, long maxSize, MemoryPoolMXBean b
134115
}
135116

136117
private static void provokeEvents() throws NoSuchMethodException, InterruptedException {
137-
System.out.println("provokeEvents()");
138-
ProvocationEvent provocationEvent = new ProvocationEvent();
139118
// Prepare for later, since we don't want to trigger any compilation
140119
// setting this up.
141120
Method method = TestCodeSweeper.class.getDeclaredMethod(METHOD_NAME, new Class[] { RecordedEvent.class });
@@ -180,7 +159,6 @@ private static void provokeEvents() throws NoSuchMethodException, InterruptedExc
180159
for (Long blob : blobs) {
181160
WHITE_BOX.freeCodeBlob(blob);
182161
}
183-
provocationEvent.commit();
184162
}
185163

186164
private static void verifyFullEvent(RecordedEvent event) throws Throwable {

0 commit comments

Comments
 (0)