V8 Project
v8::V8 Class Reference

Container class for static utility functions. More...

#include <v8.h>

+ Collaboration diagram for v8::V8:

Static Public Member Functions

static void SetFatalErrorHandler (FatalErrorCallback that)
 Set the callback to invoke in case of fatal errors. More...
 
static void SetAllowCodeGenerationFromStringsCallback (AllowCodeGenerationFromStringsCallback that)
 Set the callback to invoke to check if code generation from strings should be allowed. More...
 
static void SetArrayBufferAllocator (ArrayBuffer::Allocator *allocator)
 Set allocator to use for ArrayBuffer memory. More...
 
static bool IsDead ()
 Check if V8 is dead and therefore unusable. More...
 
static StartupData::CompressionAlgorithm GetCompressedStartupDataAlgorithm ()
 The following 4 functions are to be used when V8 is built with the 'compress_startup_data' flag enabled. More...
 
static int GetCompressedStartupDataCount ()
 
static void GetCompressedStartupData (StartupData *compressed_data)
 
static void SetDecompressedStartupData (StartupData *decompressed_data)
 
static void SetNativesDataBlob (StartupData *startup_blob)
 Hand startup data to V8, in case the embedder has chosen to build V8 with external startup data. More...
 
static void SetSnapshotDataBlob (StartupData *startup_blob)
 
static bool AddMessageListener (MessageCallback that, Handle< Value > data=Handle< Value >())
 Adds a message listener. More...
 
static void RemoveMessageListeners (MessageCallback that)
 Remove all message listeners from the specified callback function. More...
 
static void SetCaptureStackTraceForUncaughtExceptions (bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
 Tells V8 to capture current stack trace when uncaught exception occurs and report it to the message listeners. More...
 
static void SetFlagsFromString (const char *str, int length)
 Sets V8 flags from a string. More...
 
static void SetFlagsFromCommandLine (int *argc, char **argv, bool remove_flags)
 Sets V8 flags from the command line. More...
 
static const char * GetVersion ()
 Get the version string. More...
 
static void SetFailedAccessCheckCallbackFunction (FailedAccessCheckCallback)
 Callback function for reporting failed access checks. More...
 
static void AddGCPrologueCallback (GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)
 Enables the host application to receive a notification before a garbage collection. More...
 
static void RemoveGCPrologueCallback (GCPrologueCallback callback)
 This function removes callback which was installed by AddGCPrologueCallback function. More...
 
static void AddGCEpilogueCallback (GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll)
 Enables the host application to receive a notification after a garbage collection. More...
 
static void RemoveGCEpilogueCallback (GCEpilogueCallback callback)
 This function removes callback which was installed by AddGCEpilogueCallback function. More...
 
static void AddMemoryAllocationCallback (MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
 Enables the host application to provide a mechanism to be notified and perform custom logging when V8 Allocates Executable Memory. More...
 
static void RemoveMemoryAllocationCallback (MemoryAllocationCallback callback)
 Removes callback that was installed by AddMemoryAllocationCallback. More...
 
static bool Initialize ()
 Initializes V8. More...
 
static void SetEntropySource (EntropySource source)
 Allows the host application to provide a callback which can be used as a source of entropy for random number generators. More...
 
static void SetReturnAddressLocationResolver (ReturnAddressLocationResolver return_address_resolver)
 Allows the host application to provide a callback that allows v8 to cooperate with a profiler that rewrites return addresses on stack. More...
 
static void TerminateExecution (Isolate *isolate)
 Forcefully terminate the current thread of JavaScript execution in the given isolate. More...
 
static bool IsExecutionTerminating (Isolate *isolate=NULL)
 Is V8 terminating JavaScript execution. More...
 
static void CancelTerminateExecution (Isolate *isolate)
 Resume execution capability in the given isolate, whose execution was previously forcefully terminated using TerminateExecution(). More...
 
static bool Dispose ()
 Releases any resources used by v8 and stops any utility threads that may be running. More...
 
static void VisitExternalResources (ExternalResourceVisitor *visitor)
 Iterates through all external resources referenced from current isolate heap. More...
 
static void VisitHandlesWithClassIds (PersistentHandleVisitor *visitor)
 Iterates through all the persistent handles in the current isolate's heap that have class_ids. More...
 
static void VisitHandlesForPartialDependence (Isolate *isolate, PersistentHandleVisitor *visitor)
 Iterates through all the persistent handles in the current isolate's heap that have class_ids and are candidates to be marked as partially dependent handles. More...
 
static bool InitializeICU (const char *icu_data_file=NULL)
 Initialize the ICU library bundled with V8. More...
 
static void InitializePlatform (Platform *platform)
 Sets the v8::Platform to use. More...
 
static void ShutdownPlatform ()
 Clears all references to the v8::Platform. More...
 

Private Types

typedef WeakCallbackData< Value, void >::Callback WeakCallback
 

Private Member Functions

 V8 ()
 

Static Private Member Functions

static internal::Object ** GlobalizeReference (internal::Isolate *isolate, internal::Object **handle)
 
static internal::Object ** CopyPersistent (internal::Object **handle)
 
static void DisposeGlobal (internal::Object **global_handle)
 
static void MakeWeak (internal::Object **global_handle, void *data, WeakCallback weak_callback)
 
static void * ClearWeak (internal::Object **global_handle)
 
static void Eternalize (Isolate *isolate, Value *handle, int *index)
 
static Local< ValueGetEternal (Isolate *isolate, int index)
 

Friends

template<class T >
class Handle
 
template<class T >
class Local
 
template<class T >
class Eternal
 
template<class T >
class PersistentBase
 
template<class T , class M >
class Persistent
 
class Context
 

Detailed Description

Container class for static utility functions.

Definition at line 4964 of file v8.h.

Member Typedef Documentation

◆ WeakCallback

typedef WeakCallbackData<Value, void>::Callback v8::V8::WeakCallback
private

Definition at line 5249 of file v8.h.

Constructor & Destructor Documentation

◆ V8()

v8::V8::V8 ( )
private

Member Function Documentation

◆ AddGCEpilogueCallback()

void v8::V8::AddGCEpilogueCallback ( GCEpilogueCallback  callback,
GCType  gc_type_filter = kGCTypeAll 
)
static

Enables the host application to receive a notification after a garbage collection.

Allocations are not allowed in the callback function, you therefore cannot manipulate objects (set or delete properties for example) since it is possible such operations will result in the allocation of objects. It is possible to specify the GCType filter for your callback. But it is not possible to register the same callback function two times with different GCType filters.

Definition at line 6494 of file api.cc.

6494  {
6495  i::Isolate* isolate = i::Isolate::Current();
6496  isolate->heap()->AddGCEpilogueCallback(
6497  reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback),
6498  gc_type,
6499  false);
6500 }
void(* GCEpilogueCallback)(Isolate *isolate, GCType type, GCCallbackFlags flags)
Definition: v8.h:4651
void AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, GCType gc_type_filter, bool pass_isolate=true)
Definition: heap.cc:5319

