Skip to content

Commit

Permalink
[Wisp] Get the correct _thread_stat in Coroutine
Browse files Browse the repository at this point in the history
Summary: We get the wrong _thread_stat in wisp, which will make PerfCounter not precise and may cause an assert error as well.

Test Plan: test/jdk/com/alibaba/wisp/io/TestDatagramSocket.java with -XX:+UseWispMonitor, and other tests

Reviewers: shiyue.xw, lei.yul, sanhong.lsh

Issue: https://aone.alibaba-inc.com/task/29031438

CR: https://code.aone.alibaba-inc.com/xcode/jdk11/codereview/3219099
  • Loading branch information
zhengxiaolinX authored and Sere-Fu committed Aug 19, 2021
1 parent de67558 commit 82d7c59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/hotspot/share/runtime/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3288,6 +3288,10 @@ void JavaThread::prepare(jobject jni_thread, ThreadPriority prio) {
Threads::add(this);
}

ThreadStatistics* JavaThread::get_thread_stat() const {
return UseWispMonitor ? WispThread::current(const_cast<JavaThread*>(this))->_thread_stat : _thread_stat;
}

oop JavaThread::current_park_blocker() {
// Support for JSR-166 locks
oop thread_oop = threadObj();
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ class JavaThread: public Thread {
ThreadStatistics *_thread_stat;

public:
ThreadStatistics* get_thread_stat() const { return _thread_stat; }
ThreadStatistics* get_thread_stat() const;

// Return a blocker object for which this thread is blocked parking.
oop current_park_blocker();
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/com/alibaba/wisp/io/TestDatagramSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @library /lib/testlibrary
* @summary Test WispEngine's DatagramSocket, InitialDirContext use dup socket to query dns.
* @modules java.base/jdk.internal.misc
* @run main/othervm -XX:+EnableCoroutine -Dcom.alibaba.wisp.transparentWispSwitch=true TestDatagramSocket
* @run main/othervm -XX:+EnableCoroutine -XX:+UseWispMonitor -Dcom.alibaba.wisp.transparentWispSwitch=true TestDatagramSocket
*/


Expand Down

0 comments on commit 82d7c59

Please sign in to comment.