blob: 63efe16818d0add6813675a6fbdad3935279b096 [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001// Copyright 2012 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
5#ifndef V8_ZONE_INL_H_
6#define V8_ZONE_INL_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "src/zone.h"
Ben Murdoch3ef787d2012-04-12 10:51:47 +01009
Ben Murdochb8a8cc12014-11-26 15:28:44 +000010#ifdef V8_USE_ADDRESS_SANITIZER
11 #include <sanitizer/asan_interface.h>
12#else
13 #define ASAN_UNPOISON_MEMORY_REGION(start, size) ((void) 0)
14#endif
15
16#include "src/counters.h"
17#include "src/isolate.h"
18#include "src/utils.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000019
20namespace v8 {
21namespace internal {
22
23
Ben Murdochb8a8cc12014-11-26 15:28:44 +000024static const int kASanRedzoneBytes = 24; // Must be a multiple of 8.
Steve Blocka7e24c12009-10-30 11:49:00 +000025
26
27bool Zone::excess_allocation() {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000028 return segment_bytes_allocated_ > kExcessLimit;
Steve Blocka7e24c12009-10-30 11:49:00 +000029}
30
31
32void Zone::adjust_segment_bytes_allocated(int delta) {
33 segment_bytes_allocated_ += delta;
Steve Blocka7e24c12009-10-30 11:49:00 +000034}
35
36
Steve Block6ded16b2010-05-10 14:33:55 +010037template <typename Config>
38ZoneSplayTree<Config>::~ZoneSplayTree() {
39 // Reset the root to avoid unneeded iteration over all tree nodes
40 // in the destructor. For a zone-allocated tree, nodes will be
41 // freed by the Zone.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000042 SplayTree<Config, ZoneAllocationPolicy>::ResetRoot();
Steve Blocka7e24c12009-10-30 11:49:00 +000043}
44
45
Ben Murdoch8b112d22011-06-08 16:22:53 +010046void* ZoneObject::operator new(size_t size, Zone* zone) {
47 return zone->New(static_cast<int>(size));
48}
49
Ben Murdochb8a8cc12014-11-26 15:28:44 +000050inline void* ZoneAllocationPolicy::New(size_t size) {
51 DCHECK(zone_);
52 return zone_->New(static_cast<int>(size));
Ben Murdoch257744e2011-11-30 15:57:28 +000053}
54
55
56template <typename T>
57void* ZoneList<T>::operator new(size_t size, Zone* zone) {
58 return zone->New(static_cast<int>(size));
59}
60
61
Ben Murdochb8a8cc12014-11-26 15:28:44 +000062template <typename T>
63void* ZoneSplayTree<T>::operator new(size_t size, Zone* zone) {
64 return zone->New(static_cast<int>(size));
Steve Block44f0eee2011-05-26 01:26:41 +010065}
66
67
Steve Blocka7e24c12009-10-30 11:49:00 +000068} } // namespace v8::internal
69
70#endif // V8_ZONE_INL_H_