Skip to content

Commit

Permalink
[TurboFan] Concurrency test needs to accept that worker thread exits
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Nico Hartmann <[email protected]>
Reviewed-by: Nico Hartmann <[email protected]>
Cr-Commit-Position: refs/heads/master@{#70962}
  • Loading branch information
ripsawridge authored and Commit Bot committed Nov 4, 2020
1 parent 4f4dda3 commit 1ef2936
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions test/cctest/test-concurrent-feedback-vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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),
Expand All @@ -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");
}

Expand All @@ -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");
}

Expand All @@ -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");
}

Expand Down

0 comments on commit 1ef2936

Please sign in to comment.