summaryrefslogtreecommitdiff
path: root/deps/v8/src/zone/accounting-allocator.h
blob: 31016a5018326d8c89e7cf1fd779ce111da5b2bb (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
// Copyright 2016 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_ACCOUNTING_ALLOCATOR_H_
#define V8_ZONE_ACCOUNTING_ALLOCATOR_H_

#include "include/v8-platform.h"
#include "src/base/atomic-utils.h"
#include "src/base/atomicops.h"
#include "src/base/macros.h"
#include "src/base/platform/mutex.h"
#include "src/base/platform/semaphore.h"
#include "src/base/platform/time.h"
#include "src/zone/zone-segment.h"

namespace v8 {
namespace internal {

class V8_EXPORT_PRIVATE AccountingAllocator {
 public:
  AccountingAllocator() = default;
  virtual ~AccountingAllocator() = default;

  virtual Segment* AllocateSegment(size_t bytes);
  virtual void FreeSegment(Segment* memory);

  size_t GetCurrentMemoryUsage() const;
  size_t GetMaxMemoryUsage() const;

 private:
  base::AtomicWord current_memory_usage_ = 0;
  base::AtomicWord max_memory_usage_ = 0;

  DISALLOW_COPY_AND_ASSIGN(AccountingAllocator);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_ZONE_ACCOUNTING_ALLOCATOR_H_