V8 Project
v8::internal::SamplerThread Class Reference
+ Inheritance diagram for v8::internal::SamplerThread:
+ Collaboration diagram for v8::internal::SamplerThread:

Public Member Functions

 SamplerThread (int interval)
 
virtual void Run ()
 
- Public Member Functions inherited from v8::base::Thread
 Thread (const Options &options)
 
virtual ~Thread ()
 
void Start ()
 
void StartSynchronously ()
 
void Join ()
 
const char * name () const
 
PlatformDatadata ()
 
void NotifyStartedAndRun ()
 

Static Public Member Functions

static void SetUp ()
 
static void TearDown ()
 
static void AddActiveSampler (Sampler *sampler)
 
static void RemoveActiveSampler (Sampler *sampler)
 
- Static Public Member Functions inherited from v8::base::Thread
static LocalStorageKey CreateThreadLocalKey ()
 
static void DeleteThreadLocalKey (LocalStorageKey key)
 
static void * GetThreadLocal (LocalStorageKey key)
 
static int GetThreadLocalInt (LocalStorageKey key)
 
static void SetThreadLocal (LocalStorageKey key, void *value)
 
static void SetThreadLocalInt (LocalStorageKey key, int value)
 
static bool HasThreadLocal (LocalStorageKey key)
 
static void * GetExistingThreadLocal (LocalStorageKey key)
 
static void YieldCPU ()
 

Static Public Attributes

static const int kSamplerThreadStackSize = 64 * KB
 
- Static Public Attributes inherited from v8::base::Thread
static const int kMaxThreadNameLength = 16
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (SamplerThread)
 

Private Attributes

const int interval_
 
List< Sampler * > active_samplers_
 

Static Private Attributes

static base::Mutex * mutex_ = NULL
 
static SamplerThreadinstance_ = NULL
 

Additional Inherited Members

- Public Types inherited from v8::base::Thread
typedef int32_t LocalStorageKey
 

Detailed Description

Definition at line 489 of file sampler.cc.

Constructor & Destructor Documentation

◆ SamplerThread()

v8::internal::SamplerThread::SamplerThread ( int  interval)
inlineexplicit

Definition at line 493 of file sampler.cc.

495  interval_(interval) {}
Thread(const Options &options)
static const int kSamplerThreadStackSize
Definition: sampler.cc:491

Referenced by AddActiveSampler().

+ Here is the caller graph for this function:

Member Function Documentation

◆ AddActiveSampler()

static void v8::internal::SamplerThread::AddActiveSampler ( Sampler sampler)
inlinestatic

Definition at line 500 of file sampler.cc.

500  {
501  bool need_to_start = false;
502  base::LockGuard<base::Mutex> lock_guard(mutex_);
503  if (instance_ == NULL) {
504  // Start a thread that will send SIGPROF signal to VM threads,
505  // when CPU profiling will be enabled.
506  instance_ = new SamplerThread(sampler->interval());
507  need_to_start = true;
508  }
509 
510  DCHECK(sampler->IsActive());
511  DCHECK(!instance_->active_samplers_.Contains(sampler));
512  DCHECK(instance_->interval_ == sampler->interval());
513  instance_->active_samplers_.Add(sampler);
514 
515  if (need_to_start) instance_->StartSynchronously();
516  }
void StartSynchronously()
Definition: platform.h:440
static base::Mutex * mutex_
Definition: sampler.cc:562
SamplerThread(int interval)
Definition: sampler.cc:493
List< Sampler * > active_samplers_
Definition: sampler.cc:566
static SamplerThread * instance_
Definition: sampler.cc:563
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

References active_samplers_, DCHECK, instance_, v8::internal::Sampler::interval(), interval_, v8::internal::Sampler::IsActive(), mutex_, NULL, SamplerThread(), and v8::base::Thread::StartSynchronously().

Referenced by v8::internal::Sampler::Start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::SamplerThread::DISALLOW_COPY_AND_ASSIGN ( SamplerThread  )
private

◆ RemoveActiveSampler()

