V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
lsan-page-allocator.h
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_BASE_LSAN_PAGE_ALLOCATOR_H_
6 #define V8_BASE_LSAN_PAGE_ALLOCATOR_H_
7 
8 #include "include/v8-platform.h"
9 #include "src/base/base-export.h"
10 #include "src/base/compiler-specific.h"
11 
12 namespace v8 {
13 namespace base {
14 
15 // This is a v8::PageAllocator implementation that decorates provided page
16 // allocator object with leak sanitizer notifications when LEAK_SANITIZER
17 // is defined.
18 class V8_BASE_EXPORT LsanPageAllocator
19  : public NON_EXPORTED_BASE(::v8::PageAllocator) {
20  public:
21  LsanPageAllocator(v8::PageAllocator* page_allocator);
22  ~LsanPageAllocator() override = default;
23 
24  size_t AllocatePageSize() override { return allocate_page_size_; }
25 
26  size_t CommitPageSize() override { return commit_page_size_; }
27 
28  void SetRandomMmapSeed(int64_t seed) override {
29  return page_allocator_->SetRandomMmapSeed(seed);
30  }
31 
32  void* GetRandomMmapAddr() override {
33  return page_allocator_->GetRandomMmapAddr();
34  }
35 
36  void* AllocatePages(void* address, size_t size, size_t alignment,
37  PageAllocator::Permission access) override;
38 
39  bool FreePages(void* address, size_t size) override;
40 
41  bool ReleasePages(void* address, size_t size, size_t new_size) override;
42 
43  bool SetPermissions(void* address, size_t size,
44  PageAllocator::Permission access) override {
45  return page_allocator_->SetPermissions(address, size, access);
46  }
47 
48  private:
49  v8::PageAllocator* const page_allocator_;
50  const size_t allocate_page_size_;
51  const size_t commit_page_size_;
52 };
53 
54 } // namespace base
55 } // namespace v8
56 #endif // V8_BASE_LSAN_PAGE_ALLOCATOR_H_
Definition: libplatform.h:13