LCOV - code coverage report
Current view: top level - src/base - page-allocator.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 21 21 100.0 %
Date: 2019-04-17 Functions: 8 8 100.0 %

          Line data    Source code
       1             : // Copyright 2017 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/page-allocator.h"
       6             : 
       7             : #include "src/base/platform/platform.h"
       8             : 
       9             : namespace v8 {
      10             : namespace base {
      11             : 
      12             : #define STATIC_ASSERT_ENUM(a, b)                            \
      13             :   static_assert(static_cast<int>(a) == static_cast<int>(b), \
      14             :                 "mismatching enum: " #a)
      15             : 
      16             : STATIC_ASSERT_ENUM(PageAllocator::kNoAccess,
      17             :                    base::OS::MemoryPermission::kNoAccess);
      18             : STATIC_ASSERT_ENUM(PageAllocator::kReadWrite,
      19             :                    base::OS::MemoryPermission::kReadWrite);
      20             : STATIC_ASSERT_ENUM(PageAllocator::kReadWriteExecute,
      21             :                    base::OS::MemoryPermission::kReadWriteExecute);
      22             : STATIC_ASSERT_ENUM(PageAllocator::kReadExecute,
      23             :                    base::OS::MemoryPermission::kReadExecute);
      24             : 
      25             : #undef STATIC_ASSERT_ENUM
      26             : 
      27       61029 : PageAllocator::PageAllocator()
      28       61029 :     : allocate_page_size_(base::OS::AllocatePageSize()),
      29      122058 :       commit_page_size_(base::OS::CommitPageSize()) {}
      30             : 
      31       59504 : void PageAllocator::SetRandomMmapSeed(int64_t seed) {
      32       59504 :   base::OS::SetRandomMmapSeed(seed);
      33       59504 : }
      34             : 
      35     2349966 : void* PageAllocator::GetRandomMmapAddr() {
      36     2349966 :   return base::OS::GetRandomMmapAddr();
      37             : }
      38             : 
      39     2332926 : void* PageAllocator::AllocatePages(void* address, size_t size, size_t alignment,
      40             :                                    PageAllocator::Permission access) {
      41     2332926 :   return base::OS::Allocate(address, size, alignment,
      42     2332926 :                             static_cast<base::OS::MemoryPermission>(access));
      43             : }
      44             : 
      45     2332614 : bool PageAllocator::FreePages(void* address, size_t size) {
      46     2332614 :   return base::OS::Free(address, size);
      47             : }
      48             : 
      49      124709 : bool PageAllocator::ReleasePages(void* address, size_t size, size_t new_size) {
      50             :   DCHECK_LT(new_size, size);
      51      124709 :   return base::OS::Release(reinterpret_cast<uint8_t*>(address) + new_size,
      52      124709 :                            size - new_size);
      53             : }
      54             : 
      55     9698000 : bool PageAllocator::SetPermissions(void* address, size_t size,
      56             :                                    PageAllocator::Permission access) {
      57     9698000 :   return base::OS::SetPermissions(
      58     9698000 :       address, size, static_cast<base::OS::MemoryPermission>(access));
      59             : }
      60             : 
      61       27678 : bool PageAllocator::DiscardSystemPages(void* address, size_t size) {
      62       27678 :   return base::OS::DiscardSystemPages(address, size);
      63             : }
      64             : 
      65             : }  // namespace base
      66             : }  // namespace v8

Generated by: LCOV version 1.10