Commit 67f3103a authored by ulan's avatar ulan Committed by Commit bot

Reland "Check for semaphore alignment on posix platforms. (patchset #1 id:1 of...

Reland "Check for semaphore alignment on posix platforms. (patchset #1 id:1 of https://codereview.chromium.org/1912923003/ )"

This patch also fixed three misaligned semaphores.

This reverts commit 80c73e2c.

BUG=chromium:605349
LOG=NO

Review URL: https://codereview.chromium.org/1917923002

Cr-Commit-Position: refs/heads/master@{#35773}
parent 431ea9a0
......@@ -74,6 +74,13 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) {
#elif V8_OS_POSIX
Semaphore::Semaphore(int count) {
// The sem_init() does not check for alignment of the native handle.
// Unaligned native handle can later cause a failure in semaphore signal.
// Check the alignment here to catch the failure earlier.
// Context: crbug.com/605349.
const uintptr_t kPointerAlignmentMask = sizeof(void*) - 1;
CHECK_EQ(
0, reinterpret_cast<uintptr_t>(&native_handle_) & kPointerAlignmentMask);
DCHECK(count >= 0);
#if V8_LIBC_GLIBC
// sem_init in glibc prior to 2.1 does not zero out semaphores.
......
......@@ -62,7 +62,6 @@ MarkCompactCollector::MarkCompactCollector(Heap* heap)
embedder_heap_tracer_(nullptr),
have_code_to_deoptimize_(false),
compacting_(false),
pending_compaction_tasks_semaphore_(0),
sweeper_(heap) {
}
......
......@@ -461,8 +461,8 @@ class MarkCompactCollector {
void PrepareToBeSweptPage(AllocationSpace space, Page* page);
Heap* heap_;
base::Mutex mutex_;
base::Semaphore pending_sweeper_tasks_semaphore_;
base::Mutex mutex_;
SweptList swept_list_[kAllocationSpaces];
SweepingList sweeping_list_[kAllocationSpaces];
bool sweeping_in_progress_;
......@@ -868,9 +868,6 @@ class MarkCompactCollector {
// candidates.
bool compacting_;
// Semaphore used to synchronize compaction tasks.
base::Semaphore pending_compaction_tasks_semaphore_;
bool black_allocation_;
Sweeper sweeper_;
......
......@@ -33,8 +33,8 @@ class TaskQueue {
void Terminate();
private:
base::Mutex lock_;
base::Semaphore process_queue_semaphore_;
base::Mutex lock_;
std::queue<Task*> task_queue_;
bool terminated_;
......
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