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#ifdef V8_TARGET_OS_ANDROID
101 const bool kV8TargetOsIsAndroid = true;
102#else
103 const bool kV8TargetOsIsAndroid = false;
104#endif
105
106 const int kBuildConfiguration =
107 (internal::PointerCompressionIsEnabled() ? kPointerCompression : 0) |
108 (internal::SmiValuesAre31Bits() ? k31BitSmis : 0) |
109 (internal::SandboxIsEnabled() ? kSandbox : 0) |
110 (kV8TargetOsIsAndroid ? kTargetOsIsAndroid : 0);
111 return Initialize(kBuildConfiguration);
112 }
113
118 static void SetEntropySource(EntropySource source);
119
125 ReturnAddressLocationResolver return_address_resolver);
126
136 static bool Dispose();
137
145 static bool InitializeICU(const char* icu_data_file = nullptr);
146
159 static bool InitializeICUDefaultLocation(const char* exec_path,
160 const char* icu_data_file = nullptr);
161
177 static void InitializeExternalStartupData(const char* directory_path);
178 static void InitializeExternalStartupDataFromFile(const char* snapshot_blob);
179
184 static void InitializePlatform(Platform* platform);
185
190 static void DisposePlatform();
191
192#if defined(V8_ENABLE_SANDBOX)
203 static bool IsSandboxConfiguredSecurely();
204
217 static VirtualAddressSpace* GetSandboxAddressSpace();
218
225 static size_t GetSandboxSizeInBytes();
226
237 static size_t GetSandboxReservationSizeInBytes();
238#endif // V8_ENABLE_SANDBOX
239
246 static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler);
247
248#if defined(V8_OS_WIN)
258 static void SetUnhandledExceptionCallback(
259 UnhandledExceptionCallback callback);
260#endif
261
268
273
274 private:
275 V8();
276
277 enum BuildConfigurationFeatures {
278 kPointerCompression = 1 << 0,
279 k31BitSmis = 1 << 1,
280 kSandbox = 1 << 2,
281 kTargetOsIsAndroid = 1 << 3,
282 };
283
288 static bool Initialize(int build_config);
289
290 friend class Context;
291 template <class K, class V, class T>
293};
294
295} // namespace v8
296
297#endif // INCLUDE_V8_INITIALIZATION_H_
Definition: v8-context.h:48
Definition: v8-util.h:166
Definition: v8-platform.h:1058
Definition: v8-statistics.h:116
Definition: v8-snapshot.h:21
Definition: v8-initialization.h:58
static void InitializePlatform(Platform *platform)
static const char * GetVersion()
static bool InitializeICUDefaultLocation(const char *exec_path, const char *icu_data_file=nullptr)
static void SetSnapshotDataBlob(StartupData *startup_blob)
static void InitializeExternalStartupDataFromFile(const char *snapshot_blob)
static bool EnableWebAssemblyTrapHandler(bool use_v8_signal_handler)
static bool Initialize()
Definition: v8-initialization.h:99
static void SetEntropySource(EntropySource source)
static bool Dispose()
static void SetDcheckErrorHandler(DcheckErrorCallback that)
static void SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags)
static void DisposePlatform()
static bool InitializeICU(const char *icu_data_file=nullptr)
static void GetSharedMemoryStatistics(SharedMemoryStatistics *statistics)
static void SetReturnAddressLocationResolver(ReturnAddressLocationResolver return_address_resolver)
static void SetFlagsFromString(const char *str, size_t length)
static void SetFatalMemoryErrorCallback(OOMErrorCallback callback)
static void InitializeExternalStartupData(const char *directory_path)
static void SetFlagsFromString(const char *str)
Definition: v8-platform.h:728
v8::PageAllocator PageAllocator
Definition: platform.h:22
Definition: libplatform.h:15
void(*)(const char *location, const OOMDetails &details) OOMErrorCallback
Definition: v8-callbacks.h:231
void(*)(const char *file, int line, const char *message) DcheckErrorCallback
Definition: v8-initialization.h:53
uintptr_t(*)(uintptr_t return_addr_location) ReturnAddressLocationResolver
Definition: v8-initialization.h:50
bool(*)(unsigned char *buffer, size_t length) EntropySource
Definition: v8-initialization.h:34
#define V8_EXPORT
Definition: v8config.h:762
#define V8_INLINE
Definition: v8config.h:477