V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
lsan-page-allocator.cc
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 #include "src/base/lsan-page-allocator.h"
6 
7 #include "src/base/logging.h"
8 
9 #if defined(LEAK_SANITIZER)
10 #include <sanitizer/lsan_interface.h>
11 #endif
12 
13 namespace v8 {
14 namespace base {
15 
16 LsanPageAllocator::LsanPageAllocator(v8::PageAllocator* page_allocator)
17  : page_allocator_(page_allocator),
18  allocate_page_size_(page_allocator_->AllocatePageSize()),
19  commit_page_size_(page_allocator_->CommitPageSize()) {
20  DCHECK_NOT_NULL(page_allocator);
21 }
22 
23 void* LsanPageAllocator::AllocatePages(void* address, size_t size,
24  size_t alignment,
26  void* result =
27  page_allocator_->AllocatePages(address, size, alignment, access);
28 #if defined(LEAK_SANITIZER)
29  if (result != nullptr) {
30  __lsan_register_root_region(result, size);
31  }
32 #endif
33  return result;
34 }
35 
36 bool LsanPageAllocator::FreePages(void* address, size_t size) {
37  bool result = page_allocator_->FreePages(address, size);
38 #if defined(LEAK_SANITIZER)
39  if (result) {
40  __lsan_unregister_root_region(address, size);
41  }
42 #endif
43  return result;
44 }
45 
46 bool LsanPageAllocator::ReleasePages(void* address, size_t size,
47  size_t new_size) {
48  bool result = page_allocator_->ReleasePages(address, size, new_size);
49 #if defined(LEAK_SANITIZER)
50  if (result) {
51  __lsan_unregister_root_region(address, size);
52  __lsan_register_root_region(address, new_size);
53  }
54 #endif
55  return result;
56 }
57 
58 } // namespace base
59 } // namespace v8
virtual bool FreePages(void *address, size_t length)=0
Definition: libplatform.h:13
virtual bool ReleasePages(void *address, size_t length, size_t new_length)=0
virtual void * AllocatePages(void *address, size_t length, size_t alignment, Permission permissions)=0