v8.h 3.14 KB
Newer Older
1
// Copyright 2011 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4 5 6 7 8 9 10 11

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

#ifndef V8_V8_H_
#define V8_V8_H_

12 13
#if defined(GOOGLE3) || defined(DCHECK_ALWAYS_ON)
// Google3 and Chromium special flag handling.
14
#if defined(DEBUG) && defined(NDEBUG)
15 16 17
// 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.
18
#undef NDEBUG
19
#endif
20
#endif  // defined(GOOGLE3)
21 22 23 24 25 26 27 28

// 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
29 30
#include "include/v8.h"
#include "include/v8-platform.h"
31
#include "src/checks.h"  // NOLINT
32 33 34 35 36
#include "src/allocation.h"  // NOLINT
#include "src/assert-scope.h"  // NOLINT
#include "src/utils.h"  // NOLINT
#include "src/flags.h"  // NOLINT
#include "src/globals.h"  // NOLINT
37 38

// Objects & heap
39
#include "src/objects-inl.h"  // NOLINT
40 41 42 43
#include "src/heap/spaces-inl.h"               // NOLINT
#include "src/heap/heap-inl.h"                 // NOLINT
#include "src/heap/incremental-marking-inl.h"  // NOLINT
#include "src/heap/mark-compact-inl.h"         // NOLINT
44 45 46
#include "src/log-inl.h"  // NOLINT
#include "src/handles-inl.h"  // NOLINT
#include "src/types-inl.h"  // NOLINT
47

48 49
namespace v8 {
namespace internal {
50 51 52 53 54

class V8 : public AllStatic {
 public:
  // Global actions.

55
  static bool Initialize();
56
  static void TearDown();
57 58

  // Report process out of memory. Implementation found in api.cc.
59
  // This function will not return, but will terminate the execution.
60 61
  static void FatalProcessOutOfMemory(const char* location,
                                      bool take_snapshot = false);
62

63 64 65
  // Allows an entropy source to be provided for use in random number
  // generation.
  static void SetEntropySource(EntropySource source);
66 67 68
  // Support for return-address rewriting profilers.
  static void SetReturnAddressLocationResolver(
      ReturnAddressLocationResolver resolver);
69 70
  // Support for entry hooking JITed code.
  static void SetFunctionEntryHook(FunctionEntryHook entry_hook);
71

72 73 74 75 76
  static v8::ArrayBuffer::Allocator* ArrayBufferAllocator() {
    return array_buffer_allocator_;
  }

  static void SetArrayBufferAllocator(v8::ArrayBuffer::Allocator *allocator) {
77
    CHECK_NULL(array_buffer_allocator_);
78 79 80
    array_buffer_allocator_ = allocator;
  }

81 82 83 84
  static void InitializePlatform(v8::Platform* platform);
  static void ShutdownPlatform();
  static v8::Platform* GetCurrentPlatform();

85 86 87
  static void SetNativesBlob(StartupData* natives_blob);
  static void SetSnapshotBlob(StartupData* snapshot_blob);

88
 private:
89
  static void InitializeOncePerProcessImpl();
90 91
  static void InitializeOncePerProcess();

92 93
  // Allocator for external array buffers.
  static v8::ArrayBuffer::Allocator* array_buffer_allocator_;
94 95
  // v8::Platform to use.
  static v8::Platform* platform_;
96 97
};

98 99 100 101 102

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


103 104 105
} }  // namespace v8::internal

#endif  // V8_V8_H_