References v8::internal::Heap::AddGCEpilogueCallback(), and v8::internal::Isolate::heap().

+ Here is the call graph for this function:

◆ AddGCPrologueCallback()

void v8::V8::AddGCPrologueCallback ( GCPrologueCallback  callback,
GCType  gc_type_filter = kGCTypeAll 
)
static

Enables the host application to receive a notification before a garbage collection.

Allocations are not allowed in the callback function, you therefore cannot manipulate objects (set or delete properties for example) since it is possible such operations will result in the allocation of objects. It is possible to specify the GCType filter for your callback. But it is not possible to register the same callback function two times with different GCType filters.

Definition at line 6478 of file api.cc.

6478  {
6479  i::Isolate* isolate = i::Isolate::Current();
6480  isolate->heap()->AddGCPrologueCallback(
6481  reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback),
6482  gc_type,
6483  false);
6484 }
void(* GCPrologueCallback)(Isolate *isolate, GCType type, GCCallbackFlags flags)
Definition: v8.h:4648
void AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback, GCType gc_type_filter, bool pass_isolate=true)
Definition: heap.cc:5298

References v8::internal::Heap::AddGCPrologueCallback(), and v8::internal::Isolate::heap().

+ Here is the call graph for this function:

◆ AddMemoryAllocationCallback()

void v8::V8::AddMemoryAllocationCallback ( MemoryAllocationCallback  callback,
ObjectSpace  space,
AllocationAction  action 
)
static

Enables the host application to provide a mechanism to be notified and perform custom logging when V8 Allocates Executable Memory.

Definition at line 6510 of file api.cc.

