[M120 Migration] Set IO|GPU thread type with higher priorites
[platform/framework/web/chromium-efl.git] / gin / v8_platform_page_allocator.h
1 // Copyright 2021 The Chromium Authors
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 GIN_V8_PLATFORM_PAGE_ALLOCATOR_H_
6 #define GIN_V8_PLATFORM_PAGE_ALLOCATOR_H_
7
8 #include "build/build_config.h"
9 #include "build/buildflag.h"
10
11 #include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
12
13 #if BUILDFLAG(USE_PARTITION_ALLOC)
14
15 #include "base/allocator/partition_allocator/src/partition_alloc/page_allocator.h"
16 #include "gin/gin_export.h"
17 #include "v8/include/v8-platform.h"
18
19 namespace gin {
20
21 // A v8::PageAllocator implementation to use with gin.
22 class GIN_EXPORT PageAllocator final : public v8::PageAllocator {
23  public:
24   ~PageAllocator() override;
25
26   size_t AllocatePageSize() override;
27
28   size_t CommitPageSize() override;
29
30   void SetRandomMmapSeed(int64_t seed) override;
31
32   void* GetRandomMmapAddr() override;
33
34   void* AllocatePages(void* address,
35                       size_t length,
36                       size_t alignment,
37                       v8::PageAllocator::Permission permissions) override;
38
39   bool FreePages(void* address, size_t length) override;
40
41   bool ReleasePages(void* address, size_t length, size_t new_length) override;
42
43   bool SetPermissions(void* address,
44                       size_t length,
45                       Permission permissions) override;
46
47   bool RecommitPages(void* address,
48                      size_t length,
49                      Permission permissions) override;
50
51   bool DiscardSystemPages(void* address, size_t size) override;
52
53   bool DecommitPages(void* address, size_t size) override;
54
55   // For testing purposes only: Map the v8 page permissions into a page
56   // configuration from base.
57   ::partition_alloc::PageAccessibilityConfiguration::Permissions
58   GetPageConfigPermissionsForTesting(v8::PageAllocator::Permission permission);
59 };
60 }  // namespace gin
61
62 #endif  // BUILDFLAG(USE_PARTITION_ALLOC)
63
64 #endif  // GIN_V8_PLATFORM_PAGE_ALLOCATOR_H_