Revision: 24352
Author:   [email protected]
Date:     Wed Oct  1 09:16:28 2014 UTC
Log:      Remove sweeper threads

Job based sweeping is enabled since 3.29, so remove the now obsolete
thread based implementation

BUG=none
[email protected]
LOG=n

Review URL: https://codereview.chromium.org/615933003
https://code.google.com/p/v8/source/detail?r=24352

Deleted:
 /branches/bleeding_edge/src/heap/sweeper-thread.cc
 /branches/bleeding_edge/src/heap/sweeper-thread.h
Modified:
 /branches/bleeding_edge/BUILD.gn
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/heap/mark-compact.cc
 /branches/bleeding_edge/src/heap/mark-compact.h
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/tools/gyp/v8.gyp

=======================================
--- /branches/bleeding_edge/src/heap/sweeper-thread.cc Tue Aug 5 08:18:22 2014 UTC
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/heap/sweeper-thread.h"
-
-#include "src/v8.h"
-
-#include "src/isolate.h"
-#include "src/v8threads.h"
-
-namespace v8 {
-namespace internal {
-
-static const int kSweeperThreadStackSize = 64 * KB;
-
-SweeperThread::SweeperThread(Isolate* isolate)
-    : Thread(Thread::Options("v8:SweeperThread", kSweeperThreadStackSize)),
-      isolate_(isolate),
-      heap_(isolate->heap()),
-      collector_(heap_->mark_compact_collector()),
-      start_sweeping_semaphore_(0),
-      end_sweeping_semaphore_(0),
-      stop_semaphore_(0) {
-  DCHECK(!FLAG_job_based_sweeping);
- base::NoBarrier_Store(&stop_thread_, static_cast<base::AtomicWord>(false));
-}
-
-
-void SweeperThread::Run() {
-  Isolate::SetIsolateThreadLocals(isolate_, NULL);
-  DisallowHeapAllocation no_allocation;
-  DisallowHandleAllocation no_handles;
-  DisallowHandleDereference no_deref;
-
-  while (true) {
-    start_sweeping_semaphore_.Wait();
-
-    if (base::Acquire_Load(&stop_thread_)) {
-      stop_semaphore_.Signal();
-      return;
-    }
-
-    collector_->SweepInParallel(heap_->old_data_space(), 0);
-    collector_->SweepInParallel(heap_->old_pointer_space(), 0);
-    end_sweeping_semaphore_.Signal();
-  }
-}
-
-
-void SweeperThread::Stop() {
-  base::Release_Store(&stop_thread_, static_cast<base::AtomicWord>(true));
-  start_sweeping_semaphore_.Signal();
-  stop_semaphore_.Wait();
-  Join();
-}
-
-
-void SweeperThread::StartSweeping() { start_sweeping_semaphore_.Signal(); }
-
-
-void SweeperThread::WaitForSweeperThread() { end_sweeping_semaphore_.Wait(); }
-
-
-bool SweeperThread::SweepingCompleted() {
- bool value = end_sweeping_semaphore_.WaitFor(base::TimeDelta::FromSeconds(0));
-  if (value) {
-    end_sweeping_semaphore_.Signal();
-  }
-  return value;
-}
-
-
-int SweeperThread::NumberOfThreads(int max_available) {
-  if (!FLAG_concurrent_sweeping && !FLAG_parallel_sweeping) return 0;
-  if (FLAG_sweeper_threads > 0) return FLAG_sweeper_threads;
-  if (FLAG_concurrent_sweeping) return max_available - 1;
-  DCHECK(FLAG_parallel_sweeping);
-  return max_available;
-}
-}
-}  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/heap/sweeper-thread.h Tue Aug 5 08:18:22 2014 UTC
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_HEAP_SWEEPER_THREAD_H_
-#define V8_HEAP_SWEEPER_THREAD_H_
-
-#include "src/base/atomicops.h"
-#include "src/base/platform/platform.h"
-#include "src/flags.h"
-#include "src/utils.h"
-
-#include "src/heap/spaces.h"
-
-#include "src/heap/heap.h"
-
-namespace v8 {
-namespace internal {
-
-class SweeperThread : public base::Thread {
- public:
-  explicit SweeperThread(Isolate* isolate);
-  ~SweeperThread() {}
-
-  void Run();
-  void Stop();
-  void StartSweeping();
-  void WaitForSweeperThread();
-  bool SweepingCompleted();
-
-  static int NumberOfThreads(int max_available);
-
- private:
-  Isolate* isolate_;
-  Heap* heap_;
-  MarkCompactCollector* collector_;
-  base::Semaphore start_sweeping_semaphore_;
-  base::Semaphore end_sweeping_semaphore_;
-  base::Semaphore stop_semaphore_;
-  volatile base::AtomicWord stop_thread_;
-};
-}
-}  // namespace v8::internal
-
-#endif  // V8_HEAP_SWEEPER_THREAD_H_
=======================================
--- /branches/bleeding_edge/BUILD.gn    Tue Sep 30 10:46:04 2014 UTC
+++ /branches/bleeding_edge/BUILD.gn    Wed Oct  1 09:16:28 2014 UTC
@@ -676,8 +676,6 @@
     "src/heap/store-buffer-inl.h",
     "src/heap/store-buffer.cc",
     "src/heap/store-buffer.h",