6512  {
6513  i::Isolate* isolate = i::Isolate::Current();
6515  callback, space, action);
6516 }
MemoryAllocator * memory_allocator()
Definition: isolate.h:883
void AddMemoryAllocationCallback(MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
Definition: spaces.cc:772
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 expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi space(in MBytes)

References v8::internal::MemoryAllocator::AddMemoryAllocationCallback(), v8::internal::Isolate::memory_allocator(), and space().

+ Here is the call graph for this function:

◆ AddMessageListener()

bool v8::V8::AddMessageListener ( MessageCallback  that,
Handle< Value data = Handle<Value>() 
)
static

Adds a message listener.

The same message listener can be added more than once and in that case it will be called more than once for each message.

If data is specified, it will be passed to the callback when it is called. Otherwise, the exception object will be passed to the callback instead.

Definition at line 6307 of file api.cc.

6307  {
6308  i::Isolate* isolate = i::Isolate::Current();
6309  ON_BAILOUT(isolate, "v8::V8::AddMessageListener()", return false);
6310  ENTER_V8(isolate);
6311  i::HandleScope scope(isolate);
6312  NeanderArray listeners(isolate->factory()->message_listeners());
6313  NeanderObject obj(isolate, 2);
6314  obj.set(0, *isolate->factory()->NewForeign(FUNCTION_ADDR(that)));
6315  obj.set(1, data.IsEmpty() ? isolate->heap()->undefined_value()
6316  : *Utils::OpenHandle(*data));
6317  listeners.add(obj.value());
6318  return true;
6319 }
#define ON_BAILOUT(isolate, location, code)
Definition: api.cc:60
#define ENTER_V8(isolate)
Definition: api.cc:54
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288
Factory * factory()
Definition: isolate.h:982
#define FUNCTION_ADDR(f)
Definition: globals.h:195

References v8::NeanderArray::add(), ENTER_V8, v8::internal::Isolate::factory(), FUNCTION_ADDR, v8::internal::Isolate::heap(), v8::Handle< T >::IsEmpty(), ON_BAILOUT, v8::Utils::OpenHandle(), v8::NeanderObject::set(), and v8::NeanderObject::value().

+ Here is the call graph for this function:

◆ CancelTerminateExecution()

void v8::V8::CancelTerminateExecution ( Isolate isolate)
static

Resume execution capability in the given isolate, whose execution was previously forcefully terminated using TerminateExecution().

When execution is forcefully terminated using TerminateExecution(), the isolate can not resume execution until all JavaScript frames have propagated the uncatchable exception which is generated. This method allows the program embedding the engine to handle the termination event and resume execution capability, even if JavaScript frames remain on the stack.

This method can be used by any thread even if that thread has not acquired the V8 lock with a Locker object.

Parameters
isolateThe isolate in which to resume execution capability.

Definition at line 6539 of file api.cc.

6539  {
6540  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6541  i_isolate->stack_guard()->ClearTerminateExecution();
6542  i_isolate->CancelTerminateExecution();
6543 }
StackGuard * stack_guard()
Definition: isolate.h:872
void CancelTerminateExecution()
Definition: isolate.cc:795

References v8::internal::Isolate::CancelTerminateExecution(), and v8::internal::Isolate::stack_guard().

+ Here is the call graph for this function:

◆ ClearWeak()

void * v8::V8::ClearWeak ( internal::Object **  global_handle)
staticprivate

Definition at line 520 of file api.cc.

520  {
522 }
static void * ClearWeakness(Object **location)

References v8::internal::GlobalHandles::ClearWeakness().

Referenced by v8::PersistentBase< T >::ClearWeak().

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

◆ CopyPersistent()

i::Object ** v8::V8::CopyPersistent ( internal::Object **  handle)
staticprivate

Definition at line 504 of file api.cc.

504  {
506 #ifdef DEBUG
507  (*obj)->ObjectVerify();
508 #endif // DEBUG
509  return result.location();
510 }
static Handle< Object > CopyGlobal(Object **location)

References v8::internal::GlobalHandles::CopyGlobal().

Referenced by v8::Persistent< T, M >::Copy().

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

◆ Dispose()

bool v8::V8::Dispose ( )
static

Releases any resources used by v8 and stops any utility threads that may be running.

Note that disposing v8 is permanent, it cannot be reinitialized.

It should generally not be necessary to dispose v8 before exiting a process, this should happen automatically. It is only necessary to use if the process needs the resources taken up by v8.

Definition at line 5084 of file api.cc.

5084  {
5085  i::V8::TearDown();
5086  return true;
5087 }
static void TearDown()
Definition: v8.cc:42

References v8::internal::V8::TearDown().

Referenced by main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::TearDown().

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

◆ DisposeGlobal()

void v8::V8::DisposeGlobal ( internal::Object **  global_handle)
staticprivate

Definition at line 525 of file api.cc.

525  {
527 }
static void Destroy(Object **location)

References v8::internal::GlobalHandles::Destroy().

Referenced by v8::PersistentBase< T >::Reset().

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

◆ Eternalize()

void v8::V8::Eternalize ( Isolate isolate,
Value handle,
int index 
)
staticprivate

Definition at line 530 of file api.cc.

530  {
531  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
532  i::Object* object = *Utils::OpenHandle(value);
533  isolate->eternal_handles()->Create(isolate, object, index);
534 }
void Create(Isolate *isolate, Object *object, int *index)
EternalHandles * eternal_handles()
Definition: isolate.h:919

References v8::internal::EternalHandles::Create(), v8::internal::Isolate::eternal_handles(), and v8::Utils::OpenHandle().

Referenced by v8::Eternal< T >::Set().

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

◆ GetCompressedStartupData()

void v8::V8::GetCompressedStartupData ( StartupData compressed_data)
static

Definition at line 273 of file api.cc.

273  {
274 #ifdef COMPRESS_STARTUP_DATA_BZ2
275  compressed_data[kSnapshot].data =
276  reinterpret_cast<const char*>(i::Snapshot::data());
277  compressed_data[kSnapshot].compressed_size = i::Snapshot::size();
278  compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size();
279 
280  compressed_data[kSnapshotContext].data =
281  reinterpret_cast<const char*>(i::Snapshot::context_data());
282  compressed_data[kSnapshotContext].compressed_size =
284  compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size();
285 
287  compressed_data[kLibraries].data =
288  reinterpret_cast<const char*>(libraries_source.start());
289  compressed_data[kLibraries].compressed_size = libraries_source.length();
290  compressed_data[kLibraries].raw_size = i::Natives::GetRawScriptsSize();
291 
292  i::Vector<const i::byte> exp_libraries_source =
294  compressed_data[kExperimentalLibraries].data =
295  reinterpret_cast<const char*>(exp_libraries_source.start());
296  compressed_data[kExperimentalLibraries].compressed_size =
297  exp_libraries_source.length();
298  compressed_data[kExperimentalLibraries].raw_size =
300 #endif
301 }
static Vector< const byte > GetScriptsSource()
static int size()
Definition: snapshot.h:26
static const byte * context_data()
Definition: snapshot.h:31
static int raw_size()
Definition: snapshot.h:27
static const byte * data()
Definition: snapshot.h:25
static int context_size()
Definition: snapshot.h:32
static int context_raw_size()
Definition: snapshot.h:33
T * start() const
Definition: vector.h:47
int length() const
Definition: vector.h:41
@ kLibraries
Definition: api.cc:258
@ kSnapshotContext
Definition: api.cc:257
@ kExperimentalLibraries
Definition: api.cc:259
@ kSnapshot
Definition: api.cc:256

References v8::StartupData::compressed_size, v8::internal::Snapshot::context_data(), v8::internal::Snapshot::context_raw_size(), v8::internal::Snapshot::context_size(), v8::StartupData::data, v8::internal::Snapshot::data(), v8::internal::NativesCollection< type >::GetRawScriptsSize(), v8::internal::NativesCollection< type >::GetScriptsSource(), v8::kExperimentalLibraries, v8::kLibraries, v8::kSnapshot, v8::kSnapshotContext, v8::internal::Vector< T >::length(), v8::StartupData::raw_size, v8::internal::Snapshot::raw_size(), v8::internal::Snapshot::size(), and v8::internal::Vector< T >::start().

Referenced by v8::StartupDataDecompressor::Decompress().

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

◆ GetCompressedStartupDataAlgorithm()

StartupData::CompressionAlgorithm v8::V8::GetCompressedStartupDataAlgorithm ( )
static

The following 4 functions are to be used when V8 is built with the 'compress_startup_data' flag enabled.

In this case, the embedder must decompress startup data prior to initializing V8.

This is how interaction with V8 should look like: int compressed_data_count = v8::V8::GetCompressedStartupDataCount(); v8::StartupData* compressed_data = new v8::StartupData[compressed_data_count]; v8::V8::GetCompressedStartupData(compressed_data); ... decompress data (compressed_data can be updated in-place) ... v8::V8::SetDecompressedStartupData(compressed_data); ... now V8 can be initialized ... make sure the decompressed data stays valid until V8 shutdown

A helper class StartupDataDecompressor is provided. It implements the protocol of the interaction described above, and can be used in most cases instead of calling these API functions directly.

Definition at line 246 of file api.cc.

246  {
247 #ifdef COMPRESS_STARTUP_DATA_BZ2
248  return StartupData::kBZip2;
249 #else
251 #endif
252 }
@ kUncompressed
Definition: v8.h:4881

References v8::StartupData::kBZip2, and v8::StartupData::kUncompressed.

◆ GetCompressedStartupDataCount()

int v8::V8::GetCompressedStartupDataCount ( )
static

Definition at line 264 of file api.cc.

264  {
265 #ifdef COMPRESS_STARTUP_DATA_BZ2
267 #else
268  return 0;
269 #endif
270 }
@ kCompressedStartupDataCount
Definition: api.cc:260

References v8::kCompressedStartupDataCount.

Referenced by v8::StartupDataDecompressor::Decompress(), v8::StartupDataDecompressor::StartupDataDecompressor(), and v8::StartupDataDecompressor::~StartupDataDecompressor().

+ Here is the caller graph for this function:

◆ GetEternal()

Local< Value > v8::V8::GetEternal ( Isolate isolate,
int  index 
)
staticprivate

Definition at line 537 of file api.cc.

537  {
538  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
539  return Utils::ToLocal(isolate->eternal_handles()->Get(index));
540 }
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
Handle< Object > Get(int index)

References v8::internal::Isolate::eternal_handles(), v8::internal::EternalHandles::Get(), and v8::Utils::ToLocal().

Referenced by v8::Eternal< T >::Get().

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

◆ GetVersion()

const char * v8::V8::GetVersion ( )
static

Get the version string.

Definition at line 5146 of file api.cc.

5146  {
5147  return i::Version::GetVersion();
5148 }
static const char * GetVersion()
Definition: version.h:27

References v8::internal::Version::GetVersion().

Referenced by v8::Shell::RunShell(), v8::internal::RUNTIME_FUNCTION(), and v8::Shell::Version().

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

◆ GlobalizeReference()

i::Object ** v8::V8::GlobalizeReference ( internal::Isolate isolate,
internal::Object **  handle 
)
staticprivate

Definition at line 494 of file api.cc.

494  {
495  LOG_API(isolate, "Persistent::New");
496  i::Handle<i::Object> result = isolate->global_handles()->Create(*obj);
497 #ifdef DEBUG
498  (*obj)->ObjectVerify();
499 #endif // DEBUG
500  return result.location();
501 }
#define LOG_API(isolate, expr)
Definition: api.cc:52

References v8::internal::GlobalHandles::Create(), v8::internal::Isolate::global_handles(), and LOG_API.

Referenced by v8::PersistentBase< T >::New().

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

◆ Initialize()

bool v8::V8::Initialize ( )
static

Initializes V8.

This function needs to be called before the first Isolate is created. It always returns true.

Definition at line 5058 of file api.cc.

5058  {
5060  return true;
5061 }
static bool Initialize()
Definition: v8.cc:36

References v8::internal::V8::Initialize().

Referenced by v8::Locker::Initialize(), main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::SetUp().

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

◆ InitializeICU()

bool v8::V8::InitializeICU ( const char *  icu_data_file = NULL)
static

Initialize the ICU library bundled with V8.

The embedder should only invoke this method when using the bundled ICU. Returns true on success.

If V8 was compiled with the ICU data in an external file, the location of the data file has to be provided.

Definition at line 5141 of file api.cc.

5141  {
5142  return i::InitializeICU(icu_data_file);
5143 }
bool InitializeICU(const char *icu_data_file)
Definition: icu_util.cc:41

References v8::internal::InitializeICU().

Referenced by main(), and v8::Shell::Main().

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

◆ InitializePlatform()

void v8::V8::InitializePlatform ( Platform platform)
static

Sets the v8::Platform to use.

This should be invoked before V8 is initialized.

Definition at line 5048 of file api.cc.

5048  {
5049  i::V8::InitializePlatform(platform);
5050 }
static void InitializePlatform(v8::Platform *platform)
Definition: v8.cc:102

References v8::internal::V8::InitializePlatform().

Referenced by main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::SetUp().

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

◆ IsDead()

bool v8::V8::IsDead ( )
static

Check if V8 is dead and therefore unusable.

This is the case after fatal errors such as out-of-memory situations.

Definition at line 189 of file api.cc.

189  {
190  i::Isolate* isolate = i::Isolate::Current();
191  return isolate->IsDead();
192 }

References v8::internal::Isolate::IsDead().

+ Here is the call graph for this function:

◆ IsExecutionTerminating()

bool v8::V8::IsExecutionTerminating ( Isolate isolate = NULL)
static

Is V8 terminating JavaScript execution.

Returns true if JavaScript execution is currently terminating because of a call to TerminateExecution. In that case there are still JavaScript frames on the stack and the termination exception is still active.

Parameters
isolateThe isolate in which to check.

Definition at line 6532 of file api.cc.

6532  {
6533  i::Isolate* i_isolate = isolate != NULL ?
6534  reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current();
6535  return IsExecutionTerminatingCheck(i_isolate);
6536 }
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
static bool IsExecutionTerminatingCheck(i::Isolate *isolate)
Definition: api.cc:195

References v8::IsExecutionTerminatingCheck(), and NULL.

+ Here is the call graph for this function:

◆ MakeWeak()

void v8::V8::MakeWeak ( internal::Object **  global_handle,
void *  data,
WeakCallback  weak_callback 
)
staticprivate

Definition at line 513 of file api.cc.

515  {
516  i::GlobalHandles::MakeWeak(object, parameters, weak_callback);
517 }
static void MakeWeak(Object **location, void *parameter, WeakCallback weak_callback)

References v8::internal::GlobalHandles::MakeWeak().

Referenced by v8::PersistentBase< T >::SetWeak().

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

◆ RemoveGCEpilogueCallback()

void v8::V8::RemoveGCEpilogueCallback ( GCEpilogueCallback  callback)
static

This function removes callback which was installed by AddGCEpilogueCallback function.

Definition at line 6503 of file api.cc.

6503  {
6504  i::Isolate* isolate = i::Isolate::Current();
6505  isolate->heap()->RemoveGCEpilogueCallback(
6506  reinterpret_cast<v8::Isolate::GCEpilogueCallback>(callback));
6507 }
void RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
Definition: heap.cc:5328

References v8::internal::Isolate::heap(), and v8::internal::Heap::RemoveGCEpilogueCallback().

+ Here is the call graph for this function:

◆ RemoveGCPrologueCallback()

void v8::V8::RemoveGCPrologueCallback ( GCPrologueCallback  callback)
static

This function removes callback which was installed by AddGCPrologueCallback function.

Definition at line 6487 of file api.cc.

6487  {
6488  i::Isolate* isolate = i::Isolate::Current();
6489  isolate->heap()->RemoveGCPrologueCallback(
6490  reinterpret_cast<v8::Isolate::GCPrologueCallback>(callback));
6491 }
void RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
Definition: heap.cc:5307

References v8::internal::Isolate::heap(), and v8::internal::Heap::RemoveGCPrologueCallback().

+ Here is the call graph for this function:

◆ RemoveMemoryAllocationCallback()

void v8::V8::RemoveMemoryAllocationCallback ( MemoryAllocationCallback  callback)
static

Removes callback that was installed by AddMemoryAllocationCallback.

Definition at line 6519 of file api.cc.

6519  {
6520  i::Isolate* isolate = i::Isolate::Current();
6522  callback);
6523 }
void RemoveMemoryAllocationCallback(MemoryAllocationCallback callback)
Definition: spaces.cc:782

