Skip to content

Commit

Permalink
[Wisp] Fix Windows and MacOS capability
Browse files Browse the repository at this point in the history
Summary: Fix build failure of the two platforms

Test Plan: Successfully generate builds of the two platforms

Reviewed-by: yuleil, shiyuexw, sanhong

Issue: dragonwell-project/dragonwell8#113
  • Loading branch information
zhengxiaolinX committed Jul 30, 2020
1 parent 13f9240 commit f79dce4
Show file tree
Hide file tree
Showing 37 changed files with 72 additions and 34 deletions.
5 changes: 5 additions & 0 deletions make/bsd/makefiles/mapfile-vers-debug
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
_JVM_Available
_JVM_BeforeHalt
_JVM_Bind
_JVM_CheckAndClearNativeInterruptForWisp
_JVM_CheckJWarmUpCompilationIsComplete
_JVM_ClassDepth
_JVM_ClassLoaderDepth
Expand Down Expand Up @@ -167,6 +168,7 @@
_JVM_GetMethodTypeAnnotations
_JVM_GetPrimitiveArrayElement
_JVM_GetProtectionDomain
_JVM_GetProxyUnpark
_JVM_GetSockName
_JVM_GetSockOpt
_JVM_GetStackAccessControlContext
Expand All @@ -190,6 +192,7 @@
_JVM_InvokeMethod
_JVM_IsArrayClass
_JVM_IsConstructorIx
_JVM_IsInSameNative
_JVM_IsInterface
_JVM_IsInterrupted
_JVM_IsNaN
Expand All @@ -207,6 +210,7 @@
_JVM_LoadClass0
_JVM_LoadLibrary
_JVM_Lseek
_JVM_MarkPreempted
_JVM_MaxObjectInspectionAge
_JVM_MaxMemory
_JVM_MonitorNotify
Expand Down Expand Up @@ -241,6 +245,7 @@
_JVM_SetNativeThreadName
_JVM_SetPrimitiveArrayElement
_JVM_SetSockOpt
_JVM_SetWispTask
_JVM_SetThreadPriority
_JVM_Sleep
_JVM_Socket
Expand Down
5 changes: 5 additions & 0 deletions make/bsd/makefiles/mapfile-vers-product
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
_JVM_Available
_JVM_BeforeHalt
_JVM_Bind
_JVM_CheckAndClearNativeInterruptForWisp
_JVM_CheckJWarmUpCompilationIsComplete
_JVM_ClassDepth
_JVM_ClassLoaderDepth
Expand Down Expand Up @@ -167,6 +168,7 @@
_JVM_GetMethodTypeAnnotations
_JVM_GetPrimitiveArrayElement
_JVM_GetProtectionDomain
_JVM_GetProxyUnpark
_JVM_GetSockName
_JVM_GetSockOpt
_JVM_GetStackAccessControlContext
Expand All @@ -190,6 +192,7 @@
_JVM_InvokeMethod
_JVM_IsArrayClass
_JVM_IsConstructorIx
_JVM_IsInSameNative
_JVM_IsInterface
_JVM_IsInterrupted
_JVM_IsNaN
Expand All @@ -207,6 +210,7 @@
_JVM_LoadClass0
_JVM_LoadLibrary
_JVM_Lseek
_JVM_MarkPreempted
_JVM_MaxObjectInspectionAge
_JVM_MaxMemory
_JVM_MonitorNotify
Expand Down Expand Up @@ -241,6 +245,7 @@
_JVM_SetNativeThreadName
_JVM_SetPrimitiveArrayElement
_JVM_SetSockOpt
_JVM_SetWispTask
_JVM_SetThreadPriority
_JVM_Sleep
_JVM_Socket
Expand Down
4 changes: 3 additions & 1 deletion src/cpu/x86/vm/assembler_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,9 @@ class Assembler : public AbstractAssembler {

// End avoid using directly


#ifdef _WINDOWS
public:
#endif
// Instruction prefixes
void prefix(Prefix p);

Expand Down
12 changes: 0 additions & 12 deletions src/os/linux/vm/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4528,18 +4528,6 @@ void os::interrupt(Thread* thread) {

}

bool clear_interrupt_for_wisp(Thread* thread) {
// If we only use -XX:+EnableCoroutine and -Dcom.alibaba.transparentAsync=true, we will
// fall here, so we cannot use `assert(UseWispMonitor)` only.
if (UseWispMonitor && thread->is_Wisp_thread()) {
thread = ((WispThread *)thread)->thread();
}
bool interrupted = thread->osthread()->interrupted();
thread->osthread()->set_interrupted(false);

return interrupted;
}

bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
if (UseWispMonitor && thread->is_Wisp_thread()) {
thread = ((WispThread*) thread)->thread();
Expand Down
2 changes: 1 addition & 1 deletion src/share/vm/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,7 @@ void com_alibaba_wisp_engine_WispCarrier::compute_offsets() {
compute_offset(_isInCritical_offset, k, vmSymbols::isInCritical_name(), vmSymbols::bool_signature());
}

bool com_alibaba_wisp_engine_WispCarrier::in_critical(oop obj) {
jboolean com_alibaba_wisp_engine_WispCarrier::in_critical(oop obj) {
return obj->bool_field(_isInCritical_offset);
}

Expand Down
2 changes: 1 addition & 1 deletion src/share/vm/classfile/javaClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1504,7 +1504,7 @@ class com_alibaba_wisp_engine_WispCarrier: AllStatic {
private:
static int _isInCritical_offset;
public:
static bool in_critical(oop obj);
static jboolean in_critical(oop obj);

static void compute_offsets();
};
Expand Down
8 changes: 8 additions & 0 deletions src/share/vm/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4130,6 +4130,14 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
}
}

#ifndef LINUX
if (EnableCoroutine || UseWispMonitor) {
warning("Wisp supports Linux only"
"; ignore Wisp related flags");
EnableCoroutine = UseWispMonitor = false;
}
#endif

// Set object alignment values.
set_object_alignment();

Expand Down
30 changes: 18 additions & 12 deletions src/share/vm/runtime/coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,12 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo);
void coroutine_start(Coroutine* coroutine, jobject coroutineObj) {
coroutine->thread()->set_thread_state(_thread_in_vm);

if (UseVectoredExceptions) {
// If we are using vectored exception we don't need to set a SEH
coroutine->run(coroutineObj);
}
else {
// Install a win32 structured exception handler around every thread created
// by VM, so VM can genrate error dump when an exception occurred in non-
// Java thread (e.g. VM thread).
__try {
coroutine->run(coroutineObj);
} __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
}
// Install a win32 structured exception handler around every thread created
// by VM, so VM can genrate error dump when an exception occurred in non-
// Java thread (e.g. VM thread).
__try {
coroutine->run(coroutineObj);
} __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
}

