Skip to content

Commit

Permalink
Update with input from reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Oct 2, 2020
1 parent 13b4033 commit 90fb310
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
6 changes: 2 additions & 4 deletions src/hotspot/share/prims/whitebox.cpp
Expand Up @@ -2290,10 +2290,8 @@ WB_ENTRY(jboolean, WB_IsJVMTIIncluded(JNIEnv* env, jobject wb))
return INCLUDE_JVMTI ? JNI_TRUE : JNI_FALSE;
WB_END

WB_ENTRY(jboolean, WB_WaitUnsafe(JNIEnv* env, jobject wb, jint time))
SafepointStateTracker tracker = SafepointSynchronize::safepoint_state_tracker();
WB_ENTRY(void, WB_WaitUnsafe(JNIEnv* env, jobject wb, jint time))
os::naked_short_sleep(time);
return tracker.safepoint_state_changed();
WB_END

#define CC (char*)
Expand Down Expand Up @@ -2547,7 +2545,7 @@ static JNINativeMethod methods[] = {
{CC"aotLibrariesCount", CC"()I", (void*)&WB_AotLibrariesCount },
{CC"getKlassMetadataSize", CC"(Ljava/lang/Class;)I",(void*)&WB_GetKlassMetadataSize},
{CC"isJVMTIIncluded", CC"()Z", (void*)&WB_IsJVMTIIncluded},
{CC"waitUnsafe", CC"(I)Z", (void*)&WB_WaitUnsafe},
{CC"waitUnsafe", CC"(I)V", (void*)&WB_WaitUnsafe},
};


Expand Down
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -38,32 +39,19 @@
public class TestAbortVMOnSafepointTimeout {

public static void main(String[] args) throws Exception {
if (args.length > 0) {
Integer waitTime = Integer.parseInt(args[0]);
WhiteBox wb = WhiteBox.getWhiteBox();
while (!wb.waitUnsafe(waitTime)) {
System.out.println("Waiting for safepoint");
}
System.out.println("This message would occur after some time.");
} else {
testWith(50, 1, 999);
}
}

public static void testWith(int sfpt_interval, int timeout_delay, int unsafe_wait) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xbootclasspath/a:.",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:+SafepointTimeout",
"-XX:+SafepointALot",
"-XX:+AbortVMOnSafepointTimeout",
"-XX:SafepointTimeoutDelay=" + timeout_delay,
"-XX:GuaranteedSafepointInterval=" + sfpt_interval,
"-XX:SafepointTimeoutDelay=50",
"-XX:GuaranteedSafepointInterval=1",
"-XX:-CreateCoredumpOnCrash",
"-Xms64m",
"TestAbortVMOnSafepointTimeout",
"" + unsafe_wait
"TestAbortVMOnSafepointTimeout$Test",
"999" /* 999 is max unsafe sleep */
);

OutputAnalyzer output = new OutputAnalyzer(pb.start());
Expand All @@ -78,4 +66,15 @@ public static void testWith(int sfpt_interval, int timeout_delay, int unsafe_wai
}
output.shouldNotHaveExitValue(0);
}

public static class Test {
public static void main(String[] args) throws Exception {
Integer waitTime = Integer.parseInt(args[0]);
WhiteBox wb = WhiteBox.getWhiteBox();
// While no safepoint timeout.
while (true) {
wb.waitUnsafe(waitTime);
}
}
}
}
2 changes: 1 addition & 1 deletion test/lib/sun/hotspot/WhiteBox.java
Expand Up @@ -618,5 +618,5 @@ public native int validateCgroup(String procCgroups,

public native boolean isJVMTIIncluded();

public native boolean waitUnsafe(int time_ms);
public native void waitUnsafe(int time_ms);
}

0 comments on commit 90fb310

Please sign in to comment.