-    "src/heap/sweeper-thread.h",
-    "src/heap/sweeper-thread.cc",
     "src/hydrogen-alias-analysis.h",
     "src/hydrogen-bce.cc",
     "src/hydrogen-bce.h",
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Mon Sep 29 07:29:14 2014 UTC +++ /branches/bleeding_edge/src/flag-definitions.h Wed Oct 1 09:16:28 2014 UTC
@@ -535,7 +535,6 @@
 DEFINE_BOOL(concurrent_sweeping, true, "enable concurrent sweeping")
 DEFINE_INT(sweeper_threads, 0,
            "number of parallel and concurrent sweeping threads")
-DEFINE_BOOL(job_based_sweeping, true, "enable job based sweeping")
 #ifdef VERIFY_HEAP
 DEFINE_BOOL(verify_heap, false, "verify heap pointers before and after GC")
 #endif
@@ -666,7 +665,6 @@
 DEFINE_NEG_IMPLICATION(predictable, concurrent_osr)
 DEFINE_NEG_IMPLICATION(predictable, concurrent_sweeping)
 DEFINE_NEG_IMPLICATION(predictable, parallel_sweeping)
-DEFINE_NEG_IMPLICATION(predictable, job_based_sweeping)


 //
=======================================
--- /branches/bleeding_edge/src/heap/mark-compact.cc Wed Sep 17 15:29:42 2014 UTC +++ /branches/bleeding_edge/src/heap/mark-compact.cc Wed Oct 1 09:16:28 2014 UTC
@@ -18,7 +18,6 @@
 #include "src/heap/objects-visiting.h"
 #include "src/heap/objects-visiting-inl.h"
 #include "src/heap/spaces-inl.h"
-#include "src/heap/sweeper-thread.h"
 #include "src/heap-profiler.h"
 #include "src/ic/ic.h"
 #include "src/ic/stub-cache.h"
@@ -557,39 +556,27 @@
   DCHECK(free_list_old_pointer_space_.get()->IsEmpty());
   DCHECK(free_list_old_data_space_.get()->IsEmpty());
   sweeping_in_progress_ = true;
