• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2011 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 V8_INIT_V8_H_
6 #define V8_INIT_V8_H_
7 
8 #include "src/common/globals.h"
9 
10 namespace v8 {
11 
12 class Platform;
13 class StartupData;
14 
15 namespace internal {
16 
17 class Isolate;
18 
19 class V8 : public AllStatic {
20  public:
21   // Global actions.
22 
23   static bool Initialize();
24   static void TearDown();
25 
26   // Report process out of memory. Implementation found in api.cc.
27   // This function will not return, but will terminate the execution.
28   [[noreturn]] static void FatalProcessOutOfMemory(Isolate* isolate,
29                                                    const char* location,
30                                                    bool is_heap_oom = false);
31 
32   static void InitializePlatform(v8::Platform* platform);
33   static void ShutdownPlatform();
34   V8_EXPORT_PRIVATE static v8::Platform* GetCurrentPlatform();
35   // Replaces the current platform with the given platform.
36   // Should be used only for testing.
37   V8_EXPORT_PRIVATE static void SetPlatformForTesting(v8::Platform* platform);
38 
39   static void SetSnapshotBlob(StartupData* snapshot_blob);
40 
41  private:
42   static void InitializeOncePerProcessImpl();
43   static void InitializeOncePerProcess();
44 
45   // v8::Platform to use.
46   static v8::Platform* platform_;
47 };
48 
49 }  // namespace internal
50 }  // namespace v8
51 
52 #endif  // V8_INIT_V8_H_
53