From 99600c72d979b2d71758b13e3774330bcb930a75 Mon Sep 17 00:00:00 2001 From: Xiaomin Date: Thu, 29 Jun 2023 11:40:45 +0800 Subject: [PATCH] [Misc] Fix bugs in previous commit. Summary: - Basic change such as naming convention or typo. - Fix wrong usage of some functions. - Add one more dereference when encouter _threadObj since it's oop* rather than oop in Java11. - Add WispThread convertion in clinit_barrier when UseWispMonitor is enabled, because ini thread is WispThread. - Pass correct current thread to ExceptionMark constructor in Runtime1::monitorexit_wisp. - Modify code in test to pass hotspot and jdk jtregs. - Fix wisp2 create property crash. - Delete control node in make_runtime_call() since it is wrong that treating control node to memory node. - Refine coroutine properties append logic(From JVM_GetProperties to Arguments::init_system_properties). - Hoist code of safepoint state out of MutexLocker to prevent safepoint deadlock problem. - Fix WispThread BarrierSet and JavaCalls assert. - Fix Thread interrupted flag in public class Thread. - Fix threadObj changed in coroutine steal. - Add more debug functions for switchTo. - Delete jniDetachThreadHoldingMonitorTest.sh, jniMonitorExitTest.sh and SelectorInitCriticalTest.java because SelectorProvider removed lock in Java17. - test/hotspot/jtreg/runtime/jni/registerNativesWarning/TestRegisterNativesWarning.java: yield() in Thread.java is not a native method after we port wisp coroutine to JDK. Thus we use currentTimeMillis() instead. - vmTestbase/nsk/monitoring/stress/thread/strace001/TestDescription.java: Add "java.lang.Thread.sleep0" and "java.lang.Thread.yield0" in expectedTrace, and let expectedLength = depth + 4. - test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java: Add sleep0 and yield0 in expectedMethods. - test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace00*.java: Add sleep0 and yield0 in EXPECTED_METHODS. - test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java and RunningThread.java: Add sleep0 and yield0 in expectedMethods. - test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java: Add 1 to expectedDepth and add function myWait to add 1 more stack frame. - test/jdk/java/beans/XMLDecoder/8028054/Task.java: Remove "java.dyn.CoroutineSupport" from fileNames. - test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java: Add "com.alibaba.coroutine.enableCoroutine" to SystemProperty. - test/jdk/com/alibaba/wisp2/Wisp2ShutdownTest.java: Change awaitTermination time to 5 seconds, because all coroutines may not terminated in 1 second. Reviewed-by: yulei Test Plan: test/hotspot/jtreg/runtime/coroutine/ test/jdk/com/alibaba/wisp test/jdk/com/alibaba/wisp2 Issue: https://github.com/dragonwell-project/dragonwell17/issues/77 --- make/modules/java.base/Copy.gmk | 16 ++-- src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 7 ++ src/hotspot/cpu/x86/interp_masm_x86.cpp | 6 +- src/hotspot/cpu/x86/macroAssembler_x86.cpp | 7 ++ src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp | 45 ++++++++--- src/hotspot/os/posix/os_posix.cpp | 14 ---- src/hotspot/share/c1/c1_Runtime1.cpp | 8 +- src/hotspot/share/classfile/javaClasses.cpp | 11 ++- .../share/classfile/systemDictionary.cpp | 32 ++++---- .../share/classfile/systemDictionary.hpp | 6 +- src/hotspot/share/gc/shared/barrierSet.cpp | 4 + .../share/interpreter/interpreterRuntime.cpp | 8 +- .../share/interpreter/interpreterRuntime.hpp | 3 + src/hotspot/share/jvmci/jvmciRuntime.cpp | 2 +- src/hotspot/share/oops/weakHandle.hpp | 2 +- src/hotspot/share/opto/graphKit.cpp | 26 +++--- src/hotspot/share/opto/graphKit.hpp | 3 +- src/hotspot/share/opto/library_call.cpp | 30 ++++++- src/hotspot/share/prims/jvm.cpp | 11 +-- .../share/prims/universalUpcallHandler.cpp | 4 +- src/hotspot/share/runtime/coroutine.cpp | 31 ++++--- src/hotspot/share/runtime/coroutine.hpp | 4 +- src/hotspot/share/runtime/handles.hpp | 1 - src/hotspot/share/runtime/javaCalls.cpp | 7 +- src/hotspot/share/runtime/mutexLocker.cpp | 8 +- src/hotspot/share/runtime/mutexLocker.hpp | 21 +++-- src/hotspot/share/runtime/objectMonitor.cpp | 54 ++++++++----- src/hotspot/share/runtime/os.hpp | 2 - src/hotspot/share/runtime/reflection.cpp | 9 +-- src/hotspot/share/runtime/sharedRuntime.cpp | 7 +- src/hotspot/share/runtime/sharedRuntime.hpp | 3 + src/hotspot/share/runtime/synchronizer.cpp | 80 ++++++++++++++----- src/hotspot/share/runtime/synchronizer.hpp | 42 ++++++---- src/hotspot/share/runtime/thread.cpp | 28 +++++-- src/hotspot/share/runtime/thread.hpp | 4 +- src/hotspot/share/runtime/vframe.hpp | 1 + src/hotspot/share/utilities/exceptions.cpp | 5 -- .../share/classes/java/dyn/CoroutineBase.java | 2 +- .../share/classes/java/lang/Thread.java | 4 +- .../classes/java/net/DatagramSocket.java | 20 +++-- .../sun/nio/ch/ServerSocketChannelImpl.java | 6 +- .../coroutine/C1ThrowSyncExceptionTest.java | 2 +- .../TestAvoidDeoptCoroutineMethod.java | 2 +- .../runtime/coroutine/TimeSliceSyncTest.java | 2 +- .../runtime/coroutine/Wisp2SwitchTest.java | 2 +- .../runtime/coroutine/Wisp2SwitchTest2.java | 2 +- .../jniDetachThreadHoldingMonitorTest.sh | 18 ----- .../runtime/coroutine/jniMonitorExitTest.sh | 19 ----- .../TestRegisterNativesWarning.java | 11 ++- .../libregisterNativesWarning.c | 7 +- .../monitoring/share/ThreadController.java | 2 + .../share/thread/RunningThread.java | 3 +- .../share/thread/SleepingThread.java | 1 + .../monitoring/stress/thread/strace001.java | 14 +++- .../nsk/share/locks/LockingThread.java | 17 +++- .../nsk/stress/strace/strace001.java | 1 + .../nsk/stress/strace/strace002.java | 1 + .../nsk/stress/strace/strace003.java | 1 + .../nsk/stress/strace/strace004.java | 1 + .../nsk/stress/strace/strace005.java | 1 + .../nsk/stress/strace/strace006.java | 1 + .../nsk/stress/strace/strace007.java | 1 + .../nsk/stress/strace/strace008.java | 1 + .../nsk/stress/strace/strace009.java | 1 + .../nsk/stress/strace/strace010.java | 1 + .../nsk/stress/strace/strace011.java | 1 + .../nsk/stress/strace/strace012.java | 1 + test/jdk/com/alibaba/wisp/ExecutionTest.java | 2 +- test/jdk/com/alibaba/wisp/IoTest.java | 2 +- test/jdk/com/alibaba/wisp/ParkTest.java | 2 +- .../alibaba/wisp/SelectorLazyCreateTest.java | 6 +- .../wisp/boot/UnsafeDependencyBugTest.java | 4 +- .../wisp/bug/CancelTimerAndSleepTest.java | 2 +- .../com/alibaba/wisp/bug/ClearEventTest.java | 2 +- .../alibaba/wisp/bug/Id2TaskMapLeakTest.java | 4 +- .../bug/ReleaseWispSocketAndExitTest.java | 2 +- .../wisp/bug/ResetTaskCancelTimerBugTest.java | 4 +- .../wisp/bug/SelectorInitCriticalTest.java | 32 -------- .../alibaba/wisp/bug/TestThreadStackTrace.sh | 6 +- .../com/alibaba/wisp/bug/ThreadLockTest.java | 4 +- .../bug/WispEngineCriticalSectionTest.java | 8 +- .../WispSocketLeakWhenConnectTimeoutTest.java | 4 +- .../wisp/env/CtxClassLoaderIsolateTest.java | 4 +- .../alibaba/wisp/io/CreateFdOnDemandTest.java | 6 +- .../alibaba/wisp/io/DatagramSocketTest.java | 6 +- .../com/alibaba/wisp/io/GlobalPollerTest.java | 6 +- .../wisp/io/ReuseUdpSocektBufTest.java | 4 +- test/jdk/com/alibaba/wisp/lock/AQSTest.java | 2 +- .../alibaba/wisp/lock/ElisionSpinTest.java | 8 +- test/jdk/com/alibaba/wisp/lock/LockTest.java | 2 +- .../wisp/lock/LockUninterruptiblyTest.java | 4 +- .../com/alibaba/wisp/lock/UnsafeParkTest.java | 4 +- .../alibaba/wisp/monitor/JNICriticalTest.java | 2 +- .../wisp/monitor/LazyUnparkBugTest.java | 2 +- .../alibaba/wisp/monitor/MultiThreadTest.java | 4 +- .../alibaba/wisp/monitor/WaitNotifyTest.java | 4 +- .../DisableThreadAsWispAtRuntimeTest.java | 6 +- .../wisp/thread/EngineExecutorTest.java | 2 +- .../wisp/thread/InterruptedSleepTest.java | 8 +- .../com/alibaba/wisp/thread/IsAliveTest.java | 6 +- .../wisp/thread/SubmittedTaskLimitTest.java | 8 +- .../alibaba/wisp/thread/ThreadAsWispTest.java | 8 +- .../alibaba/wisp/thread/ThrowErrorTest.java | 4 +- .../alibaba/wisp/thread/TimeSliceTest.java | 4 +- .../com/alibaba/wisp/thread/YieldTest.java | 4 +- .../wisp/timer/DaemonThreadGroupTest.java | 6 +- .../com/alibaba/wisp/timer/OverflowTest.java | 6 +- .../wisp/timer/PriorityQueueSortTest.java | 4 +- .../com/alibaba/wisp/timer/SleepRPCTest.java | 4 +- .../jdk/com/alibaba/wisp/timer/SleepTest.java | 4 +- .../jdk/com/alibaba/wisp/timer/TimerTest.java | 2 +- .../alibaba/wisp2/AllThreadAsWispTest.java | 6 +- .../wisp2/CtxClassLoaderInheritanceTest.java | 4 +- test/jdk/com/alibaba/wisp2/DispatchTest.java | 2 +- test/jdk/com/alibaba/wisp2/HandOffTest.java | 4 +- .../alibaba/wisp2/NioBlockingAcceptTest.java | 4 +- .../ReuseWispTaskAfterThreadJoinTest.java | 2 +- .../jdk/com/alibaba/wisp2/ThreadJoinTest.java | 2 +- .../com/alibaba/wisp2/Wisp2ShutdownTest.java | 7 +- .../alibaba/wisp2/Wisp2WaitNotifyTest.java | 4 +- .../com/alibaba/wisp2/Wisp2WorkStealTest.java | 6 +- .../jdk/com/alibaba/wisp2/Wisp2YieldTest.java | 4 +- .../wisp2/bug/ConcurrentThreadJoinTest.java | 4 +- .../wisp2/bug/DisableStealBugTest.java | 6 +- .../Wisp2ThreadObjLeakInThreadGroupTest.java | 4 +- .../java/beans/XMLDecoder/8028054/Task.java | 5 ++ test/jdk/java/dyn/BasicStealTest.java | 6 +- .../runtime/TestSystemPropertyEvent.java | 5 ++ 128 files changed, 559 insertions(+), 432 deletions(-) delete mode 100644 test/hotspot/jtreg/runtime/coroutine/jniDetachThreadHoldingMonitorTest.sh delete mode 100644 test/hotspot/jtreg/runtime/coroutine/jniMonitorExitTest.sh delete mode 100644 test/jdk/com/alibaba/wisp/bug/SelectorInitCriticalTest.java diff --git a/make/modules/java.base/Copy.gmk b/make/modules/java.base/Copy.gmk index b2ceb409d6a..b581017281d 100644 --- a/make/modules/java.base/Copy.gmk +++ b/make/modules/java.base/Copy.gmk @@ -196,6 +196,15 @@ $(NET_PROPERTIES_DST): $(NET_PROPERTIES_SRCS) TARGETS += $(NET_PROPERTIES_DST) +################################################################################ + +$(eval $(call SetupCopyFiles, COPY_WISP_PROPERTIES, \ + FILES := $(TOPDIR)/src/java.base/share/conf/wisp.properties, \ + DEST := $(CONF_DST_DIR), \ +)) + +TARGETS += $(COPY_WISP_PROPERTIES) + ifeq ($(call isTargetOs, linux), true) $(eval $(call SetupCopyFiles, COPY_SDP_CONF, \ FILES := $(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \ @@ -205,13 +214,6 @@ ifeq ($(call isTargetOs, linux), true) TARGETS += $(COPY_SDP_CONF) endif -$(eval $(call SetupCopyFiles, COPY_WISP_PROPERTIES, \ - FILES := $(TOPDIR)/src/java.base/share/conf/wisp.properties, \ - DEST := $(CONF_DST_DIR), \ -)) - -TARGETS += $(COPY_WISP_PROPERTIES) - ################################################################################ # JDK license and assembly exception files to be packaged in JMOD diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 9bc73c386d2..26feaf6a88e 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -615,7 +615,14 @@ void C2_MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmp // Propagate ICC.ZF from CAS above into DONE_LABEL. jcc(Assembler::equal, DONE_LABEL); // CAS above succeeded; propagate ZF = 1 (success) + if (UseWispMonitor) { + movptr (r15_thread, Address(r15_thread, JavaThread::current_coroutine_offset())); + movptr (r15_thread, Address(r15_thread, Coroutine::wisp_thread_offset())); + } cmpptr(r15_thread, rax); // Check if we are already the owner (recursive lock) + if (UseWispMonitor) { + movptr (r15_thread, Address(r15_thread, WispThread::thread_offset())); + } jcc(Assembler::notEqual, DONE_LABEL); // If not recursive, ZF = 0 at this point (fail) incq(Address(scrReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(recursions))); xorq(rax, rax); // Set ZF = 1 (success) for recursive lock, denoting locking success diff --git a/src/hotspot/cpu/x86/interp_masm_x86.cpp b/src/hotspot/cpu/x86/interp_masm_x86.cpp index 16550f78bd4..77f02d94bc9 100644 --- a/src/hotspot/cpu/x86/interp_masm_x86.cpp +++ b/src/hotspot/cpu/x86/interp_masm_x86.cpp @@ -817,11 +817,11 @@ void InterpreterMacroAssembler::jump_from_interpreted(Register method, Register cmpb(Address(temp, JavaThread::interp_only_mode_offset()), 0); jccb(Assembler::zero, run_compiled_code); if (EnableCoroutine) { - cmpq(Address(method, Method::intrinsic_id_offset_in_bytes()), (int)vmIntrinsics::_switchTo); + cmpq(Address(method, Method::intrinsic_id_offset_in_bytes()), (int32_t)vmIntrinsics::_switchTo); jcc(Assembler::zero, coroutine_skip_interpret); - cmpq(Address(method, Method::intrinsic_id_offset_in_bytes()), (int)vmIntrinsics::_switchToAndExit); + cmpq(Address(method, Method::intrinsic_id_offset_in_bytes()), (int32_t)vmIntrinsics::_switchToAndExit); jcc(Assembler::zero, coroutine_skip_interpret); - cmpq(Address(method, Method::intrinsic_id_offset_in_bytes()), (int)vmIntrinsics::_switchToAndTerminate); + cmpq(Address(method, Method::intrinsic_id_offset_in_bytes()), (int32_t)vmIntrinsics::_switchToAndTerminate); jcc(Assembler::zero, coroutine_skip_interpret); } jmp(Address(method, Method::interpreter_entry_offset())); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 7fb116aec13..ded490b354a 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -4161,8 +4161,15 @@ void MacroAssembler::clinit_barrier(Register klass, Register thread, Label* L_fa cmpb(Address(klass, InstanceKlass::init_state_offset()), InstanceKlass::fully_initialized); jcc(Assembler::equal, *L_fast_path); + if (UseWispMonitor) { + movptr(thread, Address(thread, JavaThread::current_coroutine_offset())); + movptr(thread, Address(thread, Coroutine::wisp_thread_offset())); + } // Fast path check: current thread is initializer thread cmpptr(thread, Address(klass, InstanceKlass::init_thread_offset())); + if (UseWispMonitor) { + movptr(thread, Address(thread, WispThread::thread_offset())); + } if (L_slow_path == &L_fallthrough) { jcc(Assembler::equal, *L_fast_path); bind(*L_slow_path); diff --git a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp index 649a4dec9cf..a880c31f787 100644 --- a/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp +++ b/src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp @@ -1531,7 +1531,11 @@ static void gen_special_dispatch(MacroAssembler* masm, receiver_reg, member_reg, /*for_compiler_entry:*/ true); } -void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_maps, int &stack_slots, int total_in_args, BasicType *in_sig_bt, VMRegPair *in_regs, BasicType ret_type, bool terminate); +void create_switchTo_contents(MacroAssembler *masm, int start, + OopMapSet* oop_maps, int &stack_slots, + int total_in_args, BasicType *in_sig_bt, VMRegPair *in_regs, + BasicType ret_type, bool terminate, + int total_c_args, VMRegPair *out_regs); void generate_thread_fix(MacroAssembler *masm, Method *method) { // we can have a check here at the codegen time, so no cost in runtime. @@ -1823,10 +1827,14 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, if (EnableCoroutine) { // the coroutine support methods have a hand-coded fast version that will handle the most common cases if (method->intrinsic_id() == vmIntrinsics::_switchTo) { - create_switchTo_contents(masm, start, oop_maps, stack_slots, total_in_args, in_sig_bt, in_regs, ret_type, false); + create_switchTo_contents(masm, start, oop_maps, stack_slots, + total_in_args, in_sig_bt, in_regs, ret_type, false, + total_c_args, out_regs); } else if (method->intrinsic_id() == vmIntrinsics::_switchToAndTerminate || method->intrinsic_id() == vmIntrinsics::_switchToAndExit) { - create_switchTo_contents(masm, start, oop_maps, stack_slots, total_in_args, in_sig_bt, in_regs, ret_type, true); + create_switchTo_contents(masm, start, oop_maps, stack_slots, + total_in_args, in_sig_bt, in_regs, ret_type, true, + total_c_args, out_regs); } } @@ -3991,8 +3999,24 @@ MacroAssembler* debug_line(MacroAssembler* masm, int l) { return masm; } +static const int64_t invalid_val = 0x500000005L; +void crash_if_reg_invalid(MacroAssembler *masm, Register reg, int loc) { + Label skip; + __ cmp64(reg, ExternalAddress((address)&invalid_val)); + __ jcc(Assembler::notEqual, skip); + __ movptr(Address(reg, (ByteSize)loc), (intptr_t)loc); + __ bind(skip); +} + +void trace_switch(MacroAssembler *masm, Register reg, int total_c_args, VMRegPair *out_regs) { + save_args(masm, total_c_args, 0, out_regs); + __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::coroutine_switch_trace), r15_thread, reg); + restore_args(masm, total_c_args, 0, out_regs); +} + void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_maps, int &stack_slots, int total_in_args, - BasicType *in_sig_bt, VMRegPair *in_regs, BasicType ret_type, bool terminate) { + BasicType *in_sig_bt, VMRegPair *in_regs, BasicType ret_type, bool terminate, + int total_c_args, VMRegPair *out_regs) { assert(total_in_args == 2, "wrong number of arguments"); if (j_rarg0 != rsi) { @@ -4033,7 +4057,6 @@ void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_ma DEBUG_ONLY(stop_if_null(masm, old_coroutine_obj, "null old_coroutine")); __ movptr(old_coroutine, Address(old_coroutine_obj, java_dyn_CoroutineBase::get_data_offset())); DEBUG_ONLY(stop_if_null(masm, old_coroutine, "old_coroutine without data")); - __ movptr(old_stack, Address(old_coroutine, Coroutine::stack_offset())); #if defined(_WINDOWS) // rescue the SEH pointer @@ -4059,14 +4082,18 @@ void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_ma __ movptr(Address(old_coroutine, Coroutine::last_Java_pc_offset()), temp); __ movptr(temp, Address(thread, JavaThread::last_Java_sp_offset())); __ movptr(Address(old_coroutine, Coroutine::last_Java_sp_offset()), temp); - // __ movptr(temp, Address(thread, JavaThread::privileged_stack_top_offset())); - // __ movptr(Address(old_coroutine, Coroutine::privileged_stack_top_offset()), temp); __ movptr(temp, Address(thread, JavaThread::threadObj_offset())); + // Now temp is JavaThread::_threadObj. + // In Java17, JavaThread::_threadObj is oop* while Java11 stores JavaThread::_threadObj as oop. + // So we dereference temp here to get the target JavaThread oop. + __ movptr(temp, Address(temp, 0)); __ movl(temp, Address(temp, java_lang_Thread::thread_status_offset())); __ movl(Address(old_coroutine, Coroutine::thread_status_offset()), temp); __ movl(temp, Address(thread, JavaThread::java_call_counter_offset())); __ movl(Address(old_coroutine, Coroutine::java_call_counter_offset()), temp); + // store rsp into CorotineStack + __ movptr(old_stack, Address(old_coroutine, Coroutine::stack_offset())); __ movptr(Address(old_stack, CoroutineStack::last_sp_offset()), rsp); } Register target_stack = r12; @@ -4100,10 +4127,10 @@ void create_switchTo_contents(MacroAssembler *masm, int start, OopMapSet* oop_ma __ movptr(Address(thread, JavaThread::last_Java_pc_offset()), temp); __ movptr(temp, Address(target_coroutine, Coroutine::last_Java_sp_offset())); __ movptr(Address(thread, JavaThread::last_Java_sp_offset()), temp); - // __ movptr(temp, Address(target_coroutine, Coroutine::privileged_stack_top_offset())); - // __ movptr(Address(thread, JavaThread::privileged_stack_top_offset()), temp); __ movl(temp2, Address(target_coroutine, Coroutine::thread_status_offset())); __ movptr(temp, Address(thread, JavaThread::threadObj_offset())); + // Dereference temp here to get the target JavaThread oop. + __ movptr(temp, Address(temp, 0)); __ movl(Address(temp, java_lang_Thread::thread_status_offset()), temp2); __ movl(temp, Address(target_coroutine, Coroutine::java_call_counter_offset())); __ movl(Address(thread, JavaThread::java_call_counter_offset()), temp); diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 8bb484c4ac8..5c34a30a07d 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -24,7 +24,6 @@ #include "jvm.h" -#include "memory/allocation.hpp" #ifdef LINUX #include "classfile/classLoader.hpp" #endif @@ -876,19 +875,6 @@ void os::naked_short_sleep(jlong ms) { return; } -bool clear_interrupt_for_wisp(Thread* thread) { - assert(EnableCoroutine, "Coroutine is disabled"); - // 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 = ((JavaThread*) thread->as_Java_thread())->is_interrupted(false); - thread->osthread()->set_interrupted(false); - - return interrupted; -} - char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) { size_t stack_size = 0; size_t guard_size = 0; diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index 351204ac829..77f16cc93e5 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/hotspot/share/c1/c1_Runtime1.cpp @@ -716,8 +716,8 @@ JRT_END JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorexit_wisp(JavaThread* current, BasicObjectLock* lock)) NOT_PRODUCT(_monitorexit_slowcase_cnt++;) assert(UseWispMonitor, "UseWispMonitor is off"); - JavaThread* thread_tmp = NULL; - ExceptionMark __em(thread_tmp); + assert(current == Thread::current(), "sanity check"); + ExceptionMark em(current); oop obj = lock->obj(); // Almost a copy from Runtime1::monitorexit, // excpet that handles are used to access objects. @@ -733,7 +733,7 @@ JRT_END // 3. There is no exception handler in this method, So it needs to unwind to its caller // 4. GC happened during unpark // This path will not call Java, so JRT_LEAF is used. -JRT_LEAF(void, Runtime1::monitorexit_wisp_proxy(JavaThread* thread, BasicObjectLock* lock)) +JRT_LEAF(void, Runtime1::monitorexit_wisp_proxy(JavaThread* current, BasicObjectLock* lock)) NOT_PRODUCT(_monitorexit_slowcase_cnt++;) assert(UseWispMonitor, "UseWispMonitor is off"); EXCEPTION_MARK; @@ -741,7 +741,7 @@ JRT_LEAF(void, Runtime1::monitorexit_wisp_proxy(JavaThread* thread, BasicObjectL assert(oopDesc::is_oop(obj), "must be NULL or an object"); // Setting _is_proxy_unpark of current wisp thread to true. // Proxy unpark will be used when this flag is true. - WispThread* wisp_thread = WispThread::current(thread); + WispThread* wisp_thread = WispThread::current(current); wisp_thread->set_proxy_unpark_flag(); // When using fast locking, the compiled code has already tried the fast case ObjectSynchronizer::exit(obj, lock->lock(), THREAD); diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index e0802196c1a..ef995e01fc5 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -4755,9 +4755,9 @@ void java_dyn_CoroutineBase::set_data(oop obj, jlong value) { int com_alibaba_wisp_engine_WispEngine::_isInCritical_offset = 0; void com_alibaba_wisp_engine_WispEngine::compute_offsets() { - Klass* k = vmClasses::com_alibaba_wisp_engine_WispEngine_klass(); - assert(k != NULL, "WispEngine_klass is null"); - compute_offset(_isInCritical_offset, InstanceKlass::cast(k), vmSymbols::isInCritical_name(), vmSymbols::bool_signature()); + InstanceKlass* ik = vmClasses::com_alibaba_wisp_engine_WispEngine_klass(); + assert(ik != NULL, "WispEngine_klass is null"); + compute_offset(_isInCritical_offset, ik, vmSymbols::isInCritical_name(), vmSymbols::bool_signature()); } bool com_alibaba_wisp_engine_WispEngine::in_critical(oop obj) { @@ -4773,9 +4773,8 @@ int com_alibaba_wisp_engine_WispTask::_stealCount_offset = 0; int com_alibaba_wisp_engine_WispTask::_stealFailureCount_offset = 0; void com_alibaba_wisp_engine_WispTask::compute_offsets() { - Klass* k = vmClasses::com_alibaba_wisp_engine_WispTask_klass(); - assert(k != NULL, "WispTask_klass is null"); - InstanceKlass *ik = InstanceKlass::cast(k); + InstanceKlass* ik = vmClasses::com_alibaba_wisp_engine_WispTask_klass(); + assert(ik != NULL, "WispTask_klass is null"); compute_offset(_jvmParkStatus_offset, ik, vmSymbols::jvmParkStatus_name(), vmSymbols::int_signature()); compute_offset(_id_offset, ik, vmSymbols::id_name(), vmSymbols::int_signature()); compute_offset(_threadWrapper_offset, ik, vmSymbols::threadWrapper_name(), vmSymbols::thread_signature()); diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index cf6a44483a1..4d0cee4f0d4 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -224,7 +224,7 @@ Symbol* SystemDictionary::class_name_symbol(const char* name, Symbol* exception, #ifdef ASSERT // Used to verify that class loading succeeded in adding k to the dictionary. void verify_dictionary_entry(Symbol* class_name, InstanceKlass* k) { - SystemDictLocker mu(SystemDictionary_lock); + SystemDictLocker mu(JavaThread::current(), SystemDictionary_lock); ClassLoaderData* loader_data = k->class_loader_data(); Dictionary* dictionary = loader_data->dictionary(); assert(class_name == k->name(), "Must be the same"); @@ -470,7 +470,7 @@ InstanceKlass* SystemDictionary::resolve_super_or_fail(Symbol* class_name, // // The notify allows applications that did an untimed wait() on // the classloader object lock to not hang. -static void double_lock_wait(SystemDictLocker *mu, JavaThread* thread, Handle lockObject) { +static void double_lock_wait(JavaThread* thread, SystemDictLocker *mu, Handle lockObject) { assert_lock_strong(SystemDictionary_lock); assert(lockObject() != NULL, "lockObject must be non-NULL"); @@ -520,7 +520,8 @@ InstanceKlass* SystemDictionary::handle_parallel_loading(JavaThread* current, Symbol* name, ClassLoaderData* loader_data, Handle lockObject, - bool* throw_circularity_error) { + bool* throw_circularity_error, + SystemDictLocker* mu) { PlaceholderEntry* oldprobe = placeholders()->get_entry(name_hash, name, loader_data); if (oldprobe != NULL) { // only need check_seen_thread once, not on each loop @@ -549,11 +550,10 @@ InstanceKlass* SystemDictionary::handle_parallel_loading(JavaThread* current, // which we will find below in the systemDictionary. oldprobe = NULL; // Other thread could delete this placeholder entry - SystemDictLocker mu(JavaThread::current(), SystemDictionary_lock); if (lockObject.is_null()) { - mu.wait(); + mu->wait(); } else { - double_lock_wait(&mu, current, lockObject); + double_lock_wait(current, mu, lockObject); } // Check if classloading completed while we were waiting @@ -689,7 +689,8 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, name, loader_data, lockObject, - &throw_circularity_error); + &throw_circularity_error, + &mu); } // Recheck if the class has been loaded for all class loader cases and @@ -732,7 +733,7 @@ InstanceKlass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, // and initiating loaders SystemDictLocker mu(THREAD, SystemDictionary_lock); placeholders()->find_and_remove(name_hash, name, loader_data, PlaceholderTable::LOAD_INSTANCE, THREAD); - SystemDictionary_lock->notify_all(THREAD); + mu.notify_all(); } } @@ -1514,7 +1515,7 @@ InstanceKlass* SystemDictionary::find_or_define_helper(Symbol* class_name, Handl if (is_parallelDefine(class_loader) && (probe->instance_klass() != NULL)) { InstanceKlass* ik = probe->instance_klass(); placeholders()->find_and_remove(name_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); - SystemDictionary_lock->notify_all(THREAD); + mu.notify_all(); #ifdef ASSERT InstanceKlass* check = dictionary->find_class(name_hash, name_h); assert(check != NULL, "definer missed recording success"); @@ -1538,7 +1539,7 @@ InstanceKlass* SystemDictionary::find_or_define_helper(Symbol* class_name, Handl } probe->set_definer(NULL); placeholders()->find_and_remove(name_hash, name_h, loader_data, PlaceholderTable::DEFINE_CLASS, THREAD); - SystemDictionary_lock->notify_all(THREAD); + mu.notify_all(); } return HAS_PENDING_EXCEPTION ? NULL : k; @@ -1606,7 +1607,7 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer) { MutexLocker ml2(is_concurrent ? Module_lock : NULL); JFR_ONLY(Jfr::on_unloading_classes();) - SystemDictLocker ml1(JavaThread::current(), is_concurrent ? SystemDictionary_lock : NULL); + GCSystemDictLocker ml1(is_concurrent ? SystemDictionary_lock : NULL); ClassLoaderDataGraph::clean_module_and_package_info(); constraints()->purge_loader_constraints(); resolution_errors()->purge_resolution_errors(); @@ -1777,7 +1778,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( if (t != T_OBJECT) { klass = Universe::typeArrayKlassObj(t); } else { - SystemDictLocker mu(JavaThread::current(), SystemDictionary_lock); + SystemDictLocker mu((JavaThread*)current, SystemDictionary_lock); klass = constraints()->find_constrained_klass(ss.as_symbol(), class_loader); } // If element class already loaded, allocate array klass @@ -1785,7 +1786,7 @@ Klass* SystemDictionary::find_constrained_instance_or_array_klass( klass = klass->array_klass_or_null(ndims); } } else { - SystemDictLocker mu(JavaThread::current(), SystemDictionary_lock); + SystemDictLocker mu((JavaThread*)current, SystemDictionary_lock); // Non-array classes are easy: simply check the constraint table. klass = constraints()->find_constrained_klass(class_name, class_loader); } @@ -2488,8 +2489,3 @@ void SystemDictionaryDCmd::execute(DCmdSource source, TRAPS) { _verbose.value()); VMThread::execute(&dumper); } - -void SystemDictionary::system_dict_lock_change(JavaThread* THREAD) { - assert(UseWispMonitor, "UseWispMonitor is off"); - SystemDictionary_lock->set_obj_lock(oopFactory::new_intArray(0, THREAD), THREAD); -} diff --git a/src/hotspot/share/classfile/systemDictionary.hpp b/src/hotspot/share/classfile/systemDictionary.hpp index 11dd5dc081a..787ea5baa51 100644 --- a/src/hotspot/share/classfile/systemDictionary.hpp +++ b/src/hotspot/share/classfile/systemDictionary.hpp @@ -334,7 +334,8 @@ class SystemDictionary : AllStatic { Symbol* name, ClassLoaderData* loader_data, Handle lockObject, - bool* throw_circularity_error); + bool* throw_circularity_error, + SystemDictLocker *mu); static void define_instance_class(InstanceKlass* k, Handle class_loader, TRAPS); static InstanceKlass* find_or_define_helper(Symbol* class_name, @@ -416,9 +417,6 @@ class SystemDictionary : AllStatic { static TableStatistics placeholders_statistics(); static TableStatistics loader_constraints_statistics(); static TableStatistics protection_domain_cache_statistics(); - -public: - static void system_dict_lock_change(TRAPS); }; #endif // SHARE_CLASSFILE_SYSTEMDICTIONARY_HPP diff --git a/src/hotspot/share/gc/shared/barrierSet.cpp b/src/hotspot/share/gc/shared/barrierSet.cpp index 614011827f4..c50b192e639 100644 --- a/src/hotspot/share/gc/shared/barrierSet.cpp +++ b/src/hotspot/share/gc/shared/barrierSet.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetAssembler.hpp" +#include "runtime/coroutine.hpp" #include "runtime/thread.hpp" #include "utilities/debug.hpp" #include "utilities/macros.hpp" @@ -47,6 +48,9 @@ void BarrierSet::set_barrier_set(BarrierSet* barrier_set) { assert(!JavaThread::current()->on_thread_list(), "Main thread already on thread list."); _barrier_set->on_thread_create(Thread::current()); + if (UseWispMonitor) { + _barrier_set->on_thread_create(WispThread::current(Thread::current())); + } } // Called from init.cpp diff --git a/src/hotspot/share/interpreter/interpreterRuntime.cpp b/src/hotspot/share/interpreter/interpreterRuntime.cpp index e9d68d12b77..6f4e05d8a56 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.cpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp @@ -590,6 +590,9 @@ JRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* current) // nothing to do - eventually we should remove this code entirely (see comments @ call sites) JRT_END +JRT_ENTRY(void, InterpreterRuntime::print_site(JavaThread* current, void* arg0, void* arg1)) + assert(current->has_pending_exception(), "must only be called if there's an exception pending"); +JRT_END JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* current)) THROW(vmSymbols::java_lang_AbstractMethodError()); @@ -732,10 +735,9 @@ JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* current, B if (PrintBiasedLockingStatistics) { Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); } - - Thread* t = THREAD; + // thread steal support - WispPostStealHandleUpdateMark w(current, t, __tiv, __hm); + WispPostStealHandleUpdateMark w(current, (Thread *&)THREAD, __tiv, __hm); // Coroutine work steal support EnableStealMark p(THREAD); diff --git a/src/hotspot/share/interpreter/interpreterRuntime.hpp b/src/hotspot/share/interpreter/interpreterRuntime.hpp index c32431784aa..77ef7a6e093 100644 --- a/src/hotspot/share/interpreter/interpreterRuntime.hpp +++ b/src/hotspot/share/interpreter/interpreterRuntime.hpp @@ -94,6 +94,9 @@ class InterpreterRuntime: AllStatic { static void throw_pending_exception(JavaThread* current); static void resolve_from_cache(JavaThread* current, Bytecodes::Code bytecode); + + static void print_site(JavaThread* current, void* arg0, void* arg1); + private: // Statics & fields static void resolve_get_put(JavaThread* current, Bytecodes::Code bytecode); diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index aca748d2442..4953f324f34 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -392,7 +392,7 @@ address JVMCIRuntime::exception_handler_for_pc(JavaThread* current) { } JRT_BLOCK_ENTRY(void, JVMCIRuntime::monitorenter(JavaThread* current, oopDesc* obj, BasicLock* lock)) -WispPostStealHandleUpdateMark w(__hm); + WispPostStealHandleUpdateMark w(__hm); SharedRuntime::monitor_enter_helper(obj, lock, current); JRT_END diff --git a/src/hotspot/share/oops/weakHandle.hpp b/src/hotspot/share/oops/weakHandle.hpp index c2b589958d2..df6a9fef37f 100644 --- a/src/hotspot/share/oops/weakHandle.hpp +++ b/src/hotspot/share/oops/weakHandle.hpp @@ -26,7 +26,7 @@ #define SHARE_OOPS_WEAKHANDLE_HPP #include "oops/oop.hpp" -#include "runtime/handles.hpp" +#include "runtime/handles.inline.hpp" class outputStream; class OopStorage; diff --git a/src/hotspot/share/opto/graphKit.cpp b/src/hotspot/share/opto/graphKit.cpp index b50e7abb870..0a8552c7a29 100644 --- a/src/hotspot/share/opto/graphKit.cpp +++ b/src/hotspot/share/opto/graphKit.cpp @@ -2625,8 +2625,7 @@ Node* GraphKit::make_runtime_call(int flags, Node* parm0, Node* parm1, Node* parm2, Node* parm3, Node* parm4, Node* parm5, - Node* parm6, Node* parm7, - Node* ctrl) { + Node* parm6, Node* parm7) { assert(call_addr != NULL, "must not call NULL targets"); // Slow-path call @@ -2657,7 +2656,7 @@ Node* GraphKit::make_runtime_call(int flags, Node* prev_mem = NULL; if (wide_in) { - prev_mem = set_predefined_input_for_runtime_call(call, ctrl); + prev_mem = set_predefined_input_for_runtime_call(call); } else { assert(!wide_out, "narrow in => narrow out"); Node* narrow_mem = memory(adr_type); @@ -3663,9 +3662,7 @@ void GraphKit::make_wisp_yield(ciMethod* method) { Node* mark_preempt_addr = __ AddP(no_base, tls, __ ConX(mark_offset)); Node* mark_preempt_val = __ load(__ ctrl(), mark_preempt_addr, TypeInt::BYTE, T_BYTE, Compile::AliasIdxRaw); Node* zero = __ ConI(0); - const TypeFunc *call_type = OptoRuntime::yield_method_exit_Type(); - address call_address = CAST_FROM_FN_PTR(address, SharedRuntime::wisp_yield); - const char *call_name = "wisp_yield"; + // Get base of thread-local storage area Node* thread = _gvn.transform( new ThreadLocalNode() ); @@ -3676,17 +3673,16 @@ void GraphKit::make_wisp_yield(ciMethod* method) { kill_dead_locals(); // For some reason, this call reads only raw memory. - const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; __ if_then(mark_preempt_val, BoolTest::ne, zero) ; { - // Totally 8 parameters, 2 used, 6 NULL + // Totally 8 parameters, 2 used, 6 NULL. + // make_runtime_call itself would set control node, so + // we should never pass control node here. Node* call = make_runtime_call(RC_NARROW_MEM, - call_type, call_address, - call_name, raw_adr_type, - thread, method_node, - NULL, NULL, NULL, - NULL, NULL, NULL, - __ ctrl()); - __ set_ctrl( _gvn.transform( new ProjNode(call, TypeFunc::Control))); + OptoRuntime::yield_method_exit_Type(), + CAST_FROM_FN_PTR(address, SharedRuntime::wisp_yield), + "wisp_yield", + TypeRawPtr::BOTTOM, + thread, method_node); } __ end_if(); final_sync(ideal); } diff --git a/src/hotspot/share/opto/graphKit.hpp b/src/hotspot/share/opto/graphKit.hpp index 422adf1c23e..1ab68efe8e8 100644 --- a/src/hotspot/share/opto/graphKit.hpp +++ b/src/hotspot/share/opto/graphKit.hpp @@ -803,8 +803,7 @@ class GraphKit : public Phase { Node* parm0 = NULL, Node* parm1 = NULL, Node* parm2 = NULL, Node* parm3 = NULL, Node* parm4 = NULL, Node* parm5 = NULL, - Node* parm6 = NULL, Node* parm7 = NULL, - Node* ctrl = NULL); + Node* parm6 = NULL, Node* parm7 = NULL); void make_wisp_yield(ciMethod* method); Node* sign_extend_byte(Node* in); diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index b5970545c4e..c84fc886db5 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -870,9 +870,35 @@ Node* LibraryCallKit::generate_current_thread(Node* &tls_output) { Node* thread = _gvn.transform(new ThreadLocalNode()); Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::threadObj_offset())); tls_output = thread; - Node* thread_obj_handle = LoadNode::make(_gvn, NULL, immutable_memory(), p, p->bottom_type()->is_ptr(), TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); + + Node* thread_obj_handle = NULL; + DecoratorSet decorators = IN_NATIVE; + // threadObj oop is linked to JavaThread by oopstorage at Java17 while it is + // linked to JavaThread as oop at java11. Java11 always refetches threadObj + // because oop may be moved by GC. In theory, Java17 also should always + // refetch threadObj. But threadObj refetch by oopstorage is a little + // expensive because oopstorage needs one more dereference. To save cost, + // Java17 current_thread inline caches the oopstorage address because + // oopstorage address is never changed during the method in thread semantic. + // threadObj oop refech can be speed up if oopstorage address is cached + // because we need not to refetch oopstorage address from r15_thread. We + // can get threadObj directly from the cached oopstorage address. + // In the middle of method execution, the underly thread is never changed and + // oopstorage caching is a good optimization for thread semantic. + // But in coroutine semantic, one method may be executed by different + // underly threads. The oopstorage caching may lead to wrong results + // because of coroutine stealing machanism. So in coroutine mode, we should + // never cache oopstorage to speed up threadObj refetch. + if (EnableCoroutine) { + // if enable coroutine, we should use make_load to avoid threadObj changed + thread_obj_handle = make_load(nullptr, p, p->bottom_type()->is_ptr(), T_ADDRESS, MemNode::unordered); + } else { + thread_obj_handle = LoadNode::make(_gvn, NULL, immutable_memory(), p, p->bottom_type()->is_ptr(), TypeRawPtr::NOTNULL, T_ADDRESS, MemNode::unordered); + decorators |= C2_IMMUTABLE_MEMORY; + } + thread_obj_handle = _gvn.transform(thread_obj_handle); - return access_load(thread_obj_handle, thread_type, T_OBJECT, IN_NATIVE | C2_IMMUTABLE_MEMORY); + return access_load(thread_obj_handle, thread_type, T_OBJECT, decorators); } diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 1f48f7fa299..beaf32c6521 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -607,8 +607,7 @@ JVM_ENTRY(void, JVM_MonitorWait(JNIEnv* env, jobject handle, jlong ms)) Handle obj(THREAD, JNIHandles::resolve_non_null(handle)); JavaThreadInObjectWaitState jtiows(thread, ms != 0); - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(thread, t, env, __tiv, __hm, &jtiows); + WispPostStealHandleUpdateMark w(thread, (Thread *&)THREAD, env, __tiv, __hm, &jtiows); // Coroutine work steal support EnableStealMark p(THREAD); @@ -3119,7 +3118,7 @@ JVM_ENTRY(jboolean, JVM_CheckAndClearNativeInterruptForWisp(JNIEnv* env, jobject assert(EnableCoroutine, "Coroutine is disabled"); JavaThread *th = java_lang_Thread::thread(JNIHandles::resolve_non_null(jthread)); if (th != NULL) { - return (jboolean)clear_interrupt_for_wisp(th); + return (jboolean)(th->clear_interrupt_for_wisp()); } else { return (jboolean)false; } @@ -3514,8 +3513,7 @@ jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, JVM_ENTRY(jobject, JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0)) // Coroutine work steal support - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(thread, t, env, __tiv, __hm); + WispPostStealHandleUpdateMark w(thread, (Thread *&)THREAD, env, __tiv, __hm); Handle method_handle; if (thread->stack_overflow_state()->stack_available((address) &method_handle) >= JVMInvokeMethodSlack) { @@ -3542,8 +3540,7 @@ JVM_END JVM_ENTRY(jobject, JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0)) // Coroutine work steal support - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(thread, t, env, __tiv, __hm); + WispPostStealHandleUpdateMark w(thread, (Thread *&)THREAD, env, __tiv, __hm); oop constructor_mirror = JNIHandles::resolve(c); objArrayHandle args(THREAD, objArrayOop(JNIHandles::resolve(args0))); diff --git a/src/hotspot/share/prims/universalUpcallHandler.cpp b/src/hotspot/share/prims/universalUpcallHandler.cpp index 44b64504d1c..993b7a03a6b 100644 --- a/src/hotspot/share/prims/universalUpcallHandler.cpp +++ b/src/hotspot/share/prims/universalUpcallHandler.cpp @@ -108,7 +108,7 @@ JavaThread* ProgrammableUpcallHandler::on_entry(OptimizedEntryBlob::FrameData* c context->jfa.copy(thread->frame_anchor()); thread->frame_anchor()->clear(); - debug_only(thread->inc_java_call_counter()); + thread->inc_java_call_counter(); thread->set_active_handles(context->new_handles); // install new handle block and reset Java frame linkage // clear any pending exception in thread (native calls start with no exception pending) @@ -133,7 +133,7 @@ void ProgrammableUpcallHandler::on_exit(OptimizedEntryBlob::FrameData* context) thread->frame_anchor()->zap(); - debug_only(thread->dec_java_call_counter()); + thread->dec_java_call_counter(); // Old thread-local info. has been restored. We are now back in native code. ThreadStateTransition::transition_from_java(thread, _thread_in_native); diff --git a/src/hotspot/share/runtime/coroutine.cpp b/src/hotspot/share/runtime/coroutine.cpp index de6514612b7..640595e616d 100644 --- a/src/hotspot/share/runtime/coroutine.cpp +++ b/src/hotspot/share/runtime/coroutine.cpp @@ -23,7 +23,6 @@ */ #include "precompiled.hpp" -//#include "prims/privilegedStack.hpp" #include "classfile/vmSymbols.hpp" #include "interpreter/linkResolver.hpp" #include "runtime/coroutine.hpp" @@ -128,7 +127,6 @@ Coroutine* Coroutine::create_thread_coroutine(JavaThread* thread, CoroutineStack #if defined(_WINDOWS) coro->_last_SEH = NULL; #endif - // coro->_privileged_stack_top = NULL; coro->_wisp_thread = UseWispMonitor ? new WispThread(coro) : NULL; coro->_wisp_engine = NULL; coro->_wisp_task = NULL; @@ -177,7 +175,6 @@ Coroutine* Coroutine::create_coroutine(JavaThread* thread, CoroutineStack* stack #if defined(_WINDOWS) coro->_last_SEH = NULL; #endif - // coro->_privileged_stack_top = NULL; coro->_wisp_thread = UseWispMonitor ? new WispThread(coro) : NULL; coro->_wisp_engine = NULL; coro->_wisp_task = NULL; @@ -246,9 +243,6 @@ void Coroutine::oops_do(OopClosure* f, CodeBlobClosure* cf) { DEBUG_CORO_ONLY(tty->print_cr("collecting handle area %08x", _handle_area)); _handle_area->oops_do(f); _active_handles->oops_do(f); - // if (_privileged_stack_top != NULL) { - // _privileged_stack_top->oops_do(f); - // } } if (_wisp_task != NULL) { f->do_oop((oop*) &_wisp_engine); @@ -332,7 +326,7 @@ CoroutineStack* CoroutineStack::create_stack(JavaThread* thread, intptr_t size/* default_size = true; } - uint reserved_pages = StackShadowPages + StackRedPages + StackYellowPages + + StackReservedPages; + uint reserved_pages = StackShadowPages + StackRedPages + StackYellowPages + StackReservedPages; uintx real_stack_size = size + (reserved_pages * os::vm_page_size()); uintx reserved_size = align_up(real_stack_size, os::vm_allocation_granularity()); @@ -475,17 +469,17 @@ void WispThread::set_wisp_booted(JavaThread* thread) { LinkInfo link_info(vmClasses::com_alibaba_wisp_engine_WispTask_klass(), vmSymbols::park_name(), vmSymbols::long_void_signature()); LinkResolver::resolve_static_call(callinfo, link_info, true, thread); parkMethod = callinfo.selected_method(); - assert(parkMethod.not_null(), "should have thrown exception"); + assert(parkMethod != NULL, "should have thrown exception"); LinkInfo link_info_unpark(vmClasses::com_alibaba_wisp_engine_WispTask_klass(), vmSymbols::unparkById_name(), vmSymbols::int_void_signature()); LinkResolver::resolve_static_call(callinfo, link_info_unpark, true, thread); unparkMethod = callinfo.selected_method(); - assert(unparkMethod.not_null(), "should have thrown exception"); + assert(unparkMethod != NULL, "should have thrown exception"); if (UseWispMonitor) { - _proxy_unpark = new (ResourceObj::C_HEAP, mtWisp) GrowableArray(30); + _proxy_unpark = new (ResourceObj::C_HEAP, mtWisp) GrowableArray(30, mtWisp); if (!AlwaysLockClassLoader) { - SystemDictionary::system_dict_lock_change(thread); + SystemDictionary_lock->create_obj_lock(thread); } } @@ -681,9 +675,14 @@ void WispThread::unpark(int task_id, bool using_wisp_park, bool proxy_unpark, Pa } int WispThread::get_proxy_unpark(jintArray res) { + // We need to hoist code of safepoint state out of MutexLocker to prevent safepoint deadlock problem + // See the same usage: SR_lock in `JavaThread::exit()` + ThreadBlockInVM tbivm(JavaThread::current()); + // When wait()ing, GC may occur. So we shouldn't verify GC. + NoSafepointVerifier nsv; MutexLocker mu(Wisp_lock, Mutex::_no_safepoint_check_flag); while (_proxy_unpark == NULL || _proxy_unpark->is_empty()) { - Wisp_lock->wait(); + Wisp_lock->wait_without_safepoint_check(); } typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(res)); if (a == NULL) { @@ -892,6 +891,14 @@ WispPostStealHandleUpdateMark::WispPostStealHandleUpdateMark(JavaThread *thread, WispPostStealHandle h(&(tbv._tbivmpp)); } +WispPostStealHandleUpdateMark::WispPostStealHandleUpdateMark(JavaThread *thread, ThreadStateTransition & tst) +{ + initialize(thread, true); + + if (!_success) return; + WispPostStealHandle h(&tst); +} + WispPostStealHandleUpdateMark::WispPostStealHandleUpdateMark(JavaThread *&th) // this is a special one { initialize(th, true); diff --git a/src/hotspot/share/runtime/coroutine.hpp b/src/hotspot/share/runtime/coroutine.hpp index 6bbbe1418ed..1b6c31e5b0d 100644 --- a/src/hotspot/share/runtime/coroutine.hpp +++ b/src/hotspot/share/runtime/coroutine.hpp @@ -49,6 +49,7 @@ #define DEBUG_CORO_PRINT(x) #endif +class ThreadStateTransition; class Coroutine; class CoroutineStack; class WispThread; @@ -115,7 +116,6 @@ class Coroutine: public CHeapObj, public DoublyLinkedList { JNIHandleBlock* _active_handles; GrowableArray* _metadata_handles; JavaFrameAnchor _anchor; - // PrivilegedElement* _privileged_stack_top; JavaThreadStatus _thread_status; int _enable_steal_count; int _java_call_counter; @@ -208,7 +208,6 @@ class Coroutine: public CHeapObj, public DoublyLinkedList { static ByteSize last_handle_mark_offset() { return byte_offset_of(Coroutine, _last_handle_mark); } static ByteSize active_handles_offset() { return byte_offset_of(Coroutine, _active_handles); } static ByteSize metadata_handles_offset() { return byte_offset_of(Coroutine, _metadata_handles); } - // static ByteSize privileged_stack_top_offset(){ return byte_offset_of(Coroutine, _privileged_stack_top); } static ByteSize last_Java_sp_offset() { return byte_offset_of(Coroutine, _anchor) + JavaFrameAnchor::last_Java_sp_offset(); } @@ -525,6 +524,7 @@ class WispPostStealHandleUpdateMark: public StackObj { ThreadInVMfromJava & tiva); WispPostStealHandleUpdateMark(HandleMarkCleaner & hmc); WispPostStealHandleUpdateMark(JavaThread *thread, ThreadBlockInVM & tbv); // constructor is used inside objectMonitor call, which is also within EnableStealMark scope. + WispPostStealHandleUpdateMark(JavaThread *thread, ThreadStateTransition & tst); WispPostStealHandleUpdateMark(JavaThread *& th); // this is a special one, used for a fix inside EnableStealMark ~WispPostStealHandleUpdateMark(); diff --git a/src/hotspot/share/runtime/handles.hpp b/src/hotspot/share/runtime/handles.hpp index b8ecd42c7fa..a7e09cd38c7 100644 --- a/src/hotspot/share/runtime/handles.hpp +++ b/src/hotspot/share/runtime/handles.hpp @@ -328,7 +328,6 @@ class HandleMarkCleaner: public StackObj { inline HandleMarkCleaner(Thread* thread); inline ~HandleMarkCleaner(); Thread *& thread_ref() { - assert(EnableCoroutine, "EnableCoroutine is off"); return _thread; } }; diff --git a/src/hotspot/share/runtime/javaCalls.cpp b/src/hotspot/share/runtime/javaCalls.cpp index e78249924bc..f6031655bd5 100644 --- a/src/hotspot/share/runtime/javaCalls.cpp +++ b/src/hotspot/share/runtime/javaCalls.cpp @@ -39,6 +39,7 @@ #include "prims/jniCheck.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/init.hpp" #include "runtime/interfaceSupport.inline.hpp" #include "runtime/javaCalls.hpp" #include "runtime/jniHandles.inline.hpp" @@ -347,9 +348,6 @@ Handle JavaCalls::construct_new_instance(InstanceKlass* klass, Symbol* construct void JavaCalls::call(JavaValue* result, const methodHandle& method, JavaCallArguments* args, TRAPS) { // Check if we need to wrap a potential OS exception handler around thread. // This is used for e.g. Win32 structured exception handlers. - assert(!UseWispMonitor || !is_init_completed() || - java_lang_Thread::park_event(((JavaThread*) THREAD)->threadObj()), - "park_event need to be set before calling java"); // Need to wrap each and every time, since there might be native code down the // stack that has installed its own exception handlers. os::os_exception_wrapper(call_helper, result, method, args, THREAD); @@ -440,8 +438,7 @@ void JavaCalls::call_helper(JavaValue* result, const methodHandle& method, JavaC #endif // thread steal support methodHandle* m = const_cast(&method); - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(thread, t, *m, m, link); + WispPostStealHandleUpdateMark w(thread, (Thread *&)THREAD, *m, m, link); StubRoutines::call_stub()( (address)&link, diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index d9a9fc8bea0..acdab61c3eb 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/shared/gc_globals.hpp" #include "memory/universe.hpp" +#include "runtime/coroutine.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.inline.hpp" #include "runtime/safepoint.hpp" @@ -217,7 +218,6 @@ static bool is_owner(const SystemDictMonitor* lock, Thread* THREAD) { } void assert_lock_strong(const SystemDictMonitor* lock) { - if (IgnoreLockingAssertions) return; assert(lock != NULL, "Need non-NULL lock"); if (is_owner(lock, Thread::current())) return; fatal("must own lock %s", lock->monitor()->name()); @@ -225,7 +225,6 @@ void assert_lock_strong(const SystemDictMonitor* lock) { void assert_locked_or_safepoint(const SystemDictMonitor* lock) { // check if this thread owns the lock (common case) - if (IgnoreLockingAssertions) return; assert(lock != NULL, "Need non-NULL lock"); if (SafepointSynchronize::is_at_safepoint()) return; if (is_owner(lock, Thread::current())) return; @@ -408,8 +407,11 @@ GCMutexLocker::GCMutexLocker(Mutex* mutex) { } } +SystemDictLocker::SystemDictLocker(JavaThread* THREAD, SystemDictMonitor* mutex, bool do_lock) + : SystemDictLockerBase(THREAD, mutex, do_lock) {} + GCSystemDictLocker::GCSystemDictLocker(SystemDictMonitor* mutex) - : SystemDictLocker(JavaThread::current(), mutex, !SafepointSynchronize::is_at_safepoint()) {} + : SystemDictLockerBase(Thread::current(), mutex, !SafepointSynchronize::is_at_safepoint()) {} // Print all mutexes/monitors that are currently owned by a thread; called // by fatal error handler. diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 0893d940abe..aa9a5703efd 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -28,6 +28,7 @@ #include "memory/allocation.hpp" #include "runtime/flags/flagSetting.hpp" #include "runtime/mutex.hpp" +#include "runtime/synchronizer.hpp" // Mutexes used in the VM. @@ -320,18 +321,19 @@ class MutexUnlocker: StackObj { } }; -class SystemDictLocker: StackObj { + +class SystemDictLockerBase: StackObj { private: SystemDictMonitor* _mutex; - JavaThread* _thread; + Thread* _thread; BasicLock _lock; bool _locked; public: - SystemDictLocker(JavaThread* THREAD, SystemDictMonitor* mutex, bool do_lock=true) { + SystemDictLockerBase(Thread* thread, SystemDictMonitor* mutex, bool do_lock=true) { _locked = do_lock; _mutex = mutex; - _thread = THREAD; - if (do_lock) { + _thread = thread; + if (_locked && _mutex != NULL) { _mutex->lock(&_lock, _thread); } } @@ -342,10 +344,15 @@ class SystemDictLocker: StackObj { void unlock() { _mutex->unlock(&_lock, _thread); } - ~SystemDictLocker() { if (_locked) _mutex->unlock(&_lock, _thread); } + ~SystemDictLockerBase() { if (_locked && _mutex != NULL) _mutex->unlock(&_lock, _thread); } +}; + +class SystemDictLocker: public SystemDictLockerBase { + public: + SystemDictLocker(JavaThread* THREAD, SystemDictMonitor* mutex, bool do_lock=true); }; -class GCSystemDictLocker: public SystemDictLocker { +class GCSystemDictLocker: public SystemDictLockerBase { public: GCSystemDictLocker(SystemDictMonitor* mutex); }; diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index e404201725b..464cbff3381 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -422,7 +422,12 @@ bool ObjectMonitor::enter(JavaThread* current) { for (;;) { ExitOnSuspend eos(this); { - ThreadBlockInVMPreprocess tbivs(current, eos); + // If UseWispMonitor, We should record the stack frame and Thread status onto the + // JavaThread which corresponds to the WispThread, instead of WispThread itself. + ThreadBlockInVMPreprocess tbivs(UseWispMonitor ? ((WispThread*)current)->thread(): current, eos); + + // Coroutine work steal support + WispPostStealHandleUpdateMark w(UseWispMonitor ? ((WispThread*)current)->thread() : current, (ThreadStateTransition &)tbivs); EnterI(current); current->set_current_pending_monitor(NULL); // We can go to a safepoint at the end of this block. If we @@ -689,7 +694,9 @@ void ObjectMonitor::EnterI(JavaThread* current) { if (UseWispMonitor) { current = WispThread::current(current); } - assert(current->thread_state() == _thread_blocked, "invariant"); + assert(current->thread_state() == _thread_blocked || + UseWispMonitor && ((WispThread*) current)->thread()->thread_state() == _thread_blocked, + "invariant"); // Try the lock - TATAS if (TryLock (current) > 0) { @@ -987,9 +994,12 @@ void ObjectMonitor::ReenterI(JavaThread* current, ObjectWaiter* currentNode) { { ClearSuccOnSuspend csos(this); - ThreadBlockInVMPreprocess tbivs(current, csos); + ThreadBlockInVMPreprocess tbivs(UseWispMonitor ? ((WispThread *)current)->thread() : current, csos); + + // Coroutine work steal support + WispPostStealHandleUpdateMark w(UseWispMonitor ? ((WispThread*)current)->thread() : current, (ThreadStateTransition &)tbivs); if (UseWispMonitor) { - WispThread::park(MAX_RECHECK_INTERVAL, currentNode); + WispThread::park(-1, currentNode); } else { current->_ParkEvent->park(); } @@ -1451,10 +1461,10 @@ bool ObjectMonitor::reenter(intx recursions, JavaThread* current) { // (IMSE). If there is a pending exception and the specified thread // is not the owner, that exception will be replaced by the IMSE. bool ObjectMonitor::check_owner(TRAPS) { + JavaThread* current = THREAD; if (UseWispMonitor) { - THREAD = WispThread::current(THREAD); + current = WispThread::current(current); } - JavaThread* current = THREAD; void* cur = owner_raw(); if (cur == current) { return true; @@ -1496,12 +1506,14 @@ static void post_monitor_wait_event(EventJavaMonitorWait* event, event->commit(); } -static bool check_interrupt(Thread* self, bool clear_interrupted) { +// is_interrupted method is not virtual. +// So we should dispatch it by type convertion. +static bool check_interrupt(Thread* current, bool clear_interrupted) { if (UseWispMonitor) { - assert(self->is_Wisp_thread(), "must be"); - return ((WispThread*) self)->is_interrupted(clear_interrupted); + assert(current->is_Wisp_thread(), "must be"); + return ((WispThread*) current)->is_interrupted(clear_interrupted); } else { - return ((JavaThread*) self)->is_interrupted(clear_interrupted); + return ((JavaThread*) current)->is_interrupted(clear_interrupted); } } @@ -1511,10 +1523,10 @@ static bool check_interrupt(Thread* self, bool clear_interrupted) { // Note: a subset of changes to ObjectMonitor::wait() // will need to be replicated in complete_exit void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { + JavaThread* current = THREAD; if (UseWispMonitor) { - THREAD = WispThread::current(THREAD); + current = WispThread::current(current); } - JavaThread* current = THREAD; assert(InitDone, "Unexpectedly not initialized"); @@ -1545,7 +1557,7 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { return; } - assert(current->_Stalled || UseWispMonitor == 0, "invariant"); + assert(current->_Stalled == 0 || UseWispMonitor, "invariant"); current->_Stalled = intptr_t(this); current->set_current_waiting_monitor(this); @@ -1591,7 +1603,7 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { int WasNotified = 0; // Need to check interrupt state whilst still _thread_in_vm - bool interrupted = interruptible && current->is_interrupted(false); + bool interrupted = interruptible && check_interrupt(current, false); { // State transition wrappers OSThread* osthread = current->osthread(); @@ -1601,7 +1613,11 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) { { ClearSuccOnSuspend csos(this); - ThreadBlockInVMPreprocess tbivs(current, csos); + ThreadBlockInVMPreprocess tbivs(UseWispMonitor ? ((WispThread*)current)->thread() : current, csos); + + // Coroutine work steal support + WispPostStealHandleUpdateMark w(UseWispMonitor ? ((WispThread*)current)->thread() : current, (ThreadStateTransition &)tbivs); + if (interrupted || HAS_PENDING_EXCEPTION) { // Intentionally empty } else if (node._notified == 0) { @@ -1811,10 +1827,10 @@ void ObjectMonitor::INotify(JavaThread* current) { // that suggests a lost wakeup bug. void ObjectMonitor::notify(TRAPS) { + JavaThread* current = THREAD; if (UseWispMonitor) { - THREAD = WispThread::current(THREAD); + current = WispThread::current(current); } - JavaThread* current = THREAD; CHECK_OWNER(); // Throws IMSE if not owner. if (_WaitSet == NULL) { return; @@ -1833,10 +1849,10 @@ void ObjectMonitor::notify(TRAPS) { // mode the waitset will be empty and the EntryList will be "DCBAXYZ". void ObjectMonitor::notifyAll(TRAPS) { + JavaThread* current = THREAD; if (UseWispMonitor) { - THREAD = WispThread::current(THREAD); + current = WispThread::current(current); } - JavaThread* current = THREAD; CHECK_OWNER(); // Throws IMSE if not owner. if (_WaitSet == NULL) { return; diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index 5bb451c9e25..b0d1ad9ae48 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -1039,6 +1039,4 @@ class os: AllStatic { extern "C" int SpinPause(); -bool clear_interrupt_for_wisp(Thread *); - #endif // SHARE_RUNTIME_OS_HPP diff --git a/src/hotspot/share/runtime/reflection.cpp b/src/hotspot/share/runtime/reflection.cpp index 5ef52d50450..f67c0c6c172 100644 --- a/src/hotspot/share/runtime/reflection.cpp +++ b/src/hotspot/share/runtime/reflection.cpp @@ -1108,8 +1108,7 @@ static oop invoke(InstanceKlass* klass, JavaValue result(rtype); { - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(t, const_cast(&reflected_method), &method); + WispPostStealHandleUpdateMark w((Thread *&)THREAD, const_cast(&reflected_method), &method); EnableStealMark p(THREAD); JavaCalls::call(&result, method, &java_args, THREAD); } @@ -1159,8 +1158,7 @@ oop Reflection::invoke_method(oop method_mirror, Handle receiver, objArrayHandle methodHandle method(THREAD, m); // Coroutine work steal support - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(t, &method); + WispPostStealHandleUpdateMark w((Thread *&)THREAD, &method); return invoke(klass, method, receiver, override, ptypes, rtype, args, true, THREAD); } @@ -1188,8 +1186,7 @@ oop Reflection::invoke_constructor(oop constructor_mirror, objArrayHandle args, Handle receiver = klass->allocate_instance_handle(CHECK_NULL); // Coroutine work steal support - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(t, &method); + WispPostStealHandleUpdateMark w((Thread *&)THREAD, &method); // Ignore result from call and return receiver invoke(klass, method, receiver, override, ptypes, T_VOID, args, false, CHECK_NULL); diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index c609321ac94..9a65f51c96d 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -558,6 +558,10 @@ address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* curr return NULL; } +JRT_LEAF(void, SharedRuntime::coroutine_switch_trace(JavaThread* current, void* arg)) + tty->print_cr("Current thread = (%p, %s), arg = %p\n", current, current->name(), arg); +JRT_END + JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(JavaThread* current, address return_address)) return raw_exception_handler_for_return_address(current, return_address); @@ -2151,8 +2155,7 @@ void SharedRuntime::monitor_enter_helper(oopDesc* obj, BasicLock* lock, JavaThre } // must place it befor EnableStealMark. - Thread* t = THREAD; - WispPostStealHandleUpdateMark w(current, t, __tiv); + WispPostStealHandleUpdateMark w(current, (Thread *&)THREAD, __tiv); // Coroutine work steal support EnableStealMark p(THREAD); diff --git a/src/hotspot/share/runtime/sharedRuntime.hpp b/src/hotspot/share/runtime/sharedRuntime.hpp index f2967a89a75..f1c04f740c3 100644 --- a/src/hotspot/share/runtime/sharedRuntime.hpp +++ b/src/hotspot/share/runtime/sharedRuntime.hpp @@ -277,6 +277,9 @@ class SharedRuntime: AllStatic { static int dtrace_method_exit(JavaThread* thread, Method* m); static int wisp_yield(JavaThread* thread, Method* m); + // Trace wisp coroutine switch. + static void coroutine_switch_trace(JavaThread* thread, void* arg); + // Utility method for retrieving the Java thread id, returns 0 if the // thread is not a well formed Java thread. static jlong get_java_tid(Thread* thread); diff --git a/src/hotspot/share/runtime/synchronizer.cpp b/src/hotspot/share/runtime/synchronizer.cpp index c9bab5b59d2..ea79564928b 100644 --- a/src/hotspot/share/runtime/synchronizer.cpp +++ b/src/hotspot/share/runtime/synchronizer.cpp @@ -28,11 +28,13 @@ #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" +#include "memory/oopFactory.hpp" #include "memory/padded.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/markWord.hpp" #include "oops/oop.inline.hpp" +#include "oops/oopHandle.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/coroutine.hpp" @@ -432,7 +434,7 @@ void ObjectSynchronizer::exit(Handle object, BasicLock* lock, TRAPS) { markWord mark = object->mark(); // We cannot check for Biased Locking if we are racing an inflation. assert(mark == markWord::INFLATING() || - !mark->has_bias_pattern(), "should not see bias pattern here"); + !mark.has_bias_pattern(), "should not see bias pattern here"); markWord dhw = lock->displaced_header(); if (dhw.value() == 0) { @@ -443,10 +445,10 @@ void ObjectSynchronizer::exit(Handle object, BasicLock* lock, TRAPS) { // Only do diagnostics if we are not racing an inflation. Simply // exiting a recursive enter of a Java Monitor that is being // inflated is safe; see the has_monitor() comment below. - assert(!mark->is_neutral(), "invariant"); - assert(!mark->has_locker() || - THREAD->is_lock_owned((address)mark->locker()), "invariant"); - if (mark->has_monitor()) { + assert(!mark.is_neutral(), "invariant"); + assert(!mark.has_locker() || + THREAD->is_lock_owned((address)mark.locker()), "invariant"); + if (mark.has_monitor()) { // The BasicLock's displaced_header is marked as a recursive // enter and we have an inflated Java Monitor (ObjectMonitor). // This is a special case where the Java Monitor was inflated @@ -455,7 +457,7 @@ void ObjectSynchronizer::exit(Handle object, BasicLock* lock, TRAPS) { // Monitor owner's stack and update the BasicLocks because a // Java Monitor can be asynchronously inflated by a thread that // does not own the Java Monitor. - ObjectMonitor * m = mark->monitor(); + ObjectMonitor * m = mark.monitor(); assert(((oop)(m->object()))->mark() == mark, "invariant"); assert(m->is_entered(THREAD), "invariant"); } @@ -467,7 +469,7 @@ void ObjectSynchronizer::exit(Handle object, BasicLock* lock, TRAPS) { if (mark == markWord::from_pointer(lock)) { // If the object is stack-locked by the current thread, try to // swing the displaced header from the BasicLock back to the mark. - assert(dhw->is_neutral(), "invariant"); + assert(dhw.is_neutral(), "invariant"); if (object->cas_set_mark(dhw, mark) == mark) { return; } @@ -666,7 +668,7 @@ void ObjectSynchronizer::jni_exit(oop obj, TRAPS) { // If this thread has locked the object, exit the monitor. We // intentionally do not use CHECK on check_owner because we must exit the // monitor even if an exception was already pending. - if (monitor->check_owner(THREAD)) { + if (monitor->check_owner(current)) { monitor->exit(current); } } @@ -1846,8 +1848,14 @@ void ObjectSynchronizer::log_in_use_monitor_details(outputStream* out) { out->flush(); } -void SystemDictObjMonitor::lock(BasicLock* lock, TRAPS) { +void SystemDictObjMonitor::lock(BasicLock* lock, Thread* current) { assert(UseWispMonitor, "SystemDictObjMonitor if only for UseWispMonitor"); + if (!current->is_Java_thread()) { + _monitor->lock(); + return; + } + + JavaThread* jt = current->as_Java_thread(); if (!is_obj_lock()) { _monitor->lock(); if (is_obj_lock()) { @@ -1855,48 +1863,76 @@ void SystemDictObjMonitor::lock(BasicLock* lock, TRAPS) { // now _monitor is Pointless. re-fetch the objectMonitor to // satisfy the critical section semantics. _monitor->unlock(); - ObjectSynchronizer::enter(Handle(THREAD, _obj), lock, THREAD); + ObjectSynchronizer::enter(Handle(jt, _obj.resolve()), lock, jt); } } else { - ObjectSynchronizer::enter(Handle(THREAD, _obj), lock, THREAD); + ObjectSynchronizer::enter(Handle(jt, _obj.resolve()), lock, jt); } } -void SystemDictObjMonitor::unlock(BasicLock* lock, TRAPS) { +void SystemDictObjMonitor::unlock(BasicLock* lock, Thread* current) { assert(UseWispMonitor, "SystemDictObjMonitor if only for UseWispMonitor"); + if (!current->is_Java_thread()) { + _monitor->unlock(); + return; + } + + JavaThread* jt = current->as_Java_thread(); if (!is_obj_lock()) { _monitor->unlock(); } else { - ObjectSynchronizer::exit(_obj, lock, THREAD); + ObjectSynchronizer::exit(_obj.resolve(), lock, jt); } } -void SystemDictObjMonitor::wait(BasicLock* lock, TRAPS) { +void SystemDictObjMonitor::wait(BasicLock* lock, Thread* current) { assert(UseWispMonitor, "SystemDictObjMonitor if only for UseWispMonitor"); + if (!current->is_Java_thread()) { + _monitor->wait(); + return; + } + + JavaThread* jt = current->as_Java_thread(); if (!is_obj_lock()) { _monitor->wait(); if (is_obj_lock()) { _monitor->unlock(); - ObjectSynchronizer::enter(Handle(THREAD, _obj), lock, THREAD); + ObjectSynchronizer::enter(Handle(jt, _obj.resolve()), lock, jt); } } else { - ObjectSynchronizer::wait(Handle(THREAD, _obj), 0, THREAD); + ObjectSynchronizer::wait(Handle(jt, _obj.resolve()), 0, jt); } } -void SystemDictObjMonitor::notify_all(TRAPS) { +void SystemDictObjMonitor::notify_all(Thread* current) { assert(UseWispMonitor, "SystemDictObjMonitor if only for UseWispMonitor"); + if (!current->is_Java_thread()) { + _monitor->notify_all(); + return; + } + + JavaThread* jt = current->as_Java_thread(); if (!is_obj_lock()) { _monitor->notify_all(); } else { - ObjectSynchronizer::notifyall(Handle(THREAD, _obj), THREAD); + ObjectSynchronizer::notifyall(Handle(jt, _obj.resolve()), jt); } } -void SystemDictObjMonitor::set_obj_lock(oop obj, TRAPS) { - MutexLocker mu(THREAD, _monitor); +void SystemDictObjMonitor::create_obj_lock(Thread* current) { + guarantee(current->is_Java_thread(), "sanity check"); assert(UseWispMonitor, "UseWispMonitor if off"); - assert(_obj == NULL, "_obj already been set"); - _obj = obj; + + oop obj = oopFactory::new_intArray(0, current->as_Java_thread()); + MutexLocker mu(current, _monitor); + _obj = OopHandle(Universe::vm_global(), obj); _monitor->notify_all(); } + +oop SystemDictObjMonitor::obj() const { + return _obj.resolve(); +} + +bool SystemDictObjMonitor::is_obj_lock() const { + return _obj.peek() != NULL; +} diff --git a/src/hotspot/share/runtime/synchronizer.hpp b/src/hotspot/share/runtime/synchronizer.hpp index fcaa31cb628..76e682d750f 100644 --- a/src/hotspot/share/runtime/synchronizer.hpp +++ b/src/hotspot/share/runtime/synchronizer.hpp @@ -27,6 +27,7 @@ #include "memory/padded.hpp" #include "oops/markWord.hpp" +#include "oops/oopHandle.hpp" #include "runtime/basicLock.hpp" #include "runtime/handles.hpp" #include "runtime/mutex.hpp" @@ -213,32 +214,41 @@ class SystemDictMonitor : public CHeapObj { Monitor* _monitor; public: SystemDictMonitor(Monitor* monitor): _monitor(monitor) { } - virtual void lock(BasicLock* lock, TRAPS) { _monitor->lock(); } - virtual void unlock(BasicLock* lock, TRAPS) { _monitor->unlock(); } - virtual void wait(BasicLock* lock, TRAPS) { _monitor->wait(); } - virtual void notify_all(TRAPS) { _monitor->notify_all(); } - virtual void set_obj_lock(oop obj, TRAPS) { ShouldNotReachHere(); } + virtual void lock(BasicLock* lock, Thread* current) { + _monitor->lock(); + } + virtual void unlock(BasicLock* lock, Thread* current) { + _monitor->unlock(); + } + virtual void wait(BasicLock* lock, Thread* current) { + _monitor->wait(); + } + virtual void notify_all(Thread* current) { + _monitor->notify_all(); + } + virtual void create_obj_lock(Thread* current) { + ShouldNotReachHere(); + } Monitor* monitor() const { return _monitor; } virtual oop obj() const { return NULL; } virtual bool is_obj_lock() const { return false; } - virtual void oops_do(OopClosure* f) { } }; class SystemDictObjMonitor : public SystemDictMonitor { private: - oop _obj; + // Prefer to use obj lock. Only use monitor when obj lock is not set. + OopHandle _obj; public: - SystemDictObjMonitor(Monitor* monitor): SystemDictMonitor(monitor), _obj(NULL) { + SystemDictObjMonitor(Monitor* monitor) : SystemDictMonitor(monitor) { assert(UseWispMonitor, "SystemDictObjMonitor if only for UseWispMonitor"); } - virtual void lock(BasicLock* lock, TRAPS); - virtual void unlock(BasicLock* lock, TRAPS); - virtual void wait(BasicLock* lock, TRAPS); - virtual void notify_all(TRAPS); - virtual void set_obj_lock(oop obj, TRAPS); - virtual oop obj() const { return _obj; } - virtual bool is_obj_lock() const { return _obj != NULL; } - virtual void oops_do(OopClosure* f) { if (_obj != NULL) f->do_oop(&_obj); } + virtual void lock(BasicLock* lock, Thread* current); + virtual void unlock(BasicLock* lock, Thread* current); + virtual void wait(BasicLock* lock, Thread* current); + virtual void notify_all(Thread* current); + virtual void create_obj_lock(Thread* current); + virtual oop obj() const; + virtual bool is_obj_lock() const; }; #endif // SHARE_RUNTIME_SYNCHRONIZER_HPP diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp index a04fbeb8d6c..9ae42e1a587 100644 --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -82,6 +82,7 @@ #include "runtime/flags/jvmFlagLimit.hpp" #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" +#include "runtime/globals.hpp" #include "runtime/handles.inline.hpp" #include "runtime/handshake.hpp" #include "runtime/init.hpp" @@ -310,7 +311,7 @@ Thread::Thread() { // and that happens just before Thread::current is set. No other thread // can attach as the VM is not created yet, so they can't execute this code. // If the main thread creates other threads before the barrier set that is an error. - assert(Thread::current_or_null() == NULL, "creating thread before barrier set"); + assert(UseWispMonitor || Thread::current_or_null() == NULL, "creating thread before barrier set"); } MACOS_AARCH64_ONLY(DEBUG_ONLY(_wx_init = false)); @@ -1134,9 +1135,7 @@ JavaThread::JavaThread() : // Setup safepoint state info for this thread ThreadSafepointState::create(this); -#ifdef ASSERT _java_call_counter = 0; -#endif SafepointMechanism::initialize_header(this); @@ -1175,10 +1174,7 @@ void JavaThread::interrupt() { } bool JavaThread::is_interrupted(bool clear_interrupted) { - JavaThread* thread = JavaThread::current(); - if (UseWispMonitor && thread->is_Wisp_thread()) { - thread = ((WispThread*) thread)->thread(); - } + guarantee(!UseWispMonitor || !is_Wisp_thread(), "sanity check"); debug_only(check_for_dangling_thread_pointer(this);) if (_threadObj.peek() == NULL) { @@ -1216,6 +1212,22 @@ bool JavaThread::is_interrupted(bool clear_interrupted) { return interrupted; } +bool JavaThread::clear_interrupt_for_wisp() { + assert(EnableCoroutine, "Coroutine is disabled"); + // If we only use -XX:+EnableCoroutine and + // -Dcom.alibaba.transparentAsync=true, we will fall here, so we cannot use + // `assert(UseWispMonitor)` only. + JavaThread* thread = this; + if (UseWispMonitor && thread->is_Wisp_thread()) { + thread = ((WispThread*)thread)->thread(); + } + + bool interrupted = thread->is_interrupted(false); + java_lang_Thread::set_interrupted(thread->threadObj(), false); + + return interrupted; +} + void JavaThread::block_if_vm_exited() { if (_terminated == _vm_exited) { // _vm_exited is set at safepoint, and Threads_lock is never released @@ -1525,7 +1537,7 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { // SurrogateLockerThread and ServiceThread are "is_hidden_from_external_view()" !is_jvmti_agent_thread()) { assert(!UseWispMonitor || destroy_vm || - java_lang_Thread::park_event(_threadObj), "park_event should been set"); + java_lang_Thread::park_event(threadObj()), "park_event should been set"); EXCEPTION_MARK; JavaValue result(T_VOID); JavaCalls::call_virtual(&result, diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index 543558a5ce2..697d6ce4d1b 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -1505,9 +1505,6 @@ class JavaThread: public Thread { void thread_main_inner(); virtual void post_run(); - public: -// static ByteSize privileged_stack_top_offset() { return byte_offset_of(JavaThread, _privileged_stack_top); } - public: // Thread local information maintained by JVMTI. void set_jvmti_thread_state(JvmtiThreadState *value) { _jvmti_thread_state = value; } @@ -1654,6 +1651,7 @@ class JavaThread: public Thread { // java.lang.Thread interruption support void interrupt(); bool is_interrupted(bool clear_interrupted); + bool clear_interrupt_for_wisp(); static OopStorage* thread_oop_storage(); diff --git a/src/hotspot/share/runtime/vframe.hpp b/src/hotspot/share/runtime/vframe.hpp index bf9473ff2d7..3b09bc4b0ab 100644 --- a/src/hotspot/share/runtime/vframe.hpp +++ b/src/hotspot/share/runtime/vframe.hpp @@ -340,6 +340,7 @@ class vframeStream : public vframeStreamCommon { vframeStream(JavaThread* thread, bool stop_at_java_call_stub = false, bool process_frames = true); Thread *& thread_ref() { + assert(EnableCoroutine, "EnableCoroutine is off"); return (Thread *&)_thread; } diff --git a/src/hotspot/share/utilities/exceptions.cpp b/src/hotspot/share/utilities/exceptions.cpp index 3f6ef1deff4..84352322473 100644 --- a/src/hotspot/share/utilities/exceptions.cpp +++ b/src/hotspot/share/utilities/exceptions.cpp @@ -291,11 +291,6 @@ Handle Exceptions::new_exception(JavaThread* thread, Symbol* name, signature, args, thread); - - { - guarantee(!EnableSteal || thread == Thread::current(), "fatal: stealed"); - } - } // Check if another exception was thrown in the process, if so rethrow that one diff --git a/src/java.base/share/classes/java/dyn/CoroutineBase.java b/src/java.base/share/classes/java/dyn/CoroutineBase.java index 7ee5f4facad..ce7f92ca597 100644 --- a/src/java.base/share/classes/java/dyn/CoroutineBase.java +++ b/src/java.base/share/classes/java/dyn/CoroutineBase.java @@ -28,7 +28,7 @@ import jdk.internal.access.SharedSecrets; /** - * * Abstract of coroutines. + * Abstract of coroutines. */ public abstract class CoroutineBase { transient long data; diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java index bb22af09a8d..a2879848877 100644 --- a/src/java.base/share/classes/java/lang/Thread.java +++ b/src/java.base/share/classes/java/lang/Thread.java @@ -1099,10 +1099,10 @@ public void interrupt() { synchronized (blockerLock) { Interruptible b = blocker; if (b != null) { - interrupted = true; if (WEA != null && wispTask != null) { WEA.interrupt(wispTask); } else { + interrupted = true; interrupt0(); // Just to set the interrupt flag } b.interrupt(this); @@ -1110,10 +1110,10 @@ public void interrupt() { } } } - interrupted = true; if (WEA != null && wispTask != null) { WEA.interrupt(wispTask); } else { + interrupted = true; interrupt0(); } } diff --git a/src/java.base/share/classes/java/net/DatagramSocket.java b/src/java.base/share/classes/java/net/DatagramSocket.java index 020b2e1d69b..91262636b46 100644 --- a/src/java.base/share/classes/java/net/DatagramSocket.java +++ b/src/java.base/share/classes/java/net/DatagramSocket.java @@ -267,6 +267,10 @@ DatagramSocket delegate() { * @param delegate The wrapped DatagramSocket implementation, or null. */ DatagramSocket(DatagramSocket delegate) { + if (WispEngine.transparentWispSwitch()) { + asyncImpl = new WispUdpSocketImpl(this); + assert delegate == null; + } assert delegate == null || delegate instanceof NetMulticastSocket || delegate instanceof sun.nio.ch.DatagramSocketAdaptor; @@ -332,12 +336,15 @@ protected DatagramSocket(DatagramSocketImpl impl) { * @since 1.4 */ public DatagramSocket(SocketAddress bindaddr) throws SocketException { - // if (WispEngine.transparentWispSwitch()) { - // asyncImpl = new WispUdpSocketImpl(this); - // } else { - // DatagramSocket(createDelegate(bindaddr, DatagramSocket.class)); - // } this(createDelegate(bindaddr, DatagramSocket.class)); + if (WispEngine.transparentWispSwitch() && bindaddr != null) { + try { + bind(bindaddr); + } finally { + if (!isBound()) + close(); + } + } } /** @@ -1489,6 +1496,9 @@ private static SocketException toSocketException(IOException e) { */ static T createDelegate(SocketAddress bindaddr, Class type) throws SocketException { + if (WispEngine.transparentWispSwitch()) { + return null; + } // Temporary solution until JDK-8237352 is addressed if (bindaddr == NO_DELEGATE) return null; diff --git a/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java b/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java index 4aeadee8d45..9572948dc80 100644 --- a/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java +++ b/src/java.base/share/classes/sun/nio/ch/ServerSocketChannelImpl.java @@ -394,14 +394,16 @@ public SocketChannel accept() throws IOException { final boolean wispAndBlocking = WispEngine.transparentWispSwitch() && blocking; try { begin(blocking); + if (wispAndBlocking) { + IOUtil.configureBlocking(fd, false); + } n = implAccept(this.fd, newfd, saa); if (blocking) { while (IOStatus.okayToRetry(n) && isOpen()) { if (wispAndBlocking && n < 0) { WEA.registerEvent(this, SelectionKey.OP_ACCEPT); WEA.park(-1); - } - else { + } else { park(Net.POLLIN); } n = implAccept(this.fd, newfd, saa); diff --git a/test/hotspot/jtreg/runtime/coroutine/C1ThrowSyncExceptionTest.java b/test/hotspot/jtreg/runtime/coroutine/C1ThrowSyncExceptionTest.java index 686fc28ee28..53532d5aa26 100644 --- a/test/hotspot/jtreg/runtime/coroutine/C1ThrowSyncExceptionTest.java +++ b/test/hotspot/jtreg/runtime/coroutine/C1ThrowSyncExceptionTest.java @@ -1,7 +1,7 @@ /* * @test * @summary test a special wisp unpark case for C1 compiled method - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.transparentAsync=true -XX:TieredStopAtLevel=1 C1ThrowSyncExceptionTest */ diff --git a/test/hotspot/jtreg/runtime/coroutine/TestAvoidDeoptCoroutineMethod.java b/test/hotspot/jtreg/runtime/coroutine/TestAvoidDeoptCoroutineMethod.java index 5d01c2ff442..edcb267c6c6 100644 --- a/test/hotspot/jtreg/runtime/coroutine/TestAvoidDeoptCoroutineMethod.java +++ b/test/hotspot/jtreg/runtime/coroutine/TestAvoidDeoptCoroutineMethod.java @@ -2,7 +2,7 @@ * @test TestAvoidDeoptCoroutineMethod * @library /test/lib * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox * @build TestAvoidDeoptCoroutineMethod * @run main/othervm -XX:+EnableCoroutine -Xmx10m -Xms10m -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI TestAvoidDeoptCoroutineMethod * @summary test avoid coroutine intrinsic method to be deoptimized diff --git a/test/hotspot/jtreg/runtime/coroutine/TimeSliceSyncTest.java b/test/hotspot/jtreg/runtime/coroutine/TimeSliceSyncTest.java index cf87fcc9257..151ba4d8caa 100644 --- a/test/hotspot/jtreg/runtime/coroutine/TimeSliceSyncTest.java +++ b/test/hotspot/jtreg/runtime/coroutine/TimeSliceSyncTest.java @@ -2,7 +2,7 @@ * @test * @library /testlibrary * @summary This test ensures that coroutine time slice feature won't cause hang. - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -XX:-Inline -XX:+EnableCoroutineTimeSlice TimeSliceSyncTest * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -XX:-Inline -XX:+EnableCoroutineTimeSlice -Dcom.alibaba.wisp.version=2 TimeSliceSyncTest */ diff --git a/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest.java b/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest.java index 6f7a9c0c951..777041d8d01 100644 --- a/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest.java +++ b/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest.java @@ -2,7 +2,7 @@ * @test * @summary test wisp2 switch * @library /test/lib - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+UseWisp2 Wisp2SwitchTest */ diff --git a/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest2.java b/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest2.java index 7baab36c447..11edee4a3aa 100644 --- a/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest2.java +++ b/test/hotspot/jtreg/runtime/coroutine/Wisp2SwitchTest2.java @@ -2,7 +2,7 @@ * @test * @summary test XX:+UseWisp2 switch with -Dcom.alibaba.wisp.allThreadAsWisp=false * @library /test/lib - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+UseWisp2 -Dcom.alibaba.wisp.allThreadAsWisp=false Wisp2SwitchTest2 */ diff --git a/test/hotspot/jtreg/runtime/coroutine/jniDetachThreadHoldingMonitorTest.sh b/test/hotspot/jtreg/runtime/coroutine/jniDetachThreadHoldingMonitorTest.sh deleted file mode 100644 index 0f266fcc012..00000000000 --- a/test/hotspot/jtreg/runtime/coroutine/jniDetachThreadHoldingMonitorTest.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -## @test -## -## @summary test DetachCurrentThread unpark -## @run shell jniDetachThreadHoldingMonitorTest.sh -## - - -export LD_LIBRARY_PATH=.:${COMPILEJAVA}/lib/server:/usr/lib:$LD_LIBRARY_PATH - -g++ -DLINUX -o jniDetachThreadHoldingMonitorTest \ - -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \ - -L${COMPILEJAVA}/lib/server \ - -ljvm -lpthread ${TESTSRC}/jniDetachThreadHoldingMonitorTest.c - -./jniDetachThreadHoldingMonitorTest -exit $? diff --git a/test/hotspot/jtreg/runtime/coroutine/jniMonitorExitTest.sh b/test/hotspot/jtreg/runtime/coroutine/jniMonitorExitTest.sh deleted file mode 100644 index ede41f4360c..00000000000 --- a/test/hotspot/jtreg/runtime/coroutine/jniMonitorExitTest.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -## @test -## -## @summary test jni MonitorExit -## @run shell jniMonitorExitTest.sh -## - - -export LD_LIBRARY_PATH=.:${COMPILEJAVA}/lib/server:/usr/lib:$LD_LIBRARY_PATH -echo ${COMPILEJAVA} -echo $LD_LIBRARY_PATH -g++ -DLINUX -o jniMonitorExitTest \ - -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \ - -L${COMPILEJAVA}/lib/server \ - -ljvm -lpthread ${TESTSRC}/jniMonitorExitTest.c - -./jniMonitorExitTest -exit $? diff --git a/test/hotspot/jtreg/runtime/jni/registerNativesWarning/TestRegisterNativesWarning.java b/test/hotspot/jtreg/runtime/jni/registerNativesWarning/TestRegisterNativesWarning.java index 77aabcc7a01..112d77b302d 100644 --- a/test/hotspot/jtreg/runtime/jni/registerNativesWarning/TestRegisterNativesWarning.java +++ b/test/hotspot/jtreg/runtime/jni/registerNativesWarning/TestRegisterNativesWarning.java @@ -43,9 +43,12 @@ public class TestRegisterNativesWarning { /* * We will replace: - * java/lang/Thread.java: public static native void yield(); + * java/lang/System.java: public static native void currentTimeMillis(); * * as it is simple and innocuous. + * + * KBOX: yield() in Thread.java is not a native method after we + * port wisp coroutine to JDK. Thus we use currentTimeMillis() instead. */ native static void test(Class jlThread); @@ -55,13 +58,13 @@ static class Tester { public static void main(String[] args) throws Exception { System.out.println("Running test() in class loader " + Tester.class.getClassLoader()); - test(Thread.class); - Thread.yield(); + test(System.class); + System.currentTimeMillis(); } } public static void main(String[] args) throws Exception { - String warning = "Re-registering of platform native method: java.lang.Thread.yield()V from code in a different classloader"; + String warning = "Re-registering of platform native method: java.lang.System.currentTimeMillis()J from code in a different classloader"; String cp = Utils.TEST_CLASS_PATH; String libp = Utils.TEST_NATIVE_PATH; diff --git a/test/hotspot/jtreg/runtime/jni/registerNativesWarning/libregisterNativesWarning.c b/test/hotspot/jtreg/runtime/jni/registerNativesWarning/libregisterNativesWarning.c index 1ced153f553..c3572802f3d 100644 --- a/test/hotspot/jtreg/runtime/jni/registerNativesWarning/libregisterNativesWarning.c +++ b/test/hotspot/jtreg/runtime/jni/registerNativesWarning/libregisterNativesWarning.c @@ -30,6 +30,9 @@ * java/lang/Thread.java: public static native void yield(); * * as it is simple and innocuous. + * + * KBOX: yield() in Thread.java is not a native method after we + * port wisp coroutine to JDK. Thus we use currentTimeMillis() instead. */ static void myYield(JNIEnv* env, jclass cls) { printf("myYield executed\n"); @@ -41,8 +44,8 @@ Java_TestRegisterNativesWarning_test (JNIEnv *env, jclass cls, jclass jlThread) { JNINativeMethod nativeMethods[] = { { - (char*) "yield", // name - (char*) "()V", // sig + (char*) "currentTimeMillis", // name + (char*) "()J", // sig (void*) myYield // native method ptr } }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java index a6c13bcee8a..c399084f3c7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/ThreadController.java @@ -655,6 +655,7 @@ public SleepingThread(ThreadController controller, String name, Log log, Threads expectedLength += 3; expectedMethods.add(Thread.class.getName() + ".sleep"); + expectedMethods.add(Thread.class.getName() + ".sleep0"); expectedMethods.add(SleepingThread.class.getName() + ".run"); switch (controller.invocationType) { @@ -722,6 +723,7 @@ public RunningThread(ThreadController controller, String name, Log log, ThreadsG expectedLength += 2; expectedMethods.add(Thread.class.getName() + ".yield"); + expectedMethods.add(Thread.class.getName() + ".yield0"); switch (controller.invocationType) { case ThreadController.JAVA_TYPE: diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RunningThread.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RunningThread.java index 7f1db6d9325..25da293c5ec 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RunningThread.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/RunningThread.java @@ -36,7 +36,8 @@ public class RunningThread extends RecursiveMonitoringThread { private Object readyLock = new Object(); private static final String[] expectedMethods = { "nsk.monitoring.share.thread.RunningThread.runInside", - "java.lang.Thread.yield" + "java.lang.Thread.yield", + "java.lang.Thread.yield0" }; public RunningThread(Log log, RunType recursionType, int maxDepth) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java index 05e3b9de418..5f97d0529da 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/share/thread/SleepingThread.java @@ -36,6 +36,7 @@ public class SleepingThread extends RecursiveMonitoringThread { private Object readyLock = new Object(); private static final String[] expectedMethods = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.monitoring.share.thread.SleepingThread.runInside" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java index 77b881ed0cf..8e620ce5db0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/strace001.java @@ -140,7 +140,9 @@ private static boolean fillTrace() { switch (controller.getInvocationType()) { case ThreadController.JAVA_TYPE: expectedTrace = new String[] { - "java.lang.Thread.sleep" + "java.lang.Thread.sleep0" + , "java.lang.Thread.sleep" + , "java.lang.Thread.yield0" , "java.lang.Thread.yield" , THREAD_NAME + ".waitForSign" , THREAD_NAME + ".recursionJava" @@ -150,7 +152,9 @@ private static boolean fillTrace() { case ThreadController.NATIVE_TYPE: expectedTrace = new String[] { - "java.lang.Thread.sleep" + "java.lang.Thread.sleep0" + , "java.lang.Thread.sleep" + , "java.lang.Thread.yield0" , "java.lang.Thread.yield" , THREAD_NAME + ".waitForSign" , THREAD_NAME + ".recursionNative" @@ -160,7 +164,9 @@ private static boolean fillTrace() { case ThreadController.MIXED_TYPE: expectedTrace = new String[] { - "java.lang.Thread.sleep" + "java.lang.Thread.sleep0" + , "java.lang.Thread.sleep" + , "java.lang.Thread.yield0" , "java.lang.Thread.yield" , THREAD_NAME + ".waitForSign" , THREAD_NAME + ".recursionNative" @@ -194,7 +200,7 @@ private static void printStackTrace(StackTraceElement[] elements) { // The method performs checks of the stack trace private static boolean checkTrace(StackTraceElement[] elements) { int length = elements.length; - int expectedLength = depth +3; + int expectedLength = depth +4; boolean result = true; // Check the length of the trace. It must not be greater than diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java b/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java index ab97a02fdf5..f80a43f5536 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/locks/LockingThread.java @@ -411,6 +411,17 @@ public void exitSingleFrame() { interrupt(); } + // This function add one more stack frame when calling relinquishedMonitor.wait(). + private void myWait(Object relinquishedMonitor) { + try { + relinquishedMonitor.wait(0); + } catch (Exception e) { + executedWithErrors = true; + log("Unexpected exception: " + e); + e.printStackTrace(log.getOutStream()); + } + } + // LockingThread call this method when required state is reached private void doWait() { while (true) { @@ -440,7 +451,7 @@ private void doWait() { // and this method waits when LockingThred change state to 'Thread.State.WAITING' while (relinquishMonitor) - relinquishedMonitor.wait(0); + myWait(relinquishedMonitor); log("Acquire relinquished monitor: " + relinquishedMonitor); } catch (Exception e) { @@ -488,7 +499,9 @@ static synchronized void synchronizedStaticMethod(LockingThread lockingThread) { int expectedDepth() { // for each monitor call 2 methods: createStackFrame() and method which acquire monitor // + when stack creation is finished call 3 methods: createStackFrame()->doWait()->sleep() - return (stackFramesDescription.size() - currentIndex) * 2 + 3; + // return (stackFramesDescription.size() - currentIndex) * 2 + 3; + // After port wisp coroutine, need to add 1 more call after sleep(), i.e. sleep()->sleep0() + return (stackFramesDescription.size() - currentIndex) * 2 + 4; } private native void nativeJNIMonitorEnter(Object object); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java index ec92fc3df47..5ff4a6d7ec2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace001.java @@ -71,6 +71,7 @@ public class strace001 { "java.lang.Object.wait", "java.lang.Thread.exit", "java.lang.Thread.yield", + "java.lang.Thread.yield0", "java.lang.ThreadGroup.remove", "java.lang.ThreadGroup.threadTerminated", "nsk.stress.strace.strace001Thread.run", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java index 793a2e680f4..2b16326491a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace002.java @@ -77,6 +77,7 @@ public class strace002 { "java.lang.Object.wait", "java.lang.Thread.exit", "java.lang.Thread.yield", + "java.lang.Thread.yield0", "java.lang.ThreadGroup.remove", "java.lang.ThreadGroup.threadTerminated", "nsk.stress.strace.strace002Thread.run", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java index f20bb4a5cf6..28a779a5203 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace003.java @@ -117,6 +117,7 @@ public class strace003 { "java.lang.Object.wait", "java.lang.Thread.exit", "java.lang.Thread.yield", + "java.lang.Thread.yield0", "java.lang.ThreadGroup.remove", "java.lang.ThreadGroup.threadTerminated", "nsk.stress.strace.strace003Thread.run", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java index b28b5b119b4..667421c7a1e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace004.java @@ -110,6 +110,7 @@ public class strace004 { "java.lang.Object.wait", "java.lang.Thread.exit", "java.lang.Thread.yield", + "java.lang.Thread.yield0", "java.lang.ThreadGroup.remove", "java.lang.ThreadGroup.threadTerminated", "nsk.stress.strace.strace004Thread.run", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java index 6badd2bf1fb..40e9c380a06 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace005.java @@ -136,6 +136,7 @@ public class strace005 { "java.lang.Object.wait", "java.lang.Thread.exit", "java.lang.Thread.yield", + "java.lang.Thread.yield0", "java.lang.ThreadGroup.remove", "java.lang.ThreadGroup.threadTerminated", "nsk.stress.strace.strace005Thread.run", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java index 20813247438..e9375727a45 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace006.java @@ -76,6 +76,7 @@ public class strace006 { "java.lang.Object.wait", "java.lang.Thread.exit", "java.lang.Thread.yield", + "java.lang.Thread.yield0", "java.lang.ThreadGroup.remove", "java.lang.ThreadGroup.threadTerminated", "nsk.stress.strace.strace006Thread.run", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java index 65fe92cab89..74189b1f7ae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace007.java @@ -72,6 +72,7 @@ public class strace007 { static final int SLEEP_TIME = 50; static final String[] EXPECTED_METHODS = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.stress.strace.strace007Thread.run", "nsk.stress.strace.strace007Thread.recursiveMethod" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java index c110af8b421..49a84f77ddf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace008.java @@ -76,6 +76,7 @@ public class strace008 { static final String NATIVE_LIB = "strace008"; static final String[] EXPECTED_METHODS = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.stress.strace.strace008Thread.run", "nsk.stress.strace.strace008Thread.recursiveMethod" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java index b8dcbe93919..c5ac24fe2ae 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace009.java @@ -75,6 +75,7 @@ public class strace009 { static final int SLEEP_TIME = 50; static final String[] EXPECTED_METHODS = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.stress.strace.strace009Thread.run", "nsk.stress.strace.strace009Thread.recursiveMethod1", "nsk.stress.strace.strace009Thread.recursiveMethod2" diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java index ebf07bd310a..e373212f40a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace010.java @@ -71,6 +71,7 @@ public class strace010 { static final int THRD_COUNT = 100; static final String[] EXPECTED_METHODS = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.stress.strace.strace010Thread.run", "nsk.stress.strace.strace010Thread.recursiveMethod" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java index f18ca08e387..82a25f5937d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace011.java @@ -72,6 +72,7 @@ public class strace011 { static final int THRD_COUNT = 50; static final String[] EXPECTED_METHODS = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.stress.strace.strace011Thread.run", "nsk.stress.strace.strace011Thread.recursiveMethod" }; diff --git a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java index ad14f71cf88..cf11de1ce4e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/stress/strace/strace012.java @@ -75,6 +75,7 @@ public class strace012 { static final int THRD_COUNT = 100; static final String[] EXPECTED_METHODS = { "java.lang.Thread.sleep", + "java.lang.Thread.sleep0", "nsk.stress.strace.strace012Thread.run", "nsk.stress.strace.strace012Thread.recursiveMethod1", "nsk.stress.strace.strace012Thread.recursiveMethod2" diff --git a/test/jdk/com/alibaba/wisp/ExecutionTest.java b/test/jdk/com/alibaba/wisp/ExecutionTest.java index 35742fdf676..2738f418015 100644 --- a/test/jdk/com/alibaba/wisp/ExecutionTest.java +++ b/test/jdk/com/alibaba/wisp/ExecutionTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test WispEngine's multi-task schedule - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true ExecutionTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 ExecutionTest */ diff --git a/test/jdk/com/alibaba/wisp/IoTest.java b/test/jdk/com/alibaba/wisp/IoTest.java index 5fa35f0dff6..f89881a6174 100644 --- a/test/jdk/com/alibaba/wisp/IoTest.java +++ b/test/jdk/com/alibaba/wisp/IoTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test Wisp engine's NIO support - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine IoTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.version=2 IoTest */ diff --git a/test/jdk/com/alibaba/wisp/ParkTest.java b/test/jdk/com/alibaba/wisp/ParkTest.java index ef2e07b2a78..8cdc6dc1396 100644 --- a/test/jdk/com/alibaba/wisp/ParkTest.java +++ b/test/jdk/com/alibaba/wisp/ParkTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test Wisp engine park / unpark - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine ParkTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.version=2 ParkTest */ diff --git a/test/jdk/com/alibaba/wisp/SelectorLazyCreateTest.java b/test/jdk/com/alibaba/wisp/SelectorLazyCreateTest.java index 033ac0a9066..5abd4838fce 100644 --- a/test/jdk/com/alibaba/wisp/SelectorLazyCreateTest.java +++ b/test/jdk/com/alibaba/wisp/SelectorLazyCreateTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test for engine.selector lazy created * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.globalPoller=false SelectorLazyCreateTest @@ -11,8 +11,8 @@ import java.lang.reflect.Field; import java.net.Socket; -import static jdk.testlibrary.Asserts.assertNotNull; -import static jdk.testlibrary.Asserts.assertNull; +import static jdk.test.lib.Asserts.assertNotNull; +import static jdk.test.lib.Asserts.assertNull; public class SelectorLazyCreateTest { diff --git a/test/jdk/com/alibaba/wisp/boot/UnsafeDependencyBugTest.java b/test/jdk/com/alibaba/wisp/boot/UnsafeDependencyBugTest.java index 5fa9036da0e..2121f28b5aa 100644 --- a/test/jdk/com/alibaba/wisp/boot/UnsafeDependencyBugTest.java +++ b/test/jdk/com/alibaba/wisp/boot/UnsafeDependencyBugTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test bug fix of SharedSecrets and Unsafe class initializer circular dependency * @run main UnsafeDependencyBugTest 10 */ @@ -9,7 +9,7 @@ import java.io.File; import java.util.concurrent.TimeUnit; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; /** * We need thousand times to reproduce the DEADLOCK. Don't spend too much time here.. diff --git a/test/jdk/com/alibaba/wisp/bug/CancelTimerAndSleepTest.java b/test/jdk/com/alibaba/wisp/bug/CancelTimerAndSleepTest.java index f6a79a70807..23831fb8b26 100644 --- a/test/jdk/com/alibaba/wisp/bug/CancelTimerAndSleepTest.java +++ b/test/jdk/com/alibaba/wisp/bug/CancelTimerAndSleepTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test sleep - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true CancelTimerAndSleepTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 CancelTimerAndSleepTest */ diff --git a/test/jdk/com/alibaba/wisp/bug/ClearEventTest.java b/test/jdk/com/alibaba/wisp/bug/ClearEventTest.java index da37806ddac..e771fbc6ccd 100644 --- a/test/jdk/com/alibaba/wisp/bug/ClearEventTest.java +++ b/test/jdk/com/alibaba/wisp/bug/ClearEventTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Explain the fix of T11748781 - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true ClearEventTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 ClearEventTest diff --git a/test/jdk/com/alibaba/wisp/bug/Id2TaskMapLeakTest.java b/test/jdk/com/alibaba/wisp/bug/Id2TaskMapLeakTest.java index b93a1e8292d..6e6638e209e 100644 --- a/test/jdk/com/alibaba/wisp/bug/Id2TaskMapLeakTest.java +++ b/test/jdk/com/alibaba/wisp/bug/Id2TaskMapLeakTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test for thread WispTask leak * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true Id2TaskMapLeakTest @@ -13,7 +13,7 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class Id2TaskMapLeakTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp/bug/ReleaseWispSocketAndExitTest.java b/test/jdk/com/alibaba/wisp/bug/ReleaseWispSocketAndExitTest.java index 9115b2a3385..33c9f454029 100644 --- a/test/jdk/com/alibaba/wisp/bug/ReleaseWispSocketAndExitTest.java +++ b/test/jdk/com/alibaba/wisp/bug/ReleaseWispSocketAndExitTest.java @@ -4,7 +4,7 @@ * 1. task A fetch a socket S and release it. * 2. task B get the socket S and block on IO. * 3. task A exit and clean S's event, now B waiting forever... - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=1 ReleaseWispSocketAndExitTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 ReleaseWispSocketAndExitTest */ diff --git a/test/jdk/com/alibaba/wisp/bug/ResetTaskCancelTimerBugTest.java b/test/jdk/com/alibaba/wisp/bug/ResetTaskCancelTimerBugTest.java index 34a44805294..40e6e72e2c6 100644 --- a/test/jdk/com/alibaba/wisp/bug/ResetTaskCancelTimerBugTest.java +++ b/test/jdk/com/alibaba/wisp/bug/ResetTaskCancelTimerBugTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test reset task doesn't cancel the current task's timer unexpectedly. * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=1 ResetTaskCancelTimerBugTest */ @@ -12,7 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class ResetTaskCancelTimerBugTest { diff --git a/test/jdk/com/alibaba/wisp/bug/SelectorInitCriticalTest.java b/test/jdk/com/alibaba/wisp/bug/SelectorInitCriticalTest.java deleted file mode 100644 index fa7c82c2cb7..00000000000 --- a/test/jdk/com/alibaba/wisp/bug/SelectorInitCriticalTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * @test - * @library /lib/testlibrary - * @summary Test the fix to NPE issue caused by unexpected co-routine yielding on synchronized(lock) in SelectorProvider.provider() during initialization of WispEngine - * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -XX:+UseWispMonitor SelectorInitCriticalTest - * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -XX:+UseWispMonitor -Dcom.alibaba.wisp.version=2 SelectorInitCriticalTest -*/ - - -import java.lang.reflect.Field; -import java.nio.channels.spi.SelectorProvider; -import java.util.concurrent.CountDownLatch; - -public class SelectorInitCriticalTest { - public static void main(String[] args) throws Exception { - Field f = SelectorProvider.class.getDeclaredField("lock"); - f.setAccessible(true); - Object selectorProviderLock = f.get(null); - CountDownLatch latch = new CountDownLatch(1); - - Thread t = new Thread(latch::countDown); - - synchronized (selectorProviderLock) { - t.start(); - // Holding selectorProviderLock for a while which will eventually blocks the initialization of t' WispEngine - Thread.sleep(100); - } - - latch.await(); - - } -} diff --git a/test/jdk/com/alibaba/wisp/bug/TestThreadStackTrace.sh b/test/jdk/com/alibaba/wisp/bug/TestThreadStackTrace.sh index 740cc98444d..810504f94bc 100644 --- a/test/jdk/com/alibaba/wisp/bug/TestThreadStackTrace.sh +++ b/test/jdk/com/alibaba/wisp/bug/TestThreadStackTrace.sh @@ -2,7 +2,7 @@ # # @test # @summary test Thread.getStackTrace() in wisp transparentAsync model -# @modules java.base/jdk.internal.misc +# @modules java.base/jdk.internal.access # @modules java.base/com.alibaba.wisp.engine:+open # @run shell TestThreadStackTrace.sh # @@ -107,7 +107,7 @@ public class TmpThreadStackTrace { EOF # Do compilation -${JAVAC} --add-exports java.base/jdk.internal.misc=ALL-UNNAMED -cp ${TESTCLASSES} -d ${TESTCLASSES} ${TESTCLASSES}${FS}$TEST_SOURCE >> /dev/null 2>&1 +${JAVAC} --add-exports java.base/jdk.internal.access=ALL-UNNAMED -cp ${TESTCLASSES} -d ${TESTCLASSES} ${TESTCLASSES}${FS}$TEST_SOURCE >> /dev/null 2>&1 if [ $? != '0' ] then printf "Failed to compile ${TESTCLASSES}${FS}${TEST_SOURCE}" @@ -115,7 +115,7 @@ then fi #run -${JAVA} -XX:+PrintSafepointStatistics -XX:PrintSafepointStatisticsCount=1 -Dcom.alibaba.wisp.config=${TEST_WISP_CONFIG} -XX:-UseBiasedLocking -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -cp ${TESTCLASSES} ${TEST_CLASS} > output.txt 2>&1 +${JAVA} -Xlog:safepoint+stats=debug -Dcom.alibaba.wisp.config=${TEST_WISP_CONFIG} -XX:-UseBiasedLocking -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -cp ${TESTCLASSES} ${TEST_CLASS} > output.txt 2>&1 rm -f $TEST_WISP_CONFIG cat output.txt diff --git a/test/jdk/com/alibaba/wisp/bug/ThreadLockTest.java b/test/jdk/com/alibaba/wisp/bug/ThreadLockTest.java index 81fe5def1e2..ca7e56a0f23 100644 --- a/test/jdk/com/alibaba/wisp/bug/ThreadLockTest.java +++ b/test/jdk/com/alibaba/wisp/bug/ThreadLockTest.java @@ -2,8 +2,8 @@ * @test * @summary Test fix of WispEngine block on Thread.class lock * @modules java.base/java.lang:+open - * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -XX:+UnlockExperimentalVMOptions -XX:SyncKnobs="ReportSettings=1:QMode=1" -Dcom.alibaba.wisp.transparentWispSwitch=true ThreadLockTest - * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -XX:+UnlockExperimentalVMOptions -XX:SyncKnobs="ReportSettings=1:QMode=1" -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 ThreadLockTest + * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true ThreadLockTest + * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 ThreadLockTest */ import com.alibaba.wisp.engine.WispEngine; diff --git a/test/jdk/com/alibaba/wisp/bug/WispEngineCriticalSectionTest.java b/test/jdk/com/alibaba/wisp/bug/WispEngineCriticalSectionTest.java index f96f46ebd04..68c62fb2eb1 100644 --- a/test/jdk/com/alibaba/wisp/bug/WispEngineCriticalSectionTest.java +++ b/test/jdk/com/alibaba/wisp/bug/WispEngineCriticalSectionTest.java @@ -1,8 +1,9 @@ /* * @test * @summary Test case for fix a deadlock caused by critical section of WispEngine - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open + * @modules java.base/java.nio.channels.spi:+open * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.globalPoller=false WispEngineCriticalSectionTest */ @@ -14,6 +15,7 @@ import java.net.Socket; import java.nio.channels.spi.AbstractSelector; import java.util.HashSet; +import java.util.Set; import java.util.concurrent.CountDownLatch; public class WispEngineCriticalSectionTest { @@ -31,8 +33,8 @@ public static void main(String[] args) throws Exception { AbstractSelector selector = (AbstractSelector) f.get(WispEngine.current()); f = AbstractSelector.class.getDeclaredField("cancelledKeys"); f.setAccessible(true); - final HashSet cancelSet = (HashSet) f.get(selector); - + Set set = (Set)(f.get(selector)); + final HashSet cancelSet = new HashSet(set); // made an runnable wisp CountDownLatch cd = new CountDownLatch(1); diff --git a/test/jdk/com/alibaba/wisp/bug/WispSocketLeakWhenConnectTimeoutTest.java b/test/jdk/com/alibaba/wisp/bug/WispSocketLeakWhenConnectTimeoutTest.java index 725832626f8..7af3919a6c0 100644 --- a/test/jdk/com/alibaba/wisp/bug/WispSocketLeakWhenConnectTimeoutTest.java +++ b/test/jdk/com/alibaba/wisp/bug/WispSocketLeakWhenConnectTimeoutTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test the fix to fd leakage when socket connect timeout * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 WispSocketLeakWhenConnectTimeoutTest */ @@ -10,7 +10,7 @@ import java.net.Socket; import java.net.SocketTimeoutException; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class WispSocketLeakWhenConnectTimeoutTest { public static void main(String[] args) throws IOException { diff --git a/test/jdk/com/alibaba/wisp/env/CtxClassLoaderIsolateTest.java b/test/jdk/com/alibaba/wisp/env/CtxClassLoaderIsolateTest.java index 9adb6d19e98..a4df7176f2c 100644 --- a/test/jdk/com/alibaba/wisp/env/CtxClassLoaderIsolateTest.java +++ b/test/jdk/com/alibaba/wisp/env/CtxClassLoaderIsolateTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Verify the context class loader isolation per co-routine * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true CtxClassLoaderIsolateTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 CtxClassLoaderIsolateTest @@ -9,7 +9,7 @@ import com.alibaba.wisp.engine.WispEngine; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class CtxClassLoaderIsolateTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp/io/CreateFdOnDemandTest.java b/test/jdk/com/alibaba/wisp/io/CreateFdOnDemandTest.java index e9731ac78f7..389cdd45797 100644 --- a/test/jdk/com/alibaba/wisp/io/CreateFdOnDemandTest.java +++ b/test/jdk/com/alibaba/wisp/io/CreateFdOnDemandTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test fix of unconnected Socket fd leak. * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true CreateFdOnDemandTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 CreateFdOnDemandTest @@ -13,8 +13,8 @@ import com.alibaba.wisp.engine.WispEngine; -import static jdk.testlibrary.Asserts.assertEQ; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertTrue; public class CreateFdOnDemandTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp/io/DatagramSocketTest.java b/test/jdk/com/alibaba/wisp/io/DatagramSocketTest.java index e580720def0..886d389de93 100644 --- a/test/jdk/com/alibaba/wisp/io/DatagramSocketTest.java +++ b/test/jdk/com/alibaba/wisp/io/DatagramSocketTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test WispEngine's DatagramSocket, InitialDirContext use dup socket to query dns. - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true DatagramSocketTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 DatagramSocketTest */ @@ -15,7 +15,7 @@ import java.io.IOException; import java.net.*; import java.util.concurrent.CountDownLatch; -import static jdk.testlibrary.Asserts.*; +import static jdk.test.lib.Asserts.*; public class DatagramSocketTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp/io/GlobalPollerTest.java b/test/jdk/com/alibaba/wisp/io/GlobalPollerTest.java index 9189516f4f2..26bf2aba76d 100644 --- a/test/jdk/com/alibaba/wisp/io/GlobalPollerTest.java +++ b/test/jdk/com/alibaba/wisp/io/GlobalPollerTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test for Global Poller - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/sun.nio.ch * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.transparentAsync=true GlobalPollerTest @@ -20,7 +20,7 @@ import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class GlobalPollerTest { private static WispEngineAccess access = SharedSecrets.getWispEngineAccess(); diff --git a/test/jdk/com/alibaba/wisp/io/ReuseUdpSocektBufTest.java b/test/jdk/com/alibaba/wisp/io/ReuseUdpSocektBufTest.java index 44ceceecca4..0f46625e1d8 100644 --- a/test/jdk/com/alibaba/wisp/io/ReuseUdpSocektBufTest.java +++ b/test/jdk/com/alibaba/wisp/io/ReuseUdpSocektBufTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test reuse WispUdpSocket buffer * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true ReuseUdpSocektBufTest */ @@ -9,7 +9,7 @@ import java.net.DatagramSocket; import java.net.InetAddress; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class ReuseUdpSocektBufTest { diff --git a/test/jdk/com/alibaba/wisp/lock/AQSTest.java b/test/jdk/com/alibaba/wisp/lock/AQSTest.java index cdba42525e8..5d4d6a6bf4c 100644 --- a/test/jdk/com/alibaba/wisp/lock/AQSTest.java +++ b/test/jdk/com/alibaba/wisp/lock/AQSTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test AQS: CountDownLatch is implement by AQS - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true AQSTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 AQSTest */ diff --git a/test/jdk/com/alibaba/wisp/lock/ElisionSpinTest.java b/test/jdk/com/alibaba/wisp/lock/ElisionSpinTest.java index 4428d7a198a..e56e02072da 100644 --- a/test/jdk/com/alibaba/wisp/lock/ElisionSpinTest.java +++ b/test/jdk/com/alibaba/wisp/lock/ElisionSpinTest.java @@ -1,8 +1,8 @@ /* * @test * @summary Test elision spin - * @modules java.base/jdk.internal.misc - * @library /lib/testlibrary + * @modules java.base/jdk.internal.access + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.useStealLock=false ElisionSpinTest */ @@ -12,8 +12,8 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; -import static jdk.testlibrary.Asserts.assertFalse; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; public class ElisionSpinTest { public static void main(String[] args) { diff --git a/test/jdk/com/alibaba/wisp/lock/LockTest.java b/test/jdk/com/alibaba/wisp/lock/LockTest.java index 18dd446cf3c..bdc74598028 100644 --- a/test/jdk/com/alibaba/wisp/lock/LockTest.java +++ b/test/jdk/com/alibaba/wisp/lock/LockTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test ReentrantLock in coroutine environment - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true LockTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 LockTest */ diff --git a/test/jdk/com/alibaba/wisp/lock/LockUninterruptiblyTest.java b/test/jdk/com/alibaba/wisp/lock/LockUninterruptiblyTest.java index 4cc9e34ca70..58cffa63ac4 100644 --- a/test/jdk/com/alibaba/wisp/lock/LockUninterruptiblyTest.java +++ b/test/jdk/com/alibaba/wisp/lock/LockUninterruptiblyTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test to verify we are not spinning when we're trying to acquire monitor with interrupted status * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true LockUninterruptiblyTest @@ -12,7 +12,7 @@ import java.lang.reflect.Field; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class LockUninterruptiblyTest { diff --git a/test/jdk/com/alibaba/wisp/lock/UnsafeParkTest.java b/test/jdk/com/alibaba/wisp/lock/UnsafeParkTest.java index 2edd745b01f..3945df55e5a 100644 --- a/test/jdk/com/alibaba/wisp/lock/UnsafeParkTest.java +++ b/test/jdk/com/alibaba/wisp/lock/UnsafeParkTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test to verify we can do proper wisp scheduling while calling on Unsafe.park() * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true UnsafeParkTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 UnsafeParkTest @@ -13,7 +13,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class UnsafeParkTest { diff --git a/test/jdk/com/alibaba/wisp/monitor/JNICriticalTest.java b/test/jdk/com/alibaba/wisp/monitor/JNICriticalTest.java index 394bd9909e5..da033e43829 100644 --- a/test/jdk/com/alibaba/wisp/monitor/JNICriticalTest.java +++ b/test/jdk/com/alibaba/wisp/monitor/JNICriticalTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test unpark in JNI critical case - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 JNICriticalTest */ diff --git a/test/jdk/com/alibaba/wisp/monitor/LazyUnparkBugTest.java b/test/jdk/com/alibaba/wisp/monitor/LazyUnparkBugTest.java index 59489f242d2..008408cf8df 100644 --- a/test/jdk/com/alibaba/wisp/monitor/LazyUnparkBugTest.java +++ b/test/jdk/com/alibaba/wisp/monitor/LazyUnparkBugTest.java @@ -1,7 +1,7 @@ /* * @test * @summary T12212948 - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true LazyUnparkBugTest * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 LazyUnparkBugTest */ diff --git a/test/jdk/com/alibaba/wisp/monitor/MultiThreadTest.java b/test/jdk/com/alibaba/wisp/monitor/MultiThreadTest.java index 0621411bcd6..851268e1cb7 100644 --- a/test/jdk/com/alibaba/wisp/monitor/MultiThreadTest.java +++ b/test/jdk/com/alibaba/wisp/monitor/MultiThreadTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test object lock with coroutine - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 MultiThreadTest */ diff --git a/test/jdk/com/alibaba/wisp/monitor/WaitNotifyTest.java b/test/jdk/com/alibaba/wisp/monitor/WaitNotifyTest.java index dbbb7c3088d..668f76441ac 100644 --- a/test/jdk/com/alibaba/wisp/monitor/WaitNotifyTest.java +++ b/test/jdk/com/alibaba/wisp/monitor/WaitNotifyTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test Object.wait/notify with coroutine * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true WaitNotifyTest */ @@ -9,7 +9,7 @@ import java.util.concurrent.CountDownLatch; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class WaitNotifyTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp/thread/DisableThreadAsWispAtRuntimeTest.java b/test/jdk/com/alibaba/wisp/thread/DisableThreadAsWispAtRuntimeTest.java index b1eeb4e0080..028216e23be 100644 --- a/test/jdk/com/alibaba/wisp/thread/DisableThreadAsWispAtRuntimeTest.java +++ b/test/jdk/com/alibaba/wisp/thread/DisableThreadAsWispAtRuntimeTest.java @@ -1,9 +1,9 @@ /* * @test * @summary test to turn on/off shiftThreadModel on demand - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true DisableThreadAsWispAtRuntimeTest * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 DisableThreadAsWispAtRuntimeTest */ @@ -19,7 +19,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class DisableThreadAsWispAtRuntimeTest { diff --git a/test/jdk/com/alibaba/wisp/thread/EngineExecutorTest.java b/test/jdk/com/alibaba/wisp/thread/EngineExecutorTest.java index 5fb13f2a312..f0473c8c42e 100644 --- a/test/jdk/com/alibaba/wisp/thread/EngineExecutorTest.java +++ b/test/jdk/com/alibaba/wisp/thread/EngineExecutorTest.java @@ -1,7 +1,7 @@ /* * @test * @summary test submit task to engine. - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true EngineExecutorTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 EngineExecutorTest */ diff --git a/test/jdk/com/alibaba/wisp/thread/InterruptedSleepTest.java b/test/jdk/com/alibaba/wisp/thread/InterruptedSleepTest.java index 68babde1f9f..6c705ab7bd4 100644 --- a/test/jdk/com/alibaba/wisp/thread/InterruptedSleepTest.java +++ b/test/jdk/com/alibaba/wisp/thread/InterruptedSleepTest.java @@ -1,16 +1,16 @@ /* * @test * @summary test InterruptedException was thrown by sleep() - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true InterruptedSleepTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 InterruptedSleepTest */ import com.alibaba.wisp.engine.WispEngine; -import static jdk.testlibrary.Asserts.assertFalse; -import static jdk.testlibrary.Asserts.assertLessThan; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertLessThan; +import static jdk.test.lib.Asserts.assertTrue; public class InterruptedSleepTest { public static void main(String[] args) { diff --git a/test/jdk/com/alibaba/wisp/thread/IsAliveTest.java b/test/jdk/com/alibaba/wisp/thread/IsAliveTest.java index 6b275cfbb92..b47ba747f0b 100644 --- a/test/jdk/com/alibaba/wisp/thread/IsAliveTest.java +++ b/test/jdk/com/alibaba/wisp/thread/IsAliveTest.java @@ -2,7 +2,7 @@ * @test * @summary test thread.isAlive() of wispTask * @modules java.base/com.alibaba.wisp.engine:+open - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true IsAliveTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.version=2 IsAliveTest * @@ -16,8 +16,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertFalse; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertTrue; public class IsAliveTest { diff --git a/test/jdk/com/alibaba/wisp/thread/SubmittedTaskLimitTest.java b/test/jdk/com/alibaba/wisp/thread/SubmittedTaskLimitTest.java index f1c09e31a76..cc625bbec37 100644 --- a/test/jdk/com/alibaba/wisp/thread/SubmittedTaskLimitTest.java +++ b/test/jdk/com/alibaba/wisp/thread/SubmittedTaskLimitTest.java @@ -2,7 +2,7 @@ * @test * @summary Test to verify threshold setting for submitted wisp tasks. * @modules java.base/com.alibaba.wisp.engine:+open - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true SubmittedTaskLimitTest */ @@ -14,9 +14,9 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; -import static jdk.testlibrary.Asserts.assertGT; -import static jdk.testlibrary.Asserts.assertGTE; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertGT; +import static jdk.test.lib.Asserts.assertGTE; +import static jdk.test.lib.Asserts.assertTrue; public class SubmittedTaskLimitTest { diff --git a/test/jdk/com/alibaba/wisp/thread/ThreadAsWispTest.java b/test/jdk/com/alibaba/wisp/thread/ThreadAsWispTest.java index df2c222aa65..63b1627f314 100644 --- a/test/jdk/com/alibaba/wisp/thread/ThreadAsWispTest.java +++ b/test/jdk/com/alibaba/wisp/thread/ThreadAsWispTest.java @@ -1,9 +1,9 @@ /* * @test * @summary test dispatching thread into our managed workers - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.threadPoolLimit=true -Dcom.alibaba.wisp.enableThreadAsWisp=true ThreadAsWispTest * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.threadPoolLimit=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.version=2 -XX:ActiveProcessorCount=4 ThreadAsWispTest */ @@ -30,8 +30,8 @@ import java.util.function.BiConsumer; import java.util.stream.IntStream; -import static jdk.testlibrary.Asserts.assertEQ; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertTrue; public class ThreadAsWispTest { static Thread mainThread; diff --git a/test/jdk/com/alibaba/wisp/thread/ThrowErrorTest.java b/test/jdk/com/alibaba/wisp/thread/ThrowErrorTest.java index 373ceb31a8e..cc04e8a7f4d 100644 --- a/test/jdk/com/alibaba/wisp/thread/ThrowErrorTest.java +++ b/test/jdk/com/alibaba/wisp/thread/ThrowErrorTest.java @@ -1,14 +1,14 @@ /* * @test * @summary test coroutine throw Error - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true ThrowErrorTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 ThrowErrorTest */ import com.alibaba.wisp.engine.WispEngine; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class ThrowErrorTest { public static void main(String[] args) { diff --git a/test/jdk/com/alibaba/wisp/thread/TimeSliceTest.java b/test/jdk/com/alibaba/wisp/thread/TimeSliceTest.java index d2c38f79e20..6f9fd078cc3 100644 --- a/test/jdk/com/alibaba/wisp/thread/TimeSliceTest.java +++ b/test/jdk/com/alibaba/wisp/thread/TimeSliceTest.java @@ -1,7 +1,7 @@ /* * @test * @summary test wisp time slice - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+EnableCoroutineTimeSlice -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableHandOff=true -Dcom.alibaba.wisp.sysmonTickUs=10000 -XX:-Inline -Dcom.alibaba.wisp.version=2 TimeSliceTest */ @@ -10,7 +10,7 @@ import java.util.Date; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class TimeSliceTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp/thread/YieldTest.java b/test/jdk/com/alibaba/wisp/thread/YieldTest.java index 7a2ec67455e..5cd318991b1 100644 --- a/test/jdk/com/alibaba/wisp/thread/YieldTest.java +++ b/test/jdk/com/alibaba/wisp/thread/YieldTest.java @@ -1,13 +1,13 @@ /* * @test * @summary test yield() - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true YieldTest */ import com.alibaba.wisp.engine.WispEngine; -import static jdk.testlibrary.Asserts.*; +import static jdk.test.lib.Asserts.*; public class YieldTest { private static int i = 0; diff --git a/test/jdk/com/alibaba/wisp/timer/DaemonThreadGroupTest.java b/test/jdk/com/alibaba/wisp/timer/DaemonThreadGroupTest.java index 82cf959998f..0c3248aa16e 100644 --- a/test/jdk/com/alibaba/wisp/timer/DaemonThreadGroupTest.java +++ b/test/jdk/com/alibaba/wisp/timer/DaemonThreadGroupTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test Daemon Thread Group implementation - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.version=2 DaemonThreadGroupTest */ @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; /** diff --git a/test/jdk/com/alibaba/wisp/timer/OverflowTest.java b/test/jdk/com/alibaba/wisp/timer/OverflowTest.java index 088c93debcf..8bec4d74c02 100644 --- a/test/jdk/com/alibaba/wisp/timer/OverflowTest.java +++ b/test/jdk/com/alibaba/wisp/timer/OverflowTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test timer implementation - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine OverflowTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.version=2 OverflowTest */ @@ -16,7 +16,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; /** diff --git a/test/jdk/com/alibaba/wisp/timer/PriorityQueueSortTest.java b/test/jdk/com/alibaba/wisp/timer/PriorityQueueSortTest.java index 0a4290cb922..5e2f1d8cf1f 100644 --- a/test/jdk/com/alibaba/wisp/timer/PriorityQueueSortTest.java +++ b/test/jdk/com/alibaba/wisp/timer/PriorityQueueSortTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test TimeOut.Queue's offer and remove function, make sure it's consistent with the behavior of the jdk's priority queue * @modules java.base/com.alibaba.wisp.engine:+open * @run main/othervm PriorityQueueSortTest @@ -14,7 +14,7 @@ import java.util.*; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class PriorityQueueSortTest { diff --git a/test/jdk/com/alibaba/wisp/timer/SleepRPCTest.java b/test/jdk/com/alibaba/wisp/timer/SleepRPCTest.java index 85cabc40a85..93b48e07131 100644 --- a/test/jdk/com/alibaba/wisp/timer/SleepRPCTest.java +++ b/test/jdk/com/alibaba/wisp/timer/SleepRPCTest.java @@ -1,7 +1,7 @@ /* * @test * @summary test use sleep in RPC senorina - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true SleepRPCTest * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.version=2 SleepRPCTest */ @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class SleepRPCTest { public static void main(String[] args) { diff --git a/test/jdk/com/alibaba/wisp/timer/SleepTest.java b/test/jdk/com/alibaba/wisp/timer/SleepTest.java index 197e2e537b1..b6596888c90 100644 --- a/test/jdk/com/alibaba/wisp/timer/SleepTest.java +++ b/test/jdk/com/alibaba/wisp/timer/SleepTest.java @@ -1,7 +1,7 @@ /* * @test * @summary test sleep - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.version=2 SleepTest */ @@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.IntStream; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class SleepTest { public static void main(String[] args) { diff --git a/test/jdk/com/alibaba/wisp/timer/TimerTest.java b/test/jdk/com/alibaba/wisp/timer/TimerTest.java index e221af92d07..14079946dc6 100644 --- a/test/jdk/com/alibaba/wisp/timer/TimerTest.java +++ b/test/jdk/com/alibaba/wisp/timer/TimerTest.java @@ -1,7 +1,7 @@ /* * @test * @summary Test timer implement - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine TimerTest * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.version=2 TimerTest */ diff --git a/test/jdk/com/alibaba/wisp2/AllThreadAsWispTest.java b/test/jdk/com/alibaba/wisp2/AllThreadAsWispTest.java index 539bf39bf58..a5acdc1f90f 100644 --- a/test/jdk/com/alibaba/wisp2/AllThreadAsWispTest.java +++ b/test/jdk/com/alibaba/wisp2/AllThreadAsWispTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary convert all thread to wisp - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -XX:+UseWispMonitor -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.allThreadAsWisp=true AllThreadAsWispTest */ @@ -14,7 +14,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class AllThreadAsWispTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp2/CtxClassLoaderInheritanceTest.java b/test/jdk/com/alibaba/wisp2/CtxClassLoaderInheritanceTest.java index e5a4b85a774..a25e37dd8a6 100644 --- a/test/jdk/com/alibaba/wisp2/CtxClassLoaderInheritanceTest.java +++ b/test/jdk/com/alibaba/wisp2/CtxClassLoaderInheritanceTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test context ClassLoader inherit. * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -XX:+UseWispMonitor -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.allThreadAsWisp=true CtxClassLoaderInheritanceTest */ @@ -8,7 +8,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class CtxClassLoaderInheritanceTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp2/DispatchTest.java b/test/jdk/com/alibaba/wisp2/DispatchTest.java index 284672a7ca9..00c9c45e714 100644 --- a/test/jdk/com/alibaba/wisp2/DispatchTest.java +++ b/test/jdk/com/alibaba/wisp2/DispatchTest.java @@ -1,7 +1,7 @@ /* * @test * @summary basic wisp2 - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -XX:+UseWispMonitor DispatchTest */ diff --git a/test/jdk/com/alibaba/wisp2/HandOffTest.java b/test/jdk/com/alibaba/wisp2/HandOffTest.java index 8f2dcfd4fb3..b824d0261e7 100644 --- a/test/jdk/com/alibaba/wisp2/HandOffTest.java +++ b/test/jdk/com/alibaba/wisp2/HandOffTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test long running or blocking syscall task could be retaken * @run main/othervm -Dcom.alibaba.wisp.carrierEngines=1 -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -Dcom.alibaba.wisp.enableHandOff=true -Dcom.alibaba.wisp.sysmonTickUs=100000 HandOffTest */ @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class HandOffTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp2/NioBlockingAcceptTest.java b/test/jdk/com/alibaba/wisp2/NioBlockingAcceptTest.java index ff7389f8956..b881820b84b 100644 --- a/test/jdk/com/alibaba/wisp2/NioBlockingAcceptTest.java +++ b/test/jdk/com/alibaba/wisp2/NioBlockingAcceptTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test nio blocking accept * @run main/othervm -Dcom.alibaba.wisp.carrierEngines=1 -XX:ActiveProcessorCount=1 -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -XX:+UseWispMonitor -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.allThreadAsWisp=true NioBlockingAcceptTest */ @@ -13,7 +13,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class NioBlockingAcceptTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp2/ReuseWispTaskAfterThreadJoinTest.java b/test/jdk/com/alibaba/wisp2/ReuseWispTaskAfterThreadJoinTest.java index 6c5db785e1b..cbc9c8b4e99 100644 --- a/test/jdk/com/alibaba/wisp2/ReuseWispTaskAfterThreadJoinTest.java +++ b/test/jdk/com/alibaba/wisp2/ReuseWispTaskAfterThreadJoinTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test wisp task reusing after thread.join() * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -XX:+UseWispMonitor -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.allThreadAsWisp=true ReuseWispTaskAfterThreadJoinTest */ diff --git a/test/jdk/com/alibaba/wisp2/ThreadJoinTest.java b/test/jdk/com/alibaba/wisp2/ThreadJoinTest.java index d920775e936..1d9b0847106 100644 --- a/test/jdk/com/alibaba/wisp2/ThreadJoinTest.java +++ b/test/jdk/com/alibaba/wisp2/ThreadJoinTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test thread.join() * @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -XX:+UseWispMonitor -Dcom.alibaba.wisp.enableThreadAsWisp=true -Dcom.alibaba.wisp.allThreadAsWisp=true ThreadJoinTest */ diff --git a/test/jdk/com/alibaba/wisp2/Wisp2ShutdownTest.java b/test/jdk/com/alibaba/wisp2/Wisp2ShutdownTest.java index 5eabd763686..de9091d156e 100644 --- a/test/jdk/com/alibaba/wisp2/Wisp2ShutdownTest.java +++ b/test/jdk/com/alibaba/wisp2/Wisp2ShutdownTest.java @@ -2,7 +2,7 @@ * @test * @summary Wisp2ShutdownTest * @modules java.base/com.alibaba.wisp.engine:+open - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 Wisp2ShutdownTest */ @@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class Wisp2ShutdownTest { public static void main(String[] args) throws Exception { @@ -39,6 +39,7 @@ public Thread newThread(Runnable r) { n.decrementAndGet(); } }); + } while (n.get() != 888) { @@ -49,7 +50,7 @@ public Thread newThread(Runnable r) { g.shutdown(); - g.awaitTermination(1, TimeUnit.SECONDS); + g.awaitTermination(5, TimeUnit.SECONDS); System.out.println(System.currentTimeMillis() - start + "ms"); diff --git a/test/jdk/com/alibaba/wisp2/Wisp2WaitNotifyTest.java b/test/jdk/com/alibaba/wisp2/Wisp2WaitNotifyTest.java index ed1e85db07b..42ab7b54624 100644 --- a/test/jdk/com/alibaba/wisp2/Wisp2WaitNotifyTest.java +++ b/test/jdk/com/alibaba/wisp2/Wisp2WaitNotifyTest.java @@ -1,6 +1,6 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test Object.wait/notify with coroutine in wisp2 * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 Wisp2WaitNotifyTest */ @@ -10,7 +10,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class Wisp2WaitNotifyTest { diff --git a/test/jdk/com/alibaba/wisp2/Wisp2WorkStealTest.java b/test/jdk/com/alibaba/wisp2/Wisp2WorkStealTest.java index f9dc6938047..f95b0cc0c79 100644 --- a/test/jdk/com/alibaba/wisp2/Wisp2WorkStealTest.java +++ b/test/jdk/com/alibaba/wisp2/Wisp2WorkStealTest.java @@ -1,8 +1,8 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary verification of work stealing really happened - * @modules java.base/jdk.internal.misc + * @modules java.base/jdk.internal.access * @run main/othervm -XX:+UseWisp2 Wisp2WorkStealTest */ @@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertNE; +import static jdk.test.lib.Asserts.assertNE; public class Wisp2WorkStealTest { public static void main(String[] args) { diff --git a/test/jdk/com/alibaba/wisp2/Wisp2YieldTest.java b/test/jdk/com/alibaba/wisp2/Wisp2YieldTest.java index c5ade47a334..eb05604e7be 100644 --- a/test/jdk/com/alibaba/wisp2/Wisp2YieldTest.java +++ b/test/jdk/com/alibaba/wisp2/Wisp2YieldTest.java @@ -1,13 +1,13 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary Test yield in wisp2 * @run main/othervm -XX:-UseBiasedLocking -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true -Dcom.alibaba.wisp.version=2 -Dcom.alibaba.wisp.workerEngines=1 Wisp2YieldTest */ import com.alibaba.wisp.engine.WispEngine; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class Wisp2YieldTest { diff --git a/test/jdk/com/alibaba/wisp2/bug/ConcurrentThreadJoinTest.java b/test/jdk/com/alibaba/wisp2/bug/ConcurrentThreadJoinTest.java index cba11d95bbf..4cdfb9dd1fb 100644 --- a/test/jdk/com/alibaba/wisp2/bug/ConcurrentThreadJoinTest.java +++ b/test/jdk/com/alibaba/wisp2/bug/ConcurrentThreadJoinTest.java @@ -1,11 +1,11 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary ensure thread.isAlive() is false after thread.join() * @run main/othervm -XX:+UseWisp2 ConcurrentThreadJoinTest */ -import static jdk.testlibrary.Asserts.assertFalse; +import static jdk.test.lib.Asserts.assertFalse; public class ConcurrentThreadJoinTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp2/bug/DisableStealBugTest.java b/test/jdk/com/alibaba/wisp2/bug/DisableStealBugTest.java index d5e4ecc6a84..95eeba663d2 100644 --- a/test/jdk/com/alibaba/wisp2/bug/DisableStealBugTest.java +++ b/test/jdk/com/alibaba/wisp2/bug/DisableStealBugTest.java @@ -1,7 +1,7 @@ /* * @test - * @library /lib/testlibrary - * @modules java.base/jdk.internal.misc + * @library /test/lib + * @modules java.base/jdk.internal.access * @modules java.base/com.alibaba.wisp.engine:+open * @summary test bug of update stealEnable fail * @run main/othervm -XX:+UseWisp2 -XX:-EnableSteal DisableStealBugTest @@ -14,7 +14,7 @@ import java.lang.reflect.Field; import java.util.concurrent.atomic.AtomicReference; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertTrue; public class DisableStealBugTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/alibaba/wisp2/bug/Wisp2ThreadObjLeakInThreadGroupTest.java b/test/jdk/com/alibaba/wisp2/bug/Wisp2ThreadObjLeakInThreadGroupTest.java index 43532427ddd..05646d161c8 100644 --- a/test/jdk/com/alibaba/wisp2/bug/Wisp2ThreadObjLeakInThreadGroupTest.java +++ b/test/jdk/com/alibaba/wisp2/bug/Wisp2ThreadObjLeakInThreadGroupTest.java @@ -1,13 +1,13 @@ /* * @test - * @library /lib/testlibrary + * @library /test/lib * @summary test bug fix of thread object leak in thread group * @run main/othervm -XX:+UseWisp2 Wisp2ThreadObjLeakInThreadGroupTest */ import java.util.concurrent.CountDownLatch; -import static jdk.testlibrary.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertEQ; public class Wisp2ThreadObjLeakInThreadGroupTest { public static void main(String[] args) throws Exception { diff --git a/test/jdk/java/beans/XMLDecoder/8028054/Task.java b/test/jdk/java/beans/XMLDecoder/8028054/Task.java index 1d55fa8e358..0f96be3d5bb 100644 --- a/test/jdk/java/beans/XMLDecoder/8028054/Task.java +++ b/test/jdk/java/beans/XMLDecoder/8028054/Task.java @@ -130,6 +130,11 @@ static List> getClasses(int count) throws Exception { .map(s -> s.substring(s.indexOf("java"))) .collect(Collectors.toList()); + // If enclude java.dyn.CoroutineSupport, it will cause the following error: + // java.lang.UnsatisfiedLinkError: 'void java.dyn.CoroutineSupport.registerNatives()' + // Let any brilliant guy to fix it. + fileNames.remove("java.dyn.CoroutineSupport"); + for (String name : fileNames) { classes.add(Class.forName(name)); if (count == classes.size()) { diff --git a/test/jdk/java/dyn/BasicStealTest.java b/test/jdk/java/dyn/BasicStealTest.java index c878f3e7a75..7a3a00c5d08 100644 --- a/test/jdk/java/dyn/BasicStealTest.java +++ b/test/jdk/java/dyn/BasicStealTest.java @@ -1,7 +1,7 @@ /* * @test * @summary test basic coroutine steal mechanism - * @library /lib/testlibrary + * @library /test/lib * @run main/othervm -XX:+EnableCoroutine BasicStealTest */ @@ -9,8 +9,8 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import static jdk.testlibrary.Asserts.assertEQ; -import static jdk.testlibrary.Asserts.assertTrue; +import static jdk.test.lib.Asserts.assertEQ; +import static jdk.test.lib.Asserts.assertTrue; public class BasicStealTest { public static void main(String[] args) { diff --git a/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java b/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java index 9cb506c45cb..b1bc3ad21c5 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestSystemPropertyEvent.java @@ -105,6 +105,11 @@ private static Map createInitialSystemProperties() { result.put(key, System.getProperty(key)); System.out.println("initialProp: " + key); } + { + // Add a property that is not set at JVM start. + String key = "com.alibaba.coroutine.enableCoroutine"; + result.put(key, System.getProperty(key)); + } return result; } }