33#if defined(V8_USE_PERFETTO)
38#if V8_ENABLE_WEBASSEMBLY
42#if defined(V8_ENABLE_ETW_STACK_WALKING)
55enum class V8StartupState {
57 kPlatformInitializing,
67std::atomic<V8StartupState> v8_startup_state_(V8StartupState::kIdle);
69void AdvanceStartupState(V8StartupState expected_next_state) {
70 V8StartupState current_state = v8_startup_state_;
71 CHECK_NE(current_state, V8StartupState::kPlatformDisposed);
72 V8StartupState next_state =
73 static_cast<V8StartupState
>(
static_cast<int>(current_state) + 1);
74 if (next_state != expected_next_state) {
83 FATAL(
"Wrong initialization order: from %d to %d, expected to %d!",
84 static_cast<int>(current_state),
static_cast<int>(next_state),
85 static_cast<int>(expected_next_state));
87 if (!v8_startup_state_.compare_exchange_strong(current_state, next_state)) {
89 "Multiple threads are initializating V8 in the wrong order: expected "
91 static_cast<int>(current_state),
92 static_cast<int>(v8_startup_state_.load()));
98#ifdef V8_USE_EXTERNAL_STARTUP_DATA
104 AdvanceStartupState(V8StartupState::kPlatformInitializing);
110#if defined(V8_ENABLE_ETW_STACK_WALKING)
111 if (
v8_flags.enable_etw_stack_walking ||
112 v8_flags.enable_etw_by_custom_filter_only) {
122 AdvanceStartupState(V8StartupState::kPlatformInitialized);
127 if (v8_startup_state_ != V8StartupState::kIdle) {
129 "The platform was initialized before. Note that running multiple tests "
130 "in the same process is not supported.");
136 AdvanceStartupState(V8StartupState::kV8Initializing);
152 std::ios_base::trunc);
167 }
else if (
v8_flags.sandbox_testing) {
191#ifdef V8_ENABLE_SANDBOX
205 SandboxTesting::Mode mode =
v8_flags.sandbox_testing
206 ? SandboxTesting::Mode::kForTesting
207 : SandboxTesting::Mode::kForFuzzing;
208 SandboxTesting::Enable(mode);
212#if defined(V8_USE_PERFETTO)
213 if (perfetto::Tracing::IsInitialized()) {
214 TrackEvent::Register();
215 if (
v8_flags.perfetto_code_logger) {
223#if defined(USE_SIMULATOR)
224 Simulator::InitializeOncePerProcess();
231#if V8_ENABLE_WEBASSEMBLY
237 AdvanceStartupState(V8StartupState::kV8Initialized);
241 AdvanceStartupState(V8StartupState::kV8Disposing);
243#if V8_ENABLE_WEBASSEMBLY
246#if defined(USE_SIMULATOR)
247 Simulator::GlobalTearDown();
254 AdvanceStartupState(V8StartupState::kV8Disposed);
258 AdvanceStartupState(V8StartupState::kPlatformDisposing);
260#if defined(V8_OS_WIN) && defined(V8_ENABLE_ETW_STACK_WALKING)
261 if (
v8_flags.enable_etw_stack_walking ||
262 v8_flags.enable_etw_by_custom_filter_only) {
269#ifdef V8_ENABLE_SANDBOX
270 Sandbox::TearDownDefault();
276 internal::ThreadIsolation::CheckTrackedMemoryEmpty();
279 AdvanceStartupState(V8StartupState::kPlatformDisposed);
295#ifdef V8_USE_EXTERNAL_STARTUP_DATA
310#if V8_HAS_PKU_JIT_WRITE_PROTECT
311 internal::RwxMemoryWriteScope::SetDefaultPermissionsForSignalHandler();
virtual void SetRandomMmapSeed(int64_t seed)=0
static void UnregisterAll()
static V8_EXPORT void InitializeBeforeThreadCreation()
static void SetDefaultPermissionsForSignalHandler()
virtual void SetRandomSeed(int64_t seed)=0
static void Initialize(AbortMode abort_mode, const char *const gc_fake_mmap)
static double TimeCurrentMillis()
static void InitializeOncePerProcess()
static void InitializeOncePerProcess()
static void InitializeOncePerProcess()
static void Probe(bool cross_compile)
static void InitializeOncePerProcess()
static void InitializeOncePerIsolateGroup(MemorySpan< Address > shared_external_references)
static void EnforceFlagImplications()
static void PrintValues()
static void ReleaseDynamicAllocations()
static void FreezeFlags()
static void TearDownOncePerProcess()
static IsolateGroup * current()
static void InitializeOncePerProcess()
static void InitializeOncePerProcess()
static std::string GetTurboCfgFileName(Isolate *isolate)
static void InitializeBeforeThreadCreation()
static void SetDefaultPermissionsForSignalHandler()
static void Initialize(ThreadIsolatedAllocator *allocator)
static V8_EXPORT_PRIVATE void SetPlatformForTesting(v8::Platform *platform)
static v8::Platform * platform_
static V8_EXPORT_PRIVATE const OOMDetails kNoOOMDetails
static void SetSnapshotBlob(StartupData *snapshot_blob)
static V8_EXPORT_PRIVATE void InitializePlatformForTesting(v8::Platform *platform)
static V8_EXPORT_PRIVATE v8::Platform * GetCurrentPlatform()
static void InitializePlatform(v8::Platform *platform)
static void DisposePlatform()
static V8_EXPORT_PRIVATE const OOMDetails kHeapOOM
static void InitializeOncePerProcess()
static void GlobalTearDown()
void Relaxed_Store(volatile Atomic8 *ptr, Atomic8 value)
Atomic8 Relaxed_Load(volatile const Atomic8 *ptr)
@ kExitWithFailureAndIgnoreDcheckFailures
@ kExitWithSuccessAndIgnoreDcheckFailures
void CallOnce(OnceType *once, std::function< void()> init_func)
void SetPrintStackTrace(void(*print_stack_trace)())
v8::PageAllocator * GetPlatformPageAllocator()
v8::VirtualAddressSpace * GetPlatformVirtualAddressSpace()
V8_EXPORT_PRIVATE FlagValues v8_flags
void SetSnapshotFromFile(StartupData *snapshot_blob)
#define V8_DECLARE_ONCE(NAME)
#define CHECK_NOT_NULL(val)
#define CHECK_NE(lhs, rhs)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)