blob: 4267434e4b6284abb9d03915d7b4ab842f71067f [file] [log] [blame]
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001// Copyright 2011 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
5//
6// Top include for all V8 .cc files.
7//
8
9#ifndef V8_V8_H_
10#define V8_V8_H_
11
Emily Bernierd0a1eb72015-03-24 16:35:39 -040012#if defined(GOOGLE3) || defined(DCHECK_ALWAYS_ON)
13// Google3 and Chromium special flag handling.
Steve Blocka7e24c12009-10-30 11:49:00 +000014#if defined(DEBUG) && defined(NDEBUG)
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000015// 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.
Steve Blocka7e24c12009-10-30 11:49:00 +000018#undef NDEBUG
Steve Blocka7e24c12009-10-30 11:49:00 +000019#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
Ben Murdochb8a8cc12014-11-26 15:28:44 +000029#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
Steve Blocka7e24c12009-10-30 11:49:00 +000037
38// Objects & heap
Ben Murdochb8a8cc12014-11-26 15:28:44 +000039#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
Steve Blocka7e24c12009-10-30 11:49:00 +000048
49namespace v8 {
50namespace internal {
51
52class V8 : public AllStatic {
53 public:
54 // Global actions.
55
Ben Murdochb8a8cc12014-11-26 15:28:44 +000056 static bool Initialize();
Steve Blocka7e24c12009-10-30 11:49:00 +000057 static void TearDown();
Steve Blocka7e24c12009-10-30 11:49:00 +000058
59 // Report process out of memory. Implementation found in api.cc.
Ben Murdochbb769b22010-08-11 14:56:33 +010060 static void FatalProcessOutOfMemory(const char* location,
61 bool take_snapshot = false);
Steve Blocka7e24c12009-10-30 11:49:00 +000062
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000063 // Allows an entropy source to be provided for use in random number
64 // generation.
65 static void SetEntropySource(EntropySource source);
Ben Murdoch3ef787d2012-04-12 10:51:47 +010066 // Support for return-address rewriting profilers.
67 static void SetReturnAddressLocationResolver(
68 ReturnAddressLocationResolver resolver);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000069 // Support for entry hooking JITed code.
70 static void SetFunctionEntryHook(FunctionEntryHook entry_hook);
Steve Blocka7e24c12009-10-30 11:49:00 +000071
Ben Murdochb8a8cc12014-11-26 15:28:44 +000072 static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() {
73 return array_buffer_allocator_;
74 }
Ben Murdoch3ef787d2012-04-12 10:51:47 +010075
Ben Murdochb8a8cc12014-11-26 15:28:44 +000076 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();
Steve Blocka7e24c12009-10-30 11:49:00 +000084
Emily Bernierd0a1eb72015-03-24 16:35:39 -040085 static void SetNativesBlob(StartupData* natives_blob);
86 static void SetSnapshotBlob(StartupData* snapshot_blob);
87
Steve Blocka7e24c12009-10-30 11:49:00 +000088 private:
Ben Murdoch3ef787d2012-04-12 10:51:47 +010089 static void InitializeOncePerProcessImpl();
Ben Murdoch8b112d22011-06-08 16:22:53 +010090 static void InitializeOncePerProcess();
91
Ben Murdochb8a8cc12014-11-26 15:28:44 +000092 // Allocator for external array buffers.
93 static v8::ArrayBuffer::Allocator* array_buffer_allocator_;
94 // v8::Platform to use.
95 static v8::Platform* platform_;
Steve Blocka7e24c12009-10-30 11:49:00 +000096};
97
Ben Murdoch3ef787d2012-04-12 10:51:47 +010098
99// JavaScript defines two kinds of 'nil'.
100enum NilValue { kNullValue, kUndefinedValue };
101
102
Steve Blocka7e24c12009-10-30 11:49:00 +0000103} } // namespace v8::internal
104
Steve Blocka7e24c12009-10-30 11:49:00 +0000105#endif // V8_V8_H_