blob: 5848f748185e27c7ce4ceaaf1deaccf139d24a7b [file] [log] [blame]
svenpanne@chromium.org6d786c92011-06-15 10:58:27 +00001// Copyright 2011 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// 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.ager31e71382008-08-13 09:32:07 +000035#if defined(GOOGLE3)
36// Google3 special flag handling.
37#if defined(DEBUG) && defined(NDEBUG)
svenpanne@chromium.org6d786c92011-06-15 10:58:27 +000038// 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.ager31e71382008-08-13 09:32:07 +000041#undef NDEBUG
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000042#endif
mads.s.ager31e71382008-08-13 09:32:07 +000043#endif // defined(GOOGLE3)
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000044
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
51// Basic includes
v8.team.kasperl727e9952008-09-02 14:56:44 +000052#include "../include/v8.h"
erik.corry@gmail.com4a6c3272010-11-18 12:04:40 +000053#include "v8globals.h"
ager@chromium.orgbeb25712010-11-29 08:02:25 +000054#include "v8checks.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000055#include "allocation.h"
rossberg@chromium.org79e79022013-06-03 15:43:46 +000056#include "assert-scope.h"
whesse@chromium.orgf0ac72d2010-11-08 12:47:26 +000057#include "v8utils.h"
kasperl@chromium.orgb9123622008-09-17 14:05:56 +000058#include "flags.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000059
60// Objects & heap
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000061#include "objects-inl.h"
62#include "spaces-inl.h"
63#include "heap-inl.h"
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000064#include "incremental-marking-inl.h"
65#include "mark-compact-inl.h"
ager@chromium.org3e875802009-06-29 08:26:34 +000066#include "log-inl.h"
ager@chromium.orgce5e87b2010-03-10 10:24:18 +000067#include "handles-inl.h"
rossberg@chromium.org400388e2012-06-06 09:29:22 +000068#include "zone-inl.h"
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000069
kasperl@chromium.org71affb52009-05-26 05:44:31 +000070namespace v8 {
71namespace internal {
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000072
ager@chromium.orgc4c92722009-11-18 14:12:51 +000073class Deserializer;
74
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000075class V8 : public AllStatic {
76 public:
77 // Global actions.
78
ager@chromium.orgeadaf222009-06-16 09:43:10 +000079 // If Initialize is called with des == NULL, the initial state is
80 // created from scratch. If a non-null Deserializer is given, the
81 // initial state is created by reading the deserialized data into an
82 // empty heap.
ager@chromium.orgc4c92722009-11-18 14:12:51 +000083 static bool Initialize(Deserializer* des);
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000084 static void TearDown();
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000085
86 // Report process out of memory. Implementation found in api.cc.
lrn@chromium.orgc4e51ac2010-08-09 09:47:21 +000087 static void FatalProcessOutOfMemory(const char* location,
88 bool take_snapshot = false);
ager@chromium.orgeadaf222009-06-16 09:43:10 +000089
svenpanne@chromium.org84bcc552011-07-18 09:50:57 +000090 // Allows an entropy source to be provided for use in random number
91 // generation.
92 static void SetEntropySource(EntropySource source);
ulan@chromium.org967e2702012-02-28 09:49:15 +000093 // Support for return-address rewriting profilers.
94 static void SetReturnAddressLocationResolver(
95 ReturnAddressLocationResolver resolver);
mstarzinger@chromium.org1510d582013-06-28 14:00:48 +000096 // Support for entry hooking JITed code.
97 static void SetFunctionEntryHook(FunctionEntryHook entry_hook);
ager@chromium.orgeadaf222009-06-16 09:43:10 +000098 // Random number generation support. Not cryptographically safe.
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +000099 static uint32_t Random(Context* context);
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000100 static Object* FillHeapNumberWithRandom(Object* heap_number,
erik.corry@gmail.com394dbcf2011-10-27 07:38:48 +0000101 Context* context);
ager@chromium.orgeadaf222009-06-16 09:43:10 +0000102
rossberg@chromium.orgfab14982012-01-05 15:02:15 +0000103 static void AddCallCompletedCallback(CallCompletedCallback callback);
104 static void RemoveCallCompletedCallback(CallCompletedCallback callback);
105 static void FireCallCompletedCallback(Isolate* isolate);
106
ulan@chromium.org837a67e2013-06-11 15:39:48 +0000107 static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() {
108 return array_buffer_allocator_;
109 }
110
111 static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator) {
112 CHECK_EQ(NULL, array_buffer_allocator_);
113 array_buffer_allocator_ = allocator;
114 }
115
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000116 private:
jkummerow@chromium.org1456e702012-03-30 08:38:13 +0000117 static void InitializeOncePerProcessImpl();
kmillikin@chromium.orgc36ce6e2011-04-04 08:25:31 +0000118 static void InitializeOncePerProcess();
119
rossberg@chromium.orgfab14982012-01-05 15:02:15 +0000120 // List of callbacks when a Call completes.
121 static List<CallCompletedCallback>* call_completed_callbacks_;
ulan@chromium.org837a67e2013-06-11 15:39:48 +0000122 // Allocator for external array buffers.
123 static v8::ArrayBuffer::Allocator* array_buffer_allocator_;
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000124};
125
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000126
127// JavaScript defines two kinds of 'nil'.
128enum NilValue { kNullValue, kUndefinedValue };
129
130
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000131} } // namespace v8::internal
132
kasperl@chromium.org7be3c992009-03-12 07:19:55 +0000133namespace i = v8::internal;
134
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +0000135#endif // V8_V8_H_