summaryrefslogtreecommitdiff
path: root/deps/v8/src/zone-inl.h
blob: 63efe16818d0add6813675a6fbdad3935279b096 (plain)
1
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_ZONE_INL_H_
#define V8_ZONE_INL_H_

#include "src/zone.h"

#ifdef V8_USE_ADDRESS_SANITIZER
  #include <sanitizer/asan_interface.h>
#else
  #define ASAN_UNPOISON_MEMORY_REGION(start, size) ((void) 0)
#endif

#include "src/counters.h"
#include "src/isolate.h"
#include "src/utils.h"

namespace v8 {
namespace internal {


static const int kASanRedzoneBytes = 24;  // Must be a multiple of 8.


bool Zone::excess_allocation() {
  return segment_bytes_allocated_ > kExcessLimit;
}


void Zone::adjust_segment_bytes_allocated(int delta) {
  segment_bytes_allocated_ += delta;
}


template <typename Config>
ZoneSplayTree<Config>::~ZoneSplayTree() {
  // Reset the root to avoid unneeded iteration over all tree nodes
  // in the destructor.  For a zone-allocated tree, nodes will be
  // freed by the Zone.
  SplayTree<Config, ZoneAllocationPolicy>::ResetRoot();
}


void* ZoneObject::operator new(size_t size, Zone* zone) {
  return zone->New(static_cast<int>(size));
}

inline void* ZoneAllocationPolicy::New(size_t size) {
  DCHECK(zone_);
  return zone_->New(static_cast<int>(size));
}


template <typename T>
void* ZoneList<T>::operator new(size_t size, Zone* zone) {
  return zone->New(static_cast<int>(size));
}


template <typename T>
void* ZoneSplayTree<T>::operator new(size_t size, Zone* zone) {
  return zone->New(static_cast<int>(size));
}


} }  // namespace v8::internal

#endif  // V8_ZONE_INL_H_