v8 12.4.254 (node 22.4.1)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-initialization.h
Go to the documentation of this file.
1// Copyright 2021 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_V8_INITIALIZATION_H_
6#define INCLUDE_V8_INITIALIZATION_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "v8-callbacks.h" // NOLINT(build/include_directory)
12#include "v8-internal.h" // NOLINT(build/include_directory)
13#include "v8-isolate.h" // NOLINT(build/include_directory)
14#include "v8-platform.h" // NOLINT(build/include_directory)
15#include "v8config.h" // NOLINT(build/include_directory)
16
17// We reserve the V8_* prefix for macros defined in V8 public API and
18// assume there are no name conflicts with the embedder's code.
19
23namespace v8 {
24
25class PageAllocator;
26class Platform;
27template <class K, class V, class T>
28class PersistentValueMapBase;
29
34using EntropySource = bool (*)(unsigned char* buffer, size_t length);
35
50 uintptr_t (*)(uintptr_t return_addr_location);
51
52using DcheckErrorCallback = void (*)(const char* file, int line,
53 const char* message);
54
59 public:
75 static void SetSnapshotDataBlob(StartupData* startup_blob);
76
79
83 static void SetFlagsFromString(const char* str);
84 static void SetFlagsFromString(const char* str, size_t length);
85
89 static void SetFlagsFromCommandLine(int* argc, char** argv,
90 bool remove_flags);
91
93 static const char* GetVersion();
94
99 V8_INLINE static bool Initialize() {
100 const int kBuildConfiguration =
101 (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
102 (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) |
103 (internal::SandboxIsEnabled() ? kSandbox : 0);
104 return Initialize(kBuildConfiguration);
105 }
106
111 static void SetEntropySource(EntropySource source);
112
118 ReturnAddressLocationResolver return_address_resolver);
119
129 static bool Dispose();
130
138 static bool InitializeICU(const char* icu_data_file = nullptr);
139
152 static bool InitializeICUDefaultLocation(const char* exec_path,
153 const char* icu_data_file = nullptr);
154
170 static void InitializeExternalStartupData(const char* directory_path);
171 static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
172
177 static void InitializePlatform(Platform* platform);
178
183 static void DisposePlatform();
184
185#if defined(V8_ENABLE_SANDBOX)
196 static bool IsSandboxConfiguredSecurely();
197
210 static VirtualAddressSpace* GetSandboxAddressSpace();
211
218 static size_t GetSandboxSizeInBytes();
219
230 static size_t GetSandboxReservationSizeInBytes();
231#endif // V8_ENABLE_SANDBOX
232
239 static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
240
241#if defined(V8_OS_WIN)
251 static void SetUnhandledExceptionCallback(
252 UnhandledExceptionCallback callback);
253#endif
254
261
266
267 private:
268 V8();
269
270 enum BuildConfigurationFeatures {
271 kPointerCompression = 1 << 0,
272 k31BitSmis = 1 << 1,
273 kSandbox = 1 << 2,
274 };
275
280 static bool Initialize(int build_config);
281
282 friend class Context;
283 template <class K, class V, class T>
285};
286
287} // namespace v8
288
289#endif // INCLUDE_V8_INITIALIZATION_H_
static void InitializeExternalStartupDataFromFile(const char *snapshot_blob)
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver return_address_resolver)
static const char * GetVersion()
static void InitializeExternalStartupData(const char *directory_path)
static V8_INLINE bool Initialize()
static void SetFatalMemoryErrorCallback(OOMErrorCallback callback)
static void SetDcheckErrorHandler(DcheckErrorCallback that)
static void SetFlagsFromString(const char *str, size_t length)
static void GetSharedMemoryStatistics(SharedMemoryStatistics *statistics)
static bool Dispose()
static bool InitializeICU(const char *icu_data_file=nullptr)
static bool InitializeICUDefaultLocation(const char *exec_path, const char *icu_data_file=nullptr)
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
static void SetFlagsFromString(const char *str)
static void SetEntropySource(EntropySource source)
static void InitializePlatform(Platform *platform)
static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler)
static void DisposePlatform()
static void SetSnapshotDataBlob(StartupData *startup_blob)
v8::PageAllocator PageAllocator
Definition platform.h:22
bool(*)(unsigned char *buffer, size_t length) EntropySource
void(*)(const char *location, const OOMDetails &details) OOMErrorCallback
uintptr_t(*)(uintptr_t return_addr_location) ReturnAddressLocationResolver
void(*)(const char *file, int line, const char *message) DcheckErrorCallback
#define V8_EXPORT
Definition v8config.h:753
#define V8_INLINE
Definition v8config.h:477