Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / v8 / src / v8.h
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 "v8globals.h"
32 #include "v8checks.h"
33 #include "allocation.h"
34 #include "assert-scope.h"
35 #include "utils.h"
36 #include "flags.h"
37
38 // Objects & heap
39 #include "objects-inl.h"
40 #include "spaces-inl.h"
41 #include "heap-inl.h"
42 #include "incremental-marking-inl.h"
43 #include "mark-compact-inl.h"
44 #include "log-inl.h"
45 #include "handles-inl.h"
46 #include "types-inl.h"
47 #include "zone-inl.h"
48
49 namespace v8 {
50 namespace internal {
51
52 class Deserializer;
53
54 class V8 : public AllStatic {
55  public:
56   // Global actions.
57
58   // If Initialize is called with des == NULL, the initial state is
59   // created from scratch. If a non-null Deserializer is given, the
60   // initial state is created by reading the deserialized data into an
61   // empty heap.
62   static bool Initialize(Deserializer* des);
63   static void TearDown();
64
65   // Report process out of memory. Implementation found in api.cc.
66   static void FatalProcessOutOfMemory(const char* location,
67                                       bool take_snapshot = false);
68
69   // Allows an entropy source to be provided for use in random number
70   // generation.
71   static void SetEntropySource(EntropySource source);
72   // Support for return-address rewriting profilers.
73   static void SetReturnAddressLocationResolver(
74       ReturnAddressLocationResolver resolver);
75   // Support for entry hooking JITed code.
76   static void SetFunctionEntryHook(FunctionEntryHook entry_hook);
77
78   static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() {
79     return array_buffer_allocator_;
80   }
81
82   static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator) {
83     CHECK_EQ(NULL, array_buffer_allocator_);
84     array_buffer_allocator_ = allocator;
85   }
86
87   static void InitializePlatform(v8::Platform* platform);
88   static void ShutdownPlatform();
89   static v8::Platform* GetCurrentPlatform();
90
91  private:
92   static void InitializeOncePerProcessImpl();
93   static void InitializeOncePerProcess();
94
95   // Allocator for external array buffers.
96   static v8::ArrayBuffer::Allocator* array_buffer_allocator_;
97   // v8::Platform to use.
98   static v8::Platform* platform_;
99 };
100
101
102 // JavaScript defines two kinds of 'nil'.
103 enum NilValue { kNullValue, kUndefinedValue };
104
105
106 } }  // namespace v8::internal
107
108 #endif  // V8_V8_H_