static void v8::internal::SamplerThread::RemoveActiveSampler ( Sampler sampler)
inlinestatic

Definition at line 518 of file sampler.cc.

518  {
519  SamplerThread* instance_to_remove = NULL;
520  {
521  base::LockGuard<base::Mutex> lock_guard(mutex_);
522 
523  DCHECK(sampler->IsActive());
524  bool removed = instance_->active_samplers_.RemoveElement(sampler);
525  DCHECK(removed);
526  USE(removed);
527 
528  // We cannot delete the instance immediately as we need to Join() the
529  // thread but we are holding mutex_ and the thread may try to acquire it.
530  if (instance_->active_samplers_.is_empty()) {
531  instance_to_remove = instance_;
532  instance_ = NULL;
533  }
534  }
535 
536  if (!instance_to_remove) return;
537  instance_to_remove->Join();
538  delete instance_to_remove;
539  }
void USE(T)
Definition: macros.h:322

References active_samplers_, DCHECK, instance_, v8::internal::Sampler::IsActive(), v8::base::Thread::Join(), mutex_, NULL, and USE().

Referenced by v8::internal::Sampler::Stop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Run()

virtual void v8::internal::SamplerThread::Run ( )
inlinevirtual

Implements v8::base::Thread.

Definition at line 542 of file sampler.cc.

542  {
543  while (true) {
544  {
545  base::LockGuard<base::Mutex> lock_guard(mutex_);
546  if (active_samplers_.is_empty()) break;
547  // When CPU profiling is enabled both JavaScript and C++ code is
548  // profiled. We must not suspend.
549  for (int i = 0; i < active_samplers_.length(); ++i) {
550  Sampler* sampler = active_samplers_.at(i);
551  if (!sampler->isolate()->IsInitialized()) continue;
552  if (!sampler->IsProfiling()) continue;
553  sampler->DoSample();
554  }
555  }
557  }
558  }
static void Sleep(const int milliseconds)

References active_samplers_, v8::internal::Sampler::DoSample(), interval_, v8::internal::Isolate::IsInitialized(), v8::internal::Sampler::isolate(), v8::internal::Sampler::IsProfiling(), mutex_, and v8::base::OS::Sleep().

+ Here is the call graph for this function:

◆ SetUp()

static void v8::internal::SamplerThread::SetUp ( )
inlinestatic

Definition at line 497 of file sampler.cc.

497 { if (!mutex_) mutex_ = new base::Mutex(); }

References mutex_.

Referenced by v8::internal::Sampler::SetUp().

+ Here is the caller graph for this function:

◆ TearDown()

static void v8::internal::SamplerThread::TearDown ( )
inlinestatic

Definition at line 498 of file sampler.cc.

498 { delete mutex_; mutex_ = NULL; }

References mutex_, and NULL.

Referenced by v8::internal::Sampler::TearDown().

+ Here is the caller graph for this function:

Member Data Documentation

◆ active_samplers_

List<Sampler*> v8::internal::SamplerThread::active_samplers_
private

Definition at line 566 of file sampler.cc.

Referenced by AddActiveSampler(), RemoveActiveSampler(), and Run().

◆ instance_

SamplerThread * v8::internal::SamplerThread::instance_ = NULL
staticprivate

Definition at line 563 of file sampler.cc.

Referenced by AddActiveSampler(), and RemoveActiveSampler().

◆ interval_

const int v8::internal::SamplerThread::interval_
private

Definition at line 565 of file sampler.cc.

Referenced by AddActiveSampler(), and Run().

◆ kSamplerThreadStackSize

const int v8::internal::SamplerThread::kSamplerThreadStackSize = 64 * KB
static

Definition at line 491 of file sampler.cc.

◆ mutex_

base::Mutex * v8::internal::SamplerThread::mutex_ = NULL
staticprivate

Definition at line 562 of file sampler.cc.

Referenced by AddActiveSampler(), RemoveActiveSampler(), Run(), SetUp(), and TearDown().


The documentation for this class was generated from the following file: