[M120 Migration] Set IO|GPU thread type with higher priorites
[platform/framework/web/chromium-efl.git] / gin / v8_platform_thread_isolated_allocator.h
1 // Copyright 2023 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_THREAD_ISOLATED_ALLOCATOR_H_
6 #define GIN_V8_PLATFORM_THREAD_ISOLATED_ALLOCATOR_H_
7
8 #include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
9
10 #if BUILDFLAG(ENABLE_THREAD_ISOLATION)
11
12 #if !BUILDFLAG(ENABLE_PKEYS)
13 #error Not implemented for non-pkey thread isolation
14 #endif  // BUILDFLAG(ENABLE_PKEYS)
15
16 #include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc.h"
17 #include "gin/gin_export.h"
18 #include "v8/include/v8-platform.h"
19
20 namespace gin {
21
22 // This is a wrapper around PartitionAlloc's ThreadIsolated pool that we pass to
23 // v8.
24 class GIN_EXPORT ThreadIsolatedAllocator final
25     : public v8::ThreadIsolatedAllocator {
26  public:
27   ThreadIsolatedAllocator();
28   ~ThreadIsolatedAllocator() override;
29
30   void Initialize(int pkey);
31
32   void* Allocate(size_t size) override;
33   void Free(void* object) override;
34   enum Type Type() const override;
35
36   int Pkey() const override;
37
38  private:
39   partition_alloc::PartitionAllocator allocator_;
40   int pkey_ = -1;
41 };
42
43 }  // namespace gin
44
45 #endif  // BUILDFLAG(ENABLE_THREAD_ISOLATION)
46
47 #endif  // GIN_V8_PLATFORM_THREAD_ISOLATED_ALLOCATOR_H_