V8 Project
|
Container class for static utility functions. More...
#include <v8.h>
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< Value > | GetEternal (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 |
|
private |
|
private |
|
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.
References v8::internal::Heap::AddGCEpilogueCallback(), and v8::internal::Isolate::heap().
|
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.
References v8::internal::Heap::AddGCPrologueCallback(), and v8::internal::Isolate::heap().
|
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.
References v8::internal::MemoryAllocator::AddMemoryAllocationCallback(), v8::internal::Isolate::memory_allocator(), and space().
|
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.
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().
|
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.
isolate | The isolate in which to resume execution capability. |
Definition at line 6539 of file api.cc.
References v8::internal::Isolate::CancelTerminateExecution(), and v8::internal::Isolate::stack_guard().
|
staticprivate |
Definition at line 520 of file api.cc.
References v8::internal::GlobalHandles::ClearWeakness().
Referenced by v8::PersistentBase< T >::ClearWeak().
|
staticprivate |
Definition at line 504 of file api.cc.
References v8::internal::GlobalHandles::CopyGlobal().
Referenced by v8::Persistent< T, M >::Copy().
|
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.
References v8::internal::V8::TearDown().
Referenced by main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::TearDown().
|
staticprivate |
Definition at line 525 of file api.cc.
References v8::internal::GlobalHandles::Destroy().
Referenced by v8::PersistentBase< T >::Reset().
Definition at line 530 of file api.cc.
References v8::internal::EternalHandles::Create(), v8::internal::Isolate::eternal_handles(), and v8::Utils::OpenHandle().
Referenced by v8::Eternal< T >::Set().
|
static |
Definition at line 273 of file api.cc.
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().
|
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.
References v8::StartupData::kBZip2, and v8::StartupData::kUncompressed.
|
static |
Definition at line 264 of file api.cc.
References v8::kCompressedStartupDataCount.
Referenced by v8::StartupDataDecompressor::Decompress(), v8::StartupDataDecompressor::StartupDataDecompressor(), and v8::StartupDataDecompressor::~StartupDataDecompressor().
Definition at line 537 of file api.cc.
References v8::internal::Isolate::eternal_handles(), v8::internal::EternalHandles::Get(), and v8::Utils::ToLocal().
Referenced by v8::Eternal< T >::Get().
|
static |
Get the version string.
Definition at line 5146 of file api.cc.
References v8::internal::Version::GetVersion().
Referenced by v8::Shell::RunShell(), v8::internal::RUNTIME_FUNCTION(), and v8::Shell::Version().
|
staticprivate |
Definition at line 494 of file api.cc.
References v8::internal::GlobalHandles::Create(), v8::internal::Isolate::global_handles(), and LOG_API.
Referenced by v8::PersistentBase< T >::New().
|
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.
References v8::internal::V8::Initialize().
Referenced by v8::Locker::Initialize(), main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::SetUp().
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.
References v8::internal::InitializeICU().
Referenced by main(), and v8::Shell::Main().
|
static |
Sets the v8::Platform to use.
This should be invoked before V8 is initialized.
Definition at line 5048 of file api.cc.
References v8::internal::V8::InitializePlatform().
Referenced by main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::SetUp().
|
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.
References v8::internal::Isolate::IsDead().
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.
isolate | The isolate in which to check. |
Definition at line 6532 of file api.cc.
References v8::IsExecutionTerminatingCheck(), and NULL.
|
staticprivate |
Definition at line 513 of file api.cc.
References v8::internal::GlobalHandles::MakeWeak().
Referenced by v8::PersistentBase< T >::SetWeak().
|
static |
This function removes callback which was installed by AddGCEpilogueCallback function.
Definition at line 6503 of file api.cc.
References v8::internal::Isolate::heap(), and v8::internal::Heap::RemoveGCEpilogueCallback().
|
static |
This function removes callback which was installed by AddGCPrologueCallback function.
Definition at line 6487 of file api.cc.
References v8::internal::Isolate::heap(), and v8::internal::Heap::RemoveGCPrologueCallback().
|
static |
Removes callback that was installed by AddMemoryAllocationCallback.
Definition at line 6519 of file api.cc.
References v8::internal::Isolate::memory_allocator(), and v8::internal::MemoryAllocator::RemoveMemoryAllocationCallback().
|
static |
Remove all message listeners from the specified callback function.
Definition at line 6322 of file api.cc.
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().
|
static |
|
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.
References v8::Utils::ApiCheck(), v8::internal::V8::ArrayBufferAllocator(), NULL, and v8::internal::V8::SetArrayBufferAllocator().
Referenced by v8::Shell::Main().
|
static |
|
static |
Definition at line 304 of file api.cc.
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().
|
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.
References v8::base::entropy_source.
|
static |
Callback function for reporting failed access checks.
Definition at line 6351 of file api.cc.
References v8::internal::Isolate::SetFailedAccessCheckCallback().
|
static |
Sets V8 flags from the command line.
Definition at line 369 of file api.cc.
References v8::internal::FlagList::SetFlagsFromCommandLine().
Referenced by main(), and v8::Shell::SetOptions().
|
static |
Sets V8 flags from a string.
Definition at line 364 of file api.cc.
References v8::internal::FlagList::SetFlagsFromString().
Referenced by vTune::InitializeVtuneForV8(), and v8::SetFlagsFromString().
|
static |
Hand startup data to V8, in case the embedder has chosen to build V8 with external startup data.
Note:
Definition at line 333 of file api.cc.
References CHECK, and v8::internal::SetNativesFromFile().
|
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.
References v8::internal::V8::SetReturnAddressLocationResolver().
|
static |
Definition at line 342 of file api.cc.
References CHECK, and v8::internal::SetSnapshotFromFile().
|
static |
Clears all references to the v8::Platform.
This should be invoked after V8 was disposed.
Definition at line 5053 of file api.cc.
References v8::internal::V8::ShutdownPlatform().
Referenced by main(), v8::Shell::Main(), and anonymous_namespace{run-all-unittests.cc}::FINAL::TearDown().
|
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.
isolate | The isolate in which to terminate the current JS execution. |
Definition at line 6526 of file api.cc.
References v8::internal::Isolate::stack_guard().
|
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.
References v8::internal::Isolate::heap(), and v8::internal::Heap::VisitExternalResources().
|
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.
References DCHECK, v8::internal::Isolate::global_handles(), and v8::internal::GlobalHandles::IterateAllRootsInNewSpaceWithClassIds().
|
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.
References v8::internal::Isolate::global_handles(), and v8::internal::GlobalHandles::IterateAllRootsWithClassIds().
|
friend |
|
friend |