ShouldNotReachHere();
Expand Down Expand Up @@ -1208,3 +1202,15 @@ WispClinitCounterMark::~WispClinitCounterMark() {
_thread->current_coroutine()->dec_clinit_call_count();
}
}

bool clear_interrupt_for_wisp(Thread* thread) {
// If we only use -XX:+EnableCoroutine and -Dcom.alibaba.transparentAsync=true, we will
// fall here, so we cannot use `assert(UseWispMonitor)` only.
if (UseWispMonitor && thread->is_Wisp_thread()) {
thread = ((WispThread *)thread)->thread();
}
bool interrupted = thread->osthread()->interrupted();
thread->osthread()->set_interrupted(false);

return interrupted;
}
7 changes: 4 additions & 3 deletions src/share/vm/runtime/coroutine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class Coroutine: public CHeapObj<mtThread>, public DoublyLinkedList<Coroutine> {
void set_wisp_task(oop x) { _wisp_task = x; }

oop coroutine() const { return _coroutine; }
oop set_coroutine(oop x) { _coroutine = x; }
void set_coroutine(oop x) { _coroutine = x; }

WispThread* wisp_thread() const { return _wisp_thread; }

Expand Down Expand Up @@ -324,8 +324,7 @@ template<class T> void DoublyLinkedList<T>::insert_into_list(pointer& list) {
}
}

