Line data Source code
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 0 : size_t AllocatePageSize() override { return allocate_page_size_; }
25 :
26 0 : size_t CommitPageSize() override { return commit_page_size_; }
27 :
28 0 : void SetRandomMmapSeed(int64_t seed) override {
29 0 : return page_allocator_->SetRandomMmapSeed(seed);
30 : }
31 :
32 0 : void* GetRandomMmapAddr() override {
33 0 : 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 0 : bool SetPermissions(void* address, size_t size,
44 : PageAllocator::Permission access) override {
45 0 : 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_
|