Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | // |
| 6 | // Top include for all V8 .cc files. |
| 7 | // |
| 8 | |
| 9 | #ifndef V8_V8_H_ |
| 10 | #define V8_V8_H_ |
| 11 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 12 | #if defined(GOOGLE3) || defined(DCHECK_ALWAYS_ON) |
| 13 | // Google3 and Chromium special flag handling. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 14 | #if defined(DEBUG) && defined(NDEBUG) |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 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. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 18 | #undef NDEBUG |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 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 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 37 | |
| 38 | // Objects & heap |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 48 | |
| 49 | namespace v8 { |
| 50 | namespace internal { |
| 51 | |
| 52 | class V8 : public AllStatic { |
| 53 | public: |
| 54 | // Global actions. |
| 55 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 56 | static bool Initialize(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 57 | static void TearDown(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 58 | |
| 59 | // Report process out of memory. Implementation found in api.cc. |
Ben Murdoch | bb769b2 | 2010-08-11 14:56:33 +0100 | [diff] [blame] | 60 | static void FatalProcessOutOfMemory(const char* location, |
| 61 | bool take_snapshot = false); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 62 | |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 63 | // Allows an entropy source to be provided for use in random number |
| 64 | // generation. |
| 65 | static void SetEntropySource(EntropySource source); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 66 | // Support for return-address rewriting profilers. |
| 67 | static void SetReturnAddressLocationResolver( |
| 68 | ReturnAddressLocationResolver resolver); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 69 | // Support for entry hooking JITed code. |
| 70 | static void SetFunctionEntryHook(FunctionEntryHook entry_hook); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 71 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 72 | static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() { |
| 73 | return array_buffer_allocator_; |
| 74 | } |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 75 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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(); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 84 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame] | 85 | static void SetNativesBlob(StartupData* natives_blob); |
| 86 | static void SetSnapshotBlob(StartupData* snapshot_blob); |
| 87 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 88 | private: |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 89 | static void InitializeOncePerProcessImpl(); |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 90 | static void InitializeOncePerProcess(); |
| 91 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 92 | // Allocator for external array buffers. |
| 93 | static v8::ArrayBuffer::Allocator* array_buffer_allocator_; |
| 94 | // v8::Platform to use. |
| 95 | static v8::Platform* platform_; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 96 | }; |
| 97 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 98 | |
| 99 | // JavaScript defines two kinds of 'nil'. |
| 100 | enum NilValue { kNullValue, kUndefinedValue }; |
| 101 | |
| 102 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 103 | } } // namespace v8::internal |
| 104 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 105 | #endif // V8_V8_H_ |