v8.h 4.71 KB
Newer Older
1
// Copyright 2011 the V8 project authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
//     * Neither the name of Google Inc. nor the names of its
//       contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

//
// Top include for all V8 .cc files.
//

#ifndef V8_V8_H_
#define V8_V8_H_

35 36 37
#if defined(GOOGLE3)
// Google3 special flag handling.
#if defined(DEBUG) && defined(NDEBUG)
38 39 40
// V8 only uses DEBUG and whenever it is set we are building a debug
// version of V8. We do not use NDEBUG and simply undef it here for
// consistency.
41
#undef NDEBUG
42
#endif
43
#endif  // defined(GOOGLE3)
44 45 46 47 48 49 50 51

// V8 only uses DEBUG, but included external files
// may use NDEBUG - make sure they are consistent.
#if defined(DEBUG) && defined(NDEBUG)
#error both DEBUG and NDEBUG are set
#endif

// Basic includes
52
#include "../include/v8.h"
53
#include "../include/v8-platform.h"
54
#include "v8globals.h"
55
#include "v8checks.h"
56
#include "allocation.h"
57
#include "assert-scope.h"
58
#include "v8utils.h"
59
#include "flags.h"
60 61 62 63 64

// Objects & heap
#include "objects-inl.h"
#include "spaces-inl.h"
#include "heap-inl.h"
65 66
#include "incremental-marking-inl.h"
#include "mark-compact-inl.h"
67
#include "log-inl.h"
68
#include "handles-inl.h"
69
#include "types-inl.h"
70
#include "zone-inl.h"
71

72 73
namespace v8 {
namespace internal {
74

75 76
class Deserializer;

77 78 79 80
class V8 : public AllStatic {
 public:
  // Global actions.

81 82 83 84
  // If Initialize is called with des == NULL, the initial state is
  // created from scratch. If a non-null Deserializer is given, the
  // initial state is created by reading the deserialized data into an
  // empty heap.
85
  static bool Initialize(Deserializer* des);
86
  static void TearDown();
87 88

  // Report process out of memory. Implementation found in api.cc.
89 90
  static void FatalProcessOutOfMemory(const char* location,
                                      bool take_snapshot = false);
91

92 93 94
  // Allows an entropy source to be provided for use in random number
  // generation.
  static void SetEntropySource(EntropySource source);
95 96 97
  // Support for return-address rewriting profilers.
  static void SetReturnAddressLocationResolver(
      ReturnAddressLocationResolver resolver);
98 99
  // Support for entry hooking JITed code.
  static void SetFunctionEntryHook(FunctionEntryHook entry_hook);
100

101 102 103 104
  static void AddCallCompletedCallback(CallCompletedCallback callback);
  static void RemoveCallCompletedCallback(CallCompletedCallback callback);
  static void FireCallCompletedCallback(Isolate* isolate);

105 106
  static void RunMicrotasks(Isolate* isolate);

107 108 109 110 111 112 113 114 115
  static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() {
    return array_buffer_allocator_;
  }

  static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator) {
    CHECK_EQ(NULL, array_buffer_allocator_);
    array_buffer_allocator_ = allocator;
  }

116 117 118 119
  static void InitializePlatform(v8::Platform* platform);
  static void ShutdownPlatform();
  static v8::Platform* GetCurrentPlatform();

120
 private:
121
  static void InitializeOncePerProcessImpl();
122 123
  static void InitializeOncePerProcess();

124 125
  // List of callbacks when a Call completes.
  static List<CallCompletedCallback>* call_completed_callbacks_;
126 127
  // Allocator for external array buffers.
  static v8::ArrayBuffer::Allocator* array_buffer_allocator_;
128 129
  // v8::Platform to use.
  static v8::Platform* platform_;
130 131
};

132 133 134 135 136

// JavaScript defines two kinds of 'nil'.
enum NilValue { kNullValue, kUndefinedValue };


137 138 139
} }  // namespace v8::internal

#endif  // V8_V8_H_