V8 Project
sweeper-thread.cc
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include "src/v8.h"
8 
9 #include "src/isolate.h"
10 #include "src/v8threads.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 static const int kSweeperThreadStackSize = 64 * KB;
16 
18  : Thread(Thread::Options("v8:SweeperThread", kSweeperThreadStackSize)),
19  isolate_(isolate),
20  heap_(isolate->heap()),
21  collector_(heap_->mark_compact_collector()),
22  start_sweeping_semaphore_(0),
23  end_sweeping_semaphore_(0),
24  stop_semaphore_(0) {
25  DCHECK(!FLAG_job_based_sweeping);
27 }
28 
29 
32  DisallowHeapAllocation no_allocation;
33  DisallowHandleAllocation no_handles;
35 
36  while (true) {
38 
40  stop_semaphore_.Signal();
41  return;
42  }
43 
46  end_sweeping_semaphore_.Signal();
47  }
48 }
49 
50 
54  stop_semaphore_.Wait();
55  Join();
56 }
57 
58 
60 
61 
63 
64 
66  bool value = end_sweeping_semaphore_.WaitFor(base::TimeDelta::FromSeconds(0));
67  if (value) {
68  end_sweeping_semaphore_.Signal();
69  }
70  return value;
71 }
72 
73 
74 int SweeperThread::NumberOfThreads(int max_available) {
75  if (!FLAG_concurrent_sweeping && !FLAG_parallel_sweeping) return 0;
76  if (FLAG_sweeper_threads > 0) return FLAG_sweeper_threads;
77  if (FLAG_concurrent_sweeping) return max_available - 1;
78  DCHECK(FLAG_parallel_sweeping);
79  return max_available;
80 }
81 }
82 } // namespace v8::internal
OldSpace * old_pointer_space()
Definition: heap.h:594
OldSpace * old_data_space()
Definition: heap.h:595
static void SetIsolateThreadLocals(Isolate *isolate, PerIsolateThreadData *data)
Definition: isolate.cc:1676
int SweepInParallel(PagedSpace *space, int required_freed_bytes)
volatile base::AtomicWord stop_thread_
base::Semaphore start_sweeping_semaphore_
base::Semaphore end_sweeping_semaphore_
SweeperThread(Isolate *isolate)
base::Semaphore stop_semaphore_
static int NumberOfThreads(int max_available)
MarkCompactCollector * collector_
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205
intptr_t AtomicWord
Definition: atomicops.h:57
Atomic32 Acquire_Load(volatile const Atomic32 *ptr)
void Release_Store(volatile Atomic32 *ptr, Atomic32 value)
void NoBarrier_Store(volatile Atomic8 *ptr, Atomic8 value)
const int KB
Definition: globals.h:106
static const int kSweeperThreadStackSize
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20