../3rdparty/pcre/sljit/sljitExecAllocator.c

Switch to Source codePreprocessed file
LineSource CodeCoverage
1static __inline void* alloc_chunk(sljit_uw size) -
2{ -
3 void* retval = mmap(0, size, 0x1 | 0x2 | 0x4, 0x02 | 0x20, -1, 0); -
4 return (retval != ((void *) -1)) ? retval : ((void *)0);
executed: return (retval != ((void *) -1)) ? retval : ((void *)0);
Execution Count:2
2
5} -
6 -
7static __inline void free_chunk(void* chunk, sljit_uw size) -
8{ -
9 munmap(chunk, size); -
10}
never executed: }
0
11struct block_header { -
12 sljit_uw size; -
13 sljit_uw prev_size; -
14}; -
15 -
16struct free_block { -
17 struct block_header header; -
18 struct free_block *next; -
19 struct free_block *prev; -
20 sljit_uw size; -
21}; -
22static struct free_block* free_blocks; -
23static sljit_uw allocated_size; -
24static sljit_uw total_size; -
25 -
26static __inline void sljit_insert_free_block(struct free_block *free_block, sljit_uw size) -
27{ -
28 free_block->header.size = 0; -
29 free_block->size = size; -
30 -
31 free_block->next = free_blocks; -
32 free_block->prev = 0; -
33 if (free_blocks)
evaluated: free_blocks
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:2
2-7
34 free_blocks->prev = free_block;
executed: free_blocks->prev = free_block;
Execution Count:7
7
35 free_blocks = free_block; -
36}
executed: }
Execution Count:9
9
37 -
38static __inline void sljit_remove_free_block(struct free_block *free_block) -
39{ -
40 if (free_block->next)
evaluated: free_block->next
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2
2-5
41 free_block->next->prev = free_block->prev;
executed: free_block->next->prev = free_block->prev;
Execution Count:5
5
42 -
43 if (free_block->prev)
evaluated: free_block->prev
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
44 free_block->prev->next = free_block->next;
executed: free_block->prev->next = free_block->next;
Execution Count:6
6
45 else { -
46 do { } while (0);
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
executed: }
Execution Count:1
0-1
47 free_blocks = free_block->next; -
48 }
executed: }
Execution Count:1
1
49} -
50 -
51static __attribute__((unused)) void* sljit_malloc_exec(sljit_uw size) -
52{ -
53 struct block_header *header; -
54 struct block_header *next_header; -
55 struct free_block *free_block; -
56 sljit_uw chunk_size; -
57 -
58 allocator_grab_lock(); -
59 if (size < sizeof(struct free_block))
partially evaluated: size < sizeof(struct free_block)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
60 size = sizeof(struct free_block);
never executed: size = sizeof(struct free_block);
0
61 size = (((size) + sizeof(struct block_header) + 7) & ~7); -
62 -
63 free_block = free_blocks; -
64 while (free_block) {
evaluated: free_block
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-13
65 if (free_block->size >= size) {
partially evaluated: free_block->size >= size
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
66 chunk_size = free_block->size; -
67 if (chunk_size > size + 64) {
partially evaluated: chunk_size > size + 64
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
68 -
69 chunk_size -= size; -
70 free_block->size = chunk_size; -
71 header = ((struct block_header*)(((sljit_ub*)free_block) + chunk_size)); -
72 header->prev_size = chunk_size; -
73 ((struct block_header*)(((sljit_ub*)header) + size))->prev_size = size; -
74 }
executed: }
Execution Count:13
13
75 else { -
76 sljit_remove_free_block(free_block); -
77 header = (struct block_header*)free_block; -
78 size = chunk_size; -
79 }
never executed: }
0
80 allocated_size += size; -
81 header->size = size; -
82 allocator_release_lock(); -
83 return ((void*)(((sljit_ub*)header) + sizeof(struct block_header)));
executed: return ((void*)(((sljit_ub*)header) + sizeof(struct block_header)));
Execution Count:13
13
84 } -
85 free_block = free_block->next; -
86 }
never executed: }
0
87 -
88 chunk_size = (size + sizeof(struct block_header) + 0x10000 - 1) & (~(0x10000 - 1)); -
89 header = (struct block_header*)alloc_chunk(chunk_size); -
90 do { if (__builtin_expect((!header), 0)) return ((void *)0); } while (0);
never executed: return ((void *)0);
executed: }
Execution Count:2
partially evaluated: __builtin_expect((!header), 0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
91 -
92 chunk_size -= sizeof(struct block_header); -
93 total_size += chunk_size; -
94 -
95 header->prev_size = 0; -
96 if (chunk_size > size + 64) {
partially evaluated: chunk_size > size + 64
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
97 -
98 allocated_size += size; -
99 header->size = size; -
100 chunk_size -= size; -
101 -
102 free_block = ((struct free_block*)(((sljit_ub*)header) + size)); -
103 free_block->header.prev_size = size; -
104 sljit_insert_free_block(free_block, chunk_size); -
105 next_header = ((struct block_header*)(((sljit_ub*)free_block) + chunk_size)); -
106 }
executed: }
Execution Count:2
2
107 else { -
108 -
109 allocated_size += chunk_size; -
110 header->size = chunk_size; -
111 next_header = ((struct block_header*)(((sljit_ub*)header) + chunk_size)); -
112 }
never executed: }
0
113 next_header->size = 1; -
114 next_header->prev_size = chunk_size; -
115 allocator_release_lock(); -
116 return ((void*)(((sljit_ub*)header) + sizeof(struct block_header)));
executed: return ((void*)(((sljit_ub*)header) + sizeof(struct block_header)));
Execution Count:2
2
117} -
118 -
119static __attribute__((unused)) void sljit_free_exec(void* ptr) -
120{ -
121 struct block_header *header; -
122 struct free_block* free_block; -
123 -
124 allocator_grab_lock(); -
125 header = ((struct block_header*)(((sljit_ub*)ptr) + -(sljit_w)sizeof(struct block_header))); -
126 allocated_size -= header->size; -
127 -
128 -
129 -
130 -
131 -
132 free_block = ((struct free_block*)(((sljit_ub*)header) + -(sljit_w)header->prev_size)); -
133 if (__builtin_expect((!free_block->header.size), 0)) {
evaluated: __builtin_expect((!free_block->header.size), 0)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:7
7-8
134 free_block->size += header->size; -
135 header = ((struct block_header*)(((sljit_ub*)free_block) + free_block->size)); -
136 header->prev_size = free_block->size; -
137 }
executed: }
Execution Count:8
8
138 else { -
139 free_block = (struct free_block*)header; -
140 sljit_insert_free_block(free_block, header->size); -
141 }
executed: }
Execution Count:7
7
142 -
143 header = ((struct block_header*)(((sljit_ub*)free_block) + free_block->size)); -
144 if (__builtin_expect((!header->size), 0)) {
evaluated: __builtin_expect((!header->size), 0)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:8
7-8
145 free_block->size += ((struct free_block*)header)->size; -
146 sljit_remove_free_block((struct free_block*)header); -
147 header = ((struct block_header*)(((sljit_ub*)free_block) + free_block->size)); -
148 header->prev_size = free_block->size; -
149 }
executed: }
Execution Count:7
7
150 -
151 -
152 if (__builtin_expect((!free_block->header.prev_size && header->size == 1), 0)) {
evaluated: __builtin_expect((!free_block->header.prev_size && header->size == 1), 0)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:6
6-9
153 -
154 if (total_size - free_block->size > (allocated_size * 3 / 2)) {
partially evaluated: total_size - free_block->size > (allocated_size * 3 / 2)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
155 total_size -= free_block->size; -
156 sljit_remove_free_block(free_block); -
157 free_chunk(free_block, free_block->size + sizeof(struct block_header)); -
158 }
never executed: }
0
159 }
executed: }
Execution Count:9
9
160 -
161 allocator_release_lock(); -
162}
executed: }
Execution Count:15
15
163 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial