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//
6// Top include for all V8 .cc files.
7//
8
9#ifndef V8_V8_H_
10#define V8_V8_H_
11
12#if defined(GOOGLE3)
13// Google3 special flag handling.
14#if defined(DEBUG) && defined(NDEBUG)
15// V8 only uses DEBUG and whenever it is set we are building a debug
16// version of V8. We do not use NDEBUG and simply undef it here for
17// consistency.
18#undef NDEBUG
19#endif
20#endif  // defined(GOOGLE3)
21
22// V8 only uses DEBUG, but included external files
23// may use NDEBUG - make sure they are consistent.
24#if defined(DEBUG) && defined(NDEBUG)
25#error both DEBUG and NDEBUG are set
26#endif
27
28// Basic includes
29#include "include/v8.h"
30#include "include/v8-platform.h"
31#include "src/checks.h"  // NOLINT
32#include "src/allocation.h"  // NOLINT
33#include "src/assert-scope.h"  // NOLINT
34#include "src/utils.h"  // NOLINT
35#include "src/flags.h"  // NOLINT
36#include "src/globals.h"  // NOLINT
37
38// Objects & heap
39#include "src/objects-inl.h"  // NOLINT
40#include "src/heap/spaces-inl.h"               // NOLINT
41#include "src/heap/heap-inl.h"                 // NOLINT
42#include "src/heap/incremental-marking-inl.h"  // NOLINT
43#include "src/heap/mark-compact-inl.h"         // NOLINT
44#include "src/log-inl.h"  // NOLINT
45#include "src/handles-inl.h"  // NOLINT
46#include "src/types-inl.h"  // NOLINT
47#include "src/zone-inl.h"  // NOLINT
48
49namespace v8 {
50namespace internal {
51
52class V8 : public AllStatic {
53 public:
54  // Global actions.
55
56  static bool Initialize();
57  static void TearDown();
58
59  // Report process out of memory. Implementation found in api.cc.
60  static void FatalProcessOutOfMemory(const char* location,
61                                      bool take_snapshot = false);
62
63  // Allows an entropy source to be provided for use in random number
64  // generation.
65  static void SetEntropySource(EntropySource source);
66  // Support for return-address rewriting profilers.
67  static void SetReturnAddressLocationResolver(
68      ReturnAddressLocationResolver resolver);
69  // Support for entry hooking JITed code.
70  static void SetFunctionEntryHook(FunctionEntryHook entry_hook);
71
72  static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() {
73    return array_buffer_allocator_;
74  }
75
76  static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator) {
77    CHECK_EQ(NULL, array_buffer_allocator_);
78    array_buffer_allocator_ = allocator;
79  }
80
81  static void InitializePlatform(v8::Platform* platform);
82  static void ShutdownPlatform();
83  static v8::Platform* GetCurrentPlatform();
84
85 private:
86  static void InitializeOncePerProcessImpl();
87  static void InitializeOncePerProcess();
88
89  // Allocator for external array buffers.
90  static v8::ArrayBuffer::Allocator* array_buffer_allocator_;
91  // v8::Platform to use.
92  static v8::Platform* platform_;
93};
94
95
96// JavaScript defines two kinds of 'nil'.
97enum NilValue { kNullValue, kUndefinedValue };
98
99
100} }  // namespace v8::internal
101
102#endif  // V8_V8_H_
103