References v8::internal::Isolate::memory_allocator(), and v8::internal::MemoryAllocator::RemoveMemoryAllocationCallback().

+ Here is the call graph for this function:

◆ RemoveMessageListeners()

void v8::V8::RemoveMessageListeners ( MessageCallback  that)
static

Remove all message listeners from the specified callback function.

Definition at line 6322 of file api.cc.

6322  {
6323  i::Isolate* isolate = i::Isolate::Current();
6324  ON_BAILOUT(isolate, "v8::V8::RemoveMessageListeners()", return);
6325  ENTER_V8(isolate);
6326  i::HandleScope scope(isolate);
6327  NeanderArray listeners(isolate->factory()->message_listeners());
6328  for (int i = 0; i < listeners.length(); i++) {
6329  if (listeners.get(i)->IsUndefined()) continue; // skip deleted ones
6330 
6331  NeanderObject listener(i::JSObject::cast(listeners.get(i)));
6332  i::Handle<i::Foreign> callback_obj(i::Foreign::cast(listener.get(0)));
6333  if (callback_obj->foreign_address() == FUNCTION_ADDR(that)) {
6334  listeners.set(i, isolate->heap()->undefined_value());
6335  }
6336  }
6337 }

References ENTER_V8, v8::internal::Isolate::factory(), FUNCTION_ADDR, v8::NeanderObject::get(), v8::NeanderArray::get(), v8::internal::Isolate::heap(), v8::NeanderArray::length(), ON_BAILOUT, and v8::NeanderArray::set().