-  for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
-    isolate()->sweeper_threads()[i]->StartSweeping();
-  }
-  if (FLAG_job_based_sweeping) {
-    V8::GetCurrentPlatform()->CallOnBackgroundThread(
-        new SweeperTask(heap(), heap()->old_data_space()),
-        v8::Platform::kShortRunningTask);
-    V8::GetCurrentPlatform()->CallOnBackgroundThread(
-        new SweeperTask(heap(), heap()->old_pointer_space()),
-        v8::Platform::kShortRunningTask);
-  }
+  V8::GetCurrentPlatform()->CallOnBackgroundThread(
+      new SweeperTask(heap(), heap()->old_data_space()),
+      v8::Platform::kShortRunningTask);
+  V8::GetCurrentPlatform()->CallOnBackgroundThread(
+      new SweeperTask(heap(), heap()->old_pointer_space()),
+      v8::Platform::kShortRunningTask);
 }


 void MarkCompactCollector::EnsureSweepingCompleted() {
   DCHECK(sweeping_in_progress_ == true);

-  // If sweeping is not completed, we try to complete it here. If we do not
-  // have sweeper threads we have to complete since we do not have a good
-  // indicator for a swept space in that case.
-  if (!AreSweeperThreadsActivated() || !IsSweepingCompleted()) {
+ // If sweeping is not completed or not running at all, we try to complete it
+  // here.
+  if (!IsSweepingCompleted()) {
     SweepInParallel(heap()->paged_space(OLD_DATA_SPACE), 0);
     SweepInParallel(heap()->paged_space(OLD_POINTER_SPACE), 0);
   }
-
-  for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
-    isolate()->sweeper_threads()[i]->WaitForSweeperThread();
-  }
-  if (FLAG_job_based_sweeping) {
-    // Wait twice for both jobs.
-    pending_sweeper_jobs_semaphore_.Wait();
-    pending_sweeper_jobs_semaphore_.Wait();
-  }
+  // Wait twice for both jobs.
+  pending_sweeper_jobs_semaphore_.Wait();
+  pending_sweeper_jobs_semaphore_.Wait();
   ParallelSweepSpacesComplete();
   sweeping_in_progress_ = false;
   RefillFreeList(heap()->paged_space(OLD_DATA_SPACE));
@@ -606,20 +593,11 @@


 bool MarkCompactCollector::IsSweepingCompleted() {
-  for (int i = 0; i < isolate()->num_sweeper_threads(); i++) {
-    if (!isolate()->sweeper_threads()[i]->SweepingCompleted()) {
-      return false;
-    }
-  }
-
-  if (FLAG_job_based_sweeping) {
-    if (!pending_sweeper_jobs_semaphore_.WaitFor(
-            base::TimeDelta::FromSeconds(0))) {
-      return false;
-    }
-    pending_sweeper_jobs_semaphore_.Signal();
+  if (!pending_sweeper_jobs_semaphore_.WaitFor(
+          base::TimeDelta::FromSeconds(0))) {
+    return false;
   }
-
+  pending_sweeper_jobs_semaphore_.Signal();
   return true;
 }

@@ -641,11 +619,6 @@
   space->AddToAccountingStats(freed_bytes);
   space->DecrementUnsweptFreeBytes(freed_bytes);
 }
-
-
-bool MarkCompactCollector::AreSweeperThreadsActivated() {
-  return isolate()->sweeper_threads() != NULL || FLAG_job_based_sweeping;
-}


 void Marking::TransferMark(Address old_start, Address new_start) {
@@ -4246,8 +4219,9 @@


static bool ShouldStartSweeperThreads(MarkCompactCollector::SweeperType type) {
-  return type == MarkCompactCollector::PARALLEL_SWEEPING ||
-         type == MarkCompactCollector::CONCURRENT_SWEEPING;
+  return (type == MarkCompactCollector::PARALLEL_SWEEPING ||
+          type == MarkCompactCollector::CONCURRENT_SWEEPING) &&
+         !FLAG_predictable;
 }


=======================================
--- /branches/bleeding_edge/src/heap/mark-compact.h Tue Sep 2 13:36:35 2014 UTC +++ /branches/bleeding_edge/src/heap/mark-compact.h Wed Oct 1 09:16:28 2014 UTC
@@ -641,8 +641,6 @@

   void RefillFreeList(PagedSpace* space);

-  bool AreSweeperThreadsActivated();
-
   // Checks if sweeping is in progress right now on any space.
   bool sweeping_in_progress() { return sweeping_in_progress_; }

=======================================
--- /branches/bleeding_edge/src/isolate.cc      Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/isolate.cc      Wed Oct  1 09:16:28 2014 UTC
@@ -18,7 +18,6 @@
 #include "src/debug.h"
 #include "src/deoptimizer.h"
 #include "src/heap/spaces.h"
-#include "src/heap/sweeper-thread.h"
 #include "src/heap-profiler.h"
 #include "src/hydrogen.h"
 #include "src/ic/stub-cache.h"
@@ -1516,8 +1515,6 @@
       function_entry_hook_(NULL),
       deferred_handles_head_(NULL),
       optimizing_compiler_thread_(NULL),
-      sweeper_thread_(NULL),
-      num_sweeper_threads_(0),
       stress_deopt_count_(0),
       next_optimization_id_(0),
       use_counter_callback_(NULL),
@@ -1612,16 +1609,7 @@
       optimizing_compiler_thread_ = NULL;
     }

-    for (int i = 0; i < num_sweeper_threads_; i++) {
-      sweeper_thread_[i]->Stop();
-      delete sweeper_thread_[i];
-      sweeper_thread_[i] = NULL;
-    }
-    delete[] sweeper_thread_;
-    sweeper_thread_ = NULL;
-
-    if (FLAG_job_based_sweeping &&
-        heap_.mark_compact_collector()->sweeping_in_progress()) {
+    if (heap_.mark_compact_collector()->sweeping_in_progress()) {
       heap_.mark_compact_collector()->EnsureSweepingCompleted();
     }

@@ -1949,11 +1937,6 @@
     max_available_threads_ =
         Max(Min(base::SysInfo::NumberOfProcessors(), 4), 1);
   }
-
-  if (!FLAG_job_based_sweeping) {
-    num_sweeper_threads_ =
-        SweeperThread::NumberOfThreads(max_available_threads_);
-  }

   if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) {
     PrintF("Concurrent recompilation has been disabled for tracing.\n");
@@ -1961,14 +1944,6 @@
     optimizing_compiler_thread_ = new OptimizingCompilerThread(this);
     optimizing_compiler_thread_->Start();
   }
