svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | // |
| 29 | // Top include for all V8 .cc files. |
| 30 | // |
| 31 | |
| 32 | #ifndef V8_V8_H_ |
| 33 | #define V8_V8_H_ |
| 34 | |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 35 | #if defined(GOOGLE3) |
| 36 | // Google3 special flag handling. |
| 37 | #if defined(DEBUG) && defined(NDEBUG) |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 38 | // V8 only uses DEBUG and whenever it is set we are building a debug |
| 39 | // version of V8. We do not use NDEBUG and simply undef it here for |
| 40 | // consistency. |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 41 | #undef NDEBUG |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 42 | #endif |
mads.s.ager | 31e7138 | 2008-08-13 09:32:07 +0000 | [diff] [blame] | 43 | #endif // defined(GOOGLE3) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 44 | |
| 45 | // V8 only uses DEBUG, but included external files |
| 46 | // may use NDEBUG - make sure they are consistent. |
| 47 | #if defined(DEBUG) && defined(NDEBUG) |
| 48 | #error both DEBUG and NDEBUG are set |
| 49 | #endif |
| 50 | |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 51 | // TODO(dcarney): remove this |
| 52 | #define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 53 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 54 | // Basic includes |
v8.team.kasperl | 727e995 | 2008-09-02 14:56:44 +0000 | [diff] [blame] | 55 | #include "../include/v8.h" |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 56 | #include "v8globals.h" |
ager@chromium.org | beb2571 | 2010-11-29 08:02:25 +0000 | [diff] [blame] | 57 | #include "v8checks.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 58 | #include "allocation.h" |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 59 | #include "v8utils.h" |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 60 | #include "flags.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 61 | |
| 62 | // Objects & heap |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 63 | #include "objects-inl.h" |
| 64 | #include "spaces-inl.h" |
| 65 | #include "heap-inl.h" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 66 | #include "incremental-marking-inl.h" |
| 67 | #include "mark-compact-inl.h" |
ager@chromium.org | 3e87580 | 2009-06-29 08:26:34 +0000 | [diff] [blame] | 68 | #include "log-inl.h" |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 69 | #include "cpu-profiler-inl.h" |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 70 | #include "handles-inl.h" |
ulan@chromium.org | 2e04b58 | 2013-02-21 14:06:02 +0000 | [diff] [blame] | 71 | #include "heap-snapshot-generator-inl.h" |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 72 | #include "zone-inl.h" |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 73 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 74 | namespace v8 { |
| 75 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 76 | |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 77 | class Deserializer; |
| 78 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 79 | class V8 : public AllStatic { |
| 80 | public: |
| 81 | // Global actions. |
| 82 | |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 83 | // If Initialize is called with des == NULL, the initial state is |
| 84 | // created from scratch. If a non-null Deserializer is given, the |
| 85 | // initial state is created by reading the deserialized data into an |
| 86 | // empty heap. |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 87 | static bool Initialize(Deserializer* des); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 88 | static void TearDown(); |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 89 | static bool IsRunning() { return is_running_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 90 | static bool UseCrankshaft() { return use_crankshaft_; } |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 91 | // To be dead you have to have lived |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 92 | // TODO(isolates): move IsDead to Isolate. |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 93 | static bool IsDead() { return has_fatal_error_ || has_been_disposed_; } |
| 94 | static void SetFatalError(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 95 | |
| 96 | // Report process out of memory. Implementation found in api.cc. |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 97 | static void FatalProcessOutOfMemory(const char* location, |
| 98 | bool take_snapshot = false); |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 99 | |
svenpanne@chromium.org | 84bcc55 | 2011-07-18 09:50:57 +0000 | [diff] [blame] | 100 | // Allows an entropy source to be provided for use in random number |
| 101 | // generation. |
| 102 | static void SetEntropySource(EntropySource source); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 103 | // Support for return-address rewriting profilers. |
| 104 | static void SetReturnAddressLocationResolver( |
| 105 | ReturnAddressLocationResolver resolver); |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 106 | // Random number generation support. Not cryptographically safe. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 107 | static uint32_t Random(Context* context); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 108 | // We use random numbers internally in memory allocation and in the |
| 109 | // compilers for security. In order to prevent information leaks we |
| 110 | // use a separate random state for internal random number |
| 111 | // generation. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 112 | static uint32_t RandomPrivate(Isolate* isolate); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 113 | static Object* FillHeapNumberWithRandom(Object* heap_number, |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 114 | Context* context); |
ager@chromium.org | eadaf22 | 2009-06-16 09:43:10 +0000 | [diff] [blame] | 115 | |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 116 | // Idle notification directly from the API. |
svenpanne@chromium.org | ecb9dd6 | 2011-12-01 08:22:35 +0000 | [diff] [blame] | 117 | static bool IdleNotification(int hint); |
ager@chromium.org | add848f | 2009-08-13 12:44:13 +0000 | [diff] [blame] | 118 | |
rossberg@chromium.org | fab1498 | 2012-01-05 15:02:15 +0000 | [diff] [blame] | 119 | static void AddCallCompletedCallback(CallCompletedCallback callback); |
| 120 | static void RemoveCallCompletedCallback(CallCompletedCallback callback); |
| 121 | static void FireCallCompletedCallback(Isolate* isolate); |
| 122 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 123 | private: |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 124 | static void InitializeOncePerProcessImpl(); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 125 | static void InitializeOncePerProcess(); |
| 126 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 127 | // True if engine is currently running |
| 128 | static bool is_running_; |
| 129 | // True if V8 has ever been run |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 130 | static bool has_been_set_up_; |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 131 | // True if error has been signaled for current engine |
| 132 | // (reset to false if engine is restarted) |
| 133 | static bool has_fatal_error_; |
| 134 | // True if engine has been shut down |
| 135 | // (reset if engine is restarted) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 136 | static bool has_been_disposed_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 137 | // True if we are using the crankshaft optimizing compiler. |
| 138 | static bool use_crankshaft_; |
rossberg@chromium.org | fab1498 | 2012-01-05 15:02:15 +0000 | [diff] [blame] | 139 | // List of callbacks when a Call completes. |
| 140 | static List<CallCompletedCallback>* call_completed_callbacks_; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 143 | |
| 144 | // JavaScript defines two kinds of 'nil'. |
| 145 | enum NilValue { kNullValue, kUndefinedValue }; |
| 146 | |
| 147 | |
| 148 | // JavaScript defines two kinds of equality. |
| 149 | enum EqualityKind { kStrictEquality, kNonStrictEquality }; |
| 150 | |
| 151 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 152 | } } // namespace v8::internal |
| 153 | |
kasperl@chromium.org | 7be3c99 | 2009-03-12 07:19:55 +0000 | [diff] [blame] | 154 | namespace i = v8::internal; |
| 155 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 156 | #endif // V8_V8_H_ |