+ Here is the call graph for this function:

◆ SetAllowCodeGenerationFromStringsCallback()

void v8::V8::SetAllowCodeGenerationFromStringsCallback ( AllowCodeGenerationFromStringsCallback  that)
static

Set the callback to invoke to check if code generation from strings should be allowed.

Definition at line 357 of file api.cc.

358  {
359  i::Isolate* isolate = i::Isolate::Current();
360  isolate->set_allow_code_gen_callback(callback);
361 }

◆ SetArrayBufferAllocator()

void v8::V8::SetArrayBufferAllocator ( ArrayBuffer::Allocator allocator)
static

Set allocator to use for ArrayBuffer memory.

The allocator should be set only once. The allocator should be set before any code tha uses ArrayBuffers is executed. This allocator is used in all isolates.

Definition at line 5074 of file api.cc.

5075  {
5077  "v8::V8::SetArrayBufferAllocator",
5078  "ArrayBufferAllocator might only be set once"))
5079  return;
5080  i::V8::SetArrayBufferAllocator(allocator);
5081 }
static bool ApiCheck(bool condition, const char *location, const char *message)
Definition: api.h:177
static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator)
Definition: v8.h:76
static v8::ArrayBuffer::Allocator * ArrayBufferAllocator()
Definition: v8.h:72

References v8::Utils::ApiCheck(), v8::internal::V8::ArrayBufferAllocator(), NULL, and v8::internal::V8::SetArrayBufferAllocator().

Referenced by v8::Shell::Main().

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

◆ SetCaptureStackTraceForUncaughtExceptions()

void v8::V8::SetCaptureStackTraceForUncaughtExceptions ( bool  capture,
int  frame_limit = 10,
StackTrace::StackTraceOptions  options = StackTrace::kOverview 
)
static

Tells V8 to capture current stack trace when uncaught exception occurs and report it to the message listeners.

The option is off by default.

Definition at line 6340 of file api.cc.

6343  {
6344  i::Isolate::Current()->SetCaptureStackTraceForUncaughtExceptions(
6345  capture,
6346  frame_limit,
6347  options);
6348 }

Referenced by main().

+ Here is the caller graph for this function:

◆ SetDecompressedStartupData()

void v8::V8::SetDecompressedStartupData ( StartupData decompressed_data)
static

Definition at line 304 of file api.cc.

304  {
305 #ifdef COMPRESS_STARTUP_DATA_BZ2
306  DCHECK_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size);
308  reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data));
309 
311  decompressed_data[kSnapshotContext].raw_size);
313  reinterpret_cast<const i::byte*>(
314  decompressed_data[kSnapshotContext].data));
315 
317  decompressed_data[kLibraries].raw_size);
318  i::Vector<const char> libraries_source(
319  decompressed_data[kLibraries].data,
320  decompressed_data[kLibraries].raw_size);
321  i::Natives::SetRawScriptsSource(libraries_source);
322 
324  decompressed_data[kExperimentalLibraries].raw_size);
325  i::Vector<const char> exp_libraries_source(
326  decompressed_data[kExperimentalLibraries].data,
327  decompressed_data[kExperimentalLibraries].raw_size);
328  i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source);
329 #endif
330 }
static void SetRawScriptsSource(Vector< const char > raw_source)
static void set_context_raw_data(const byte *context_raw_data)
Definition: snapshot.h:34
static void set_raw_data(const byte *raw_data)
Definition: snapshot.h:28
#define DCHECK_EQ(v1, v2)
Definition: logging.h:206
uint8_t byte
Definition: globals.h:100

References v8::internal::Snapshot::context_raw_size(), DCHECK_EQ, v8::internal::NativesCollection< type >::GetRawScriptsSize(), v8::kExperimentalLibraries, v8::kLibraries, v8::kSnapshot, v8::kSnapshotContext, v8::internal::Snapshot::raw_size(), v8::internal::Snapshot::set_context_raw_data(), v8::internal::Snapshot::set_raw_data(), and v8::internal::NativesCollection< type >::SetRawScriptsSource().

Referenced by v8::StartupDataDecompressor::Decompress().

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

◆ SetEntropySource()

void v8::V8::SetEntropySource ( EntropySource  source)
static

Allows the host application to provide a callback which can be used as a source of entropy for random number generators.

Definition at line 5064 of file api.cc.

5064  {
5065  base::RandomNumberGenerator::SetEntropySource(entropy_source);
5066 }
static RandomNumberGenerator::EntropySource entropy_source

References v8::base::entropy_source.

◆ SetFailedAccessCheckCallbackFunction()

void v8::V8::SetFailedAccessCheckCallbackFunction ( FailedAccessCheckCallback  callback)
static

Callback function for reporting failed access checks.

Definition at line 6351 of file api.cc.

6352  {
6353  i::Isolate* isolate = i::Isolate::Current();
6354  isolate->SetFailedAccessCheckCallback(callback);
6355 }
void SetFailedAccessCheckCallback(v8::FailedAccessCheckCallback callback)
Definition: isolate.cc:615

References v8::internal::Isolate::SetFailedAccessCheckCallback().

+ Here is the call graph for this function:

◆ SetFatalErrorHandler()

void v8::V8::SetFatalErrorHandler ( FatalErrorCallback  that)
static

Set the callback to invoke in case of fatal errors.

Definition at line 351 of file api.cc.

351  {
352  i::Isolate* isolate = i::Isolate::Current();
353  isolate->set_exception_behavior(that);
354 }

◆ SetFlagsFromCommandLine()

void v8::V8::SetFlagsFromCommandLine ( int argc,
char **  argv,
bool  remove_flags 
)
static

Sets V8 flags from the command line.

Definition at line 369 of file api.cc.

369  {
370  i::FlagList::SetFlagsFromCommandLine(argc, argv, remove_flags);
371 }
static int SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
Definition: flags.cc:334

References v8::internal::FlagList::SetFlagsFromCommandLine().

Referenced by main(), and v8::Shell::SetOptions().

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

◆ SetFlagsFromString()

void v8::V8::SetFlagsFromString ( const char *  str,
int  length 
)
static

Sets V8 flags from a string.

Definition at line 364 of file api.cc.

364  {
365  i::FlagList::SetFlagsFromString(str, length);
366 }
static int SetFlagsFromString(const char *str, int len)
Definition: flags.cc:472

References v8::internal::FlagList::SetFlagsFromString().

Referenced by vTune::InitializeVtuneForV8(), and v8::SetFlagsFromString().

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

◆ SetNativesDataBlob()

void v8::V8::SetNativesDataBlob ( StartupData startup_blob)
static

Hand startup data to V8, in case the embedder has chosen to build V8 with external startup data.

Note:

  • By default the startup data is linked into the V8 library, in which case this function is not meaningful.
  • If this needs to be called, it needs to be called before V8 tries to make use of its built-ins.
  • To avoid unnecessary copies of data, V8 will point directly into the given data blob, so pretty please keep it around until V8 exit.
  • Compression of the startup blob might be useful, but needs to handled entirely on the embedders' side.
  • The call will abort if the data is invalid.

Definition at line 333 of file api.cc.

333  {
334 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
335  i::SetNativesFromFile(natives_blob);
336 #else
337  CHECK(false);
338 #endif
339 }
#define CHECK(condition)
Definition: logging.h:36
void SetNativesFromFile(StartupData *natives_blob)
Read the Natives (library sources) blob, as generated by js2c + the build system.

References CHECK, and v8::internal::SetNativesFromFile().

+ Here is the call graph for this function:

◆ SetReturnAddressLocationResolver()

