mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8213560: gtests might hang
Reviewed-by: rwestberg, eosterlund
This commit is contained in:
parent
a0c58fb8c6
commit
041946dcb0
1 changed files with 28 additions and 16 deletions
|
@ -33,21 +33,22 @@
|
||||||
|
|
||||||
class VM_StopSafepoint : public VM_Operation {
|
class VM_StopSafepoint : public VM_Operation {
|
||||||
public:
|
public:
|
||||||
|
Semaphore* _running;
|
||||||
Semaphore* _test_complete;
|
Semaphore* _test_complete;
|
||||||
VM_StopSafepoint(Semaphore* wait_for) : _test_complete(wait_for) {}
|
VM_StopSafepoint(Semaphore* running, Semaphore* wait_for) :
|
||||||
|
_running(running), _test_complete(wait_for) {}
|
||||||
VMOp_Type type() const { return VMOp_None; }
|
VMOp_Type type() const { return VMOp_None; }
|
||||||
Mode evaluation_mode() const { return _no_safepoint; }
|
Mode evaluation_mode() const { return _no_safepoint; }
|
||||||
bool is_cheap_allocated() const { return false; }
|
bool is_cheap_allocated() const { return false; }
|
||||||
void doit() { _test_complete->wait(); }
|
void doit() { _running->signal(); _test_complete->wait(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class and thread keep the non-safepoint op running while we do our testing.
|
// This class and thread keep the non-safepoint op running while we do our testing.
|
||||||
class VMThreadBlocker : public JavaThread {
|
class VMThreadBlocker : public JavaThread {
|
||||||
public:
|
public:
|
||||||
Semaphore* _unblock;
|
Semaphore _ready;
|
||||||
Semaphore* _done;
|
Semaphore _unblock;
|
||||||
VMThreadBlocker(Semaphore* ub, Semaphore* done) : _unblock(ub), _done(done) {
|
VMThreadBlocker() {}
|
||||||
}
|
|
||||||
virtual ~VMThreadBlocker() {}
|
virtual ~VMThreadBlocker() {}
|
||||||
void run() {
|
void run() {
|
||||||
this->set_thread_state(_thread_in_vm);
|
this->set_thread_state(_thread_in_vm);
|
||||||
|
@ -55,9 +56,8 @@ public:
|
||||||
MutexLocker ml(Threads_lock);
|
MutexLocker ml(Threads_lock);
|
||||||
Threads::add(this);
|
Threads::add(this);
|
||||||
}
|
}
|
||||||
VM_StopSafepoint ss(_unblock);
|
VM_StopSafepoint ss(&_ready, &_unblock);
|
||||||
VMThread::execute(&ss);
|
VMThread::execute(&ss);
|
||||||
_done->signal();
|
|
||||||
Threads::remove(this);
|
Threads::remove(this);
|
||||||
this->smr_delete();
|
this->smr_delete();
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,12 @@ public:
|
||||||
ASSERT_TRUE(false);
|
ASSERT_TRUE(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void ready() {
|
||||||
|
_ready.wait();
|
||||||
|
}
|
||||||
|
void release() {
|
||||||
|
_unblock.signal();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// For testing in a real JavaThread.
|
// For testing in a real JavaThread.
|
||||||
|
@ -130,26 +136,32 @@ public:
|
||||||
|
|
||||||
template <typename TESTFUNC>
|
template <typename TESTFUNC>
|
||||||
static void nomt_test_doer(TESTFUNC &f) {
|
static void nomt_test_doer(TESTFUNC &f) {
|
||||||
Semaphore post, block_done, vmt_done;
|
Semaphore post;
|
||||||
VMThreadBlocker* blocker = new VMThreadBlocker(&block_done, &vmt_done);
|
|
||||||
|
VMThreadBlocker* blocker = new VMThreadBlocker();
|
||||||
blocker->doit();
|
blocker->doit();
|
||||||
|
blocker->ready();
|
||||||
|
|
||||||
SingleTestThread<TESTFUNC>* stt = new SingleTestThread<TESTFUNC>(&post, f);
|
SingleTestThread<TESTFUNC>* stt = new SingleTestThread<TESTFUNC>(&post, f);
|
||||||
stt->doit();
|
stt->doit();
|
||||||
post.wait();
|
post.wait();
|
||||||
block_done.signal();
|
|
||||||
vmt_done.wait();
|
blocker->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename RUNNER>
|
template <typename RUNNER>
|
||||||
static void mt_test_doer() {
|
static void mt_test_doer() {
|
||||||
Semaphore post, block_done, vmt_done;
|
Semaphore post;
|
||||||
VMThreadBlocker* blocker = new VMThreadBlocker(&block_done, &vmt_done);
|
|
||||||
|
VMThreadBlocker* blocker = new VMThreadBlocker();
|
||||||
blocker->doit();
|
blocker->doit();
|
||||||
|
blocker->ready();
|
||||||
|
|
||||||
RUNNER* runner = new RUNNER(&post);
|
RUNNER* runner = new RUNNER(&post);
|
||||||
runner->doit();
|
runner->doit();
|
||||||
post.wait();
|
post.wait();
|
||||||
block_done.signal();
|
|
||||||
vmt_done.wait();
|
blocker->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue