v8.h 1.97 KB
Newer Older
1
// Copyright 2011 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_INIT_V8_H_
#define V8_INIT_V8_H_
7

8
#include "src/common/globals.h"
9

10
namespace v8 {
11

12
struct OOMDetails;
13 14 15
class Platform;
class StartupData;

16
namespace internal {
17

18 19
class Isolate;

20 21 22
class V8 : public AllStatic {
 public:
  // Global actions.
23 24
  static void Initialize();
  static void Dispose();
25 26

  // Report process out of memory. Implementation found in api.cc.
27
  // This function will not return, but will terminate the execution.
28 29
  // IMPORTANT: Update the Google-internal crash processer if this signature
  // changes to be able to extract detailed v8::internal::HeapStats on OOM.
30
  [[noreturn]] V8_EXPORT_PRIVATE static void FatalProcessOutOfMemory(
31 32 33 34 35 36 37
      Isolate* isolate, const char* location,
      const OOMDetails& details = kNoOOMDetails);

  // Constants to be used for V8::FatalProcessOutOfMemory. They avoid having
  // to include v8-callbacks.h in all callers.
  V8_EXPORT_PRIVATE static const OOMDetails kNoOOMDetails;
  V8_EXPORT_PRIVATE static const OOMDetails kHeapOOM;
38

39 40 41 42 43 44
  // Another variant of FatalProcessOutOfMemory, which constructs the OOMDetails
  // struct internally from another "detail" c-string.
  // This can be removed once we support designated initializers (C++20).
  [[noreturn]] V8_EXPORT_PRIVATE static void FatalProcessOutOfMemory(
      Isolate* isolate, const char* location, const char* detail);

45
  static void InitializePlatform(v8::Platform* platform);
46
  static void DisposePlatform();
47
  V8_EXPORT_PRIVATE static v8::Platform* GetCurrentPlatform();
48 49
  // Replaces the current platform with the given platform.
  // Should be used only for testing.
50
  V8_EXPORT_PRIVATE static void SetPlatformForTesting(v8::Platform* platform);
51

52 53
  static void SetSnapshotBlob(StartupData* snapshot_blob);

54
 private:
55
  static v8::Platform* platform_;
56 57
};

58 59
}  // namespace internal
}  // namespace v8
60

61
#endif  // V8_INIT_V8_H_