-
-  if (num_sweeper_threads_ > 0) {
-    sweeper_thread_ = new SweeperThread*[num_sweeper_threads_];
-    for (int i = 0; i < num_sweeper_threads_; i++) {
-      sweeper_thread_[i] = new SweeperThread(this);
-      sweeper_thread_[i]->Start();
-    }
-  }

   // If we are deserializing, read the state into the now-empty heap.
   if (!create_heap_objects) {
=======================================
--- /branches/bleeding_edge/src/isolate.h       Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/isolate.h       Wed Oct  1 09:16:28 2014 UTC
@@ -1060,14 +1060,6 @@
   OptimizingCompilerThread* optimizing_compiler_thread() {
     return optimizing_compiler_thread_;
   }
-
-  int num_sweeper_threads() const {
-    return num_sweeper_threads_;
-  }
-
-  SweeperThread** sweeper_threads() {
-    return sweeper_thread_;
-  }

   int id() const { return static_cast<int>(id_); }

@@ -1327,8 +1319,6 @@

   DeferredHandles* deferred_handles_head_;
   OptimizingCompilerThread* optimizing_compiler_thread_;
-  SweeperThread** sweeper_thread_;
-  int num_sweeper_threads_;

   // Counts deopt points if deopt_every_n_times is enabled.
   unsigned int stress_deopt_count_;
=======================================
--- /branches/bleeding_edge/tools/gyp/v8.gyp    Tue Sep 30 10:46:04 2014 UTC
+++ /branches/bleeding_edge/tools/gyp/v8.gyp    Wed Oct  1 09:16:28 2014 UTC
@@ -588,8 +588,6 @@
         '../../src/heap/store-buffer-inl.h',
         '../../src/heap/store-buffer.cc',
         '../../src/heap/store-buffer.h',
-        '../../src/heap/sweeper-thread.h',
-        '../../src/heap/sweeper-thread.cc',
         '../../src/hydrogen-alias-analysis.h',
         '../../src/hydrogen-bce.cc',
         '../../src/hydrogen-bce.h',

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to