-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed-by: kvn, lucy
- Loading branch information
Showing
8 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
package jdk.jfr.event.compiler; | ||
|
||
import java.util.List; | ||
|
||
import jdk.jfr.Recording; | ||
import jdk.jfr.consumer.RecordedEvent; | ||
import jdk.test.lib.Asserts; | ||
import jdk.test.lib.jfr.EventNames; | ||
import jdk.test.lib.jfr.Events; | ||
import jdk.test.whitebox.WhiteBox; | ||
import jdk.test.whitebox.code.BlobType; | ||
|
||
/** | ||
* @test TestJitRestart | ||
* @requires vm.hasJFR | ||
* | ||
* @library /test/lib | ||
* @modules jdk.jfr | ||
* jdk.management.jfr | ||
* @build jdk.test.whitebox.WhiteBox | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox | ||
* | ||
* @run main/othervm -Xbootclasspath/a:. | ||
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI | ||
* -XX:+SegmentedCodeCache -XX:-UseLargePages jdk.jfr.event.compiler.TestJitRestart | ||
*/ | ||
public class TestJitRestart { | ||
|
||
public static void main(String[] args) throws Exception { | ||
boolean foundJitRestart = false; | ||
for (BlobType btype : BlobType.getAvailable()) { | ||
boolean jr = testWithBlobType(btype, calculateAvailableSize(btype)); | ||
if (jr) { | ||
System.out.println("JIT restart event found for BlobType " + btype); | ||
foundJitRestart = true; | ||
} | ||
} | ||
Asserts.assertTrue(foundJitRestart, "No JIT restart event found"); | ||
} | ||
|
||
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); | ||
|
||
private static boolean testWithBlobType(BlobType btype, long availableSize) throws Exception { | ||
Recording r = new Recording(); | ||
r.enable(EventNames.CodeCacheFull); | ||
r.enable(EventNames.JitRestart); | ||
r.start(); | ||
long addr = WHITE_BOX.allocateCodeBlob(availableSize, btype.id); | ||
WHITE_BOX.freeCodeBlob(addr); | ||
WHITE_BOX.forceNMethodSweep(); | ||
r.stop(); | ||
|
||
List<RecordedEvent> events = Events.fromRecording(r); | ||
System.out.println("# events:" + events.size()); | ||
Events.hasEvents(events); | ||
|
||
for (RecordedEvent evt: events) { | ||
System.out.println(evt); | ||
if (evt.getEventType().getName().equals("jdk.JitRestart")) { | ||
Events.assertField(evt, "codeCacheMaxCapacity").notEqual(0L); | ||
Events.assertField(evt, "freedMemory").notEqual(0L); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
// Compute the available size for this BlobType by taking into account | ||
// that it may be stored in a different code heap in case it does not fit | ||
// into the current one. | ||
private static long calculateAvailableSize(BlobType btype) { | ||
long availableSize = btype.getSize(); | ||
for (BlobType alternative : BlobType.getAvailable()) { | ||
if (btype.allowTypeWhenOverflow(alternative)) { | ||
availableSize = Math.max(availableSize, alternative.getSize()); | ||
} | ||
} | ||
return availableSize; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dfbc691
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues
dfbc691
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/backport jdk17u-dev
dfbc691
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MBaesken Could not automatically backport
dfbc6919
to openjdk/jdk17u-dev due to conflicts in the following files:Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.
Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title
Backport dfbc6919e1e233b42aede97f1323ce5529fab7cf
.