Commit 1ef2936a authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[TurboFan] Concurrency test needs to accept that worker thread exits

Timeouts occurred in test-concurrent-feedback-vector/CheckLoadICStates
because the main thread could enter "handshaking" mode precisely at
the moment when the worker thread successfully saw all states.
The main thread would miss this, and end up waiting forever on
a signal from the worker thread.

Bug: v8:11082
Change-Id: I0441785d908c5e27562a3620bb2195483727f118
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519553
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70962}
parent 4f4dda3f
......@@ -126,12 +126,11 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
auto state = nexus.ic_state();
CHECK_EQ(state, MEGAMORPHIC);
}
all_states_seen.store(true, std::memory_order_release);
vector_consumed_->Signal();
} else {
all_states_seen.store(true, std::memory_order_release);
}
all_states_seen.store(true, std::memory_order_release);
vector_consumed_->Signal();
CHECK(!ph_);
ph_ = local_heap.DetachPersistentHandles();
}
......@@ -147,6 +146,12 @@ class FeedbackVectorExplorationThread final : public v8::base::Thread {
base::Semaphore* vector_consumed_;
};
static void CheckedWait(base::Semaphore& semaphore) {
while (!all_states_seen.load(std::memory_order_acquire)) {
if (semaphore.WaitFor(base::TimeDelta::FromMilliseconds(1))) break;
}
}
// Verify that a LoadIC can be cycled through different states and safely
// read on a background thread.
TEST(CheckLoadICStates) {
......@@ -208,7 +213,7 @@ TEST(CheckLoadICStates) {
// If we haven't seen all states by the last attempt, enter an explicit
// handshaking mode.
vector_ready.Signal();
vector_consumed.Wait();
CheckedWait(vector_consumed);
fprintf(stderr, "Main thread configuring monomorphic\n");
}
nexus.ConfigureMonomorphic(Handle<Name>(), Handle<Map>(o1->map(), isolate),
......@@ -217,7 +222,7 @@ TEST(CheckLoadICStates) {
if (i == (kCycles - 1)) {
vector_ready.Signal();
vector_consumed.Wait();
CheckedWait(vector_consumed);
fprintf(stderr, "Main thread configuring polymorphic\n");
}
......@@ -236,7 +241,7 @@ TEST(CheckLoadICStates) {
if (i == (kCycles - 1)) {
vector_ready.Signal();
vector_consumed.Wait();
CheckedWait(vector_consumed);
fprintf(stderr, "Main thread configuring megamorphic\n");
}
......@@ -246,7 +251,7 @@ TEST(CheckLoadICStates) {
if (i == (kCycles - 1)) {
vector_ready.Signal();
vector_consumed.Wait();
CheckedWait(vector_consumed);
fprintf(stderr, "Main thread finishing\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment