Static Public Member Functions | Friends

v8::V8 Class Reference

#include <v8.h>

List of all members.

Static Public Member Functions

static void SetFatalErrorHandler (FatalErrorCallback that)
static void SetAllowCodeGenerationFromStringsCallback (AllowCodeGenerationFromStringsCallback that)
static void IgnoreOutOfMemoryException ()
static bool IsDead ()
static
StartupData::CompressionAlgorithm 
GetCompressedStartupDataAlgorithm ()
static int GetCompressedStartupDataCount ()
static void GetCompressedStartupData (StartupData *compressed_data)
static void SetDecompressedStartupData (StartupData *decompressed_data)
static bool AddMessageListener (MessageCallback that, Handle< Value > data=Handle< Value >())
static void RemoveMessageListeners (MessageCallback that)
static void SetCaptureStackTraceForUncaughtExceptions (bool capture, int frame_limit=10, StackTrace::StackTraceOptions options=StackTrace::kOverview)
static void SetFlagsFromString (const char *str, int length)
static void SetFlagsFromCommandLine (int *argc, char **argv, bool remove_flags)
static const char * GetVersion ()
static void SetCounterFunction (CounterLookupCallback)
static void SetCreateHistogramFunction (CreateHistogramCallback)
static void SetAddHistogramSampleFunction (AddHistogramSampleCallback)
static void EnableSlidingStateWindow ()
static void SetFailedAccessCheckCallbackFunction (FailedAccessCheckCallback)
static void AddGCPrologueCallback (GCPrologueCallback callback, GCType gc_type_filter=kGCTypeAll)
static void RemoveGCPrologueCallback (GCPrologueCallback callback)
static void SetGlobalGCPrologueCallback (GCCallback)
static void AddGCEpilogueCallback (GCEpilogueCallback callback, GCType gc_type_filter=kGCTypeAll)
static void RemoveGCEpilogueCallback (GCEpilogueCallback callback)
static void SetGlobalGCEpilogueCallback (GCCallback)
static void AddMemoryAllocationCallback (MemoryAllocationCallback callback, ObjectSpace space, AllocationAction action)
static void RemoveMemoryAllocationCallback (MemoryAllocationCallback callback)
static void AddObjectGroup (Persistent< Value > *objects, size_t length, RetainedObjectInfo *info=NULL)
static void AddImplicitReferences (Persistent< Object > parent, Persistent< Value > *children, size_t length)
static bool Initialize ()
static void SetEntropySource (EntropySource source)
static int AdjustAmountOfExternalAllocatedMemory (int change_in_bytes)
static void PauseProfiler ()
static void ResumeProfiler ()
static bool IsProfilerPaused ()
static int GetCurrentThreadId ()
static void TerminateExecution (int thread_id)
static void TerminateExecution (Isolate *isolate=NULL)
static bool IsExecutionTerminating (Isolate *isolate=NULL)
static bool Dispose ()
static void GetHeapStatistics (HeapStatistics *heap_statistics)
static bool IdleNotification ()
static void LowMemoryNotification ()
static int ContextDisposedNotification ()

Friends

class Handle
class Local
class Persistent
class Context

Detailed Description

Container class for static utility functions.


Member Function Documentation

static 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.

static 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.

static void v8::V8::AddImplicitReferences ( Persistent< Object parent,
Persistent< Value > *  children,
size_t  length 
) [static]

Allows the host application to declare implicit references between the objects: if |parent| is alive, all |children| are alive too. After each garbage collection, all implicit references are removed. It is intended to be used in the before-garbage-collection callback function.

static 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.

static bool v8::V8::AddMessageListener ( MessageCallback  that,
Handle< Value data = HandleValue >() 
) [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.

static void v8::V8::AddObjectGroup ( Persistent< Value > *  objects,
size_t  length,
RetainedObjectInfo *  info = NULL 
) [static]

Allows the host application to group objects together. If one object in the group is alive, all objects in the group are alive. After each garbage collection, object groups are removed. It is intended to be used in the before-garbage-collection callback function, for instance to simulate DOM tree connections among JS wrapper objects. See v8-profiler.h for RetainedObjectInfo interface description.

static int v8::V8::AdjustAmountOfExternalAllocatedMemory ( int  change_in_bytes  )  [static]

Adjusts the amount of registered external memory. Used to give V8 an indication of the amount of externally allocated memory that is kept alive by JavaScript objects. V8 uses this to decide when to perform global garbage collections. Registering externally allocated memory will trigger global garbage collections more often than otherwise in an attempt to garbage collect the JavaScript objects keeping the externally allocated memory alive.

Parameters:
change_in_bytes the change in externally allocated memory that is kept alive by JavaScript objects.
Returns:
the adjusted value.
static int v8::V8::ContextDisposedNotification (  )  [static]

Optional notification that a context has been disposed. V8 uses these notifications to guide the GC heuristic. Returns the number of context disposals - including this one - since the last time V8 had a chance to clean up.

static 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.

static void v8::V8::EnableSlidingStateWindow (  )  [static]

Enables the computation of a sliding window of states. The sliding window information is recorded in statistics counters.

static 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.

static int v8::V8::GetCurrentThreadId (  )  [static]

Retrieve the V8 thread id of the calling thread.

The thread id for a thread should only be retrieved after the V8 lock has been acquired with a Locker object with that thread.

static void v8::V8::GetHeapStatistics ( HeapStatistics heap_statistics  )  [static]

Get statistics about the heap memory usage.

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

Get the version string.

static bool v8::V8::IdleNotification (  )  [static]

Optional notification that the embedder is idle. V8 uses the notification to reduce memory footprint. This call can be used repeatedly if the embedder remains idle. Returns true if the embedder should stop calling IdleNotification until real work has been done. This indicates that V8 has done as much cleanup as it will be able to do.

static void v8::V8::IgnoreOutOfMemoryException (  )  [static]

Ignore out-of-memory exceptions.

V8 running out of memory is treated as a fatal error by default. This means that the fatal error handler is called and that V8 is terminated.

IgnoreOutOfMemoryException can be used to not treat an out-of-memory situation as a fatal error. This way, the contexts that did not cause the out of memory problem might be able to continue execution.

static bool v8::V8::Initialize (  )  [static]

Initializes from snapshot if possible. Otherwise, attempts to initialize from scratch. This function is called implicitly if you use the API without calling it first.

static 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.

static 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:
isolate The isolate in which to check.
static bool v8::V8::IsProfilerPaused (  )  [static]

Return whether profiler is currently paused.

static void v8::V8::LowMemoryNotification (  )  [static]

Optional notification that the system is running low on memory. V8 uses these notifications to attempt to free memory.

static void v8::V8::PauseProfiler (  )  [static]

Suspends recording of tick samples in the profiler. When the V8 profiling mode is enabled (usually via command line switches) this function suspends recording of tick samples. Profiling ticks are discarded until ResumeProfiler() is called.

See also the --prof and --prof_auto command line switches to enable V8 profiling.

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

This function removes callback which was installed by AddGCEpilogueCallback function.

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

This function removes callback which was installed by AddGCPrologueCallback function.

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

This function removes callback which was installed by AddMemoryAllocationCallback function.

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

Remove all message listeners from the specified callback function.

static void v8::V8::ResumeProfiler (  )  [static]

Resumes recording of tick samples in the profiler. See also PauseProfiler().

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

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

static 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.

static void v8::V8::SetCounterFunction ( CounterLookupCallback   )  [static]

Enables the host application to provide a mechanism for recording statistics counters.

static void v8::V8::SetCreateHistogramFunction ( CreateHistogramCallback   )  [static]

Enables the host application to provide a mechanism for recording histograms. The CreateHistogram function returns a histogram which will later be passed to the AddHistogramSample function.

static 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.

static void v8::V8::SetFailedAccessCheckCallbackFunction ( FailedAccessCheckCallback   )  [static]

Callback function for reporting failed access checks.

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

Set the callback to invoke in case of fatal errors.

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

Sets V8 flags from the command line.

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

Sets V8 flags from a string.

static void v8::V8::SetGlobalGCEpilogueCallback ( GCCallback   )  [static]

The function is deprecated. Please use AddGCEpilogueCallback instead. Enables the host application to receive a notification after a major 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.

static void v8::V8::SetGlobalGCPrologueCallback ( GCCallback   )  [static]

The function is deprecated. Please use AddGCPrologueCallback instead. 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.

static void v8::V8::TerminateExecution ( int  thread_id  )  [static]

Forcefully terminate execution of a JavaScript thread. This can be used to terminate long-running scripts.

TerminateExecution should only be called when then V8 lock has been acquired with a Locker object. Therefore, in order to be able to terminate long-running threads, preemption must be enabled to allow the user of TerminateExecution to acquire the lock.

The termination is achieved by throwing an exception that is uncatchable by JavaScript exception handlers. Termination exceptions act as if they were caught by a C++ TryCatch exception handler. If forceful termination is used, any C++ TryCatch exception handler that catches an exception should check if that exception is a termination exception and immediately return if that is the case. Returning immediately in that case will continue the propagation of the termination exception if needed.

The thread id passed to TerminateExecution must have been obtained by calling GetCurrentThreadId on the thread in question.

Parameters:
thread_id The thread id of the thread to terminate.
static void v8::V8::TerminateExecution ( Isolate isolate = NULL  )  [static]

Forcefully terminate the current thread of JavaScript execution in the given isolate. If no isolate is provided, the default isolate is used.

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

Parameters:
isolate The isolate in which to terminate the current JS execution.

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