Skip to content

[GR-67169] Support JFR emergency dumps on out of memory #11530

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

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 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 @@ -107,6 +107,12 @@ public int strcmp(CCharPointer s1, CCharPointer s2) {
return PosixLibC.strcmp(s1, s2);
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int strncmp(CCharPointer s1, CCharPointer s2, UnsignedWord n) {
return PosixLibC.strncmp(s1, s2, n);
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int isdigit(int c) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ public final class PosixPlatformTimeUtils extends PlatformTimeUtils {
@Override
@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-24+3/src/hotspot/os/posix/os_posix.cpp#L1409-L1415")
@Uninterruptible(reason = "Must not migrate platform threads when executing on a virtual thread.")
public SecondsNanos javaTimeSystemUTC() {
public void javaTimeSystemUTC(SecondsNanos secondsNanos) {
Time.timespec ts = StackValue.get(Time.timespec.class);
int status = PosixUtils.clock_gettime(Time.CLOCK_REALTIME(), ts);
PosixUtils.checkStatusIs0(status, "javaTimeSystemUTC: clock_gettime(CLOCK_REALTIME) failed.");
return allocateSecondsNanosInterruptibly(ts.tv_sec(), ts.tv_nsec());
secondsNanos.setNanos(ts.tv_nsec());
secondsNanos.setSeconds(ts.tv_sec());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public class PosixLibC {
@CFunction(transition = CFunction.Transition.NO_TRANSITION)
public static native int strcmp(PointerBase s1, PointerBase s2);

@CFunction(transition = CFunction.Transition.NO_TRANSITION)
public static native int strncmp(PointerBase s1, PointerBase s2, UnsignedWord n);

@CFunction(transition = CFunction.Transition.NO_TRANSITION)
public static native CCharPointer strcpy(CCharPointer dst, CCharPointer src);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;
import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue;
import com.oracle.svm.core.util.BasedOnJDKFile;
import com.oracle.svm.core.util.PlatformTimeUtils;
import com.oracle.svm.core.util.PlatformTimeUtils.SecondsNanos;
Expand All @@ -41,13 +42,13 @@ final class Target_jdk_internal_misc_VM {
public static long getNanoTimeAdjustment(long offsetInSeconds) {
long maxDiffSecs = 0x0100000000L;
long minDiffSecs = -maxDiffSecs;
SecondsNanos secondsNanos = UnsafeStackValue.get(SecondsNanos.class);
PlatformTimeUtils.singleton().javaTimeSystemUTC(secondsNanos);

SecondsNanos time = PlatformTimeUtils.singleton().javaTimeSystemUTC();

long diff = time.seconds() - offsetInSeconds;
long diff = secondsNanos.getSeconds() - offsetInSeconds;
if (diff >= maxDiffSecs || diff <= minDiffSecs) {
return -1;
}
return (diff * 1000000000) + time.nanos();
return (diff * 1000000000) + secondsNanos.getNanos();
}
}
Loading