Skip to content

Commit

Permalink
document BasedOnJDKFile
Browse files Browse the repository at this point in the history
  • Loading branch information
roberttoyonaga committed Dec 30, 2024
1 parent 261c38a commit 787c80a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
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 @@ -33,6 +33,7 @@
import org.graalvm.nativeimage.StackValue;
import org.graalvm.word.Pointer;

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 @@ -102,6 +103,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 @@ -116,6 +118,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

0 comments on commit 787c80a

Please sign in to comment.