Home | History | Annotate | Download | only in src
      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 "src/v8checks.h"
     32 #include "src/allocation.h"
     33 #include "src/assert-scope.h"
     34 #include "src/utils.h"
     35 #include "src/flags.h"
     36 #include "src/globals.h"
     37 
     38 // Objects & heap
     39 #include "src/objects-inl.h"
     40 #include "src/spaces-inl.h"
     41 #include "src/heap-inl.h"
     42 #include "src/incremental-marking-inl.h"
     43 #include "src/mark-compact-inl.h"
     44 #include "src/log-inl.h"
     45 #include "src/handles-inl.h"
     46 #include "src/types-inl.h"
     47 #include "src/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_
    109