template<class T> void DoublyLinkedList<T>::move(DoublyLinkedList<T>::pointer &coro,
DoublyLinkedList<T>::pointer &target) {
template<class T> void DoublyLinkedList<T>::move(pointer &coro, pointer &target) {
assert(coro != NULL, "coroutine can't be null");
assert(target != NULL, "target can't be null");
assert(coro != target, "target can't be equal to current");
Expand Down Expand Up @@ -618,4 +617,6 @@ class WispClinitCounterMark : public StackObj {
JavaThread* _thread;
};

bool clear_interrupt_for_wisp(Thread *);

#endif // SHARE_VM_RUNTIME_COROUTINE_HPP
2 changes: 0 additions & 2 deletions src/share/vm/runtime/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,4 @@ class os: AllStatic {

extern "C" int SpinPause();

bool clear_interrupt_for_wisp(Thread *);

#endif // SHARE_VM_RUNTIME_OS_HPP
1 change: 1 addition & 0 deletions test/runtime/coroutine/C1ThrowSyncExceptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary test a special wisp unpark case for C1 compiled method
* @requires os.family == "linux"
* @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.transparentAsync=true -XX:TieredStopAtLevel=1 C1ThrowSyncExceptionTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/ClassCircularityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary test fix of parallel class-loading problem when we're using coroutine
* @requires os.family == "linux"
* @run main/othervm -Xmx20m -XX:+AllowParallelDefineClass -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true ClassCircularityTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/DirectUnparkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary Test the optimization of direct unpark with Object.wait/notify
* @requires os.family == "linux"
* @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.version=2 -Dcom.alibaba.wisp.allThreadAsWisp=true DirectUnparkTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/InterruptedWaitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary test obj.wait() could be interrupted
* @requires os.family == "linux"
* @library /testlibrary
* @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true InterruptedWaitTest
*/
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/Issue11230146.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -XX:-Inline -XX:+EnableCoroutine -Xmx10m -Xms10m -XX:ReservedCodeCacheSize=3m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI Issue11230146
* @summary Issue11230146, JTreg test for D181275
* @requires os.family == "linux"
*/

import sun.hotspot.WhiteBox;
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/JStackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary Test jstack steal counter
* @requires os.family == "linux"
* @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.transparentAsync=true -XX:ActiveProcessorCount=2 JStackTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/MemLeakTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary test of memory leak while creating and destroying coroutine/thread
* @requires os.family == "linux"
* @run main/othervm -XX:+EnableCoroutine -Xmx10m -Xms10m MemLeakTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/MultiCoroutineStackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary Test jstack coroutine output
* @requires os.family == "linux"
* @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.transparentAsync=true -XX:+UseWispMonitor MultiCoroutineStackTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/PreemptExceptionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary test wisp preempt
* @requires os.family == "linux"
* @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.carrierEngines=1 -Dcom.alibaba.wisp.enableHandOff=true PreemptExceptionTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/PreemptWispInternalBugTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary Verify wisp internal logic can not be preempted
* @requires os.family == "linux"
* @library /testlibrary
* @run main PreemptWispInternalBugTest
*/
Expand Down
2 changes: 1 addition & 1 deletion test/runtime/coroutine/PremainWithWispMonitorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/*
* @test
* @summary Test the fix that unpark might not be handled in WispThread::unpark due to due to WispEngine of main thread not properly been initialized in premain().
*
* @requires os.family == "linux"
* @run shell premainWithWispMonitorTest.sh
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/TestAvoidDeoptCoroutineMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -XX:+EnableCoroutine -Xmx10m -Xms10m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestAvoidDeoptCoroutineMethod
* @summary test avoid coroutine intrinsic method to be deoptimized
* @requires os.family == "linux"
*/

import sun.hotspot.WhiteBox;
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/TestInvokeDynamicInterruption.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary Test invoke dynamic class for lambda with interrupt
* @requires os.family == "linux"
* @library /testlibrary
* @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -XX:+UseWispMonitor -Dcom.alibaba.wisp.enableHandOff=false -XX:+AllowParallelDefineClass TestInvokeDynamicInterruption
*/
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/TestPreserveFramePointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary PreserveFramePointer for coroutine stack backtrace test
* @requires os.family == "linux"
* @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -Xcomp -XX:TieredStopAtLevel=1 -XX:+PreserveFramePointer TestPreserveFramePointer
* @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -Xcomp -XX:TieredStopAtLevel=1 -XX:-PreserveFramePointer TestPreserveFramePointer
* @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -Xcomp -XX:-TieredCompilation -XX:+PreserveFramePointer TestPreserveFramePointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/*
* @test
* @summary Test Wisp2 flag Compatibility
*
* @requires os.family == "linux"
* @library /testlibrary
* @run main Wisp2FlagCompatibilityCheckTest
*/
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/Wisp2SwitchTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* @test
* @summary test wisp2 switch
* @requires os.family == "linux"
* @library /testlibrary
* @run main/othervm -XX:+UseWisp2 Wisp2SwitchTest
*/
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/Wisp2SwitchTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary test XX:+UseWisp2 switch with -Dcom.alibaba.wisp.allThreadAsWisp=false
* @requires os.family == "linux"
* @library /testlibrary
* @run main/othervm -XX:+UseWisp2 -Dcom.alibaba.wisp.allThreadAsWisp=false Wisp2SwitchTest2
*/
Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/WispClinitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary test clinit wait in coroutine
* @requires os.family == "linux"
* @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true WispClinitTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/WispEmitNewGuardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @test
* @library /testlibrary
* @summary test emit_guard_for_new in C2 will add control for load
* @requires os.family == "linux"
* @run main/othervm -Xcomp -XX:-TieredCompilation -Xbatch -XX:CompileOnly=WispEmitNewGuardTest.testMethod -XX:+PrintCompilation -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true WispEmitNewGuardTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/WispPreemptBugTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary verify vm not crash when we're preempted frequently
* @requires os.family == "linux"
* @run main/othervm -XX:ActiveProcessorCount=1 -XX:+UseWisp2 WispPreemptBugTest
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/WispStealMonitorC2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/*
* @test
* @summary c2 compiler monitorenter stub steal test
* @requires os.family == "linux"
* @run main/othervm/timeout=60 -XX:+UseWisp2 -Dcom.alibaba.wisp.schedule.stealRetry=100 -Dcom.alibaba.wisp.schedule.helpStealRetry=100 WispStealMonitorC2Test
*/

Expand Down
1 change: 1 addition & 0 deletions test/runtime/coroutine/c1AssertFailTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
## @test
##
## @summary test c1 assertion failure when UseDirectUnpark is enabled (please run it in slowdebug ver.)
## @requires os.family == "linux"
## @run shell c1AssertFailTest.sh


Expand Down
Loading

0 comments on commit f79dce4

Please sign in to comment.