V8 Project
v8::Locker Class Reference

#include <v8.h>

+ Collaboration diagram for v8::Locker:

Public Member Functions

 Locker (Isolate *isolate)
 Initialize Locker for a given Isolate. More...
 
 ~Locker ()
 

Static Public Member Functions

static bool IsLocked (Isolate *isolate)
 Returns whether or not the locker for a given isolate, is locked by the current thread. More...
 
static bool IsActive ()
 Returns whether v8::Locker is being used by this V8 instance. More...
 

Private Member Functions

void Initialize (Isolate *isolate)
 
 Locker (const Locker &)
 
void operator= (const Locker &)
 

Private Attributes

bool has_lock_
 
bool top_level_
 
internal::Isolateisolate_
 

Static Private Attributes

static bool active_ = false
 

Detailed Description

Definition at line 5692 of file v8.h.

Constructor & Destructor Documentation

◆ Locker() [1/2]

v8::Locker::Locker ( Isolate isolate)
inlineexplicit

Initialize Locker for a given Isolate.

Definition at line 5697 of file v8.h.

5697 { Initialize(isolate); }
void Initialize(Isolate *isolate)
Definition: v8threads.cc:24

◆ ~Locker()

v8::Locker::~Locker ( )

Definition at line 71 of file v8threads.cc.

71  {
73  if (has_lock_) {
74  if (top_level_) {
76  } else {
78  }
80  }
81 }
bool top_level_
Definition: v8.h:5716
bool has_lock_
Definition: v8.h:5715
internal::Isolate * isolate_
Definition: v8.h:5717
ThreadManager * thread_manager()
Definition: isolate.h:921
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::ThreadManager::ArchiveThread(), DCHECK, v8::internal::ThreadManager::FreeThreadResources(), has_lock_, v8::internal::ThreadManager::IsLockedByCurrentThread(), isolate_, v8::internal::Isolate::thread_manager(), top_level_, and v8::internal::ThreadManager::Unlock().

+ Here is the call graph for this function:

◆ Locker() [2/2]

v8::Locker::Locker ( const Locker )
private

Member Function Documentation

◆ Initialize()

void v8::Locker::Initialize ( v8::Isolate isolate)
private

Definition at line 24 of file v8threads.cc.

24  {
25  DCHECK(isolate != NULL);
26  has_lock_= false;
27  top_level_ = true;
28  isolate_ = reinterpret_cast<i::Isolate*>(isolate);
29  // Record that the Locker has been used at least once.
30  active_ = true;
31  // Get the big lock if necessary.
34  has_lock_ = true;
35 
36  // Make sure that V8 is initialized. Archiving of threads interferes
37  // with deserialization by adding additional root pointers, so we must
38  // initialize here, before anyone can call ~Locker() or Unlocker().
39  if (!isolate_->IsInitialized()) {
40  isolate_->Enter();
42  isolate_->Exit();
43  }
44 
45  // This may be a locker within an unlocker in which case we have to
46  // get the saved state for this thread and restore it.
48  top_level_ = false;
49  } else {
50  internal::ExecutionAccess access(isolate_);
51  isolate_->stack_guard()->ClearThread(access);
52  isolate_->stack_guard()->InitThread(access);
53  }
54  }
56 }
static bool active_
Definition: v8.h:5719
static bool Initialize()
Initializes V8.
Definition: api.cc:5058
StackGuard * stack_guard()
Definition: isolate.h:872
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

References active_, DCHECK, v8::internal::Isolate::Enter(), v8::internal::Isolate::Exit(), has_lock_, v8::V8::Initialize(), v8::internal::Isolate::IsInitialized(), v8::internal::ThreadManager::IsLockedByCurrentThread(), isolate_, v8::internal::ThreadManager::Lock(), NULL, v8::internal::ThreadManager::RestoreThread(), v8::internal::Isolate::stack_guard(), v8::internal::Isolate::thread_manager(), and top_level_.

+ Here is the call graph for this function:

◆ IsActive()

bool v8::Locker::IsActive ( )
static

Returns whether v8::Locker is being used by this V8 instance.

Definition at line 66 of file v8threads.cc.

66  {
67  return active_;
68 }

References active_.

Referenced by v8::HandleScope::Initialize().

+ Here is the caller graph for this function:

◆ IsLocked()

bool v8::Locker::IsLocked ( v8::Isolate isolate)
static

Returns whether or not the locker for a given isolate, is locked by the current thread.

Definition at line 59 of file v8threads.cc.

59  {
60  DCHECK(isolate != NULL);
61  i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
62  return internal_isolate->thread_manager()->IsLockedByCurrentThread();
63 }

References DCHECK, v8::internal::ThreadManager::IsLockedByCurrentThread(), NULL, and v8::internal::Isolate::thread_manager().

+ Here is the call graph for this function:

◆ operator=()

void v8::Locker::operator= ( const Locker )
private

Member Data Documentation

◆ active_

bool v8::Locker::active_ = false
staticprivate

Definition at line 5719 of file v8.h.

Referenced by Initialize(), and IsActive().

◆ has_lock_

bool v8::Locker::has_lock_
private

Definition at line 5715 of file v8.h.

Referenced by Initialize(), and ~Locker().

◆ isolate_

internal::Isolate* v8::Locker::isolate_
private

Definition at line 5717 of file v8.h.

Referenced by Initialize(), and ~Locker().

◆ top_level_

bool v8::Locker::top_level_
private

Definition at line 5716 of file v8.h.

Referenced by Initialize(), and ~Locker().


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