void v8::V8::SetReturnAddressLocationResolver ( ReturnAddressLocationResolver  return_address_resolver)
static

Allows the host application to provide a callback that allows v8 to cooperate with a profiler that rewrites return addresses on stack.

Definition at line 5069 of file api.cc.

5070  {
5071  i::V8::SetReturnAddressLocationResolver(return_address_resolver);
5072 }
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver resolver)
Definition: v8.cc:55

References v8::internal::V8::SetReturnAddressLocationResolver().

+ Here is the call graph for this function:

◆ SetSnapshotDataBlob()

void v8::V8::SetSnapshotDataBlob ( StartupData startup_blob)
static

Definition at line 342 of file api.cc.

342  {
343 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
344  i::SetSnapshotFromFile(snapshot_blob);
345 #else
346  CHECK(false);
347 #endif
348 }
void SetSnapshotFromFile(StartupData *snapshot_blob)

References CHECK, and v8::internal::SetSnapshotFromFile().

+ Here is the call graph for this function:

◆ ShutdownPlatform()

void v8::V8::ShutdownPlatform ( )
static

Clears all references to the v8::Platform.

This should be invoked after V8 was disposed.

Definition at line 5053 of file api.cc.

5053  {
5055 }
static void ShutdownPlatform()
Definition: v8.cc:109

References v8::internal::V8::ShutdownPlatform().

Referenced by main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::TearDown().

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

◆ TerminateExecution()

void v8::V8::TerminateExecution ( Isolate isolate)
static

Forcefully terminate the current thread of JavaScript execution in the given isolate.

This method can be used by any thread even if that thread has not acquired the V8 lock with a Locker object.

Parameters
isolateThe isolate in which to terminate the current JS execution.

Definition at line 6526 of file api.cc.

6526  {
6527  i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6528  i_isolate->stack_guard()->RequestTerminateExecution();
6529 }

References v8::internal::Isolate::stack_guard().

+ Here is the call graph for this function:

◆ VisitExternalResources()

void v8::V8::VisitExternalResources ( ExternalResourceVisitor visitor)
static

Iterates through all external resources referenced from current isolate heap.

GC is not invoked prior to iterating, therefore there is no guarantee that visited objects are still alive.

Definition at line 5097 of file api.cc.

5097  {
5098  i::Isolate* isolate = i::Isolate::Current();
5099  isolate->heap()->VisitExternalResources(visitor);
5100 }
void VisitExternalResources(v8::ExternalResourceVisitor *visitor)
Definition: heap.cc:1707

References v8::internal::Isolate::heap(), and v8::internal::Heap::VisitExternalResources().

+ Here is the call graph for this function:

◆ VisitHandlesForPartialDependence()

void v8::V8::VisitHandlesForPartialDependence ( Isolate isolate,
PersistentHandleVisitor visitor 
)
static

Iterates through all the persistent handles in the current isolate's heap that have class_ids and are candidates to be marked as partially dependent handles.

This will visit handles to young objects created since the last garbage collection but is free to visit an arbitrary superset of these objects.

Definition at line 5129 of file api.cc.

5130  {
5131  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
5132  DCHECK(isolate == i::Isolate::Current());
5133  i::DisallowHeapAllocation no_allocation;
5134 
5135  VisitorAdapter visitor_adapter(visitor);
5137  &visitor_adapter);
5138 }
void IterateAllRootsInNewSpaceWithClassIds(ObjectVisitor *v)
GlobalHandles * global_handles()
Definition: isolate.h:917
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::internal::Isolate::global_handles(), and v8::internal::GlobalHandles::IterateAllRootsInNewSpaceWithClassIds().

+ Here is the call graph for this function:

◆ VisitHandlesWithClassIds()

void v8::V8::VisitHandlesWithClassIds ( PersistentHandleVisitor visitor)
static

Iterates through all the persistent handles in the current isolate's heap that have class_ids.

Definition at line 5120 of file api.cc.

5120  {
5121  i::Isolate* isolate = i::Isolate::Current();
5122  i::DisallowHeapAllocation no_allocation;
5123 
5124  VisitorAdapter visitor_adapter(visitor);
5125  isolate->global_handles()->IterateAllRootsWithClassIds(&visitor_adapter);
5126 }
void IterateAllRootsWithClassIds(ObjectVisitor *v)

References v8::internal::Isolate::global_handles(), and v8::internal::GlobalHandles::IterateAllRootsWithClassIds().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Context

friend class Context
friend

Definition at line 5264 of file v8.h.

◆ Eternal

template<class T >
friend class Eternal
friend

Definition at line 5261 of file v8.h.

◆ Handle

template<class T >
friend class Handle
friend

Definition at line 5259 of file v8.h.

◆ Local

template<class T >
friend class Local
friend

Definition at line 5260 of file v8.h.

◆ Persistent

template<class T , class M >
friend class Persistent
friend

Definition at line 5263 of file v8.h.

◆ PersistentBase

template<class T >
friend class PersistentBase
friend

Definition at line 5262 of file v8.h.


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