Debian Codegraph @

vendor/Heap-Layers/heaps/threads/phothreadheap.h

raw symbols SCIP
1 /* -*- C++ -*- */cxx . . $ `<file>/vendor/Heap-Layers/heaps/threads/phothreadheap.h`/
2
3 #ifndef HL_PHOTHREADHEAP_H
4 #define HL_PHOTHREADHEAP_Hcxx . . $ `vendor/Heap-Layers/heaps/threads/phothreadheap.h:4:9`!
5
6 #include <assert.h>
7
8 #include "threads/cpuinfo.h"cxx . . $ `<file>/vendor/Heap-Layers/threads/cpuinfo.h`/
9
10 #if defined(__clang__cxx . . $ `<built-in>:3:9`!)
11 #pragma clang diagnostic push
12 #pragma clang diagnostic ignored "-Wunused-variable"
13 #endif
14
15 using namespace HL;
16
17 template <int NumHeaps, class SuperHeap>
18 class MarkThreadHeapcxx . . $ MarkThreadHeap# : public SuperHeap {
19 public:
20
21 inline void * malloccxx . . $ MarkThreadHeap#malloc(bfcfa4d6b7f7ef64). (size_t sz) {
22 int tid = CPUInfocxx . . $ HL/CPUInfo#::getThreadIdcxx . . $ HL/CPUInfo#getThreadId(db52760e79bf9054).() % NumHeaps;
23 void * ptr = SuperHeap::malloc (sz);
24 if (ptr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
25 SuperHeap::setHeap(ptr, tid);
26 SuperHeap::setPrevHeap(SuperHeap::getNext(ptr), tid);
27 }
28 return ptr;
29 }
30 };
31
32
33 template <int NumHeaps, class SuperHeap>
34 class CheckThreadHeapcxx . . $ CheckThreadHeap# : public SuperHeap {
35 public:
36
37 inline void * malloccxx . . $ CheckThreadHeap#malloc(bfcfa4d6b7f7ef64). (size_t sz) {
38 void * ptr = SuperHeap::malloc (sz);
39 #ifndef NDEBUGcxx . . $ `<built-in>:458:9`!
40 if (ptr != NULL) {
41 int tid = CPUInfo::getThreadId() % NumHeaps;
42 assert (SuperHeap::getHeap(ptr) == tid);
43 }
44 #endif
45 return ptr;
46 }
47
48 inline void freecxx . . $ CheckThreadHeap#free(5d22bdacc48458e8). (void * ptr) {
49 SuperHeap::free (ptr);
50 }
51 };
52
53
54
55 /*
56
57 A PHOThreadHeap comprises NumHeaps "per-thread" heaps.
58
59 To pick a per-thread heap, the current thread id is hashed (mod NumHeaps).
60
61 malloc gets memory from its hashed per-thread heap.
62 free returns memory to its originating heap.
63
64 NB: We assume that the thread heaps are 'locked' as needed. */
65
66
67 template <int NumHeaps, class SuperHeap>
68 class PHOThreadHeapcxx . . $ PHOThreadHeap# { // : public MarkThreadHeap<NumHeaps, SuperHeap> {
69 public:
70
71 inline void * malloccxx . . $ PHOThreadHeap#malloc(bfcfa4d6b7f7ef64). (size_t sz) {
72 int tid = CPUInfocxx . . $ HL/CPUInfo#::getThreadIdcxx . . $ HL/CPUInfo#getThreadId(db52760e79bf9054).() % NumHeaps;
73 void * ptr = selectHeapcxx . . $ PHOThreadHeap#selectHeap(93b282d6b89a94d6).(tid)->malloc (sz);
74 return ptr;
75 }
76
77 inline void freecxx . . $ PHOThreadHeap#free(5d22bdacc48458e8). (void * ptr) {
78 int tid = SuperHeap::getHeap(ptr);
79 selectHeapcxx . . $ PHOThreadHeap#selectHeap(93b282d6b89a94d6).(tid)->free (ptr);
80 }
81
82
83 inline int removecxx . . $ PHOThreadHeap#remove(dedf1e9b1c614a07). (void * ptr);
84 #if 0
85 {
86 int tid = SuperHeap::getHeap(ptr);
87 selectHeap(tid)->remove (ptr);
88 }
89 #endif
90
91 private:
92
93 // Access the given heap within the buffer.
94 MarkThreadHeapcxx . . $ MarkThreadHeap#<NumHeaps, SuperHeap> * selectHeapcxx . . $ PHOThreadHeap#selectHeap(93b282d6b89a94d6). (int index) {
95 assertcxx . . $ `/usr/include/assert.h:50:10`! (index >= 0);
96 assertcxx . . $ `/usr/include/assert.h:50:10`! (index < NumHeaps);
97 return &cxx . . $ std/`operator&`(3fbb01592cd53f2a).ptHeapscxx . . $ PHOThreadHeap#ptHeaps.[index];
98 }
99
100 MarkThreadHeapcxx . . $ MarkThreadHeap#<NumHeaps, SuperHeap> ptHeapscxx . . $ PHOThreadHeap#ptHeaps.[NumHeaps];
101
102 };
103
104 #if defined(__clang__cxx . . $ `<built-in>:3:9`!)
105 #pragma clang diagnostic pop
106 #endif
107
108 #endif