Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate JFR leak profiler with BasedOnJDKFile #10206

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.graalvm.word.UnsignedWord;

import com.oracle.svm.core.util.BasedOnJDKFile;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.jfr.JfrEvent;
import com.oracle.svm.core.thread.JavaSpinLockUtils;
Expand Down Expand Up @@ -78,6 +79,7 @@ public boolean sample(Object obj, UnsignedWord allocatedSize, int arrayLength) {
return sample0(obj, allocatedSize, arrayLength);
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp#L219-L236")
@Uninterruptible(reason = "Must not safepoint while holding the lock.")
private boolean sample0(Object obj, UnsignedWord allocatedSize, int arrayLength) {
assert allocatedSize.aboveThan(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.graalvm.word.Pointer;
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.util.BasedOnJDKFile;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue;
import com.oracle.svm.core.jdk.UninterruptibleUtils;
Expand Down Expand Up @@ -103,6 +104,7 @@ public long serializeOldObject(Object obj) {
}
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp#L124-L142")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
private static void writeDescription(Object obj, JfrNativeEventWriterData data) {
if (obj instanceof ThreadGroup group) {
Expand All @@ -117,6 +119,7 @@ private static void writeDescription(Object obj, JfrNativeEventWriterData data)
}
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp#L50-L68")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
private static void writeDescription(JfrNativeEventWriterData data, String prefix, String text) {
if (text == null || text.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.graalvm.word.UnsignedWord;

import com.oracle.svm.core.util.BasedOnJDKFile;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.collections.UninterruptibleLinkedList;
import com.oracle.svm.core.collections.UninterruptiblePriorityQueue;
Expand All @@ -54,6 +55,7 @@ final class JfrOldObjectSampler {
private UnsignedWord totalAllocated;
private UnsignedWord totalInQueue;

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp#L111-L119")
JfrOldObjectSampler(int queueSize) {
this.queue = new UninterruptiblePriorityQueue(new JfrOldObject[queueSize]);
this.usedList = new UninterruptibleLinkedList();
Expand All @@ -64,6 +66,7 @@ final class JfrOldObjectSampler {
}
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp#L239-L299")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
boolean sample(Object obj, UnsignedWord allocatedSize, int arrayLength) {
totalAllocated = totalAllocated.add(allocatedSize);
Expand Down Expand Up @@ -93,6 +96,7 @@ boolean sample(Object obj, UnsignedWord allocatedSize, int arrayLength) {
return true;
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp#L301-L310")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
private int scavenge() {
int numDead = 0;
Expand All @@ -108,6 +112,7 @@ private int scavenge() {
return numDead;
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/sampling/objectSampler.cpp#L312-L324")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
private void remove(JfrOldObject sample) {
JfrOldObject next = (JfrOldObject) sample.getNext();
Expand Down Expand Up @@ -144,6 +149,7 @@ private void release(JfrOldObject sample) {
sample.reset();
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/sampling/samplePriorityQueue.cpp#L44-L53")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
private void store(Object obj, UnsignedWord span, UnsignedWord allocatedSize, int arrayLength) {
Thread thread = JavaThreads.getCurrentThreadOrNull();
Expand All @@ -166,6 +172,7 @@ void emit(long cutoff, @SuppressWarnings("unused") boolean emitAll, @SuppressWar
}
}

@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+26/src/hotspot/share/jfr/leakprofiler/checkpoint/eventEmitter.cpp#L97-L106")
@Uninterruptible(reason = CALLED_FROM_UNINTERRUPTIBLE_CODE, mayBeInlined = true)
private void emitUnchained() {
long startTicks = JfrTicks.elapsedTicks();
Expand Down