Skip to content

Commit 6031388

Browse files
committed
8273714: jdk/jfr/api/consumer/TestRecordedFrame.java still times out after JDK-8273047
Reviewed-by: mgronlun
1 parent 8821b00 commit 6031388

File tree

2 files changed

+119
-6
lines changed

2 files changed

+119
-6
lines changed

test/jdk/jdk/jfr/api/consumer/TestRecordedFrame.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@
4242
* @key jfr
4343
* @requires vm.hasJFR
4444
* @library /test/lib
45-
* @run main/othervm -Xint -XX:+UseInterpreter -Dinterpreted=true jdk.jfr.api.consumer.TestRecordedFrame
46-
* @run main/othervm/timeout=180 -Xcomp -XX:-UseInterpreter -Dinterpreted=false jdk.jfr.api.consumer.TestRecordedFrame
45+
* @run main/othervm jdk.jfr.api.consumer.TestRecordedFrame
4746
*/
4847
public final class TestRecordedFrame {
4948

@@ -86,10 +85,6 @@ static void test() throws IOException {
8685
Asserts.assertTrue(types.contains(type));
8786
// Line number
8887
Asserts.assertEquals(getLineNumber("main"), frame.getLineNumber());
89-
// Interpreted
90-
boolean isInterpreted = "Interpreted".equals(type);
91-
boolean expectedInterpreted = "true".equals(System.getProperty("interpreted"));
92-
Asserts.assertEquals(isInterpreted, expectedInterpreted);
9388
// BCI
9489
int bci = frame.getBytecodeIndex();
9590
System.out.println("bci: " + bci);
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
package jdk.jfr.api.consumer;
24+
25+
import java.lang.reflect.Method;
26+
import java.util.List;
27+
import java.util.Set;
28+
29+
import jdk.jfr.Event;
30+
import jdk.jfr.Recording;
31+
import jdk.jfr.consumer.RecordedEvent;
32+
import jdk.jfr.consumer.RecordedFrame;
33+
import jdk.test.lib.Asserts;
34+
import jdk.test.lib.Utils;
35+
import jdk.test.lib.jfr.Events;
36+
import jdk.test.lib.jfr.SimpleEvent;
37+
import sun.hotspot.WhiteBox;
38+
39+
/**
40+
* @test
41+
* @summary Test jdk.jfr.consumer.RecordedFrame::getType()
42+
* @key jfr
43+
* @requires vm.hasJFR
44+
* @library /test/lib
45+
* @build sun.hotspot.WhiteBox
46+
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
47+
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
48+
* -XX:+WhiteBoxAPI jdk.jfr.api.consumer.TestRecordedFrameType
49+
*/
50+
public final class TestRecordedFrameType {
51+
52+
public static void main(String[] args) throws Exception {
53+
WhiteBox WB = WhiteBox.getWhiteBox();
54+
55+
try (Recording recording = new Recording()) {
56+
recording.start();
57+
58+
String directive =
59+
"""
60+
[
61+
{
62+
match: "jdk/jfr/api/consumer/TestRecordedFrameType.interpreted()",
63+
Exclude: true,
64+
},
65+
{
66+
match: "jdk/jfr/api/consumer/TestRecordedFrameType.compiled()",
67+
BackgroundCompilation: false,
68+
},
69+
]
70+
""";
71+
WB.addCompilerDirective(directive);
72+
Method mtd = TestRecordedFrameType.class.getMethod("compiled", new Class[0]);
73+
if (!WB.enqueueMethodForCompilation(mtd, 1)) {
74+
throw new Exception("Could not enqueue method for CompLevel_simple");
75+
}
76+
Utils.waitForCondition(() -> WB.isMethodCompiled(mtd));
77+
78+
interpreted();
79+
compiled();
80+
81+
List<RecordedEvent> events = Events.fromRecording(recording);
82+
83+
RecordedFrame interpreted = findFrame(events, "interpreted");
84+
System.out.println(interpreted);
85+
String iType = interpreted.getType();
86+
Asserts.assertEquals(iType, "Interpreted");
87+
88+
RecordedFrame compiled = findFrame(events, "compiled");
89+
System.out.println(compiled);
90+
String cType = compiled.getType();
91+
Asserts.assertNotEquals(cType, "Interpreted"); // "JIT compiled" or "Inlined"
92+
}
93+
}
94+
95+
private static RecordedFrame findFrame(List<RecordedEvent> events, String methodName) throws Exception {
96+
for (RecordedEvent event : events) {
97+
for (RecordedFrame frame : event.getStackTrace().getFrames()) {
98+
if (frame.getMethod().getName().equals(methodName)) {
99+
System.out.println("Found frame with method named: " + methodName);
100+
return frame;
101+
}
102+
}
103+
}
104+
throw new Exception("Could not find frame with method named " + methodName);
105+
}
106+
107+
public static void interpreted() {
108+
SimpleEvent event = new SimpleEvent();
109+
event.id = 1;
110+
event.commit();
111+
}
112+
113+
public static void compiled() {
114+
SimpleEvent event = new SimpleEvent();
115+
event.id = 2;
116+
event.commit();
117+
}
118+
}

0 commit comments

Comments
 (0)