Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp

raw symbols SCIP
1 // Copyright (c) 2005, 2007, Google Inc.cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/
2 // All rights reserved.
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 // ---
32 // Author: Sanjay Ghemawat <[email protected]>
33 //
34 // A malloc that uses a per-thread cache to satisfy small malloc requests.
35 // (The time for malloc/free of a small object drops from 300 ns to 50 ns.)
36 //
37 // See doc/tcmalloc.html for a high-level
38 // description of how this malloc works.
39 //
40 // SYNCHRONIZATION
41 // 1. The thread-specific lists are accessed without acquiring any locks.
42 // This is safe because each such list is only accessed by one thread.
43 // 2. We have a lock per central free-list, and hold it while manipulating
44 // the central free list for a particular size.
45 // 3. The central page allocator is protected by "pageheap_lock".
46 // 4. The pagemap (which maps from page-number to descriptor),
47 // can be read without holding any locks, and written while holding
48 // the "pageheap_lock".
49 // 5. To improve performance, a subset of the information one can get
50 // from the pagemap is cached in a data structure, pagemap_cache_,
51 // that atomically reads and writes its entries. This cache can be
52 // read and written without locking.
53 //
54 // This multi-threaded access to the pagemap is safe for fairly
55 // subtle reasons. We basically assume that when an object X is
56 // allocated by thread A and deallocated by thread B, there must
57 // have been appropriate synchronization in the handoff of object
58 // X from thread A to thread B. The same logic applies to pagemap_cache_.
59 //
60 // THE PAGEID-TO-SIZECLASS CACHE
61 // Hot PageID-to-sizeclass mappings are held by pagemap_cache_. If this cache
62 // returns 0 for a particular PageID then that means "no information," not that
63 // the sizeclass is 0. The cache may have stale information for pages that do
64 // not hold the beginning of any free()'able object. Staleness is eliminated
65 // in Populate() for pages with sizeclass > 0 objects, and in do_malloc() and
66 // do_memalign() for all other relevant pages.
67 //
68 // TODO: Bias reclamation to larger addresses
69 // TODO: implement mallinfo/mallopt
70 // TODO: Better testing
71 //
72 // 9/28/2003 (new page-level allocator replaces ptmalloc2):
73 // * malloc/free of small objects goes from ~300 ns to ~50 ns.
74 // * allocation of a reasonably complicated struct
75 // goes from about 1100 ns to about 300 ns.
76
77 #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/
78 #include "FastMalloc.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.h`/
79
80 #include "Assertions.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h`/
81 #include <limits>
82 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(JSC_MULTIPLE_THREADS)
83 #include <pthread.h>
84 #endif
85
86 #ifndef NO_TCMALLOC_SAMPLES
87 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
88 #define NO_TCMALLOC_SAMPLEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:88:9`!
89 #endif
90 #endif
91
92 #if !(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC) && defined(NDEBUGcxx . . $ `<built-in>:472:9`!)
93 #define FORCE_SYSTEM_MALLOCcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:93:9`! 0
94 #else
95 #define FORCE_SYSTEM_MALLOC 1
96 #endif
97
98 // Use a background thread to periodically scavenge memory to release back to the system
99 // https://bugs.webkit.org/show_bug.cgi?id=27900: don't turn this on for Tiger until we have figured out why it caused a crash.
100 #if defined(BUILDING_ON_TIGER)
101 #define USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY 0
102 #else
103 #define USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`! 1
104 #endif
105
106 #if defined(__HP_aCC)
107 // HP'a aCC compiler has broken for scoping
108 # define for if(0){}else for
109 #endif
110
111 #ifndef NDEBUGcxx . . $ `<built-in>:472:9`!
112 namespace WTF {
113
114 #if ENABLE(JSC_MULTIPLE_THREADS)
115 static pthread_key_t isForbiddenKey;
116 static pthread_once_t isForbiddenKeyOnce = PTHREAD_ONCE_INIT;
117 static void initializeIsForbiddenKey()
118 {
119 pthread_key_create(&isForbiddenKey, 0);
120 }
121
122 #if !ASSERT_DISABLED
123 static bool isForbidden()
124 {
125 pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey);
126 return !!pthread_getspecific(isForbiddenKey);
127 }
128 #endif
129
130 void fastMallocForbid()
131 {
132 pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey);
133 pthread_setspecific(isForbiddenKey, &isForbiddenKey);
134 }
135
136 void fastMallocAllow()
137 {
138 pthread_once(&isForbiddenKeyOnce, initializeIsForbiddenKey);
139 pthread_setspecific(isForbiddenKey, 0);
140 }
141
142 #else
143
144 static bool staticIsForbidden;
145 static bool isForbidden()
146 {
147 return staticIsForbidden;
148 }
149
150 void fastMallocForbid()
151 {
152 staticIsForbidden = true;
153 }
154
155 void fastMallocAllow()
156 {
157 staticIsForbidden = false;
158 }
159 #endif // ENABLE(JSC_MULTIPLE_THREADS)
160
161 } // namespace WTF
162 #endif // NDEBUG
163
164 #include <string.h>
165
166 namespace WTFcxx . . $ `<built-in>:467:9`! {
167
168 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
169
170 namespace Internal {
171
172 void fastMallocMatchFailed(void*)
173 {
174 CRASH();
175 }
176
177 } // namespace Internal
178
179 #endif
180
181 void* fastZeroedMalloccxx . . $ QTWTF/fastZeroedMalloc(bfcfa4d6b7f7ef64).(size_t n)
182 {
183 void* result = fastMalloccxx . . $ QTWTF/fastMalloc(bfcfa4d6b7f7ef64).(n);
184 memset(result, 0, n);
185 return result;
186 }
187
188 char* fastStrDupcxx . . $ QTWTF/fastStrDup(a8b8e32347182212).(const char* src)
189 {
190 int len = strlen(src) + 1;
191 char* dup = static_cast<char*>(fastMalloccxx . . $ QTWTF/fastMalloc(bfcfa4d6b7f7ef64).(len));
192
193 if (dup)
194 memcpy(dup, src, len);
195
196 return dup;
197 }
198
199 TryMallocReturnValuecxx . . $ QTWTF/TryMallocReturnValue# tryFastZeroedMalloccxx . . $ QTWTF/tryFastZeroedMalloc(a199d47e2bcba94).(size_t n)
200 {
201 void* result;
202 if (!tryFastMalloccxx . . $ QTWTF/tryFastMalloc(a199d47e2bcba94).(n).getValuecxx . . $ QTWTF/TryMallocReturnValue#getValue(e5bfd7b2d24a2428).(result))
203 returncxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(1f58393e1bf9b27e). 0cxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(5d22bdacc48458e8).;
204 memset(result, 0, n);
205 returncxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(1f58393e1bf9b27e). resultcxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(5d22bdacc48458e8).;
206 }
207
208 } // namespace WTF
209
210 #if FORCE_SYSTEM_MALLOCcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:93:9`!
211
212 namespace WTF {
213
214 TryMallocReturnValue tryFastMalloc(size_t n)
215 {
216 ASSERT(!isForbidden());
217
218 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
219 if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= n) // If overflow would occur...
220 return 0;
221
222 void* result = malloc(n + sizeof(AllocAlignmentInteger));
223 if (!result)
224 return 0;
225
226 *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
227 result = static_cast<AllocAlignmentInteger*>(result) + 1;
228
229 return result;
230 #else
231 return malloc(n);
232 #endif
233 }
234
235 void* fastMalloc(size_t n)
236 {
237 ASSERT(!isForbidden());
238
239 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
240 TryMallocReturnValue returnValue = tryFastMalloc(n);
241 void* result;
242 returnValue.getValue(result);
243 #else
244 void* result = malloc(n);
245 #endif
246
247 if (!result)
248 CRASH();
249 return result;
250 }
251
252 TryMallocReturnValue tryFastCalloc(size_t n_elements, size_t element_size)
253 {
254 ASSERT(!isForbidden());
255
256 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
257 size_t totalBytes = n_elements * element_size;
258 if (n_elements > 1 && element_size && (totalBytes / element_size) != n_elements || (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= totalBytes))
259 return 0;
260
261 totalBytes += sizeof(AllocAlignmentInteger);
262 void* result = malloc(totalBytes);
263 if (!result)
264 return 0;
265
266 memset(result, 0, totalBytes);
267 *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
268 result = static_cast<AllocAlignmentInteger*>(result) + 1;
269 return result;
270 #else
271 return calloc(n_elements, element_size);
272 #endif
273 }
274
275 void* fastCalloc(size_t n_elements, size_t element_size)
276 {
277 ASSERT(!isForbidden());
278
279 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
280 TryMallocReturnValue returnValue = tryFastCalloc(n_elements, element_size);
281 void* result;
282 returnValue.getValue(result);
283 #else
284 void* result = calloc(n_elements, element_size);
285 #endif
286
287 if (!result)
288 CRASH();
289 return result;
290 }
291
292 void fastFree(void* p)
293 {
294 ASSERT(!isForbidden());
295
296 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
297 if (!p)
298 return;
299
300 AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(p);
301 if (*header != Internal::AllocTypeMalloc)
302 Internal::fastMallocMatchFailed(p);
303 free(header);
304 #else
305 free(p);
306 #endif
307 }
308
309 TryMallocReturnValue tryFastRealloc(void* p, size_t n)
310 {
311 ASSERT(!isForbidden());
312
313 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
314 if (p) {
315 if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= n) // If overflow would occur...
316 return 0;
317 AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(p);
318 if (*header != Internal::AllocTypeMalloc)
319 Internal::fastMallocMatchFailed(p);
320 void* result = realloc(header, n + sizeof(AllocAlignmentInteger));
321 if (!result)
322 return 0;
323
324 // This should not be needed because the value is already there:
325 // *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
326 result = static_cast<AllocAlignmentInteger*>(result) + 1;
327 return result;
328 } else {
329 return fastMalloc(n);
330 }
331 #else
332 return realloc(p, n);
333 #endif
334 }
335
336 void* fastRealloc(void* p, size_t n)
337 {
338 ASSERT(!isForbidden());
339
340 #if ENABLE(FAST_MALLOC_MATCH_VALIDATION)
341 TryMallocReturnValue returnValue = tryFastRealloc(p, n);
342 void* result;
343 returnValue.getValue(result);
344 #else
345 void* result = realloc(p, n);
346 #endif
347
348 if (!result)
349 CRASH();
350 return result;
351 }
352
353 void releaseFastMallocFreeMemory() { }
354
355 FastMallocStatistics fastMallocStatistics()
356 {
357 FastMallocStatistics statistics = { 0, 0, 0, 0 };
358 return statistics;
359 }
360
361 } // namespace WTF
362
363 #if OS(DARWIN)
364 // This symbol is present in the JavaScriptCore exports file even when FastMalloc is disabled.
365 // It will never be used in this case, so it's type and value are less interesting than its presence.
366 extern "C" const int jscore_fastmalloc_introspection = 0;
367 #endif
368
369 #else // FORCE_SYSTEM_MALLOC
370
371 #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(STDINT_H)
372 #include <stdint.h>
373 #elif HAVE(INTTYPES_H)
374 #include <inttypes.h>
375 #else
376 #include <sys/types.h>
377 #endif
378
379 #include "AlwaysInline.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h`/
380 #include "Assertions.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h`/
381 #include "TCPackedCache.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCPackedCache.h`/
382 #include "TCPageMap.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCPageMap.h`/
383 #include "TCSpinLock.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSpinLock.h`/
384 #include "TCSystemAlloc.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSystemAlloc.h`/
385 #include <algorithm>
386 #include <errno.h>
387 #include <limits>
388 #include <new>
389 #include <pthread.h>
390 #include <stdarg.h>
391 #include <stddef.h>
392 #include <stdio.h>
393 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(UNIX)
394 #include <unistd.h>
395 #endif
396 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
397 #ifndef WIN32_LEAN_AND_MEAN
398 #define WIN32_LEAN_AND_MEAN
399 #endif
400 #include <windows.h>
401 #endif
402
403 #if WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
404
405 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
406 #include "MallocZoneSupport.h"
407 #include <wtf/HashSet.h>
408 #include <wtf/Vector.h>
409 #endif
410 #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(DISPATCH_H)
411 #include <dispatch/dispatch.h>
412 #endif
413
414
415 #ifndef PRIuS
416 #define PRIuScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:416:9`! "zu"
417 #endif
418
419 // Calling pthread_getspecific through a global function pointer is faster than a normal
420 // call to the function on Mac OS X, and it's used in performance-critical code. So we
421 // use a function pointer. But that's not necessarily faster on other platforms, and we had
422 // problems with this technique on Windows, so we'll do this only on Mac OS X.
423 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
424 static void* (*pthread_getspecific_function_pointer)(pthread_key_t) = pthread_getspecific;
425 #define pthread_getspecific(key) pthread_getspecific_function_pointer(key)
426 #endif
427
428 #define DEFINE_VARIABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:428:9`!(type, name, value, meaning) \
429 namespace FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead { \
430 type FLAGS_##name(value); \
431 char FLAGS_no##name; \
432 } \
433 using FLAG__namespace_do_not_use_directly_use_DECLARE_##type##_instead::FLAGS_##name
434
435 #define DEFINE_int64cxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:435:9`!(name, value, meaning) \
436 DEFINE_VARIABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:428:9`!(int64_t, name, value, meaning)
437
438 #define DEFINE_doublecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:438:9`!(name, value, meaning) \
439 DEFINE_VARIABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:428:9`!(double, name, value, meaning)
440
441 namespace WTFcxx . . $ `<built-in>:467:9`! {
442
443 #define malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`! fastMalloc
444 #define calloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:444:9`! fastCalloc
445 #define freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`! fastFree
446 #define realloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:446:9`! fastRealloc
447
448 #define MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`! LOG_ERRORcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:275:9`!
449 #define CHECK_CONDITIONcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:449:9`! ASSERT
450
451 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
452 class Span;
453 class TCMalloc_Central_FreeListPadded;
454 class TCMalloc_PageHeap;
455 class TCMalloc_ThreadCache;
456 template <typename T> class PageHeapAllocator;
457
458 class FastMallocZone {
459 public:
460 static void init();
461
462 static kern_return_t enumerate(task_t, void*, unsigned typeMmask, vm_address_t zoneAddress, memory_reader_t, vm_range_recorder_t);
463 static size_t goodSize(malloc_zone_t*, size_t size) { return size; }
464 static boolean_t check(malloc_zone_t*) { return true; }
465 static void print(malloc_zone_t*, boolean_t) { }
466 static void log(malloc_zone_t*, void*) { }
467 static void forceLock(malloc_zone_t*) { }
468 static void forceUnlock(malloc_zone_t*) { }
469 static void statistics(malloc_zone_t*, malloc_statistics_t* stats) { memset(stats, 0, sizeof(malloc_statistics_t)); }
470
471 private:
472 FastMallocZone(TCMalloc_PageHeap*, TCMalloc_ThreadCache**, TCMalloc_Central_FreeListPadded*, PageHeapAllocator<Span>*, PageHeapAllocator<TCMalloc_ThreadCache>*);
473 static size_t size(malloc_zone_t*, const void*);
474 static void* zoneMalloc(malloc_zone_t*, size_t);
475 static void* zoneCalloc(malloc_zone_t*, size_t numItems, size_t size);
476 static void zoneFree(malloc_zone_t*, void*);
477 static void* zoneRealloc(malloc_zone_t*, void*, size_t);
478 static void* zoneValloc(malloc_zone_t*, size_t) { LOG_ERROR("valloc is not supported"); return 0; }
479 static void zoneDestroy(malloc_zone_t*) { }
480
481 malloc_zone_t m_zone;
482 TCMalloc_PageHeap* m_pageHeap;
483 TCMalloc_ThreadCache** m_threadHeaps;
484 TCMalloc_Central_FreeListPadded* m_centralCaches;
485 PageHeapAllocator<Span>* m_spanAllocator;
486 PageHeapAllocator<TCMalloc_ThreadCache>* m_pageHeapAllocator;
487 };
488
489 #endif
490
491 #endif
492
493 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
494 // This #ifdef should almost never be set. Set NO_TCMALLOC_SAMPLES if
495 // you're porting to a system where you really can't get a stacktrace.
496 #ifdef NO_TCMALLOC_SAMPLES
497 // We use #define so code compiles even if you #include stacktrace.h somehow.
498 # define GetStackTrace(stack, depth, skip) (0)
499 #else
500 # include <google/stacktrace.h>
501 #endif
502 #endif
503
504 // Even if we have support for thread-local storage in the compiler
505 // and linker, the OS may not support it. We need to check that at
506 // runtime. Right now, we have to keep a manual set of "bad" OSes.
507 #if defined(HAVE_TLS)
508 static bool kernel_supports_tls = false; // be conservative
509 static inline bool KernelSupportsTLS() {
510 return kernel_supports_tls;
511 }
512 # if !HAVE_DECL_UNAME // if too old for uname, probably too old for TLS
513 static void CheckIfKernelSupportsTLS() {
514 kernel_supports_tls = false;
515 }
516 # else
517 # include <sys/utsname.h> // DECL_UNAME checked for <sys/utsname.h> too
518 static void CheckIfKernelSupportsTLS() {
519 struct utsname buf;
520 if (uname(&buf) != 0) { // should be impossible
521 MESSAGE("uname failed assuming no TLS support (errno=%d)\n", errno);
522 kernel_supports_tls = false;
523 } else if (strcasecmp(buf.sysname, "linux") == 0) {
524 // The linux case: the first kernel to support TLS was 2.6.0
525 if (buf.release[0] < '2' && buf.release[1] == '.') // 0.x or 1.x
526 kernel_supports_tls = false;
527 else if (buf.release[0] == '2' && buf.release[1] == '.' &&
528 buf.release[2] >= '0' && buf.release[2] < '6' &&
529 buf.release[3] == '.') // 2.0 - 2.5
530 kernel_supports_tls = false;
531 else
532 kernel_supports_tls = true;
533 } else { // some other kernel, we'll be optimisitic
534 kernel_supports_tls = true;
535 }
536 // TODO(csilvers): VLOG(1) the tls status once we support RAW_VLOG
537 }
538 # endif // HAVE_DECL_UNAME
539 #endif // HAVE_TLS
540
541 // __THROW is defined in glibc systems. It means, counter-intuitively,
542 // "This function will never throw an exception." It's an optional
543 // optimization tool, but we may need to use it to match glibc prototypes.
544 #ifndef __THROWcxx . . $ `<external>/15143979452489151151/cdefs.h:86:13`! // I guess we're not on a glibc system
545 # define __THROW // __THROW is just an optimization, so ok to make it ""
546 #endif
547
548 //-------------------------------------------------------------------
549 // Configuration
550 //-------------------------------------------------------------------
551
552 // Not all possible combinations of the following parameters make
553 // sense. In particular, if kMaxSize increases, you may have to
554 // increase kNumClasses as well.
555 static const size_t kPageShiftcxx . . $ QTWTF/kPageShift. = 12;
556 static const size_t kPageSizecxx . . $ QTWTF/kPageSize. = 1 << kPageShiftcxx . . $ QTWTF/kPageShift.;
557 static const size_t kMaxSizecxx . . $ QTWTF/kMaxSize. = 8u * kPageSizecxx . . $ QTWTF/kPageSize.;
558 static const size_t kAlignShiftcxx . . $ QTWTF/kAlignShift. = 3;
559 static const size_t kAlignmentcxx . . $ QTWTF/kAlignment. = 1 << kAlignShiftcxx . . $ QTWTF/kAlignShift.;
560 static const size_t kNumClassescxx . . $ QTWTF/kNumClasses. = 68;
561
562 // Allocates a big block of memory for the pagemap once we reach more than
563 // 128MB
564 static const size_t kPageMapBigAllocationThresholdcxx . . $ QTWTF/kPageMapBigAllocationThreshold. = 128 << 20;
565
566 // Minimum number of pages to fetch from system at a time. Must be
567 // significantly bigger than kPageSize to amortize system-call
568 // overhead, and also to reduce external fragementation. Also, we
569 // should keep this value big because various incarnations of Linux
570 // have small limits on the number of mmap() regions per
571 // address-space.
572 static const size_t kMinSystemAlloccxx . . $ QTWTF/kMinSystemAlloc. = 1 << (20 - kPageShiftcxx . . $ QTWTF/kPageShift.);
573
574 // Number of objects to move between a per-thread list and a central
575 // list in one shot. We want this to be not too small so we can
576 // amortize the lock overhead for accessing the central list. Making
577 // it too big may temporarily cause unnecessary memory wastage in the
578 // per-thread free list until the scavenger cleans up the list.
579 static int num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[kNumClassescxx . . $ QTWTF/kNumClasses.];
580
581 // Maximum length we allow a per-thread free-list to have before we
582 // move objects from it into the corresponding central free-list. We
583 // want this big to avoid locking the central free-list too often. It
584 // should not hurt to make this list somewhat big because the
585 // scavenging code will shrink it down when its contents are not in use.
586 static const int kMaxFreeListLengthcxx . . $ QTWTF/kMaxFreeListLength. = 256;
587
588 // Lower and upper bounds on the per-thread cache sizes
589 static const size_t kMinThreadCacheSizecxx . . $ QTWTF/kMinThreadCacheSize. = kMaxSizecxx . . $ QTWTF/kMaxSize. * 2;
590 static const size_t kMaxThreadCacheSizecxx . . $ QTWTF/kMaxThreadCacheSize. = 2 << 20;
591
592 // Default bound on the total amount of thread caches
593 static const size_t kDefaultOverallThreadCacheSizecxx . . $ QTWTF/kDefaultOverallThreadCacheSize. = 16 << 20;
594
595 // For all span-lengths < kMaxPages we keep an exact-size list.
596 // REQUIRED: kMaxPages >= kMinSystemAlloc;
597 static const size_t kMaxPagescxx . . $ QTWTF/kMaxPages. = kMinSystemAlloccxx . . $ QTWTF/kMinSystemAlloc.;
598
599 /* The smallest prime > 2^n */
600 static int primes_listcxx . . $ QTWTF/primes_list.[] = {
601 // Small values might cause high rates of sampling
602 // and hence commented out.
603 // 2, 5, 11, 17, 37, 67, 131, 257,
604 // 521, 1031, 2053, 4099, 8209, 16411,
605 32771, 65537, 131101, 262147, 524309, 1048583,
606 2097169, 4194319, 8388617, 16777259, 33554467 };
607
608 // Twice the approximate gap between sampling actions.
609 // I.e., we take one sample approximately once every
610 // tcmalloc_sample_parameter/2
611 // bytes of allocation, i.e., ~ once every 128KB.
612 // Must be a prime number.
613 #ifdef NO_TCMALLOC_SAMPLEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:88:9`!
614 DEFINE_int64cxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:435:9`!(tcmalloc_sample_parameter, 0,
615 "Unused: code is compiled with NO_TCMALLOC_SAMPLES");
616 static size_t sample_periodcxx . . $ QTWTF/sample_period. = 0;
617 #else
618 DEFINE_int64(tcmalloc_sample_parameter, 262147,
619 "Twice the approximate gap between sampling actions."
620 " Must be a prime number. Otherwise will be rounded up to a "
621 " larger prime number");
622 static size_t sample_period = 262147;
623 #endif
624
625 // Protects sample_period above
626 static SpinLockcxx . . $ SpinLock# sample_period_lockcxx . . $ QTWTF/sample_period_lock. = SPINLOCK_INITIALIZERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSpinLock.h:134:9`!;
627
628 // Parameters for controlling how fast memory is returned to the OS.
629
630 DEFINE_doublecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:438:9`!(tcmalloc_release_rate, 1,
631 "Rate at which we release unused memory to the system. "
632 "Zero means we never release memory back to the system. "
633 "Increase this flag to return memory faster; decrease it "
634 "to return memory slower. Reasonable rates are in the "
635 "range [0,10]");
636
637 //-------------------------------------------------------------------
638 // Mapping from size to size_class and vice versa
639 //-------------------------------------------------------------------
640
641 // Sizes <= 1024 have an alignment >= 8. So for such sizes we have an
642 // array indexed by ceil(size/8). Sizes > 1024 have an alignment >= 128.
643 // So for these larger sizes we have an array indexed by ceil(size/128).
644 //
645 // We flatten both logical arrays into one physical array and use
646 // arithmetic to compute an appropriate index. The constants used by
647 // ClassIndex() were selected to make the flattening work.
648 //
649 // Examples:
650 // Size Expression Index
651 // -------------------------------------------------------
652 // 0 (0 + 7) / 8 0
653 // 1 (1 + 7) / 8 1
654 // ...
655 // 1024 (1024 + 7) / 8 128
656 // 1025 (1025 + 127 + (120<<7)) / 128 129
657 // ...
658 // 32768 (32768 + 127 + (120<<7)) / 128 376
659 static const size_t kMaxSmallSizecxx . . $ QTWTF/kMaxSmallSize. = 1024;
660 static const int shift_amountcxx . . $ QTWTF/shift_amount.[2] = { 3, 7 }; // For divides by 8 or 128
661 static const int add_amountcxx . . $ QTWTF/add_amount.[2] = { 7, 127 + (120 << 7) };
662 static unsigned char class_arraycxx . . $ QTWTF/class_array.[377];
663
664 // Compute index of the class_array[] entry for a given size
665 static inline int ClassIndexcxx . . $ QTWTF/ClassIndex(15f694ef3c96d230).(size_t s) {
666 const int i = (s > kMaxSmallSizecxx . . $ QTWTF/kMaxSmallSize.);
667 return static_cast<int>((s + add_amountcxx . . $ QTWTF/add_amount.[i]) >> shift_amountcxx . . $ QTWTF/shift_amount.[i]);
668 }
669
670 // Mapping from size class to max size storable in that class
671 static size_t class_to_sizecxx . . $ QTWTF/class_to_size.[kNumClassescxx . . $ QTWTF/kNumClasses.];
672
673 // Mapping from size class to number of pages to allocate at a time
674 static size_t class_to_pagescxx . . $ QTWTF/class_to_pages.[kNumClassescxx . . $ QTWTF/kNumClasses.];
675
676 // TransferCache is used to cache transfers of num_objects_to_move[size_class]
677 // back and forth between thread caches and the central cache for a given size
678 // class.
679 struct TCEntrycxx . . $ QTWTF/TCEntry# {
680 void *headcxx . . $ QTWTF/TCEntry#head.; // Head of chain of objects.
681 void *tailcxx . . $ QTWTF/TCEntry#tail.; // Tail of chain of objects.
682 };
683 // A central cache freelist can have anywhere from 0 to kNumTransferEntries
684 // slots to put link list chains into. To keep memory usage bounded the total
685 // number of TCEntries across size classes is fixed. Currently each size
686 // class is initially given one TCEntry which also means that the maximum any
687 // one class can have is kNumClasses.
688 static const int kNumTransferEntriescxx . . $ QTWTF/kNumTransferEntries. = kNumClassescxx . . $ QTWTF/kNumClasses.;
689
690 // Note: the following only works for "n"s that fit in 32-bits, but
691 // that is fine since we only use it for small sizes.
692 static inline int LgFloorcxx . . $ QTWTF/LgFloor(15f694ef3c96d230).(size_t n) {
693 int log = 0;
694 for (int i = 4; i >= 0; --i) {
695 int shift = (1 << i);
696 size_t x = n >> shift;
697 if (x != 0) {
698 n = x;
699 log += shift;
700 }
701 }
702 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(n == 1);
703 return log;
704 }
705
706 // Some very basic linked list functions for dealing with using void * as
707 // storage.
708
709 static inline void *SLL_Nextcxx . . $ QTWTF/SLL_Next(9f162e79bfc6c74).(void *t) {
710 return *(reinterpret_cast<void**>(t));
711 }
712
713 static inline void SLL_SetNextcxx . . $ QTWTF/SLL_SetNext(6c58c5e2437d25a2).(void *t, void *n) {
714 *(reinterpret_cast<void**>(t)) = n;
715 }
716
717 static inline void SLL_Pushcxx . . $ QTWTF/SLL_Push(21d600c443e4dd01).(void **list, void *element) {
718 SLL_SetNextcxx . . $ QTWTF/SLL_SetNext(6c58c5e2437d25a2).(element, *list);
719 *list = element;
720 }
721
722 static inline void *SLL_Popcxx . . $ QTWTF/SLL_Pop(8350835cdea29fce).(void **list) {
723 void *result = *list;
724 *list = SLL_Nextcxx . . $ QTWTF/SLL_Next(9f162e79bfc6c74).(*list);
725 return result;
726 }
727
728
729 // Remove N elements from a linked list to which head points. head will be
730 // modified to point to the new head. start and end will point to the first
731 // and last nodes of the range. Note that end will point to NULL after this
732 // function is called.
733 static inline void SLL_PopRangecxx . . $ QTWTF/SLL_PopRange(8e043882d7b13f1f).(void **head, int N, void **start, void **end) {
734 if (N == 0) {
735 *start = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
736 *end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
737 return;
738 }
739
740 void *tmp = *head;
741 for (int i = 1; i < N; ++i) {
742 tmp = SLL_Nextcxx . . $ QTWTF/SLL_Next(9f162e79bfc6c74).(tmp);
743 }
744
745 *start = *head;
746 *end = tmp;
747 *head = SLL_Nextcxx . . $ QTWTF/SLL_Next(9f162e79bfc6c74).(tmp);
748 // Unlink range from list.
749 SLL_SetNextcxx . . $ QTWTF/SLL_SetNext(6c58c5e2437d25a2).(tmp, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
750 }
751
752 static inline void SLL_PushRangecxx . . $ QTWTF/SLL_PushRange(40371abbd1d86883).(void **head, void *start, void *end) {
753 if (!start) return;
754 SLL_SetNextcxx . . $ QTWTF/SLL_SetNext(6c58c5e2437d25a2).(end, *head);
755 *head = start;
756 }
757
758 static inline size_t SLL_Sizecxx . . $ QTWTF/SLL_Size(751e5d26f8574c32).(void *head) {
759 int count = 0;
760 while (head) {
761 count++;
762 head = SLL_Nextcxx . . $ QTWTF/SLL_Next(9f162e79bfc6c74).(head);
763 }
764 return count;
765 }
766
767 // Setup helper functions.
768
769 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! size_t SizeClasscxx . . $ QTWTF/SizeClass(ecdaa1632f49f591).(size_t size) {
770 return class_arraycxx . . $ QTWTF/class_array.[ClassIndexcxx . . $ QTWTF/ClassIndex(15f694ef3c96d230).(size)];
771 }
772
773 // Get the byte-size for a specified class
774 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! size_t ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(size_t cl) {
775 return class_to_sizecxx . . $ QTWTF/class_to_size.[cl];
776 }
777 static int NumMoveSizecxx . . $ QTWTF/NumMoveSize(15f694ef3c96d230).(size_t size) {
778 if (size == 0) return 0;
779 // Use approx 64k transfers between thread and central caches.
780 int num = static_cast<int>(64.0 * 1024.0 / size);
781 if (num < 2) num = 2;
782 // Clamp well below kMaxFreeListLength to avoid ping pong between central
783 // and thread caches.
784 if (num > static_cast<int>(0.8 * kMaxFreeListLengthcxx . . $ QTWTF/kMaxFreeListLength.))
785 num = static_cast<int>(0.8 * kMaxFreeListLengthcxx . . $ QTWTF/kMaxFreeListLength.);
786
787 // Also, avoid bringing in too many objects into small object free
788 // lists. There are lots of such lists, and if we allow each one to
789 // fetch too many at a time, we end up having to scavenge too often
790 // (especially when there are lots of threads and each thread gets a
791 // small allowance for its thread cache).
792 //
793 // TODO: Make thread cache free list sizes dynamic so that we do not
794 // have to equally divide a fixed resource amongst lots of threads.
795 if (num > 32) num = 32;
796
797 return num;
798 }
799
800 // Initialize the mapping arrays
801 static void InitSizeClassescxx . . $ QTWTF/InitSizeClasses(49f6e7a06ebc5aa8).() {
802 // Do some sanity checking on add_amount[]/shift_amount[]/class_array[]
803 if (ClassIndexcxx . . $ QTWTF/ClassIndex(15f694ef3c96d230).(0) < 0) {
804 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Invalid class index %d for size 0\n", ClassIndex(0));
805 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
806 }
807 if (static_cast<size_t>(ClassIndexcxx . . $ QTWTF/ClassIndex(15f694ef3c96d230).(kMaxSizecxx . . $ QTWTF/kMaxSize.)) >= sizeof(class_arraycxx . . $ QTWTF/class_array.)) {
808 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Invalid class index %d for kMaxSize\n", ClassIndex(kMaxSize));
809 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
810 }
811
812 // Compute the size classes we want to use
813 size_t sc = 1; // Next size class to assign
814 unsigned char alignshift = kAlignShiftcxx . . $ QTWTF/kAlignShift.;
815 int last_lg = -1;
816 for (size_t size = kAlignmentcxx . . $ QTWTF/kAlignment.; size <= kMaxSizecxx . . $ QTWTF/kMaxSize.; size += (1 << alignshift)) {
817 int lg = LgFloorcxx . . $ QTWTF/LgFloor(15f694ef3c96d230).(size);
818 if (lg > last_lg) {
819 // Increase alignment every so often.
820 //
821 // Since we double the alignment every time size doubles and
822 // size >= 128, this means that space wasted due to alignment is
823 // at most 16/128 i.e., 12.5%. Plus we cap the alignment at 256
824 // bytes, so the space wasted as a percentage starts falling for
825 // sizes > 2K.
826 if ((lg >= 7) && (alignshift < 8)) {
827 alignshift++;
828 }
829 last_lg = lg;
830 }
831
832 // Allocate enough pages so leftover is less than 1/8 of total.
833 // This bounds wasted space to at most 12.5%.
834 size_t psize = kPageSizecxx . . $ QTWTF/kPageSize.;
835 while ((psize % size) > (psize >> 3)) {
836 psize += kPageSizecxx . . $ QTWTF/kPageSize.;
837 }
838 const size_t my_pages = psize >> kPageShiftcxx . . $ QTWTF/kPageShift.;
839
840 if (sc > 1 && my_pages == class_to_pagescxx . . $ QTWTF/class_to_pages.[sc-1]) {
841 // See if we can merge this into the previous class without
842 // increasing the fragmentation of the previous class.
843 const size_t my_objects = (my_pages << kPageShiftcxx . . $ QTWTF/kPageShift.) / size;
844 const size_t prev_objects = (class_to_pagescxx . . $ QTWTF/class_to_pages.[sc-1] << kPageShiftcxx . . $ QTWTF/kPageShift.)
845 / class_to_sizecxx . . $ QTWTF/class_to_size.[sc-1];
846 if (my_objects == prev_objects) {
847 // Adjust last class to include this size
848 class_to_sizecxx . . $ QTWTF/class_to_size.[sc-1] = size;
849 continue;
850 }
851 }
852
853 // Add new class
854 class_to_pagescxx . . $ QTWTF/class_to_pages.[sc] = my_pages;
855 class_to_sizecxx . . $ QTWTF/class_to_size.[sc] = size;
856 sc++;
857 }
858 if (sc != kNumClassescxx . . $ QTWTF/kNumClasses.) {
859 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("wrong number of size classes: found %" PRIuS " instead of %d\n",
860 sc, int(kNumClasses));
861 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
862 }
863
864 // Initialize the mapping arrays
865 int next_size = 0;
866 for (unsigned char c = 1; c < kNumClassescxx . . $ QTWTF/kNumClasses.; c++) {
867 const size_t max_size_in_class = class_to_sizecxx . . $ QTWTF/class_to_size.[c];
868 for (size_t s = next_size; s <= max_size_in_class; s += kAlignmentcxx . . $ QTWTF/kAlignment.) {
869 class_arraycxx . . $ QTWTF/class_array.[ClassIndexcxx . . $ QTWTF/ClassIndex(15f694ef3c96d230).(s)] = c;
870 }
871 next_size = static_cast<int>(max_size_in_class + kAlignmentcxx . . $ QTWTF/kAlignment.);
872 }
873
874 // Double-check sizes just to be safe
875 for (size_t size = 0; size <= kMaxSizecxx . . $ QTWTF/kMaxSize.; size++) {
876 const size_t sc = SizeClasscxx . . $ QTWTF/SizeClass(ecdaa1632f49f591).(size);
877 if (sc == 0) {
878 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size);
879 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
880 }
881 if (sc > 1 && size <= class_to_sizecxx . . $ QTWTF/class_to_size.[sc-1]) {
882 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Allocating unnecessarily large class %" PRIuS " for %" PRIuS
883 "\n", sc, size);
884 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
885 }
886 if (sc >= kNumClassescxx . . $ QTWTF/kNumClasses.) {
887 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Bad size class %" PRIuS " for %" PRIuS "\n", sc, size);
888 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
889 }
890 const size_t s = class_to_sizecxx . . $ QTWTF/class_to_size.[sc];
891 if (size > s) {
892 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc);
893 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
894 }
895 if (s == 0) {
896 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("Bad size %" PRIuS " for %" PRIuS " (sc = %" PRIuS ")\n", s, size, sc);
897 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
898 }
899 }
900
901 // Initialize the num_objects_to_move array.
902 for (size_t cl = 1; cl < kNumClassescxx . . $ QTWTF/kNumClasses.; ++cl) {
903 num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[cl] = NumMoveSizecxx . . $ QTWTF/NumMoveSize(15f694ef3c96d230).(ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(cl));
904 }
905
906 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
907 if (false) {
908 // Dump class sizes and maximum external wastage per size class
909 for (size_t cl = 1; cl < kNumClasses; ++cl) {
910 const int alloc_size = class_to_pages[cl] << kPageShift;
911 const int alloc_objs = alloc_size / class_to_size[cl];
912 const int min_used = (class_to_size[cl-1] + 1) * alloc_objs;
913 const int max_waste = alloc_size - min_used;
914 MESSAGE("SC %3d [ %8d .. %8d ] from %8d ; %2.0f%% maxwaste\n",
915 int(cl),
916 int(class_to_size[cl-1] + 1),
917 int(class_to_size[cl]),
918 int(class_to_pages[cl] << kPageShift),
919 max_waste * 100.0 / alloc_size
920 );
921 }
922 }
923 #endif
924 }
925
926 // -------------------------------------------------------------------------
927 // Simple allocator for objects of a specified type. External locking
928 // is required before accessing one of these objects.
929 // -------------------------------------------------------------------------
930
931 // Metadata allocator -- keeps stats about how many bytes allocated
932 static uint64_tcxx . . $ uint64_t# metadata_system_bytescxx . . $ QTWTF/metadata_system_bytes. = 0;
933 static void* MetaDataAlloccxx . . $ QTWTF/MetaDataAlloc(bfcfa4d6b7f7ef64).(size_t bytes) {
934 void* result = TCMalloc_SystemAlloccxx . . $ TCMalloc_SystemAlloc(b27b84a2970bf05a).(bytes, 0);
935 if (result != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
936 metadata_system_bytescxx . . $ QTWTF/metadata_system_bytes. += bytes;
937 }
938 return result;
939 }
940
941 template <class T>
942 class PageHeapAllocatorcxx . . $ QTWTF/PageHeapAllocator# {
943 private:
944 // How much to allocate from system at a time
945 static const size_t kAllocIncrementcxx . . $ QTWTF/PageHeapAllocator#kAllocIncrement. = 32 << 10;
946
947 // Aligned size of T
948 static const size_t kAlignedSizecxx . . $ QTWTF/PageHeapAllocator#kAlignedSize.
949 = (((sizeof(T) + kAlignmentcxx . . $ QTWTF/kAlignment. - 1) / kAlignmentcxx . . $ QTWTF/kAlignment.) * kAlignmentcxx . . $ QTWTF/kAlignment.);
950
951 // Free area from which to carve new objects
952 char* free_area_cxx . . $ QTWTF/PageHeapAllocator#free_area_.;
953 size_t free_avail_cxx . . $ QTWTF/PageHeapAllocator#free_avail_.;
954
955 // Linked list of all regions allocated by this allocator
956 void* allocated_regions_cxx . . $ QTWTF/PageHeapAllocator#allocated_regions_.;
957
958 // Free list of already carved objects
959 void* free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_.;
960
961 // Number of allocated but unfreed objects
962 int inuse_cxx . . $ QTWTF/PageHeapAllocator#inuse_.;
963
964 public:
965 void Initcxx . . $ QTWTF/PageHeapAllocator#Init(49f6e7a06ebc5aa8).() {
966 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(kAlignedSize <= kAllocIncrement);
967 inuse_cxx . . $ QTWTF/PageHeapAllocator#inuse_. = 0;
968 allocated_regions_cxx . . $ QTWTF/PageHeapAllocator#allocated_regions_. = 0;
969 free_area_cxx . . $ QTWTF/PageHeapAllocator#free_area_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
970 free_avail_cxx . . $ QTWTF/PageHeapAllocator#free_avail_. = 0;
971 free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
972 }
973
974 T* Newcxx . . $ QTWTF/PageHeapAllocator#New(155dc7f103cdb9db).() {
975 // Consult free list
976 void* result;
977 if (free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
978 result = free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_.;
979 free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_. = *(reinterpret_cast<void**>(result));
980 } else {
981 if (free_avail_cxx . . $ QTWTF/PageHeapAllocator#free_avail_. < kAlignedSizecxx . . $ QTWTF/PageHeapAllocator#kAlignedSize.) {
982 // Need more room
983 char* new_allocation = reinterpret_cast<char*>(MetaDataAlloccxx . . $ QTWTF/MetaDataAlloc(bfcfa4d6b7f7ef64).(kAllocIncrementcxx . . $ QTWTF/PageHeapAllocator#kAllocIncrement.));
984 if (!new_allocation)
985 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
986
987 *(void**)new_allocation = allocated_regions_cxx . . $ QTWTF/PageHeapAllocator#allocated_regions_.;
988 allocated_regions_cxx . . $ QTWTF/PageHeapAllocator#allocated_regions_. = new_allocation;
989 free_area_cxx . . $ QTWTF/PageHeapAllocator#free_area_. = new_allocation + kAlignedSizecxx . . $ QTWTF/PageHeapAllocator#kAlignedSize.;
990 free_avail_cxx . . $ QTWTF/PageHeapAllocator#free_avail_. = kAllocIncrementcxx . . $ QTWTF/PageHeapAllocator#kAllocIncrement. - kAlignedSizecxx . . $ QTWTF/PageHeapAllocator#kAlignedSize.;
991 }
992 result = free_area_cxx . . $ QTWTF/PageHeapAllocator#free_area_.;
993 free_area_cxx . . $ QTWTF/PageHeapAllocator#free_area_. += kAlignedSizecxx . . $ QTWTF/PageHeapAllocator#kAlignedSize.;
994 free_avail_cxx . . $ QTWTF/PageHeapAllocator#free_avail_. -= kAlignedSizecxx . . $ QTWTF/PageHeapAllocator#kAlignedSize.;
995 }
996 inuse_cxx . . $ QTWTF/PageHeapAllocator#inuse_.++;
997 return reinterpret_cast<T*>(result);
998 }
999
1000 void Deletecxx . . $ QTWTF/PageHeapAllocator#Delete(ebd0a1552f8ce24f).(T* p) {
1001 *(reinterpret_cast<void**>(p)) = free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_.;
1002 free_list_cxx . . $ QTWTF/PageHeapAllocator#free_list_. = p;
1003 inuse_cxx . . $ QTWTF/PageHeapAllocator#inuse_.--;
1004 }
1005
1006 int inusecxx . . $ QTWTF/PageHeapAllocator#inuse(455f465bc33b4cdf).() const { return inuse_cxx . . $ QTWTF/PageHeapAllocator#inuse_.; }
1007
1008 #if defined(WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!) && OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
1009 template <class Recorder>
1010 void recordAdministrativeRegions(Recorder& recorder, const RemoteMemoryReader& reader)
1011 {
1012 vm_address_t adminAllocation = reinterpret_cast<vm_address_t>(allocated_regions_);
1013 while (adminAllocation) {
1014 recorder.recordRegion(adminAllocation, kAllocIncrement);
1015 adminAllocation = *reader(reinterpret_cast<vm_address_t*>(adminAllocation));
1016 }
1017 }
1018 #endif
1019 };
1020
1021 // -------------------------------------------------------------------------
1022 // Span - a contiguous run of pages
1023 // -------------------------------------------------------------------------
1024
1025 // Type that can hold a page number
1026 typedef uintptr_tcxx . . $ uintptr_t# PageIDcxx . . $ QTWTF/PageID#;
1027
1028 // Type that can hold the length of a run of pages
1029 typedef uintptr_tcxx . . $ uintptr_t# Lengthcxx . . $ QTWTF/Length#;
1030
1031 static const Lengthcxx . . $ QTWTF/Length# kMaxValidPagescxx . . $ QTWTF/kMaxValidPages. = (~static_cast<Lengthcxx . . $ QTWTF/Length#>(0)) >> kPageShiftcxx . . $ QTWTF/kPageShift.;
1032
1033 // Convert byte size into pages. This won't overflow, but may return
1034 // an unreasonably large value if bytes is huge enough.
1035 static inline Lengthcxx . . $ QTWTF/Length# pagescxx . . $ QTWTF/pages(ecdaa1632f49f591).(size_t bytes) {
1036 return (bytes >> kPageShiftcxx . . $ QTWTF/kPageShift.) +
1037 ((bytes & (kPageSizecxx . . $ QTWTF/kPageSize. - 1)) > 0 ? 1 : 0);
1038 }
1039
1040 // Convert a user size into the number of bytes that will actually be
1041 // allocated
1042 static size_t AllocationSizecxx . . $ QTWTF/AllocationSize(ecdaa1632f49f591).(size_t bytes) {
1043 if (bytes > kMaxSizecxx . . $ QTWTF/kMaxSize.) {
1044 // Large object: we allocate an integral number of pages
1045 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(bytes <= (kMaxValidPages << kPageShift));
1046 return pagescxx . . $ QTWTF/pages(ecdaa1632f49f591).(bytes) << kPageShiftcxx . . $ QTWTF/kPageShift.;
1047 } else {
1048 // Small object: find the size class to which it belongs
1049 return ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(SizeClasscxx . . $ QTWTF/SizeClass(ecdaa1632f49f591).(bytes));
1050 }
1051 }
1052
1053 // Information kept for a span (a contiguous run of pages).
1054 struct Spancxx . . $ QTWTF/Span# {
1055 PageIDcxx . . $ QTWTF/PageID# startcxx . . $ QTWTF/Span#start.; // Starting page number
1056 Lengthcxx . . $ QTWTF/Length# lengthcxx . . $ QTWTF/Span#length.; // Number of pages in span
1057 Spancxx . . $ QTWTF/Span#* nextcxx . . $ QTWTF/Span#next.; // Used when in link list
1058 Spancxx . . $ QTWTF/Span#* prevcxx . . $ QTWTF/Span#prev.; // Used when in link list
1059 void* objectscxx . . $ QTWTF/Span#objects.; // Linked list of free objects
1060 unsigned int freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`! : 1; // Is the span free
1061 #ifndef NO_TCMALLOC_SAMPLEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:88:9`!
1062 unsigned int sample : 1; // Sampled object?
1063 #endif
1064 unsigned int sizeclasscxx . . $ QTWTF/Span#sizeclass. : 8; // Size-class for small objects (or 0)
1065 unsigned int refcountcxx . . $ QTWTF/Span#refcount. : 11; // Number of non-free objects
1066 bool decommittedcxx . . $ QTWTF/Span#decommitted. : 1;
1067
1068 #undef SPAN_HISTORY
1069 #ifdef SPAN_HISTORY
1070 // For debugging, we can keep a log events per span
1071 int nexthistory;
1072 char history[64];
1073 int value[64];
1074 #endif
1075 };
1076
1077 #define ASSERT_SPAN_COMMITTEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1077:9`!(span) ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!span->decommitted)
1078
1079 #ifdef SPAN_HISTORY
1080 void Event(Span* span, char op, int v = 0) {
1081 span->history[span->nexthistory] = op;
1082 span->value[span->nexthistory] = v;
1083 span->nexthistory++;
1084 if (span->nexthistory == sizeof(span->history)) span->nexthistory = 0;
1085 }
1086 #else
1087 #define Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(s,o,v) ((void) 0)
1088 #endif
1089
1090 // Allocator/deallocator for spans
1091 static PageHeapAllocatorcxx . . $ QTWTF/PageHeapAllocator#<Spancxx . . $ QTWTF/Span#> span_allocatorcxx . . $ QTWTF/span_allocator.;
1092 static Spancxx . . $ QTWTF/Span#* NewSpancxx . . $ QTWTF/NewSpan(fe2cd51a44db566c).(PageIDcxx . . $ QTWTF/PageID# p, Lengthcxx . . $ QTWTF/Length# len) {
1093 Spancxx . . $ QTWTF/Span#* result = span_allocator.New();
1094 memset(result, 0, sizeof(*result));
1095 result->startcxx . . $ QTWTF/Span#start. = p;
1096 result->lengthcxx . . $ QTWTF/Span#length. = len;
1097 #ifdef SPAN_HISTORY
1098 result->nexthistory = 0;
1099 #endif
1100 return result;
1101 }
1102
1103 static inline void DeleteSpancxx . . $ QTWTF/DeleteSpan(41397daa150afe2e).(Spancxx . . $ QTWTF/Span#* span) {
1104 #ifndef NDEBUGcxx . . $ `<built-in>:472:9`!
1105 // In debug mode, trash the contents of deleted Spans
1106 memset(span, 0x3f, sizeof(*span));
1107 #endif
1108 span_allocatorcxx . . $ QTWTF/span_allocator..Delete(span);
1109 }
1110
1111 // -------------------------------------------------------------------------
1112 // Doubly linked list of spans.
1113 // -------------------------------------------------------------------------
1114
1115 static inline void DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(Spancxx . . $ QTWTF/Span#* list) {
1116 list->nextcxx . . $ QTWTF/Span#next. = list;
1117 list->prevcxx . . $ QTWTF/Span#prev. = list;
1118 }
1119
1120 static inline void DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(Spancxx . . $ QTWTF/Span#* span) {
1121 span->prevcxx . . $ QTWTF/Span#prev.->nextcxx . . $ QTWTF/Span#next. = span->nextcxx . . $ QTWTF/Span#next.;
1122 span->nextcxx . . $ QTWTF/Span#next.->prevcxx . . $ QTWTF/Span#prev. = span->prevcxx . . $ QTWTF/Span#prev.;
1123 span->prevcxx . . $ QTWTF/Span#prev. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1124 span->nextcxx . . $ QTWTF/Span#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1125 }
1126
1127 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! bool DLL_IsEmptycxx . . $ QTWTF/DLL_IsEmpty(8acc2b62ecd0f74).(const Spancxx . . $ QTWTF/Span#* list) {
1128 return list->nextcxx . . $ QTWTF/Span#next. == list;
1129 }
1130
1131 static int DLL_Lengthcxx . . $ QTWTF/DLL_Length(e0afbdd3ce0675a4).(const Spancxx . . $ QTWTF/Span#* list) {
1132 int result = 0;
1133 for (Spancxx . . $ QTWTF/Span#* s = list->nextcxx . . $ QTWTF/Span#next.; s != list; s = s->nextcxx . . $ QTWTF/Span#next.) {
1134 result++;
1135 }
1136 return result;
1137 }
1138
1139 #if 0 /* Not needed at the moment -- causes compiler warnings if not used */
1140 static void DLL_Print(const char* label, const Span* list) {
1141 MESSAGE("%-10s %p:", label, list);
1142 for (const Span* s = list->next; s != list; s = s->next) {
1143 MESSAGE(" <%p,%u,%u>", s, s->start, s->length);
1144 }
1145 MESSAGE("\n");
1146 }
1147 #endif
1148
1149 static inline void DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(Spancxx . . $ QTWTF/Span#* list, Spancxx . . $ QTWTF/Span#* span) {
1150 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->next == NULL);
1151 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->prev == NULL);
1152 span->nextcxx . . $ QTWTF/Span#next. = list->nextcxx . . $ QTWTF/Span#next.;
1153 span->prevcxx . . $ QTWTF/Span#prev. = list;
1154 list->nextcxx . . $ QTWTF/Span#next.->prevcxx . . $ QTWTF/Span#prev. = span;
1155 list->nextcxx . . $ QTWTF/Span#next. = span;
1156 }
1157
1158 // -------------------------------------------------------------------------
1159 // Stack traces kept for sampled allocations
1160 // The following state is protected by pageheap_lock_.
1161 // -------------------------------------------------------------------------
1162
1163 // size/depth are made the same size as a pointer so that some generic
1164 // code below can conveniently cast them back and forth to void*.
1165 static const int kMaxStackDepthcxx . . $ QTWTF/kMaxStackDepth. = 31;
1166 struct StackTracecxx . . $ QTWTF/StackTrace# {
1167 uintptr_tcxx . . $ uintptr_t# sizecxx . . $ QTWTF/StackTrace#size.; // Size of object
1168 uintptr_tcxx . . $ uintptr_t# depthcxx . . $ QTWTF/StackTrace#depth.; // Number of PC values stored in array below
1169 void* stackcxx . . $ QTWTF/StackTrace#stack.[kMaxStackDepthcxx . . $ QTWTF/kMaxStackDepth.];
1170 };
1171 static PageHeapAllocatorcxx . . $ QTWTF/PageHeapAllocator#<StackTracecxx . . $ QTWTF/StackTrace#> stacktrace_allocatorcxx . . $ QTWTF/stacktrace_allocator.;
1172 static Spancxx . . $ QTWTF/Span# sampled_objectscxx . . $ QTWTF/sampled_objects.;
1173
1174 // -------------------------------------------------------------------------
1175 // Map from page-id to per-page data
1176 // -------------------------------------------------------------------------
1177
1178 // We use PageMap2<> for 32-bit and PageMap3<> for 64-bit machines.
1179 // We also use a simple one-level cache for hot PageID-to-sizeclass mappings,
1180 // because sometimes the sizeclass is all the information we need.
1181
1182 // Selector class -- general selector uses 3-level map
1183 template <int BITS> class MapSelectorcxx . . $ QTWTF/MapSelector# {
1184 public:
1185 typedef TCMalloc_PageMap3cxx . . $ TCMalloc_PageMap3#<BITS-kPageShiftcxx . . $ QTWTF/kPageShift.> Typecxx . . $ QTWTF/MapSelector#Type#;
1186 typedef PackedCachecxx . . $ PackedCache#<BITS, uint64_tcxx . . $ uint64_t#> CacheTypecxx . . $ QTWTF/MapSelector#CacheType#;
1187 };
1188
1189 #if defined(WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!)
1190 #if CPUcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:44:9`!(X86_64)
1191 // On all known X86-64 platforms, the upper 16 bits are always unused and therefore
1192 // can be excluded from the PageMap key.
1193 // See http://en.wikipedia.org/wiki/X86-64#Virtual_address_space_details
1194
1195 static const size_t kBitsUnusedOn64Bitcxx . . $ QTWTF/kBitsUnusedOn64Bit. = 16;
1196 #else
1197 static const size_t kBitsUnusedOn64Bit = 0;
1198 #endif
1199
1200 // A three-level map for 64-bit machines
1201 template <> class MapSelectorcxx . . $ QTWTF/MapSelector#<64> {
1202 public:
1203 typedef TCMalloc_PageMap3cxx . . $ TCMalloc_PageMap3#<64 - kPageShiftcxx . . $ QTWTF/kPageShift. - kBitsUnusedOn64Bitcxx . . $ QTWTF/kBitsUnusedOn64Bit.> Typecxx . . $ QTWTF/MapSelector#Type#;
1204 typedef PackedCachecxx . . $ PackedCache#<64, uint64_tcxx . . $ uint64_t#> CacheTypecxx . . $ QTWTF/MapSelector#CacheType#;
1205 };
1206 #endif
1207
1208 // A two-level map for 32-bit machines
1209 template <> class MapSelectorcxx . . $ QTWTF/MapSelector#<32> {
1210 public:
1211 typedef TCMalloc_PageMap2cxx . . $ TCMalloc_PageMap2#<32 - kPageShiftcxx . . $ QTWTF/kPageShift.> Typecxx . . $ QTWTF/MapSelector#Type#;
1212 typedef PackedCachecxx . . $ PackedCache#<32 - kPageShiftcxx . . $ QTWTF/kPageShift., uint16_tcxx . . $ uint16_t#> CacheTypecxx . . $ QTWTF/MapSelector#CacheType#;
1213 };
1214
1215 // -------------------------------------------------------------------------
1216 // Page-level allocator
1217 // * Eager coalescing
1218 //
1219 // Heap for page-level allocation. We allow allocating and freeing a
1220 // contiguous runs of pages (called a "span").
1221 // -------------------------------------------------------------------------
1222
1223 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1224 // The central page heap collects spans of memory that have been deleted but are still committed until they are released
1225 // back to the system. We use a background thread to periodically scan the list of free spans and release some back to the
1226 // system. Every 5 seconds, the background thread wakes up and does the following:
1227 // - Check if we needed to commit memory in the last 5 seconds. If so, skip this scavenge because it's a sign that we are short
1228 // of free committed pages and so we should not release them back to the system yet.
1229 // - Otherwise, go through the list of free spans (from largest to smallest) and release up to a fraction of the free committed pages
1230 // back to the system.
1231 // - If the number of free committed pages reaches kMinimumFreeCommittedPageCount, we can stop the scavenging and block the
1232 // scavenging thread until the number of free committed pages goes above kMinimumFreeCommittedPageCount.
1233
1234 // Background thread wakes up every 5 seconds to scavenge as long as there is memory available to return to the system.
1235 static const int kScavengeTimerDelayInSecondscxx . . $ QTWTF/kScavengeTimerDelayInSeconds. = 5;
1236
1237 // Number of free committed pages that we want to keep around.
1238 static const size_t kMinimumFreeCommittedPageCountcxx . . $ QTWTF/kMinimumFreeCommittedPageCount. = 512;
1239
1240 // During a scavenge, we'll release up to a fraction of the free committed pages.
1241 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(WINDOWS)
1242 // We are slightly less aggressive in releasing memory on Windows due to performance reasons.
1243 static const int kMaxScavengeAmountFactor = 3;
1244 #else
1245 static const int kMaxScavengeAmountFactorcxx . . $ QTWTF/kMaxScavengeAmountFactor. = 2;
1246 #endif
1247 #endif
1248
1249 class TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap# {
1250 public:
1251 void initcxx . . $ QTWTF/TCMalloc_PageHeap#init(49f6e7a06ebc5aa8).();
1252
1253 // Allocate a run of "n" pages. Returns zero if out of memory.
1254 Spancxx . . $ QTWTF/Span#* Newcxx . . $ QTWTF/TCMalloc_PageHeap#New(25d23c4f8e1d4247).(Lengthcxx . . $ QTWTF/Length# n);
1255
1256 // Delete the span "[p, p+n-1]".
1257 // REQUIRES: span was returned by earlier call to New() and
1258 // has not yet been deleted.
1259 void Deletecxx . . $ QTWTF/TCMalloc_PageHeap#Delete(41397daa150afe2e).(Spancxx . . $ QTWTF/Span#* span);
1260
1261 // Mark an allocated span as being used for small objects of the
1262 // specified size-class.
1263 // REQUIRES: span was returned by an earlier call to New()
1264 // and has not yet been deleted.
1265 void RegisterSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#RegisterSizeClass(e9597f5c88419a9c).(Spancxx . . $ QTWTF/Span#* span, size_t sc);
1266
1267 // Split an allocated span into two spans: one of length "n" pages
1268 // followed by another span of length "span->length - n" pages.
1269 // Modifies "*span" to point to the first span of length "n" pages.
1270 // Returns a pointer to the second span.
1271 //
1272 // REQUIRES: "0 < n < span->length"
1273 // REQUIRES: !span->free
1274 // REQUIRES: span->sizeclass == 0
1275 Spancxx . . $ QTWTF/Span#* Splitcxx . . $ QTWTF/TCMalloc_PageHeap#Split(ae223c35f7639f8a).(Spancxx . . $ QTWTF/Span#* span, Lengthcxx . . $ QTWTF/Length# n);
1276
1277 // Return the descriptor for the specified page.
1278 inline Spancxx . . $ QTWTF/Span#* GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(PageIDcxx . . $ QTWTF/PageID# p) const {
1279 return reinterpret_cast<Span*>(pagemap_.get(p));
1280 }
1281
1282 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
1283 inline Spancxx . . $ QTWTF/Span#* GetDescriptorEnsureSafecxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptorEnsureSafe(25d23c4f8e1d4247).(PageIDcxx . . $ QTWTF/PageID# p)
1284 {
1285 pagemap_.Ensure(p, 1);
1286 return GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p);
1287 }
1288
1289 size_t ReturnedBytescxx . . $ QTWTF/TCMalloc_PageHeap#ReturnedBytes(fe4d2d262d4164a8).() const;
1290 #endif
1291
1292 // Dump state to stderr
1293 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
1294 void Dump(TCMalloc_Printer* out);
1295 #endif
1296
1297 // Return number of bytes allocated from system
1298 inline uint64_tcxx . . $ uint64_t# SystemBytescxx . . $ QTWTF/TCMalloc_PageHeap#SystemBytes(fe4d2d262d4164a8).() const { return system_bytes_cxx . . $ QTWTF/TCMalloc_PageHeap#system_bytes_.; }
1299
1300 // Return number of free bytes in heap
1301 uint64_tcxx . . $ uint64_t# FreeBytescxx . . $ QTWTF/TCMalloc_PageHeap#FreeBytes(fe4d2d262d4164a8).() const {
1302 return (static_cast<uint64_tcxx . . $ uint64_t#>(free_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_pages_.) << kPageShiftcxx . . $ QTWTF/kPageShift.);
1303 }
1304
1305 bool Checkcxx . . $ QTWTF/TCMalloc_PageHeap#Check(c9857a73d68e59ba).();
1306 bool CheckListcxx . . $ QTWTF/TCMalloc_PageHeap#CheckList(3a87bee1a6ddd5ff).(Spancxx . . $ QTWTF/Span#* list, Lengthcxx . . $ QTWTF/Length# min_pages, Lengthcxx . . $ QTWTF/Length# max_pages);
1307
1308 // Release all pages on the free list for reuse by the OS:
1309 void ReleaseFreePagescxx . . $ QTWTF/TCMalloc_PageHeap#ReleaseFreePages(49f6e7a06ebc5aa8).();
1310
1311 // Return 0 if we have no information, or else the correct sizeclass for p.
1312 // Reads and writes to pagemap_cache_ do not require locking.
1313 // The entries are 64 bits on 64-bit hardware and 16 bits on
1314 // 32-bit hardware, and we don't mind raciness as long as each read of
1315 // an entry yields a valid entry, not a partially updated entry.
1316 size_t GetSizeClassIfCachedcxx . . $ QTWTF/TCMalloc_PageHeap#GetSizeClassIfCached(611be0c07d97f8b8).(PageIDcxx . . $ QTWTF/PageID# p) const {
1317 return pagemap_cache_.GetOrDefault(p, 0);
1318 }
1319 void CacheSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#CacheSizeClass(c652d5d4e23f3c95).(PageIDcxx . . $ QTWTF/PageID# p, size_t cl) const { pagemap_cache_.Put(p, cl); }
1320
1321 private:
1322 // Pick the appropriate map and cache types based on pointer size
1323 typedef MapSelectorcxx . . $ QTWTF/MapSelector#<8*sizeof(uintptr_t)>::Typecxx . . $ QTWTF/MapSelector#Type# PageMapcxx . . $ QTWTF/TCMalloc_PageHeap#PageMap#;
1324 typedef MapSelectorcxx . . $ QTWTF/MapSelector#<8*sizeof(uintptr_t)>::CacheTypecxx . . $ QTWTF/MapSelector#CacheType# PageMapCachecxx . . $ QTWTF/TCMalloc_PageHeap#PageMapCache#;
1325 PageMapcxx . . $ QTWTF/TCMalloc_PageHeap#PageMap# pagemap_cxx . . $ QTWTF/TCMalloc_PageHeap#pagemap_.;
1326 mutable PageMapCachecxx . . $ QTWTF/TCMalloc_PageHeap#PageMapCache# pagemap_cache_cxx . . $ QTWTF/TCMalloc_PageHeap#pagemap_cache_.;
1327
1328 // We segregate spans of a given size into two circular linked
1329 // lists: one for normal spans, and one for spans whose memory
1330 // has been returned to the system.
1331 struct SpanListcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList# {
1332 Spancxx . . $ QTWTF/Span# normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.;
1333 Spancxx . . $ QTWTF/Span# returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.;
1334 };
1335
1336 // List of free spans of length >= kMaxPages
1337 SpanListcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList# large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_.;
1338
1339 // Array mapping from span length to a doubly linked list of free spans
1340 SpanListcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList# free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[kMaxPagescxx . . $ QTWTF/kMaxPages.];
1341
1342 // Number of pages kept in free lists
1343 uintptr_tcxx . . $ uintptr_t# free_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_pages_.;
1344
1345 // Bytes allocated from system
1346 uint64_tcxx . . $ uint64_t# system_bytes_cxx . . $ QTWTF/TCMalloc_PageHeap#system_bytes_.;
1347
1348 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1349 // Number of pages kept in free lists that are still committed.
1350 Lengthcxx . . $ QTWTF/Length# free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_.;
1351
1352 // Number of pages that we committed in the last scavenge wait interval.
1353 Lengthcxx . . $ QTWTF/Length# pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_.;
1354 #endif
1355
1356 bool GrowHeapcxx . . $ QTWTF/TCMalloc_PageHeap#GrowHeap(31596a199e1d8a50).(Lengthcxx . . $ QTWTF/Length# n);
1357
1358 // REQUIRES span->length >= n
1359 // Remove span from its free list, and move any leftover part of
1360 // span into appropriate free lists. Also update "span" to have
1361 // length exactly "n" and mark it as non-free so it can be returned
1362 // to the client.
1363 //
1364 // "released" is true iff "span" was found on a "returned" list.
1365 void Carvecxx . . $ QTWTF/TCMalloc_PageHeap#Carve(afdd8f0b01ab00c3).(Spancxx . . $ QTWTF/Span#* span, Lengthcxx . . $ QTWTF/Length# n, bool released);
1366
1367 void RecordSpancxx . . $ QTWTF/TCMalloc_PageHeap#RecordSpan(41397daa150afe2e).(Spancxx . . $ QTWTF/Span#* span) {
1368 pagemap_.set(span->start, span);
1369 if (span->lengthcxx . . $ QTWTF/Span#length. > 1) {
1370 pagemap_.set(span->start + span->length - 1, span);
1371 }
1372 }
1373
1374 // Allocate a large span of length == n. If successful, returns a
1375 // span of exactly the specified length. Else, returns NULL.
1376 Spancxx . . $ QTWTF/Span#* AllocLargecxx . . $ QTWTF/TCMalloc_PageHeap#AllocLarge(25d23c4f8e1d4247).(Lengthcxx . . $ QTWTF/Length# n);
1377
1378 #if !USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1379 // Incrementally release some memory to the system.
1380 // IncrementalScavenge(n) is called whenever n pages are freed.
1381 void IncrementalScavenge(Length n);
1382 #endif
1383
1384 // Number of pages to deallocate before doing more scavenging
1385 int64_tcxx . . $ int64_t# scavenge_counter_cxx . . $ QTWTF/TCMalloc_PageHeap#scavenge_counter_.;
1386
1387 // Index of last free list we scavenged
1388 size_t scavenge_index_cxx . . $ QTWTF/TCMalloc_PageHeap#scavenge_index_.;
1389
1390 #if defined(WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!) && OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
1391 friend class FastMallocZone;
1392 #endif
1393
1394 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1395 void initializeScavengercxx . . $ QTWTF/TCMalloc_PageHeap#initializeScavenger(49f6e7a06ebc5aa8).();
1396 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void signalScavengercxx . . $ QTWTF/TCMalloc_PageHeap#signalScavenger(49f6e7a06ebc5aa8).();
1397 void scavengecxx . . $ QTWTF/TCMalloc_PageHeap#scavenge(49f6e7a06ebc5aa8).();
1398 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! bool shouldContinueScavengingcxx . . $ QTWTF/TCMalloc_PageHeap#shouldContinueScavenging(50ce9a9e25b4a850).() const;
1399
1400 #if !HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(DISPATCH_H)
1401 static NO_RETURNcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:61:9`! void* runScavengerThreadcxx . . $ QTWTF/TCMalloc_PageHeap#runScavengerThread(faa83dea5422894).(void*);
1402 NO_RETURNcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:61:9`! void scavengerThreadcxx . . $ QTWTF/TCMalloc_PageHeap#scavengerThread(8df32a62017fbbf6).();
1403
1404 // Keeps track of whether the background thread is actively scavenging memory every kScavengeTimerDelayInSeconds, or
1405 // it's blocked waiting for more pages to be deleted.
1406 bool m_scavengeThreadActivecxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeThreadActive.;
1407
1408 pthread_mutex_t m_scavengeMutexcxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeMutex.;
1409 pthread_cond_t m_scavengeConditioncxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeCondition.;
1410 #else // !HAVE(DISPATCH_H)
1411 void periodicScavenge();
1412
1413 dispatch_queue_t m_scavengeQueue;
1414 dispatch_source_t m_scavengeTimer;
1415 bool m_scavengingScheduled;
1416 #endif
1417
1418 #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
1419 };
1420
1421 void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::initcxx . . $ QTWTF/TCMalloc_PageHeap#init(49f6e7a06ebc5aa8).()
1422 {
1423 pagemap_.init(MetaDataAlloc);
1424 pagemap_cache_ = PageMapCache(0);
1425 free_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_pages_. = 0;
1426 system_bytes_cxx . . $ QTWTF/TCMalloc_PageHeap#system_bytes_. = 0;
1427
1428 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1429 free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. = 0;
1430 pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. = 0;
1431 #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
1432
1433 scavenge_counter_cxx . . $ QTWTF/TCMalloc_PageHeap#scavenge_counter_. = 0;
1434 // Start scavenging at kMaxPages list
1435 scavenge_index_cxx . . $ QTWTF/TCMalloc_PageHeap#scavenge_index_. = kMaxPagescxx . . $ QTWTF/kMaxPages.-1;
1436 COMPILE_ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:247:9`!(kNumClasses <= (1 << PageMapCache::kValuebits), valuebits);
1437 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.);
1438 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.);
1439 for (size_t i = 0; i < kMaxPagescxx . . $ QTWTF/kMaxPages.; i++) {
1440 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[i].normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.);
1441 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[i].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.);
1442 }
1443
1444 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1445 initializeScavengercxx . . $ QTWTF/TCMalloc_PageHeap#initializeScavenger(49f6e7a06ebc5aa8).();
1446 #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
1447 }
1448
1449 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1450
1451 #if !HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(DISPATCH_H)
1452
1453 void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::initializeScavengercxx . . $ QTWTF/TCMalloc_PageHeap#initializeScavenger(49f6e7a06ebc5aa8).()
1454 {
1455 pthread_mutex_init(&m_scavengeMutexcxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeMutex., 0);
1456 pthread_cond_init(&m_scavengeConditioncxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeCondition., 0);
1457 m_scavengeThreadActivecxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeThreadActive. = true;
1458 pthread_t thread;
1459 pthread_create(&thread, 0, runScavengerThreadcxx . . $ QTWTF/TCMalloc_PageHeap#runScavengerThread(faa83dea5422894)., this);
1460 }
1461
1462 void* TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::runScavengerThreadcxx . . $ QTWTF/TCMalloc_PageHeap#runScavengerThread(faa83dea5422894).(void* context)
1463 {
1464 static_cast<TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#*>(context)->scavengerThreadcxx . . $ QTWTF/TCMalloc_PageHeap#scavengerThread(8df32a62017fbbf6).();
1465 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC) || OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(SOLARIS)
1466 // Without this, Visual Studio will complain that this method does not return a value.
1467 return 0;
1468 #endif
1469 }
1470
1471 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::signalScavengercxx . . $ QTWTF/TCMalloc_PageHeap#signalScavenger(49f6e7a06ebc5aa8).()
1472 {
1473 if (!m_scavengeThreadActivecxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeThreadActive. && shouldContinueScavengingcxx . . $ QTWTF/TCMalloc_PageHeap#shouldContinueScavenging(50ce9a9e25b4a850).())
1474 pthread_cond_signal(&m_scavengeConditioncxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeCondition.);
1475 }
1476
1477 #else // !HAVE(DISPATCH_H)
1478
1479 void TCMalloc_PageHeap::initializeScavenger()
1480 {
1481 m_scavengeQueue = dispatch_queue_create("com.apple.JavaScriptCore.FastMallocSavenger", NULL);
1482 m_scavengeTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, m_scavengeQueue);
1483 dispatch_time_t startTime = dispatch_time(DISPATCH_TIME_NOW, kScavengeTimerDelayInSeconds * NSEC_PER_SEC);
1484 dispatch_source_set_timer(m_scavengeTimer, startTime, kScavengeTimerDelayInSeconds * NSEC_PER_SEC, 1000 * NSEC_PER_USEC);
1485 dispatch_source_set_event_handler(m_scavengeTimer, ^{ periodicScavenge(); });
1486 m_scavengingScheduled = false;
1487 }
1488
1489 ALWAYS_INLINE void TCMalloc_PageHeap::signalScavenger()
1490 {
1491 if (!m_scavengingScheduled && shouldContinueScavenging()) {
1492 m_scavengingScheduled = true;
1493 dispatch_resume(m_scavengeTimer);
1494 }
1495 }
1496
1497 #endif
1498
1499 void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::scavengecxx . . $ QTWTF/TCMalloc_PageHeap#scavenge(49f6e7a06ebc5aa8).()
1500 {
1501 // If we have to commit memory in the last 5 seconds, it means we don't have enough free committed pages
1502 // for the amount of allocations that we do. So hold off on releasing memory back to the system.
1503 if (pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. > 0) {
1504 pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. = 0;
1505 return;
1506 }
1507 Lengthcxx . . $ QTWTF/Length# pagesDecommitted = 0;
1508 for (int i = kMaxPagescxx . . $ QTWTF/kMaxPages.; i >= 0; i--) {
1509 SpanListcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#* slist = (static_cast<size_t>(i) == kMaxPagescxx . . $ QTWTF/kMaxPages.) ? &large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_. : &free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[i];
1510 if (!DLL_IsEmptycxx . . $ QTWTF/DLL_IsEmpty(8acc2b62ecd0f74).(&slist->normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.)) {
1511 // Release the last span on the normal portion of this list
1512 Spancxx . . $ QTWTF/Span#* s = slist->normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal..prevcxx . . $ QTWTF/Span#prev.;
1513 // Only decommit up to a fraction of the free committed pages if pages_allocated_since_last_scavenge_ > 0.
1514 if ((pagesDecommitted + s->lengthcxx . . $ QTWTF/Span#length.) * kMaxScavengeAmountFactorcxx . . $ QTWTF/kMaxScavengeAmountFactor. > free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_.)
1515 continue;
1516 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(s);
1517 TCMalloc_SystemReleasecxx . . $ TCMalloc_SystemRelease(5500c4293b1bbef0).(reinterpret_cast<void*>(s->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.),
1518 static_cast<size_t>(s->lengthcxx . . $ QTWTF/Span#length. << kPageShiftcxx . . $ QTWTF/kPageShift.));
1519 if (!s->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1520 pagesDecommitted += s->lengthcxx . . $ QTWTF/Span#length.;
1521 s->decommittedcxx . . $ QTWTF/Span#decommitted. = true;
1522 }
1523 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&slist->returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned., s);
1524 // We can stop scavenging if the number of free committed pages left is less than or equal to the minimum number we want to keep around.
1525 if (free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. <= kMinimumFreeCommittedPageCountcxx . . $ QTWTF/kMinimumFreeCommittedPageCount. + pagesDecommitted)
1526 break;
1527 }
1528 }
1529 pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. = 0;
1530 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(free_committed_pages_ >= pagesDecommitted);
1531 free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. -= pagesDecommitted;
1532 }
1533
1534 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! bool TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::shouldContinueScavengingcxx . . $ QTWTF/TCMalloc_PageHeap#shouldContinueScavenging(50ce9a9e25b4a850).() const
1535 {
1536 return free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. > kMinimumFreeCommittedPageCountcxx . . $ QTWTF/kMinimumFreeCommittedPageCount.;
1537 }
1538
1539 #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
1540
1541 inline Spancxx . . $ QTWTF/Span#* TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::Newcxx . . $ QTWTF/TCMalloc_PageHeap#New(25d23c4f8e1d4247).(Lengthcxx . . $ QTWTF/Length# n) {
1542 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1543 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(n > 0);
1544
1545 // Find first size >= n that has a non-empty list
1546 for (Lengthcxx . . $ QTWTF/Length# s = n; s < kMaxPagescxx . . $ QTWTF/kMaxPages.; s++) {
1547 Spancxx . . $ QTWTF/Span#* ll = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1548 bool released = false;
1549 if (!DLL_IsEmptycxx . . $ QTWTF/DLL_IsEmpty(8acc2b62ecd0f74).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.)) {
1550 // Found normal span
1551 ll = &free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.;
1552 } else if (!DLL_IsEmptycxx . . $ QTWTF/DLL_IsEmpty(8acc2b62ecd0f74).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.)) {
1553 // Found returned span; reallocate it
1554 ll = &free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.;
1555 released = true;
1556 } else {
1557 // Keep looking in larger classes
1558 continue;
1559 }
1560
1561 Spancxx . . $ QTWTF/Span#* result = ll->nextcxx . . $ QTWTF/Span#next.;
1562 Carvecxx . . $ QTWTF/TCMalloc_PageHeap#Carve(afdd8f0b01ab00c3).(result, n, released);
1563 if (result->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1564 TCMalloc_SystemCommitcxx . . $ TCMalloc_SystemCommit(5500c4293b1bbef0).(reinterpret_cast<void*>(result->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.), static_cast<size_t>(n << kPageShiftcxx . . $ QTWTF/kPageShift.));
1565 result->decommittedcxx . . $ QTWTF/Span#decommitted. = false;
1566 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1567 pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. += n;
1568 #endif
1569 }
1570 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1571 else {
1572 // The newly allocated memory is from a span that's in the normal span list (already committed). Update the
1573 // free committed pages count.
1574 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(free_committed_pages_ >= n);
1575 free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. -= n;
1576 }
1577 #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
1578 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1579 free_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_pages_. -= n;
1580 return result;
1581 }
1582
1583 Spancxx . . $ QTWTF/Span#* result = AllocLargecxx . . $ QTWTF/TCMalloc_PageHeap#AllocLarge(25d23c4f8e1d4247).(n);
1584 if (result != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1585 ASSERT_SPAN_COMMITTEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1077:9`!(result);
1586 return result;
1587 }
1588
1589 // Grow the heap and try again
1590 if (!GrowHeapcxx . . $ QTWTF/TCMalloc_PageHeap#GrowHeap(31596a199e1d8a50).(n)) {
1591 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1592 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1593 }
1594
1595 return AllocLargecxx . . $ QTWTF/TCMalloc_PageHeap#AllocLarge(25d23c4f8e1d4247).(n);
1596 }
1597
1598 Spancxx . . $ QTWTF/Span#* TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::AllocLargecxx . . $ QTWTF/TCMalloc_PageHeap#AllocLarge(25d23c4f8e1d4247).(Lengthcxx . . $ QTWTF/Length# n) {
1599 // find the best span (closest to n in size).
1600 // The following loops implements address-ordered best-fit.
1601 bool from_released = false;
1602 Spancxx . . $ QTWTF/Span# *best = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1603
1604 // Search through normal list
1605 for (Spancxx . . $ QTWTF/Span#* span = large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal..nextcxx . . $ QTWTF/Span#next.;
1606 span != &large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.;
1607 span = span->nextcxx . . $ QTWTF/Span#next.) {
1608 if (span->lengthcxx . . $ QTWTF/Span#length. >= n) {
1609 if ((best == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
1610 || (span->lengthcxx . . $ QTWTF/Span#length. < best->lengthcxx . . $ QTWTF/Span#length.)
1611 || ((span->lengthcxx . . $ QTWTF/Span#length. == best->lengthcxx . . $ QTWTF/Span#length.) && (span->startcxx . . $ QTWTF/Span#start. < best->startcxx . . $ QTWTF/Span#start.))) {
1612 best = span;
1613 from_released = false;
1614 }
1615 }
1616 }
1617
1618 // Search through released list in case it has a better fit
1619 for (Spancxx . . $ QTWTF/Span#* span = large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned..nextcxx . . $ QTWTF/Span#next.;
1620 span != &large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.;
1621 span = span->nextcxx . . $ QTWTF/Span#next.) {
1622 if (span->lengthcxx . . $ QTWTF/Span#length. >= n) {
1623 if ((best == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
1624 || (span->lengthcxx . . $ QTWTF/Span#length. < best->lengthcxx . . $ QTWTF/Span#length.)
1625 || ((span->lengthcxx . . $ QTWTF/Span#length. == best->lengthcxx . . $ QTWTF/Span#length.) && (span->startcxx . . $ QTWTF/Span#start. < best->startcxx . . $ QTWTF/Span#start.))) {
1626 best = span;
1627 from_released = true;
1628 }
1629 }
1630 }
1631
1632 if (best != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1633 Carvecxx . . $ QTWTF/TCMalloc_PageHeap#Carve(afdd8f0b01ab00c3).(best, n, from_released);
1634 if (best->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1635 TCMalloc_SystemCommitcxx . . $ TCMalloc_SystemCommit(5500c4293b1bbef0).(reinterpret_cast<void*>(best->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.), static_cast<size_t>(n << kPageShiftcxx . . $ QTWTF/kPageShift.));
1636 best->decommittedcxx . . $ QTWTF/Span#decommitted. = false;
1637 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1638 pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. += n;
1639 #endif
1640 }
1641 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1642 else {
1643 // The newly allocated memory is from a span that's in the normal span list (already committed). Update the
1644 // free committed pages count.
1645 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(free_committed_pages_ >= n);
1646 free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. -= n;
1647 }
1648 #endif // USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORY
1649 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1650 free_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_pages_. -= n;
1651 return best;
1652 }
1653 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
1654 }
1655
1656 Spancxx . . $ QTWTF/Span#* TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::Splitcxx . . $ QTWTF/TCMalloc_PageHeap#Split(ae223c35f7639f8a).(Spancxx . . $ QTWTF/Span#* span, Lengthcxx . . $ QTWTF/Length# n) {
1657 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(0 < n);
1658 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(n < span->length);
1659 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!span->free);
1660 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->sizeclass == 0);
1661 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'T', n);
1662
1663 const Lengthcxx . . $ QTWTF/Length# extra = span->lengthcxx . . $ QTWTF/Span#length. - n;
1664 Spancxx . . $ QTWTF/Span#* leftover = NewSpancxx . . $ QTWTF/NewSpan(fe2cd51a44db566c).(span->startcxx . . $ QTWTF/Span#start. + n, extra);
1665 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(leftover, 'U', extra);
1666 RecordSpancxx . . $ QTWTF/TCMalloc_PageHeap#RecordSpan(41397daa150afe2e).(leftover);
1667 pagemap_.set(span->start + n - 1, span); // Update map from pageid to span
1668 span->lengthcxx . . $ QTWTF/Span#length. = n;
1669
1670 return leftover;
1671 }
1672
1673 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void propagateDecommittedStatecxx . . $ QTWTF/propagateDecommittedState(e855eac60d60e4f1).(Spancxx . . $ QTWTF/Span#* destination, Spancxx . . $ QTWTF/Span#* source)
1674 {
1675 destination->decommittedcxx . . $ QTWTF/Span#decommitted. = source->decommittedcxx . . $ QTWTF/Span#decommitted.;
1676 }
1677
1678 inline void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::Carvecxx . . $ QTWTF/TCMalloc_PageHeap#Carve(afdd8f0b01ab00c3).(Spancxx . . $ QTWTF/Span#* span, Lengthcxx . . $ QTWTF/Length# n, bool released) {
1679 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(n > 0);
1680 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(span);
1681 span->freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`! = 0;
1682 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'A', n);
1683
1684 const int extra = static_cast<int>(span->lengthcxx . . $ QTWTF/Span#length. - n);
1685 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(extra >= 0);
1686 if (extra > 0) {
1687 Spancxx . . $ QTWTF/Span#* leftover = NewSpancxx . . $ QTWTF/NewSpan(fe2cd51a44db566c).(span->startcxx . . $ QTWTF/Span#start. + n, extra);
1688 leftover->freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`! = 1;
1689 propagateDecommittedStatecxx . . $ QTWTF/propagateDecommittedState(e855eac60d60e4f1).(leftover, span);
1690 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(leftover, 'S', extra);
1691 RecordSpancxx . . $ QTWTF/TCMalloc_PageHeap#RecordSpan(41397daa150afe2e).(leftover);
1692
1693 // Place leftover span on appropriate free list
1694 SpanListcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#* listpair = (static_cast<size_t>(extra) < kMaxPagescxx . . $ QTWTF/kMaxPages.) ? &free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[extra] : &large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_.;
1695 Spancxx . . $ QTWTF/Span#* dst = released ? &listpair->returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned. : &listpair->normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal.;
1696 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(dst, leftover);
1697
1698 span->lengthcxx . . $ QTWTF/Span#length. = n;
1699 pagemap_.set(span->start + n - 1, span);
1700 }
1701 }
1702
1703 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void mergeDecommittedStatescxx . . $ QTWTF/mergeDecommittedStates(e855eac60d60e4f1).(Spancxx . . $ QTWTF/Span#* destination, Spancxx . . $ QTWTF/Span#* other)
1704 {
1705 if (destination->decommittedcxx . . $ QTWTF/Span#decommitted. && !other->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1706 TCMalloc_SystemReleasecxx . . $ TCMalloc_SystemRelease(5500c4293b1bbef0).(reinterpret_cast<void*>(other->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.),
1707 static_cast<size_t>(other->lengthcxx . . $ QTWTF/Span#length. << kPageShiftcxx . . $ QTWTF/kPageShift.));
1708 } else if (other->decommittedcxx . . $ QTWTF/Span#decommitted. && !destination->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1709 TCMalloc_SystemReleasecxx . . $ TCMalloc_SystemRelease(5500c4293b1bbef0).(reinterpret_cast<void*>(destination->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.),
1710 static_cast<size_t>(destination->lengthcxx . . $ QTWTF/Span#length. << kPageShiftcxx . . $ QTWTF/kPageShift.));
1711 destination->decommittedcxx . . $ QTWTF/Span#decommitted. = true;
1712 }
1713 }
1714
1715 inline void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::Deletecxx . . $ QTWTF/TCMalloc_PageHeap#Delete(41397daa150afe2e).(Spancxx . . $ QTWTF/Span#* span) {
1716 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1717 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!span->free);
1718 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->length > 0);
1719 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(GetDescriptor(span->start) == span);
1720 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(GetDescriptor(span->start + span->length - 1) == span);
1721 span->sizeclasscxx . . $ QTWTF/Span#sizeclass. = 0;
1722 #ifndef NO_TCMALLOC_SAMPLEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:88:9`!
1723 span->sample = 0;
1724 #endif
1725
1726 // Coalesce -- we guarantee that "p" != 0, so no bounds checking
1727 // necessary. We do not bother resetting the stale pagemap
1728 // entries for the pieces we are merging together because we only
1729 // care about the pagemap entries for the boundaries.
1730 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1731 // Track the total size of the neighboring free spans that are committed.
1732 Lengthcxx . . $ QTWTF/Length# neighboringCommittedSpansLength = 0;
1733 #endif
1734 const PageIDcxx . . $ QTWTF/PageID# p = span->startcxx . . $ QTWTF/Span#start.;
1735 const Lengthcxx . . $ QTWTF/Length# n = span->lengthcxx . . $ QTWTF/Span#length.;
1736 Spancxx . . $ QTWTF/Span#* prev = GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p-1);
1737 if (prev != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && prev->freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`!) {
1738 // Merge preceding span into this span
1739 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(prev->start + prev->length == p);
1740 const Lengthcxx . . $ QTWTF/Length# len = prev->lengthcxx . . $ QTWTF/Span#length.;
1741 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1742 if (!prev->decommittedcxx . . $ QTWTF/Span#decommitted.)
1743 neighboringCommittedSpansLength += len;
1744 #endif
1745 mergeDecommittedStatescxx . . $ QTWTF/mergeDecommittedStates(e855eac60d60e4f1).(span, prev);
1746 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(prev);
1747 DeleteSpancxx . . $ QTWTF/DeleteSpan(41397daa150afe2e).(prev);
1748 span->startcxx . . $ QTWTF/Span#start. -= len;
1749 span->lengthcxx . . $ QTWTF/Span#length. += len;
1750 pagemap_.set(span->start, span);
1751 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'L', len);
1752 }
1753 Spancxx . . $ QTWTF/Span#* next = GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p+n);
1754 if (next != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && next->freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`!) {
1755 // Merge next span into this span
1756 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(next->start == p+n);
1757 const Lengthcxx . . $ QTWTF/Length# len = next->lengthcxx . . $ QTWTF/Span#length.;
1758 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1759 if (!next->decommittedcxx . . $ QTWTF/Span#decommitted.)
1760 neighboringCommittedSpansLength += len;
1761 #endif
1762 mergeDecommittedStatescxx . . $ QTWTF/mergeDecommittedStates(e855eac60d60e4f1).(span, next);
1763 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(next);
1764 DeleteSpancxx . . $ QTWTF/DeleteSpan(41397daa150afe2e).(next);
1765 span->lengthcxx . . $ QTWTF/Span#length. += len;
1766 pagemap_.set(span->start + span->length - 1, span);
1767 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'R', len);
1768 }
1769
1770 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'D', span->length);
1771 span->freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`! = 1;
1772 if (span->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1773 if (span->lengthcxx . . $ QTWTF/Span#length. < kMaxPagescxx . . $ QTWTF/kMaxPages.)
1774 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[span->lengthcxx . . $ QTWTF/Span#length.].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned., span);
1775 else
1776 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned., span);
1777 } else {
1778 if (span->lengthcxx . . $ QTWTF/Span#length. < kMaxPagescxx . . $ QTWTF/kMaxPages.)
1779 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[span->lengthcxx . . $ QTWTF/Span#length.].normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal., span);
1780 else
1781 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal., span);
1782 }
1783 free_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_pages_. += n;
1784
1785 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1786 if (span->decommittedcxx . . $ QTWTF/Span#decommitted.) {
1787 // If the merged span is decommitted, that means we decommitted any neighboring spans that were
1788 // committed. Update the free committed pages count.
1789 free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. -= neighboringCommittedSpansLength;
1790 } else {
1791 // If the merged span remains committed, add the deleted span's size to the free committed pages count.
1792 free_committed_pages_cxx . . $ QTWTF/TCMalloc_PageHeap#free_committed_pages_. += n;
1793 }
1794
1795 // Make sure the scavenge thread becomes active if we have enough freed pages to release some back to the system.
1796 signalScavengercxx . . $ QTWTF/TCMalloc_PageHeap#signalScavenger(49f6e7a06ebc5aa8).();
1797 #else
1798 IncrementalScavenge(n);
1799 #endif
1800
1801 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1802 }
1803
1804 #if !USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1805 void TCMalloc_PageHeap::IncrementalScavenge(Length n) {
1806 // Fast path; not yet time to release memory
1807 scavenge_counter_ -= n;
1808 if (scavenge_counter_ >= 0) return; // Not yet time to scavenge
1809
1810 // If there is nothing to release, wait for so many pages before
1811 // scavenging again. With 4K pages, this comes to 16MB of memory.
1812 static const size_t kDefaultReleaseDelay = 1 << 8;
1813
1814 // Find index of free list to scavenge
1815 size_t index = scavenge_index_ + 1;
1816 for (size_t i = 0; i < kMaxPages+1; i++) {
1817 if (index > kMaxPages) index = 0;
1818 SpanList* slist = (index == kMaxPages) ? &large_ : &free_[index];
1819 if (!DLL_IsEmpty(&slist->normal)) {
1820 // Release the last span on the normal portion of this list
1821 Span* s = slist->normal.prev;
1822 DLL_Remove(s);
1823 TCMalloc_SystemRelease(reinterpret_cast<void*>(s->start << kPageShift),
1824 static_cast<size_t>(s->length << kPageShift));
1825 s->decommitted = true;
1826 DLL_Prepend(&slist->returned, s);
1827
1828 scavenge_counter_ = std::max<size_t>(64UL, std::min<size_t>(kDefaultReleaseDelay, kDefaultReleaseDelay - (free_pages_ / kDefaultReleaseDelay)));
1829
1830 if (index == kMaxPages && !DLL_IsEmpty(&slist->normal))
1831 scavenge_index_ = index - 1;
1832 else
1833 scavenge_index_ = index;
1834 return;
1835 }
1836 index++;
1837 }
1838
1839 // Nothing to scavenge, delay for a while
1840 scavenge_counter_ = kDefaultReleaseDelay;
1841 }
1842 #endif
1843
1844 void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::RegisterSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#RegisterSizeClass(e9597f5c88419a9c).(Spancxx . . $ QTWTF/Span#* span, size_t sc) {
1845 // Associate span object with all interior pages as well
1846 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!span->free);
1847 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(GetDescriptor(span->start) == span);
1848 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(GetDescriptor(span->start+span->length-1) == span);
1849 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'C', sc);
1850 span->sizeclasscxx . . $ QTWTF/Span#sizeclass. = static_cast<unsigned int>(sc);
1851 for (Lengthcxx . . $ QTWTF/Length# i = 1; i < span->lengthcxx . . $ QTWTF/Span#length.-1; i++) {
1852 pagemap_.set(span->start+i, span);
1853 }
1854 }
1855
1856 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
1857 size_t TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::ReturnedBytescxx . . $ QTWTF/TCMalloc_PageHeap#ReturnedBytes(fe4d2d262d4164a8).() const {
1858 size_t result = 0;
1859 for (unsigned s = 0; s < kMaxPagescxx . . $ QTWTF/kMaxPages.; s++) {
1860 const int r_length = DLL_Lengthcxx . . $ QTWTF/DLL_Length(e0afbdd3ce0675a4).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.);
1861 unsigned r_pages = s * r_length;
1862 result += r_pages << kPageShiftcxx . . $ QTWTF/kPageShift.;
1863 }
1864
1865 for (Spancxx . . $ QTWTF/Span#* s = large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned..nextcxx . . $ QTWTF/Span#next.; s != &large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.; s = s->nextcxx . . $ QTWTF/Span#next.)
1866 result += s->lengthcxx . . $ QTWTF/Span#length. << kPageShiftcxx . . $ QTWTF/kPageShift.;
1867 return result;
1868 }
1869 #endif
1870
1871 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
1872 static double PagesToMB(uint64_t pages) {
1873 return (pages << kPageShift) / 1048576.0;
1874 }
1875
1876 void TCMalloc_PageHeap::Dump(TCMalloc_Printer* out) {
1877 int nonempty_sizes = 0;
1878 for (int s = 0; s < kMaxPages; s++) {
1879 if (!DLL_IsEmpty(&free_[s].normal) || !DLL_IsEmpty(&free_[s].returned)) {
1880 nonempty_sizes++;
1881 }
1882 }
1883 out->printf("------------------------------------------------\n");
1884 out->printf("PageHeap: %d sizes; %6.1f MB free\n",
1885 nonempty_sizes, PagesToMB(free_pages_));
1886 out->printf("------------------------------------------------\n");
1887 uint64_t total_normal = 0;
1888 uint64_t total_returned = 0;
1889 for (int s = 0; s < kMaxPages; s++) {
1890 const int n_length = DLL_Length(&free_[s].normal);
1891 const int r_length = DLL_Length(&free_[s].returned);
1892 if (n_length + r_length > 0) {
1893 uint64_t n_pages = s * n_length;
1894 uint64_t r_pages = s * r_length;
1895 total_normal += n_pages;
1896 total_returned += r_pages;
1897 out->printf("%6u pages * %6u spans ~ %6.1f MB; %6.1f MB cum"
1898 "; unmapped: %6.1f MB; %6.1f MB cum\n",
1899 s,
1900 (n_length + r_length),
1901 PagesToMB(n_pages + r_pages),
1902 PagesToMB(total_normal + total_returned),
1903 PagesToMB(r_pages),
1904 PagesToMB(total_returned));
1905 }
1906 }
1907
1908 uint64_t n_pages = 0;
1909 uint64_t r_pages = 0;
1910 int n_spans = 0;
1911 int r_spans = 0;
1912 out->printf("Normal large spans:\n");
1913 for (Span* s = large_.normal.next; s != &large_.normal; s = s->next) {
1914 out->printf(" [ %6" PRIuS " pages ] %6.1f MB\n",
1915 s->length, PagesToMB(s->length));
1916 n_pages += s->length;
1917 n_spans++;
1918 }
1919 out->printf("Unmapped large spans:\n");
1920 for (Span* s = large_.returned.next; s != &large_.returned; s = s->next) {
1921 out->printf(" [ %6" PRIuS " pages ] %6.1f MB\n",
1922 s->length, PagesToMB(s->length));
1923 r_pages += s->length;
1924 r_spans++;
1925 }
1926 total_normal += n_pages;
1927 total_returned += r_pages;
1928 out->printf(">255 large * %6u spans ~ %6.1f MB; %6.1f MB cum"
1929 "; unmapped: %6.1f MB; %6.1f MB cum\n",
1930 (n_spans + r_spans),
1931 PagesToMB(n_pages + r_pages),
1932 PagesToMB(total_normal + total_returned),
1933 PagesToMB(r_pages),
1934 PagesToMB(total_returned));
1935 }
1936 #endif
1937
1938 bool TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::GrowHeapcxx . . $ QTWTF/TCMalloc_PageHeap#GrowHeap(31596a199e1d8a50).(Lengthcxx . . $ QTWTF/Length# n) {
1939 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(kMaxPages >= kMinSystemAlloc);
1940 if (n > kMaxValidPagescxx . . $ QTWTF/kMaxValidPages.) return false;
1941 Lengthcxx . . $ QTWTF/Length# ask = (n>kMinSystemAlloccxx . . $ QTWTF/kMinSystemAlloc.) ? n : static_cast<Lengthcxx . . $ QTWTF/Length#>(kMinSystemAlloccxx . . $ QTWTF/kMinSystemAlloc.);
1942 size_t actual_size;
1943 void* ptr = TCMalloc_SystemAlloccxx . . $ TCMalloc_SystemAlloc(b27b84a2970bf05a).(ask << kPageShiftcxx . . $ QTWTF/kPageShift., &actual_size, kPageSizecxx . . $ QTWTF/kPageSize.);
1944 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
1945 if (n < ask) {
1946 // Try growing just "n" pages
1947 ask = n;
1948 ptr = TCMalloc_SystemAlloccxx . . $ TCMalloc_SystemAlloc(b27b84a2970bf05a).(ask << kPageShiftcxx . . $ QTWTF/kPageShift., &actual_size, kPageSizecxx . . $ QTWTF/kPageSize.);
1949 }
1950 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return false;
1951 }
1952 ask = actual_size >> kPageShiftcxx . . $ QTWTF/kPageShift.;
1953
1954 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
1955 pages_committed_since_last_scavenge_cxx . . $ QTWTF/TCMalloc_PageHeap#pages_committed_since_last_scavenge_. += ask;
1956 #endif
1957
1958 uint64_tcxx . . $ uint64_t# old_system_bytes = system_bytes_cxx . . $ QTWTF/TCMalloc_PageHeap#system_bytes_.;
1959 system_bytes_cxx . . $ QTWTF/TCMalloc_PageHeap#system_bytes_. += (ask << kPageShiftcxx . . $ QTWTF/kPageShift.);
1960 const PageIDcxx . . $ QTWTF/PageID# p = reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(ptr) >> kPageShiftcxx . . $ QTWTF/kPageShift.;
1961 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(p > 0);
1962
1963 // If we have already a lot of pages allocated, just pre allocate a bunch of
1964 // memory for the page map. This prevents fragmentation by pagemap metadata
1965 // when a program keeps allocating and freeing large blocks.
1966
1967 if (old_system_bytes < kPageMapBigAllocationThresholdcxx . . $ QTWTF/kPageMapBigAllocationThreshold.
1968 && system_bytes_cxx . . $ QTWTF/TCMalloc_PageHeap#system_bytes_. >= kPageMapBigAllocationThresholdcxx . . $ QTWTF/kPageMapBigAllocationThreshold.) {
1969 pagemap_.PreallocateMoreMemory();
1970 }
1971
1972 // Make sure pagemap_ has entries for all of the new pages.
1973 // Plus ensure one before and one after so coalescing code
1974 // does not need bounds-checking.
1975 if (pagemap_.Ensure(p-1, ask+2)) {
1976 // Pretend the new area is allocated and then Delete() it to
1977 // cause any necessary coalescing to occur.
1978 //
1979 // We do not adjust free_pages_ here since Delete() will do it for us.
1980 Spancxx . . $ QTWTF/Span#* span = NewSpancxx . . $ QTWTF/NewSpan(fe2cd51a44db566c).(p, ask);
1981 RecordSpancxx . . $ QTWTF/TCMalloc_PageHeap#RecordSpan(41397daa150afe2e).(span);
1982 Deletecxx . . $ QTWTF/TCMalloc_PageHeap#Delete(41397daa150afe2e).(span);
1983 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
1984 return true;
1985 } else {
1986 // We could not allocate memory within "pagemap_"
1987 // TODO: Once we can return memory to the system, return the new span
1988 return false;
1989 }
1990 }
1991
1992 bool TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::Checkcxx . . $ QTWTF/TCMalloc_PageHeap#Check(c9857a73d68e59ba).() {
1993 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(free_[0].normal.next == &free_[0].normal);
1994 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(free_[0].returned.next == &free_[0].returned);
1995 CheckListcxx . . $ QTWTF/TCMalloc_PageHeap#CheckList(3a87bee1a6ddd5ff).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal., kMaxPagescxx . . $ QTWTF/kMaxPages., 1000000000);
1996 CheckListcxx . . $ QTWTF/TCMalloc_PageHeap#CheckList(3a87bee1a6ddd5ff).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned., kMaxPagescxx . . $ QTWTF/kMaxPages., 1000000000);
1997 for (Lengthcxx . . $ QTWTF/Length# s = 1; s < kMaxPagescxx . . $ QTWTF/kMaxPages.; s++) {
1998 CheckListcxx . . $ QTWTF/TCMalloc_PageHeap#CheckList(3a87bee1a6ddd5ff).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal., s, s);
1999 CheckListcxx . . $ QTWTF/TCMalloc_PageHeap#CheckList(3a87bee1a6ddd5ff).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned., s, s);
2000 }
2001 return true;
2002 }
2003
2004 #if ASSERT_DISABLEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:71:9`!
2005 bool TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::CheckListcxx . . $ QTWTF/TCMalloc_PageHeap#CheckList(3a87bee1a6ddd5ff).(Spancxx . . $ QTWTF/Span#*, Lengthcxx . . $ QTWTF/Length#, Lengthcxx . . $ QTWTF/Length#) {
2006 return true;
2007 }
2008 #else
2009 bool TCMalloc_PageHeap::CheckList(Span* list, Length min_pages, Length max_pages) {
2010 for (Span* s = list->next; s != list; s = s->next) {
2011 CHECK_CONDITION(s->free);
2012 CHECK_CONDITION(s->length >= min_pages);
2013 CHECK_CONDITION(s->length <= max_pages);
2014 CHECK_CONDITION(GetDescriptor(s->start) == s);
2015 CHECK_CONDITION(GetDescriptor(s->start+s->length-1) == s);
2016 }
2017 return true;
2018 }
2019 #endif
2020
2021 static void ReleaseFreeListcxx . . $ QTWTF/ReleaseFreeList(e855eac60d60e4f1).(Spancxx . . $ QTWTF/Span#* list, Spancxx . . $ QTWTF/Span#* returned) {
2022 // Walk backwards through list so that when we push these
2023 // spans on the "returned" list, we preserve the order.
2024 while (!DLL_IsEmptycxx . . $ QTWTF/DLL_IsEmpty(8acc2b62ecd0f74).(list)) {
2025 Spancxx . . $ QTWTF/Span#* s = list->prevcxx . . $ QTWTF/Span#prev.;
2026 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(s);
2027 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(returned, s);
2028 TCMalloc_SystemReleasecxx . . $ TCMalloc_SystemRelease(5500c4293b1bbef0).(reinterpret_cast<void*>(s->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.),
2029 static_cast<size_t>(s->lengthcxx . . $ QTWTF/Span#length. << kPageShiftcxx . . $ QTWTF/kPageShift.));
2030 }
2031 }
2032
2033 void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::ReleaseFreePagescxx . . $ QTWTF/TCMalloc_PageHeap#ReleaseFreePages(49f6e7a06ebc5aa8).() {
2034 for (Lengthcxx . . $ QTWTF/Length# s = 0; s < kMaxPagescxx . . $ QTWTF/kMaxPages.; s++) {
2035 ReleaseFreeListcxx . . $ QTWTF/ReleaseFreeList(e855eac60d60e4f1).(&free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal., &free_cxx . . $ QTWTF/TCMalloc_PageHeap#free_.[s].returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.);
2036 }
2037 ReleaseFreeListcxx . . $ QTWTF/ReleaseFreeList(e855eac60d60e4f1).(&large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..normalcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#normal., &large_cxx . . $ QTWTF/TCMalloc_PageHeap#large_..returnedcxx . . $ QTWTF/TCMalloc_PageHeap#SpanList#returned.);
2038 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(Check());
2039 }
2040
2041 //-------------------------------------------------------------------
2042 // Free list
2043 //-------------------------------------------------------------------
2044
2045 class TCMalloc_ThreadCache_FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList# {
2046 private:
2047 void* list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_.; // Linked list of nodes
2048 uint16_tcxx . . $ uint16_t# length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.; // Current length
2049 uint16_tcxx . . $ uint16_t# lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_.; // Low water mark for list length
2050
2051 public:
2052 void Initcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#Init(49f6e7a06ebc5aa8).() {
2053 list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2054 length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. = 0;
2055 lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_. = 0;
2056 }
2057
2058 // Return current length of list
2059 int lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).() const {
2060 return length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.;
2061 }
2062
2063 // Is list empty?
2064 bool emptycxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#empty(50ce9a9e25b4a850).() const {
2065 return list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2066 }
2067
2068 // Low-water mark management
2069 int lowwatermarkcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowwatermark(455f465bc33b4cdf).() const { return lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_.; }
2070 void clear_lowwatermarkcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#clear_lowwatermark(49f6e7a06ebc5aa8).() { lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_. = length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.; }
2071
2072 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void Pushcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#Push(5d22bdacc48458e8).(void* ptr) {
2073 SLL_Pushcxx . . $ QTWTF/SLL_Push(21d600c443e4dd01).(&list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_., ptr);
2074 length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.++;
2075 }
2076
2077 void PushRangecxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#PushRange(4d99a0c3ff456823).(int N, void *start, void *end) {
2078 SLL_PushRangecxx . . $ QTWTF/SLL_PushRange(40371abbd1d86883).(&list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_., start, end);
2079 length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. = length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. + static_cast<uint16_tcxx . . $ uint16_t#>(N);
2080 }
2081
2082 void PopRangecxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#PopRange(233423f5f6dce9eb).(int N, void **start, void **end) {
2083 SLL_PopRangecxx . . $ QTWTF/SLL_PopRange(8e043882d7b13f1f).(&list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_., N, start, end);
2084 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(length_ >= N);
2085 length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. = length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. - static_cast<uint16_tcxx . . $ uint16_t#>(N);
2086 if (length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. < lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_.) lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_. = length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.;
2087 }
2088
2089 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void* Popcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#Pop(50c7df7de5344ebb).() {
2090 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(list_ != NULL);
2091 length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.--;
2092 if (length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_. < lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_.) lowater_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowater_. = length_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length_.;
2093 return SLL_Popcxx . . $ QTWTF/SLL_Pop(8350835cdea29fce).(&list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_.);
2094 }
2095
2096 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
2097 template <class Finder, class Reader>
2098 void enumerateFreeObjectscxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#enumerateFreeObjects(36a71afa913f8f0f).(Finder& finder, const Reader& reader)
2099 {
2100 for (void* nextObject = list_cxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#list_.; nextObject; nextObject = *reader(reinterpret_cast<void**>(nextObject)))
2101 finder.visit(nextObject);
2102 }
2103 #endif
2104 };
2105
2106 //-------------------------------------------------------------------
2107 // Data kept per thread
2108 //-------------------------------------------------------------------
2109
2110 class TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache# {
2111 private:
2112 typedef TCMalloc_ThreadCache_FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList# FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache#FreeList#;
2113 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2114 typedef DWORD ThreadIdentifier;
2115 #else
2116 typedef pthread_t ThreadIdentifiercxx . . $ QTWTF/TCMalloc_ThreadCache#ThreadIdentifier#;
2117 #endif
2118
2119 size_t size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_.; // Combined size of data
2120 ThreadIdentifiercxx . . $ QTWTF/TCMalloc_ThreadCache#ThreadIdentifier# tid_cxx . . $ QTWTF/TCMalloc_ThreadCache#tid_.; // Which thread owns it
2121 bool in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_.; // Called pthread_setspecific?
2122 FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache#FreeList# list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[kNumClassescxx . . $ QTWTF/kNumClasses.]; // Array indexed by size-class
2123
2124 // We sample allocations, biased by the size of the allocation
2125 uint32_tcxx . . $ uint32_t# rnd_cxx . . $ QTWTF/TCMalloc_ThreadCache#rnd_.; // Cheap random number generator
2126 size_t bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_.; // Bytes until we sample next
2127
2128 // Allocate a new heap. REQUIRES: pageheap_lock is held.
2129 static inline TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* NewHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#NewHeap(9cca835e35801c07).(ThreadIdentifiercxx . . $ QTWTF/TCMalloc_ThreadCache#ThreadIdentifier# tid);
2130
2131 // Use only as pthread thread-specific destructor function.
2132 static void DestroyThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DestroyThreadCache(5d22bdacc48458e8).(void* ptr);
2133 public:
2134 // All ThreadCache objects are kept in a linked list (for stats collection)
2135 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.;
2136 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_.;
2137
2138 void Initcxx . . $ QTWTF/TCMalloc_ThreadCache#Init(2c44cd906ae4e829).(ThreadIdentifiercxx . . $ QTWTF/TCMalloc_ThreadCache#ThreadIdentifier# tid);
2139 void Cleanupcxx . . $ QTWTF/TCMalloc_ThreadCache#Cleanup(49f6e7a06ebc5aa8).();
2140
2141 // Accessors (mostly just for printing stats)
2142 int freelist_lengthcxx . . $ QTWTF/TCMalloc_ThreadCache#freelist_length(e3044d25979e9615).(size_t cl) const { return list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl].lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).(); }
2143
2144 // Total byte size in cache
2145 size_t Sizecxx . . $ QTWTF/TCMalloc_ThreadCache#Size(fe4d2d262d4164a8).() const { return size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_.; }
2146
2147 void* Allocatecxx . . $ QTWTF/TCMalloc_ThreadCache#Allocate(bfcfa4d6b7f7ef64).(size_t size);
2148 void Deallocatecxx . . $ QTWTF/TCMalloc_ThreadCache#Deallocate(5500c4293b1bbef0).(void* ptr, size_t size_class);
2149
2150 void FetchFromCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#FetchFromCentralCache(6714b5f2551eea49).(size_t cl, size_t allocationSize);
2151 void ReleaseToCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#ReleaseToCentralCache(f9942d3529bc31bc).(size_t cl, int N);
2152 void Scavengecxx . . $ QTWTF/TCMalloc_ThreadCache#Scavenge(49f6e7a06ebc5aa8).();
2153 void Printcxx . . $ QTWTF/TCMalloc_ThreadCache#Print(83f5f38750778ac8).() const;
2154
2155 // Record allocation of "k" bytes. Return true iff allocation
2156 // should be sampled
2157 bool SampleAllocationcxx . . $ QTWTF/TCMalloc_ThreadCache#SampleAllocation(31596a199e1d8a50).(size_t k);
2158
2159 // Pick next sampling point
2160 void PickNextSamplecxx . . $ QTWTF/TCMalloc_ThreadCache#PickNextSample(2c44cd906ae4e829).(size_t k);
2161
2162 static void InitModulecxx . . $ QTWTF/TCMalloc_ThreadCache#InitModule(49f6e7a06ebc5aa8).();
2163 static void InitTSDcxx . . $ QTWTF/TCMalloc_ThreadCache#InitTSD(49f6e7a06ebc5aa8).();
2164 static TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* GetThreadHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#GetThreadHeap(89f09ab4cfc717c4).();
2165 static TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* GetCachecxx . . $ QTWTF/TCMalloc_ThreadCache#GetCache(89f09ab4cfc717c4).();
2166 static TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* GetCacheIfPresentcxx . . $ QTWTF/TCMalloc_ThreadCache#GetCacheIfPresent(89f09ab4cfc717c4).();
2167 static TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* CreateCacheIfNecessarycxx . . $ QTWTF/TCMalloc_ThreadCache#CreateCacheIfNecessary(89f09ab4cfc717c4).();
2168 static void DeleteCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DeleteCache(93c22c671bc633b2).(TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap);
2169 static void BecomeIdlecxx . . $ QTWTF/TCMalloc_ThreadCache#BecomeIdle(49f6e7a06ebc5aa8).();
2170 static void RecomputeThreadCacheSizecxx . . $ QTWTF/TCMalloc_ThreadCache#RecomputeThreadCacheSize(49f6e7a06ebc5aa8).();
2171
2172 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
2173 template <class Finder, class Reader>
2174 void enumerateFreeObjectscxx . . $ QTWTF/TCMalloc_ThreadCache#enumerateFreeObjects(36a71afa913f8f0f).(Finder& finder, const Reader& reader)
2175 {
2176 for (unsigned sizeClass = 0; sizeClass < kNumClassescxx . . $ QTWTF/kNumClasses.; sizeClass++)
2177 list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[sizeClass].enumerateFreeObjectscxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#enumerateFreeObjects(36a71afa913f8f0f).(finder, reader);
2178 }
2179 #endif
2180 };
2181
2182 //-------------------------------------------------------------------
2183 // Data kept per size-class in central cache
2184 //-------------------------------------------------------------------
2185
2186 class TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList# {
2187 public:
2188 void Initcxx . . $ QTWTF/TCMalloc_Central_FreeList#Init(2c44cd906ae4e829).(size_t cl);
2189
2190 // These methods all do internal locking.
2191
2192 // Insert the specified range into the central freelist. N is the number of
2193 // elements in the range.
2194 void InsertRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#InsertRange(5be095a8278d2bf5).(void *start, void *end, int N);
2195
2196 // Returns the actual number of fetched elements into N.
2197 void RemoveRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#RemoveRange(83f0a9f02807670).(void **start, void **end, int *N);
2198
2199 // Returns the number of free objects in cache.
2200 size_t lengthcxx . . $ QTWTF/TCMalloc_Central_FreeList#length(f708dce9a8856c70).() {
2201 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_.);
2202 return counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_.;
2203 }
2204
2205 // Returns the number of free objects in the transfer cache.
2206 int tc_lengthcxx . . $ QTWTF/TCMalloc_Central_FreeList#tc_length(b126dc7c1de90089).() {
2207 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_.);
2208 return used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_. * num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.];
2209 }
2210
2211 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
2212 template <class Finder, class Reader>
2213 void enumerateFreeObjectscxx . . $ QTWTF/TCMalloc_Central_FreeList#enumerateFreeObjects(4635a9140c7daef0).(Finder& finder, const Reader& reader, TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#* remoteCentralFreeList)
2214 {
2215 for (Spancxx . . $ QTWTF/Span#* span = &empty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#empty_.; span && span != &empty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#empty_.; span = (span->nextcxx . . $ QTWTF/Span#next. ? reader(span->nextcxx . . $ QTWTF/Span#next.) : 0))
2216 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!span->objects);
2217
2218 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!nonempty_.objects);
2219 static const ptrdiff_tcxx . . $ ptrdiff_t# nonemptyOffset = reinterpret_cast<const char*>(&nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_.) - reinterpret_cast<const char*>(this);
2220
2221 Spancxx . . $ QTWTF/Span#* remoteNonempty = reinterpret_cast<Spancxx . . $ QTWTF/Span#*>(reinterpret_cast<char*>(remoteCentralFreeList) + nonemptyOffset);
2222 Spancxx . . $ QTWTF/Span#* remoteSpan = nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_..nextcxx . . $ QTWTF/Span#next.;
2223
2224 for (Spancxx . . $ QTWTF/Span#* span = reader(remoteSpan); span && remoteSpan != remoteNonempty; remoteSpan = span->nextcxx . . $ QTWTF/Span#next., span = (span->nextcxx . . $ QTWTF/Span#next. ? reader(span->nextcxx . . $ QTWTF/Span#next.) : 0)) {
2225 for (void* nextObject = span->objectscxx . . $ QTWTF/Span#objects.; nextObject; nextObject = *reader(reinterpret_cast<void**>(nextObject)))
2226 finder.visit(nextObject);
2227 }
2228 }
2229 #endif
2230
2231 private:
2232 // REQUIRES: lock_ is held
2233 // Remove object from cache and return.
2234 // Return NULL if no free entries in cache.
2235 void* FetchFromSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpans(50c7df7de5344ebb).();
2236
2237 // REQUIRES: lock_ is held
2238 // Remove object from cache and return. Fetches
2239 // from pageheap if cache is empty. Only returns
2240 // NULL on allocation failure.
2241 void* FetchFromSpansSafecxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpansSafe(50c7df7de5344ebb).();
2242
2243 // REQUIRES: lock_ is held
2244 // Release a linked list of objects to spans.
2245 // May temporarily release lock_.
2246 void ReleaseListToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseListToSpans(5d22bdacc48458e8).(void *start);
2247
2248 // REQUIRES: lock_ is held
2249 // Release an object to spans.
2250 // May temporarily release lock_.
2251 void ReleaseToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseToSpans(5d22bdacc48458e8).(void* object);
2252
2253 // REQUIRES: lock_ is held
2254 // Populate cache by fetching from the page heap.
2255 // May temporarily release lock_.
2256 void Populatecxx . . $ QTWTF/TCMalloc_Central_FreeList#Populate(49f6e7a06ebc5aa8).();
2257
2258 // REQUIRES: lock is held.
2259 // Tries to make room for a TCEntry. If the cache is full it will try to
2260 // expand it at the cost of some other cache size. Return false if there is
2261 // no space.
2262 bool MakeCacheSpacecxx . . $ QTWTF/TCMalloc_Central_FreeList#MakeCacheSpace(c9857a73d68e59ba).();
2263
2264 // REQUIRES: lock_ for locked_size_class is held.
2265 // Picks a "random" size class to steal TCEntry slot from. In reality it
2266 // just iterates over the sizeclasses but does so without taking a lock.
2267 // Returns true on success.
2268 // May temporarily lock a "random" size class.
2269 static bool EvictRandomSizeClasscxx . . $ QTWTF/TCMalloc_Central_FreeList#EvictRandomSizeClass(2a1b3e200b6293a).(size_t locked_size_class, bool force);
2270
2271 // REQUIRES: lock_ is *not* held.
2272 // Tries to shrink the Cache. If force is true it will relase objects to
2273 // spans if it allows it to shrink the cache. Return false if it failed to
2274 // shrink the cache. Decrements cache_size_ on succeess.
2275 // May temporarily take lock_. If it takes lock_, the locked_size_class
2276 // lock is released to the thread from holding two size class locks
2277 // concurrently which could lead to a deadlock.
2278 bool ShrinkCachecxx . . $ QTWTF/TCMalloc_Central_FreeList#ShrinkCache(9609253e83e89946).(int locked_size_class, bool force);
2279
2280 // This lock protects all the data members. cached_entries and cache_size_
2281 // may be looked at without holding the lock.
2282 SpinLockcxx . . $ SpinLock# lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_.;
2283
2284 // We keep linked lists of empty and non-empty spans.
2285 size_t size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.; // My size class
2286 Spancxx . . $ QTWTF/Span# empty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#empty_.; // Dummy header for list of empty spans
2287 Spancxx . . $ QTWTF/Span# nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_.; // Dummy header for list of non-empty spans
2288 size_t counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_.; // Number of free objects in cache entry
2289
2290 // Here we reserve space for TCEntry cache slots. Since one size class can
2291 // end up getting all the TCEntries quota in the system we just preallocate
2292 // sufficient number of entries here.
2293 TCEntrycxx . . $ QTWTF/TCEntry# tc_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#tc_slots_.[kNumTransferEntriescxx . . $ QTWTF/kNumTransferEntries.];
2294
2295 // Number of currently used cached entries in tc_slots_. This variable is
2296 // updated under a lock but can be read without one.
2297 int32_tcxx . . $ int32_t# used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_.;
2298 // The current number of slots for this size class. This is an
2299 // adaptive value that is increased if there is lots of traffic
2300 // on a given size class.
2301 int32_tcxx . . $ int32_t# cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.;
2302 };
2303
2304 // Pad each CentralCache object to multiple of 64 bytes
2305 class TCMalloc_Central_FreeListPaddedcxx . . $ QTWTF/TCMalloc_Central_FreeListPadded# : public TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList# {
2306 private:
2307 char pad_cxx . . $ QTWTF/TCMalloc_Central_FreeListPadded#pad_.[(64 - (sizeof(TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#) % 64)) % 64];
2308 };
2309
2310 //-------------------------------------------------------------------
2311 // Global variables
2312 //-------------------------------------------------------------------
2313
2314 // Central cache -- a collection of free-lists, one per size-class.
2315 // We have a separate lock per free-list to reduce contention.
2316 static TCMalloc_Central_FreeListPaddedcxx . . $ QTWTF/TCMalloc_Central_FreeListPadded# central_cachecxx . . $ QTWTF/central_cache.[kNumClassescxx . . $ QTWTF/kNumClasses.];
2317
2318 // Page-level allocator
2319 static SpinLockcxx . . $ SpinLock# pageheap_lockcxx . . $ QTWTF/pageheap_lock. = SPINLOCK_INITIALIZERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/TCSpinLock.h:134:9`!;
2320 static void* pageheap_memorycxx . . $ QTWTF/pageheap_memory.[(sizeof(TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#) + sizeof(void*) - 1) / sizeof(void*)];
2321 static bool phinitedcxx . . $ QTWTF/phinited. = false;
2322
2323 // Avoid extra level of indirection by making "pageheap" be just an alias
2324 // of pageheap_memory.
2325 typedef unioncxx . . $ QTWTF/$anonymous_type_509981f424c59dd5_0# {
2326 void* m_memorycxx . . $ QTWTF/$anonymous_type_509981f424c59dd5_0#m_memory.;
2327 TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#* m_pageHeapcxx . . $ QTWTF/$anonymous_type_509981f424c59dd5_0#m_pageHeap.;
2328 } PageHeapUnioncxx . . $ QTWTF/PageHeapUnion#;
2329
2330 static inline TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#* getPageHeapcxx . . $ QTWTF/getPageHeap(9f4c8545f140564).()
2331 {
2332 PageHeapUnioncxx . . $ QTWTF/PageHeapUnion# u = { &pageheap_memorycxx . . $ QTWTF/pageheap_memory.[0] };
2333 return u.m_pageHeapcxx . . $ QTWTF/$anonymous_type_509981f424c59dd5_0#m_pageHeap.;
2334 }
2335
2336 #define pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`! getPageHeap()
2337
2338 #if USE_BACKGROUND_THREAD_TO_SCAVENGE_MEMORYcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:103:9`!
2339
2340 #if !HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(DISPATCH_H)
2341 #if OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(WINDOWS)
2342 static void sleep(unsigned seconds)
2343 {
2344 ::Sleep(seconds * 1000);
2345 }
2346 #endif
2347
2348 void TCMalloc_PageHeapcxx . . $ QTWTF/TCMalloc_PageHeap#::scavengerThreadcxx . . $ QTWTF/TCMalloc_PageHeap#scavengerThread(8df32a62017fbbf6).()
2349 {
2350 #if HAVEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:46:9`!(PTHREAD_SETNAME_NP)
2351 pthread_setname_np("JavaScriptCore: FastMalloc scavenger");
2352 #endif
2353
2354 while (1) {
2355 if (!shouldContinueScavengingcxx . . $ QTWTF/TCMalloc_PageHeap#shouldContinueScavenging(50ce9a9e25b4a850).()) {
2356 pthread_mutex_lock(&m_scavengeMutexcxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeMutex.);
2357 m_scavengeThreadActivecxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeThreadActive. = false;
2358 // Block until there are enough freed pages to release back to the system.
2359 pthread_cond_wait(&m_scavengeConditioncxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeCondition., &m_scavengeMutexcxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeMutex.);
2360 m_scavengeThreadActivecxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeThreadActive. = true;
2361 pthread_mutex_unlock(&m_scavengeMutexcxx . . $ QTWTF/TCMalloc_PageHeap#m_scavengeMutex.);
2362 }
2363 sleep(kScavengeTimerDelayInSecondscxx . . $ QTWTF/kScavengeTimerDelayInSeconds.);
2364 {
2365 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
2366 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->scavengecxx . . $ QTWTF/TCMalloc_PageHeap#scavenge(49f6e7a06ebc5aa8).();
2367 }
2368 }
2369 }
2370
2371 #else
2372
2373 void TCMalloc_PageHeap::periodicScavenge()
2374 {
2375 {
2376 SpinLockHolder h(&pageheap_lock);
2377 pageheap->scavenge();
2378 }
2379
2380 if (!shouldContinueScavenging()) {
2381 m_scavengingScheduled = false;
2382 dispatch_suspend(m_scavengeTimer);
2383 }
2384 }
2385 #endif // HAVE(DISPATCH_H)
2386
2387 #endif
2388
2389 // If TLS is available, we also store a copy
2390 // of the per-thread object in a __thread variable
2391 // since __thread variables are faster to read
2392 // than pthread_getspecific(). We still need
2393 // pthread_setspecific() because __thread
2394 // variables provide no way to run cleanup
2395 // code when a thread is destroyed.
2396 #ifdef HAVE_TLS
2397 static __thread TCMalloc_ThreadCache *threadlocal_heap;
2398 #endif
2399 // Thread-specific key. Initialization here is somewhat tricky
2400 // because some Linux startup code invokes malloc() before it
2401 // is in a good enough state to handle pthread_keycreate().
2402 // Therefore, we use TSD keys only after tsd_inited is set to true.
2403 // Until then, we use a slow path to get the heap object.
2404 static bool tsd_initedcxx . . $ QTWTF/tsd_inited. = false;
2405 static pthread_key_t heap_keycxx . . $ QTWTF/heap_key.;
2406 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2407 DWORD tlsIndex = TLS_OUT_OF_INDEXES;
2408 #endif
2409
2410 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void setThreadHeapcxx . . $ QTWTF/setThreadHeap(93c22c671bc633b2).(TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap)
2411 {
2412 // still do pthread_setspecific when using MSVC fast TLS to
2413 // benefit from the delete callback.
2414 pthread_setspecific(heap_keycxx . . $ QTWTF/heap_key., heap);
2415 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2416 TlsSetValue(tlsIndex, heap);
2417 #endif
2418 }
2419
2420 // Allocator for thread heaps
2421 static PageHeapAllocatorcxx . . $ QTWTF/PageHeapAllocator#<TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#> threadheap_allocatorcxx . . $ QTWTF/threadheap_allocator.;
2422
2423 // Linked list of heap objects. Protected by pageheap_lock.
2424 static TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* thread_heapscxx . . $ QTWTF/thread_heaps. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2425 static int thread_heap_countcxx . . $ QTWTF/thread_heap_count. = 0;
2426
2427 // Overall thread cache size. Protected by pageheap_lock.
2428 static size_t overall_thread_cache_sizecxx . . $ QTWTF/overall_thread_cache_size. = kDefaultOverallThreadCacheSizecxx . . $ QTWTF/kDefaultOverallThreadCacheSize.;
2429
2430 // Global per-thread cache size. Writes are protected by
2431 // pageheap_lock. Reads are done without any locking, which should be
2432 // fine as long as size_t can be written atomically and we don't place
2433 // invariants between this variable and other pieces of state.
2434 static volatile size_t per_thread_cache_sizecxx . . $ QTWTF/per_thread_cache_size. = kMaxThreadCacheSizecxx . . $ QTWTF/kMaxThreadCacheSize.;
2435
2436 //-------------------------------------------------------------------
2437 // Central cache implementation
2438 //-------------------------------------------------------------------
2439
2440 void TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::Initcxx . . $ QTWTF/TCMalloc_Central_FreeList#Init(2c44cd906ae4e829).(size_t cl) {
2441 lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_..Initcxx . . $ TCMalloc_SpinLock#Init(49f6e7a06ebc5aa8).();
2442 size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_. = cl;
2443 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&empty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#empty_.);
2444 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_.);
2445 counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_. = 0;
2446
2447 cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_. = 1;
2448 used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_. = 0;
2449 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(cache_size_ <= kNumTransferEntries);
2450 }
2451
2452 void TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::ReleaseListToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseListToSpans(5d22bdacc48458e8).(void* start) {
2453 while (start) {
2454 void *next = SLL_Nextcxx . . $ QTWTF/SLL_Next(9f162e79bfc6c74).(start);
2455 ReleaseToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseToSpans(5d22bdacc48458e8).(start);
2456 start = next;
2457 }
2458 }
2459
2460 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::ReleaseToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseToSpans(5d22bdacc48458e8).(void* object) {
2461 const PageIDcxx . . $ QTWTF/PageID# p = reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(object) >> kPageShiftcxx . . $ QTWTF/kPageShift.;
2462 Spancxx . . $ QTWTF/Span#* span = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p);
2463 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span != NULL);
2464 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->refcount > 0);
2465
2466 // If span is empty, move it to non-empty list
2467 if (span->objectscxx . . $ QTWTF/Span#objects. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
2468 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(span);
2469 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_., span);
2470 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'N', 0);
2471 }
2472
2473 // The following check is expensive, so it is disabled by default
2474 if (false) {
2475 // Check that object does not occur in list
2476 unsigned got = 0;
2477 for (void* p = span->objectscxx . . $ QTWTF/Span#objects.; p != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; p = *((void**) p)) {
2478 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(p != object);
2479 got++;
2480 }
2481 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(got + span->refcount ==
2482 (span->length<<kPageShift)/ByteSizeForClass(span->sizeclass));
2483 }
2484
2485 counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_.++;
2486 span->refcountcxx . . $ QTWTF/Span#refcount.--;
2487 if (span->refcountcxx . . $ QTWTF/Span#refcount. == 0) {
2488 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, '#', 0);
2489 counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_. -= (span->lengthcxx . . $ QTWTF/Span#length.<<kPageShiftcxx . . $ QTWTF/kPageShift.) / ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(span->sizeclasscxx . . $ QTWTF/Span#sizeclass.);
2490 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(span);
2491
2492 // Release central list lock while operating on pageheap
2493 lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_..Unlockcxx . . $ TCMalloc_SpinLock#Unlock(49f6e7a06ebc5aa8).();
2494 {
2495 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
2496 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->Deletecxx . . $ QTWTF/TCMalloc_PageHeap#Delete(41397daa150afe2e).(span);
2497 }
2498 lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_..Lockcxx . . $ TCMalloc_SpinLock#Lock(49f6e7a06ebc5aa8).();
2499 } else {
2500 *(reinterpret_cast<void**>(object)) = span->objectscxx . . $ QTWTF/Span#objects.;
2501 span->objectscxx . . $ QTWTF/Span#objects. = object;
2502 }
2503 }
2504
2505 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! bool TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::EvictRandomSizeClasscxx . . $ QTWTF/TCMalloc_Central_FreeList#EvictRandomSizeClass(2a1b3e200b6293a).(
2506 size_t locked_size_class, bool force) {
2507 static int race_counter = 0;
2508 int t = race_counter++; // Updated without a lock, but who cares.
2509 if (t >= static_cast<int>(kNumClassescxx . . $ QTWTF/kNumClasses.)) {
2510 while (t >= static_cast<int>(kNumClassescxx . . $ QTWTF/kNumClasses.)) {
2511 t -= kNumClassescxx . . $ QTWTF/kNumClasses.;
2512 }
2513 race_counter = t;
2514 }
2515 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(t >= 0);
2516 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(t < static_cast<int>(kNumClasses));
2517 if (t == static_cast<int>(locked_size_class)) return false;
2518 return central_cachecxx . . $ QTWTF/central_cache.[t].ShrinkCachecxx . . $ QTWTF/TCMalloc_Central_FreeList#ShrinkCache(9609253e83e89946).(static_cast<int>(locked_size_class), force);
2519 }
2520
2521 bool TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::MakeCacheSpacecxx . . $ QTWTF/TCMalloc_Central_FreeList#MakeCacheSpace(c9857a73d68e59ba).() {
2522 // Is there room in the cache?
2523 if (used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_. < cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.) return true;
2524 // Check if we can expand this cache?
2525 if (cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_. == kNumTransferEntriescxx . . $ QTWTF/kNumTransferEntries.) return false;
2526 // Ok, we'll try to grab an entry from some other size class.
2527 if (EvictRandomSizeClasscxx . . $ QTWTF/TCMalloc_Central_FreeList#EvictRandomSizeClass(2a1b3e200b6293a).(size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_., false) ||
2528 EvictRandomSizeClasscxx . . $ QTWTF/TCMalloc_Central_FreeList#EvictRandomSizeClass(2a1b3e200b6293a).(size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_., true)) {
2529 // Succeeded in evicting, we're going to make our cache larger.
2530 cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.++;
2531 return true;
2532 }
2533 return false;
2534 }
2535
2536
2537 namespacecxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/ {
2538 class LockInvertercxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter# {
2539 private:
2540 SpinLockcxx . . $ SpinLock# *held_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#held_., *temp_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#temp_.;
2541 public:
2542 inline explicit LockInvertercxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#LockInverter(9813e7c37c6f3998).(SpinLockcxx . . $ SpinLock#* held, SpinLockcxx . . $ SpinLock# *temp)
2543 : held_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#held_.(held), temp_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#temp_.(temp) { held_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#held_.->Unlockcxx . . $ TCMalloc_SpinLock#Unlock(49f6e7a06ebc5aa8).(); temp_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#temp_.->Lockcxx . . $ TCMalloc_SpinLock#Lock(49f6e7a06ebc5aa8).(); }
2544 inline ~cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#`~LockInverter`(49f6e7a06ebc5aa8).LockInvertercxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#() { temp_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#temp_.->Unlockcxx . . $ TCMalloc_SpinLock#Unlock(49f6e7a06ebc5aa8).(); held_cxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#held_.->Lockcxx . . $ TCMalloc_SpinLock#Lock(49f6e7a06ebc5aa8).(); }
2545 };
2546 }
2547
2548 bool TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::ShrinkCachecxx . . $ QTWTF/TCMalloc_Central_FreeList#ShrinkCache(9609253e83e89946).(int locked_size_class, bool force) {
2549 // Start with a quick check without taking a lock.
2550 if (cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_. == 0) return false;
2551 // We don't evict from a full cache unless we are 'forcing'.
2552 if (force == false && used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_. == cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.) return false;
2553
2554 // Grab lock, but first release the other lock held by this thread. We use
2555 // the lock inverter to ensure that we never hold two size class locks
2556 // concurrently. That can create a deadlock because there is no well
2557 // defined nesting order.
2558 LockInvertercxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter# licxx . . $ QTWTF/`$anonymous_namespace_src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp`/LockInverter#LockInverter(9813e7c37c6f3998).(&central_cachecxx . . $ QTWTF/central_cache.[locked_size_class].lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_., &lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_.);
2559 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(used_slots_ <= cache_size_);
2560 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(0 <= cache_size_);
2561 if (cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_. == 0) return false;
2562 if (used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_. == cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.) {
2563 if (force == false) return false;
2564 // ReleaseListToSpans releases the lock, so we have to make all the
2565 // updates to the central list before calling it.
2566 cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.--;
2567 used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_.--;
2568 ReleaseListToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseListToSpans(5d22bdacc48458e8).(tc_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#tc_slots_.[used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_.].headcxx . . $ QTWTF/TCEntry#head.);
2569 return true;
2570 }
2571 cache_size_cxx . . $ QTWTF/TCMalloc_Central_FreeList#cache_size_.--;
2572 return true;
2573 }
2574
2575 void TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::InsertRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#InsertRange(5be095a8278d2bf5).(void *start, void *end, int N) {
2576 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_.);
2577 if (N == num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.] &&
2578 MakeCacheSpacecxx . . $ QTWTF/TCMalloc_Central_FreeList#MakeCacheSpace(c9857a73d68e59ba).()) {
2579 int slot = used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_.++;
2580 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(slot >=0);
2581 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(slot < kNumTransferEntries);
2582 TCEntrycxx . . $ QTWTF/TCEntry# *entry = &tc_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#tc_slots_.[slot];
2583 entry->headcxx . . $ QTWTF/TCEntry#head. = start;
2584 entry->tailcxx . . $ QTWTF/TCEntry#tail. = end;
2585 return;
2586 }
2587 ReleaseListToSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#ReleaseListToSpans(5d22bdacc48458e8).(start);
2588 }
2589
2590 void TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::RemoveRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#RemoveRange(83f0a9f02807670).(void **start, void **end, int *N) {
2591 int num = *N;
2592 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(num > 0);
2593
2594 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_.);
2595 if (num == num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.] && used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_. > 0) {
2596 int slot = --used_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#used_slots_.;
2597 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(slot >= 0);
2598 TCEntrycxx . . $ QTWTF/TCEntry# *entry = &tc_slots_cxx . . $ QTWTF/TCMalloc_Central_FreeList#tc_slots_.[slot];
2599 *start = entry->headcxx . . $ QTWTF/TCEntry#head.;
2600 *end = entry->tailcxx . . $ QTWTF/TCEntry#tail.;
2601 return;
2602 }
2603
2604 // TODO: Prefetch multiple TCEntries?
2605 void *tail = FetchFromSpansSafecxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpansSafe(50c7df7de5344ebb).();
2606 if (!tail) {
2607 // We are completely out of memory.
2608 *start = *end = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2609 *N = 0;
2610 return;
2611 }
2612
2613 SLL_SetNextcxx . . $ QTWTF/SLL_SetNext(6c58c5e2437d25a2).(tail, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2614 void *head = tail;
2615 int count = 1;
2616 while (count < num) {
2617 void *t = FetchFromSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpans(50c7df7de5344ebb).();
2618 if (!t) break;
2619 SLL_Pushcxx . . $ QTWTF/SLL_Push(21d600c443e4dd01).(&head, t);
2620 count++;
2621 }
2622 *start = head;
2623 *end = tail;
2624 *N = count;
2625 }
2626
2627
2628 void* TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::FetchFromSpansSafecxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpansSafe(50c7df7de5344ebb).() {
2629 void *t = FetchFromSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpans(50c7df7de5344ebb).();
2630 if (!t) {
2631 Populatecxx . . $ QTWTF/TCMalloc_Central_FreeList#Populate(49f6e7a06ebc5aa8).();
2632 t = FetchFromSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpans(50c7df7de5344ebb).();
2633 }
2634 return t;
2635 }
2636
2637 void* TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::FetchFromSpanscxx . . $ QTWTF/TCMalloc_Central_FreeList#FetchFromSpans(50c7df7de5344ebb).() {
2638 // Intel compiler bug; issue id 6000056746
2639 // if (DLL_IsEmpty(&nonempty_)) return NULL;
2640 Spancxx . . $ QTWTF/Span#* span = nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_..nextcxx . . $ QTWTF/Span#next.;
2641 if (span == &nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_.)
2642 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2643
2644 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->objects != NULL);
2645 ASSERT_SPAN_COMMITTEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1077:9`!(span);
2646 span->refcountcxx . . $ QTWTF/Span#refcount.++;
2647 void* result = span->objectscxx . . $ QTWTF/Span#objects.;
2648 span->objectscxx . . $ QTWTF/Span#objects. = *(reinterpret_cast<void**>(result));
2649 if (span->objectscxx . . $ QTWTF/Span#objects. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
2650 // Move to empty list
2651 DLL_Removecxx . . $ QTWTF/DLL_Remove(41397daa150afe2e).(span);
2652 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&empty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#empty_., span);
2653 Eventcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1087:9`!(span, 'E', 0);
2654 }
2655 counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_.--;
2656 return result;
2657 }
2658
2659 // Fetch memory from the system and add to the central cache freelist.
2660 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void TCMalloc_Central_FreeListcxx . . $ QTWTF/TCMalloc_Central_FreeList#::Populatecxx . . $ QTWTF/TCMalloc_Central_FreeList#Populate(49f6e7a06ebc5aa8).() {
2661 // Release central list lock while operating on pageheap
2662 lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_..Unlockcxx . . $ TCMalloc_SpinLock#Unlock(49f6e7a06ebc5aa8).();
2663 const size_t npages = class_to_pagescxx . . $ QTWTF/class_to_pages.[size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.];
2664
2665 Spancxx . . $ QTWTF/Span#* span;
2666 {
2667 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
2668 span = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->Newcxx . . $ QTWTF/TCMalloc_PageHeap#New(25d23c4f8e1d4247).(npages);
2669 if (span) pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->RegisterSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#RegisterSizeClass(e9597f5c88419a9c).(span, size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.);
2670 }
2671 if (span == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
2672 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!("allocation failed: %d\n", errno);
2673 lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_..Lockcxx . . $ TCMalloc_SpinLock#Lock(49f6e7a06ebc5aa8).();
2674 return;
2675 }
2676 ASSERT_SPAN_COMMITTEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1077:9`!(span);
2677 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span->length == npages);
2678 // Cache sizeclass info eagerly. Locking is not necessary.
2679 // (Instead of being eager, we could just replace any stale info
2680 // about this span, but that seems to be no better in practice.)
2681 for (size_t i = 0; i < npages; i++) {
2682 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->CacheSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#CacheSizeClass(c652d5d4e23f3c95).(span->startcxx . . $ QTWTF/Span#start. + i, size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.);
2683 }
2684
2685 // Split the block into pieces and add to the free-list
2686 // TODO: coloring of objects to avoid cache conflicts?
2687 void** tail = &span->objectscxx . . $ QTWTF/Span#objects.;
2688 char* ptr = reinterpret_cast<char*>(span->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.);
2689 char* limit = ptr + (npages << kPageShiftcxx . . $ QTWTF/kPageShift.);
2690 const size_t size = ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(size_class_cxx . . $ QTWTF/TCMalloc_Central_FreeList#size_class_.);
2691 int num = 0;
2692 char* nptr;
2693 while ((nptr = ptr + size) <= limit) {
2694 *tail = ptr;
2695 tail = reinterpret_cast<void**>(ptr);
2696 ptr = nptr;
2697 num++;
2698 }
2699 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(ptr <= limit);
2700 *tail = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2701 span->refcountcxx . . $ QTWTF/Span#refcount. = 0; // No sub-object in use yet
2702
2703 // Add span to list of non-empty spans
2704 lock_cxx . . $ QTWTF/TCMalloc_Central_FreeList#lock_..Lockcxx . . $ TCMalloc_SpinLock#Lock(49f6e7a06ebc5aa8).();
2705 DLL_Prependcxx . . $ QTWTF/DLL_Prepend(e855eac60d60e4f1).(&nonempty_cxx . . $ QTWTF/TCMalloc_Central_FreeList#nonempty_., span);
2706 counter_cxx . . $ QTWTF/TCMalloc_Central_FreeList#counter_. += num;
2707 }
2708
2709 //-------------------------------------------------------------------
2710 // TCMalloc_ThreadCache implementation
2711 //-------------------------------------------------------------------
2712
2713 inline bool TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::SampleAllocationcxx . . $ QTWTF/TCMalloc_ThreadCache#SampleAllocation(31596a199e1d8a50).(size_t k) {
2714 if (bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. < k) {
2715 PickNextSamplecxx . . $ QTWTF/TCMalloc_ThreadCache#PickNextSample(2c44cd906ae4e829).(k);
2716 return true;
2717 } else {
2718 bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. -= k;
2719 return false;
2720 }
2721 }
2722
2723 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::Initcxx . . $ QTWTF/TCMalloc_ThreadCache#Init(2c44cd906ae4e829).(ThreadIdentifiercxx . . $ QTWTF/TCMalloc_ThreadCache#ThreadIdentifier# tid) {
2724 size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_. = 0;
2725 next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2726 prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2727 tid_cxx . . $ QTWTF/TCMalloc_ThreadCache#tid_. = tid;
2728 in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_. = false;
2729 for (size_t cl = 0; cl < kNumClassescxx . . $ QTWTF/kNumClasses.; ++cl) {
2730 list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl].Initcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#Init(49f6e7a06ebc5aa8).();
2731 }
2732
2733 // Initialize RNG -- run it for a bit to get to good values
2734 bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. = 0;
2735 rnd_cxx . . $ QTWTF/TCMalloc_ThreadCache#rnd_. = static_cast<uint32_tcxx . . $ uint32_t#>(reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(this));
2736 for (int i = 0; i < 100; i++) {
2737 PickNextSamplecxx . . $ QTWTF/TCMalloc_ThreadCache#PickNextSample(2c44cd906ae4e829).(static_cast<size_t>(FLAGS_tcmalloc_sample_parametercxx . . $ QTWTF/FLAGS_tcmalloc_sample_parameter. * 2));
2738 }
2739 }
2740
2741 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::Cleanupcxx . . $ QTWTF/TCMalloc_ThreadCache#Cleanup(49f6e7a06ebc5aa8).() {
2742 // Put unused memory back into central cache
2743 for (size_t cl = 0; cl < kNumClassescxx . . $ QTWTF/kNumClasses.; ++cl) {
2744 if (list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl].lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).() > 0) {
2745 ReleaseToCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#ReleaseToCentralCache(f9942d3529bc31bc).(cl, list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl].lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).());
2746 }
2747 }
2748 }
2749
2750 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void* TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::Allocatecxx . . $ QTWTF/TCMalloc_ThreadCache#Allocate(bfcfa4d6b7f7ef64).(size_t size) {
2751 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(size <= kMaxSize);
2752 const size_t cl = SizeClasscxx . . $ QTWTF/SizeClass(ecdaa1632f49f591).(size);
2753 FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache#FreeList#* list = &list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl];
2754 size_t allocationSize = ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(cl);
2755 if (list->emptycxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#empty(50ce9a9e25b4a850).()) {
2756 FetchFromCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#FetchFromCentralCache(6714b5f2551eea49).(cl, allocationSize);
2757 if (list->emptycxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#empty(50ce9a9e25b4a850).()) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2758 }
2759 size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_. -= allocationSize;
2760 return list->Popcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#Pop(50c7df7de5344ebb).();
2761 }
2762
2763 inline void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::Deallocatecxx . . $ QTWTF/TCMalloc_ThreadCache#Deallocate(5500c4293b1bbef0).(void* ptr, size_t cl) {
2764 size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_. += ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(cl);
2765 FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache#FreeList#* list = &list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl];
2766 list->Pushcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#Push(5d22bdacc48458e8).(ptr);
2767 // If enough data is free, put back into central cache
2768 if (list->lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).() > kMaxFreeListLengthcxx . . $ QTWTF/kMaxFreeListLength.) {
2769 ReleaseToCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#ReleaseToCentralCache(f9942d3529bc31bc).(cl, num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[cl]);
2770 }
2771 if (size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_. >= per_thread_cache_sizecxx . . $ QTWTF/per_thread_cache_size.) Scavengecxx . . $ QTWTF/TCMalloc_ThreadCache#Scavenge(49f6e7a06ebc5aa8).();
2772 }
2773
2774 // Remove some objects of class "cl" from central cache and add to thread heap
2775 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::FetchFromCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#FetchFromCentralCache(6714b5f2551eea49).(size_t cl, size_t allocationSize) {
2776 int fetch_count = num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[cl];
2777 void *start, *end;
2778 central_cachecxx . . $ QTWTF/central_cache.[cl].RemoveRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#RemoveRange(83f0a9f02807670).(&start, &end, &fetch_count);
2779 list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl].PushRangecxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#PushRange(4d99a0c3ff456823).(fetch_count, start, end);
2780 size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_. += allocationSize * fetch_count;
2781 }
2782
2783 // Remove some objects of class "cl" from thread heap and add to central cache
2784 inline void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::ReleaseToCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#ReleaseToCentralCache(f9942d3529bc31bc).(size_t cl, int N) {
2785 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(N > 0);
2786 FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache#FreeList#* src = &list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl];
2787 if (N > src->lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).()) N = src->lengthcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#length(455f465bc33b4cdf).();
2788 size_cxx . . $ QTWTF/TCMalloc_ThreadCache#size_. -= N*ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(cl);
2789
2790 // We return prepackaged chains of the correct size to the central cache.
2791 // TODO: Use the same format internally in the thread caches?
2792 int batch_size = num_objects_to_movecxx . . $ QTWTF/num_objects_to_move.[cl];
2793 while (N > batch_size) {
2794 void *tail, *head;
2795 src->PopRangecxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#PopRange(233423f5f6dce9eb).(batch_size, &head, &tail);
2796 central_cachecxx . . $ QTWTF/central_cache.[cl].InsertRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#InsertRange(5be095a8278d2bf5).(head, tail, batch_size);
2797 N -= batch_size;
2798 }
2799 void *tail, *head;
2800 src->PopRangecxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#PopRange(233423f5f6dce9eb).(N, &head, &tail);
2801 central_cachecxx . . $ QTWTF/central_cache.[cl].InsertRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#InsertRange(5be095a8278d2bf5).(head, tail, N);
2802 }
2803
2804 // Release idle memory to the central cache
2805 inline void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::Scavengecxx . . $ QTWTF/TCMalloc_ThreadCache#Scavenge(49f6e7a06ebc5aa8).() {
2806 // If the low-water mark for the free list is L, it means we would
2807 // not have had to allocate anything from the central cache even if
2808 // we had reduced the free list size by L. We aim to get closer to
2809 // that situation by dropping L/2 nodes from the free list. This
2810 // may not release much memory, but if so we will call scavenge again
2811 // pretty soon and the low-water marks will be high on that call.
2812 //int64 start = CycleClock::Now();
2813
2814 for (size_t cl = 0; cl < kNumClassescxx . . $ QTWTF/kNumClasses.; cl++) {
2815 FreeListcxx . . $ QTWTF/TCMalloc_ThreadCache#FreeList#* list = &list_cxx . . $ QTWTF/TCMalloc_ThreadCache#list_.[cl];
2816 const int lowmark = list->lowwatermarkcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#lowwatermark(455f465bc33b4cdf).();
2817 if (lowmark > 0) {
2818 const int drop = (lowmark > 1) ? lowmark/2 : 1;
2819 ReleaseToCentralCachecxx . . $ QTWTF/TCMalloc_ThreadCache#ReleaseToCentralCache(f9942d3529bc31bc).(cl, drop);
2820 }
2821 list->clear_lowwatermarkcxx . . $ QTWTF/TCMalloc_ThreadCache_FreeList#clear_lowwatermark(49f6e7a06ebc5aa8).();
2822 }
2823
2824 //int64 finish = CycleClock::Now();
2825 //CycleTimer ct;
2826 //MESSAGE("GC: %.0f ns\n", ct.CyclesToUsec(finish-start)*1000.0);
2827 }
2828
2829 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::PickNextSamplecxx . . $ QTWTF/TCMalloc_ThreadCache#PickNextSample(2c44cd906ae4e829).(size_t k) {
2830 // Make next "random" number
2831 // x^32+x^22+x^2+x^1+1 is a primitive polynomial for random numbers
2832 static const uint32_tcxx . . $ uint32_t# kPoly = (1 << 22) | (1 << 2) | (1 << 1) | (1 << 0);
2833 uint32_tcxx . . $ uint32_t# r = rnd_cxx . . $ QTWTF/TCMalloc_ThreadCache#rnd_.;
2834 rnd_cxx . . $ QTWTF/TCMalloc_ThreadCache#rnd_. = (r << 1) ^ ((static_cast<int32_tcxx . . $ int32_t#>(r) >> 31) & kPoly);
2835
2836 // Next point is "rnd_ % (sample_period)". I.e., average
2837 // increment is "sample_period/2".
2838 const int flag_value = static_cast<int>(FLAGS_tcmalloc_sample_parametercxx . . $ QTWTF/FLAGS_tcmalloc_sample_parameter.);
2839 static int last_flag_value = -1;
2840
2841 if (flag_value != last_flag_value) {
2842 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&sample_period_lockcxx . . $ QTWTF/sample_period_lock.);
2843 int i;
2844 for (i = 0; i < (static_cast<int>(sizeof(primes_listcxx . . $ QTWTF/primes_list.)/sizeof(primes_listcxx . . $ QTWTF/primes_list.[0])) - 1); i++) {
2845 if (primes_listcxx . . $ QTWTF/primes_list.[i] >= flag_value) {
2846 break;
2847 }
2848 }
2849 sample_periodcxx . . $ QTWTF/sample_period. = primes_listcxx . . $ QTWTF/primes_list.[i];
2850 last_flag_value = flag_value;
2851 }
2852
2853 bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. += rnd_cxx . . $ QTWTF/TCMalloc_ThreadCache#rnd_. % sample_periodcxx . . $ QTWTF/sample_period.;
2854
2855 if (k > (static_cast<size_t>(-1) >> 2)) {
2856 // If the user has asked for a huge allocation then it is possible
2857 // for the code below to loop infinitely. Just return (note that
2858 // this throws off the sampling accuracy somewhat, but a user who
2859 // is allocating more than 1G of memory at a time can live with a
2860 // minor inaccuracy in profiling of small allocations, and also
2861 // would rather not wait for the loop below to terminate).
2862 return;
2863 }
2864
2865 while (bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. < k) {
2866 // Increase bytes_until_sample_ by enough average sampling periods
2867 // (sample_period >> 1) to allow us to sample past the current
2868 // allocation.
2869 bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. += (sample_periodcxx . . $ QTWTF/sample_period. >> 1);
2870 }
2871
2872 bytes_until_sample_cxx . . $ QTWTF/TCMalloc_ThreadCache#bytes_until_sample_. -= k;
2873 }
2874
2875 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::InitModulecxx . . $ QTWTF/TCMalloc_ThreadCache#InitModule(49f6e7a06ebc5aa8).() {
2876 // There is a slight potential race here because of double-checked
2877 // locking idiom. However, as long as the program does a small
2878 // allocation before switching to multi-threaded mode, we will be
2879 // fine. We increase the chances of doing such a small allocation
2880 // by doing one in the constructor of the module_enter_exit_hook
2881 // object declared below.
2882 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
2883 if (!phinitedcxx . . $ QTWTF/phinited.) {
2884 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
2885 InitTSDcxx . . $ QTWTF/TCMalloc_ThreadCache#InitTSD(49f6e7a06ebc5aa8).();
2886 #endif
2887 InitSizeClassescxx . . $ QTWTF/InitSizeClasses(49f6e7a06ebc5aa8).();
2888 threadheap_allocatorcxx . . $ QTWTF/threadheap_allocator..Init();
2889 span_allocatorcxx . . $ QTWTF/span_allocator..Init();
2890 span_allocatorcxx . . $ QTWTF/span_allocator..New(); // Reduce cache conflicts
2891 span_allocatorcxx . . $ QTWTF/span_allocator..New(); // Reduce cache conflicts
2892 stacktrace_allocatorcxx . . $ QTWTF/stacktrace_allocator..Init();
2893 DLL_Initcxx . . $ QTWTF/DLL_Init(41397daa150afe2e).(&sampled_objectscxx . . $ QTWTF/sampled_objects.);
2894 for (size_t i = 0; i < kNumClassescxx . . $ QTWTF/kNumClasses.; ++i) {
2895 central_cachecxx . . $ QTWTF/central_cache.[i].Initcxx . . $ QTWTF/TCMalloc_Central_FreeList#Init(2c44cd906ae4e829).(i);
2896 }
2897 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->initcxx . . $ QTWTF/TCMalloc_PageHeap#init(49f6e7a06ebc5aa8).();
2898 phinitedcxx . . $ QTWTF/phinited. = 1;
2899 #if defined(WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!) && OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
2900 FastMallocZone::init();
2901 #endif
2902 }
2903 }
2904
2905 inline TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::NewHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#NewHeap(9cca835e35801c07).(ThreadIdentifiercxx . . $ QTWTF/TCMalloc_ThreadCache#ThreadIdentifier# tid) {
2906 // Create the heap and add it to the linked list
2907 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache# *heap = threadheap_allocator.New();
2908 heap->Initcxx . . $ QTWTF/TCMalloc_ThreadCache#Init(2c44cd906ae4e829).(tid);
2909 heap->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_. = thread_heapscxx . . $ QTWTF/thread_heaps.;
2910 heap->prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2911 if (thread_heapscxx . . $ QTWTF/thread_heaps. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) thread_heapscxx . . $ QTWTF/thread_heaps.->prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_. = heap;
2912 thread_heapscxx . . $ QTWTF/thread_heaps. = heap;
2913 thread_heap_countcxx . . $ QTWTF/thread_heap_count.++;
2914 RecomputeThreadCacheSizecxx . . $ QTWTF/TCMalloc_ThreadCache#RecomputeThreadCacheSize(49f6e7a06ebc5aa8).();
2915 return heap;
2916 }
2917
2918 inline TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::GetThreadHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#GetThreadHeap(89f09ab4cfc717c4).() {
2919 #ifdef HAVE_TLS
2920 // __thread is faster, but only when the kernel supports it
2921 if (KernelSupportsTLS())
2922 return threadlocal_heap;
2923 #elif COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2924 return static_cast<TCMalloc_ThreadCache*>(TlsGetValue(tlsIndex));
2925 #else
2926 return static_cast<TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#*>(pthread_getspecific(heap_keycxx . . $ QTWTF/heap_key.));
2927 #endif
2928 }
2929
2930 inline TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::GetCachecxx . . $ QTWTF/TCMalloc_ThreadCache#GetCache(89f09ab4cfc717c4).() {
2931 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* ptr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2932 if (!tsd_initedcxx . . $ QTWTF/tsd_inited.) {
2933 InitModulecxx . . $ QTWTF/TCMalloc_ThreadCache#InitModule(49f6e7a06ebc5aa8).();
2934 } else {
2935 ptr = GetThreadHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#GetThreadHeap(89f09ab4cfc717c4).();
2936 }
2937 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) ptr = CreateCacheIfNecessarycxx . . $ QTWTF/TCMalloc_ThreadCache#CreateCacheIfNecessary(89f09ab4cfc717c4).();
2938 return ptr;
2939 }
2940
2941 // In deletion paths, we do not try to create a thread-cache. This is
2942 // because we may be in the thread destruction code and may have
2943 // already cleaned up the cache for this thread.
2944 inline TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::GetCacheIfPresentcxx . . $ QTWTF/TCMalloc_ThreadCache#GetCacheIfPresent(89f09ab4cfc717c4).() {
2945 if (!tsd_initedcxx . . $ QTWTF/tsd_inited.) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2946 void* const p = GetThreadHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#GetThreadHeap(89f09ab4cfc717c4).();
2947 return reinterpret_cast<TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#*>(p);
2948 }
2949
2950 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::InitTSDcxx . . $ QTWTF/TCMalloc_ThreadCache#InitTSD(49f6e7a06ebc5aa8).() {
2951 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!tsd_inited);
2952 pthread_key_create(&heap_keycxx . . $ QTWTF/heap_key., DestroyThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DestroyThreadCache(5d22bdacc48458e8).);
2953 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2954 tlsIndex = TlsAlloc();
2955 #endif
2956 tsd_initedcxx . . $ QTWTF/tsd_inited. = true;
2957
2958 #if !COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2959 // We may have used a fake pthread_t for the main thread. Fix it.
2960 pthread_t zero;
2961 memset(&zero, 0, sizeof(zero));
2962 #endif
2963 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
2964 SpinLockHolder h(&pageheap_lock);
2965 #else
2966 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(pageheap_lock.IsHeld());
2967 #endif
2968 for (TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* h = thread_heapscxx . . $ QTWTF/thread_heaps.; h != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; h = h->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.) {
2969 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2970 if (h->tid_ == 0) {
2971 h->tid_ = GetCurrentThreadId();
2972 }
2973 #else
2974 if (pthread_equal(h->tid_cxx . . $ QTWTF/TCMalloc_ThreadCache#tid_., zero)) {
2975 h->tid_cxx . . $ QTWTF/TCMalloc_ThreadCache#tid_. = pthread_self();
2976 }
2977 #endif
2978 }
2979 }
2980
2981 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::CreateCacheIfNecessarycxx . . $ QTWTF/TCMalloc_ThreadCache#CreateCacheIfNecessary(89f09ab4cfc717c4).() {
2982 // Initialize per-thread data if necessary
2983 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2984 {
2985 SpinLockHoldercxx . . $ SpinLockHolder# lockholdercxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
2986
2987 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
2988 DWORD me;
2989 if (!tsd_inited) {
2990 me = 0;
2991 } else {
2992 me = GetCurrentThreadId();
2993 }
2994 #else
2995 // Early on in glibc's life, we cannot even call pthread_self()
2996 pthread_t me;
2997 if (!tsd_initedcxx . . $ QTWTF/tsd_inited.) {
2998 memset(&me, 0, sizeof(me));
2999 } else {
3000 me = pthread_self();
3001 }
3002 #endif
3003
3004 // This may be a recursive malloc call from pthread_setspecific()
3005 // In that case, the heap for this thread has already been created
3006 // and added to the linked list. So we search for that first.
3007 for (TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* h = thread_heapscxx . . $ QTWTF/thread_heaps.; h != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; h = h->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.) {
3008 #if COMPILERcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:39:9`!(MSVC)
3009 if (h->tid_ == me) {
3010 #else
3011 if (pthread_equal(h->tid_cxx . . $ QTWTF/TCMalloc_ThreadCache#tid_., me)) {
3012 #endif
3013 heap = h;
3014 break;
3015 }
3016 }
3017
3018 if (heap == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) heap = NewHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#NewHeap(9cca835e35801c07).(me);
3019 }
3020
3021 // We call pthread_setspecific() outside the lock because it may
3022 // call malloc() recursively. The recursive call will never get
3023 // here again because it will find the already allocated heap in the
3024 // linked list of heaps.
3025 if (!heap->in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_. && tsd_initedcxx . . $ QTWTF/tsd_inited.) {
3026 heap->in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_. = true;
3027 setThreadHeapcxx . . $ QTWTF/setThreadHeap(93c22c671bc633b2).(heap);
3028 }
3029 return heap;
3030 }
3031
3032 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::BecomeIdlecxx . . $ QTWTF/TCMalloc_ThreadCache#BecomeIdle(49f6e7a06ebc5aa8).() {
3033 if (!tsd_initedcxx . . $ QTWTF/tsd_inited.) return; // No caches yet
3034 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap = GetThreadHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#GetThreadHeap(89f09ab4cfc717c4).();
3035 if (heap == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return; // No thread cache to remove
3036 if (heap->in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_.) return; // Do not disturb the active caller
3037
3038 heap->in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_. = true;
3039 pthread_setspecific(heap_keycxx . . $ QTWTF/heap_key., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
3040 #ifdef HAVE_TLS
3041 // Also update the copy in __thread
3042 threadlocal_heap = NULL;
3043 #endif
3044 heap->in_setspecific_cxx . . $ QTWTF/TCMalloc_ThreadCache#in_setspecific_. = false;
3045 if (GetThreadHeapcxx . . $ QTWTF/TCMalloc_ThreadCache#GetThreadHeap(89f09ab4cfc717c4).() == heap) {
3046 // Somehow heap got reinstated by a recursive call to malloc
3047 // from pthread_setspecific. We give up in this case.
3048 return;
3049 }
3050
3051 // We can now get rid of the heap
3052 DeleteCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DeleteCache(93c22c671bc633b2).(heap);
3053 }
3054
3055 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::DestroyThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DestroyThreadCache(5d22bdacc48458e8).(void* ptr) {
3056 // Note that "ptr" cannot be NULL since pthread promises not
3057 // to invoke the destructor on NULL values, but for safety,
3058 // we check anyway.
3059 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return;
3060 #ifdef HAVE_TLS
3061 // Prevent fast path of GetThreadHeap() from returning heap.
3062 threadlocal_heap = NULL;
3063 #endif
3064 DeleteCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DeleteCache(93c22c671bc633b2).(reinterpret_cast<TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#*>(ptr));
3065 }
3066
3067 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::DeleteCachecxx . . $ QTWTF/TCMalloc_ThreadCache#DeleteCache(93c22c671bc633b2).(TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap) {
3068 // Remove all memory from heap
3069 heap->Cleanupcxx . . $ QTWTF/TCMalloc_ThreadCache#Cleanup(49f6e7a06ebc5aa8).();
3070
3071 // Remove from linked list
3072 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
3073 if (heap->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) heap->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.->prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_. = heap->prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_.;
3074 if (heap->prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) heap->prev_cxx . . $ QTWTF/TCMalloc_ThreadCache#prev_.->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_. = heap->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.;
3075 if (thread_heapscxx . . $ QTWTF/thread_heaps. == heap) thread_heapscxx . . $ QTWTF/thread_heaps. = heap->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.;
3076 thread_heap_countcxx . . $ QTWTF/thread_heap_count.--;
3077 RecomputeThreadCacheSizecxx . . $ QTWTF/TCMalloc_ThreadCache#RecomputeThreadCacheSize(49f6e7a06ebc5aa8).();
3078
3079 threadheap_allocatorcxx . . $ QTWTF/threadheap_allocator..Delete(heap);
3080 }
3081
3082 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::RecomputeThreadCacheSizecxx . . $ QTWTF/TCMalloc_ThreadCache#RecomputeThreadCacheSize(49f6e7a06ebc5aa8).() {
3083 // Divide available space across threads
3084 int n = thread_heap_countcxx . . $ QTWTF/thread_heap_count. > 0 ? thread_heap_countcxx . . $ QTWTF/thread_heap_count. : 1;
3085 size_t space = overall_thread_cache_sizecxx . . $ QTWTF/overall_thread_cache_size. / n;
3086
3087 // Limit to allowed range
3088 if (space < kMinThreadCacheSizecxx . . $ QTWTF/kMinThreadCacheSize.) space = kMinThreadCacheSizecxx . . $ QTWTF/kMinThreadCacheSize.;
3089 if (space > kMaxThreadCacheSizecxx . . $ QTWTF/kMaxThreadCacheSize.) space = kMaxThreadCacheSizecxx . . $ QTWTF/kMaxThreadCacheSize.;
3090
3091 per_thread_cache_sizecxx . . $ QTWTF/per_thread_cache_size. = space;
3092 }
3093
3094 void TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::Printcxx . . $ QTWTF/TCMalloc_ThreadCache#Print(83f5f38750778ac8).() const {
3095 for (size_t cl = 0; cl < kNumClassescxx . . $ QTWTF/kNumClasses.; ++cl) {
3096 MESSAGEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:448:9`!(" %5" PRIuS " : %4d len; %4d lo\n",
3097 ByteSizeForClass(cl),
3098 list_[cl].length(),
3099 list_[cl].lowwatermark());
3100 }
3101 }
3102
3103 // Extract interesting stats
3104 struct TCMallocStatscxx . . $ QTWTF/TCMallocStats# {
3105 uint64_tcxx . . $ uint64_t# system_bytescxx . . $ QTWTF/TCMallocStats#system_bytes.; // Bytes alloced from system
3106 uint64_tcxx . . $ uint64_t# thread_bytescxx . . $ QTWTF/TCMallocStats#thread_bytes.; // Bytes in thread caches
3107 uint64_tcxx . . $ uint64_t# central_bytescxx . . $ QTWTF/TCMallocStats#central_bytes.; // Bytes in central cache
3108 uint64_tcxx . . $ uint64_t# transfer_bytescxx . . $ QTWTF/TCMallocStats#transfer_bytes.; // Bytes in central transfer cache
3109 uint64_tcxx . . $ uint64_t# pageheap_bytescxx . . $ QTWTF/TCMallocStats#pageheap_bytes.; // Bytes in page heap
3110 uint64_tcxx . . $ uint64_t# metadata_bytescxx . . $ QTWTF/TCMallocStats#metadata_bytes.; // Bytes alloced for metadata
3111 };
3112
3113 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3114 // Get stats into "r". Also get per-size-class counts if class_count != NULL
3115 static void ExtractStats(TCMallocStats* r, uint64_t* class_count) {
3116 r->central_bytes = 0;
3117 r->transfer_bytes = 0;
3118 for (int cl = 0; cl < kNumClasses; ++cl) {
3119 const int length = central_cache[cl].length();
3120 const int tc_length = central_cache[cl].tc_length();
3121 r->central_bytes += static_cast<uint64_t>(ByteSizeForClass(cl)) * length;
3122 r->transfer_bytes +=
3123 static_cast<uint64_t>(ByteSizeForClass(cl)) * tc_length;
3124 if (class_count) class_count[cl] = length + tc_length;
3125 }
3126
3127 // Add stats from per-thread heaps
3128 r->thread_bytes = 0;
3129 { // scope
3130 SpinLockHolder h(&pageheap_lock);
3131 for (TCMalloc_ThreadCache* h = thread_heaps; h != NULL; h = h->next_) {
3132 r->thread_bytes += h->Size();
3133 if (class_count) {
3134 for (size_t cl = 0; cl < kNumClasses; ++cl) {
3135 class_count[cl] += h->freelist_length(cl);
3136 }
3137 }
3138 }
3139 }
3140
3141 { //scope
3142 SpinLockHolder h(&pageheap_lock);
3143 r->system_bytes = pageheap->SystemBytes();
3144 r->metadata_bytes = metadata_system_bytes;
3145 r->pageheap_bytes = pageheap->FreeBytes();
3146 }
3147 }
3148 #endif
3149
3150 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3151 // WRITE stats to "out"
3152 static void DumpStats(TCMalloc_Printer* out, int level) {
3153 TCMallocStats stats;
3154 uint64_t class_count[kNumClasses];
3155 ExtractStats(&stats, (level >= 2 ? class_count : NULL));
3156
3157 if (level >= 2) {
3158 out->printf("------------------------------------------------\n");
3159 uint64_t cumulative = 0;
3160 for (int cl = 0; cl < kNumClasses; ++cl) {
3161 if (class_count[cl] > 0) {
3162 uint64_t class_bytes = class_count[cl] * ByteSizeForClass(cl);
3163 cumulative += class_bytes;
3164 out->printf("class %3d [ %8" PRIuS " bytes ] : "
3165 "%8" PRIu64 " objs; %5.1f MB; %5.1f cum MB\n",
3166 cl, ByteSizeForClass(cl),
3167 class_count[cl],
3168 class_bytes / 1048576.0,
3169 cumulative / 1048576.0);
3170 }
3171 }
3172
3173 SpinLockHolder h(&pageheap_lock);
3174 pageheap->Dump(out);
3175 }
3176
3177 const uint64_t bytes_in_use = stats.system_bytes
3178 - stats.pageheap_bytes
3179 - stats.central_bytes
3180 - stats.transfer_bytes
3181 - stats.thread_bytes;
3182
3183 out->printf("------------------------------------------------\n"
3184 "MALLOC: %12" PRIu64 " Heap size\n"
3185 "MALLOC: %12" PRIu64 " Bytes in use by application\n"
3186 "MALLOC: %12" PRIu64 " Bytes free in page heap\n"
3187 "MALLOC: %12" PRIu64 " Bytes free in central cache\n"
3188 "MALLOC: %12" PRIu64 " Bytes free in transfer cache\n"
3189 "MALLOC: %12" PRIu64 " Bytes free in thread caches\n"
3190 "MALLOC: %12" PRIu64 " Spans in use\n"
3191 "MALLOC: %12" PRIu64 " Thread heaps in use\n"
3192 "MALLOC: %12" PRIu64 " Metadata allocated\n"
3193 "------------------------------------------------\n",
3194 stats.system_bytes,
3195 bytes_in_use,
3196 stats.pageheap_bytes,
3197 stats.central_bytes,
3198 stats.transfer_bytes,
3199 stats.thread_bytes,
3200 uint64_t(span_allocator.inuse()),
3201 uint64_t(threadheap_allocator.inuse()),
3202 stats.metadata_bytes);
3203 }
3204
3205 static void PrintStats(int level) {
3206 const int kBufferSize = 16 << 10;
3207 char* buffer = new char[kBufferSize];
3208 TCMalloc_Printer printer(buffer, kBufferSize);
3209 DumpStats(&printer, level);
3210 write(STDERR_FILENO, buffer, strlen(buffer));
3211 delete[] buffer;
3212 }
3213
3214 static void** DumpStackTraces() {
3215 // Count how much space we need
3216 int needed_slots = 0;
3217 {
3218 SpinLockHolder h(&pageheap_lock);
3219 for (Span* s = sampled_objects.next; s != &sampled_objects; s = s->next) {
3220 StackTrace* stack = reinterpret_cast<StackTrace*>(s->objects);
3221 needed_slots += 3 + stack->depth;
3222 }
3223 needed_slots += 100; // Slop in case sample grows
3224 needed_slots += needed_slots/8; // An extra 12.5% slop
3225 }
3226
3227 void** result = new void*[needed_slots];
3228 if (result == NULL) {
3229 MESSAGE("tcmalloc: could not allocate %d slots for stack traces\n",
3230 needed_slots);
3231 return NULL;
3232 }
3233
3234 SpinLockHolder h(&pageheap_lock);
3235 int used_slots = 0;
3236 for (Span* s = sampled_objects.next; s != &sampled_objects; s = s->next) {
3237 ASSERT(used_slots < needed_slots); // Need to leave room for terminator
3238 StackTrace* stack = reinterpret_cast<StackTrace*>(s->objects);
3239 if (used_slots + 3 + stack->depth >= needed_slots) {
3240 // No more room
3241 break;
3242 }
3243
3244 result[used_slots+0] = reinterpret_cast<void*>(static_cast<uintptr_t>(1));
3245 result[used_slots+1] = reinterpret_cast<void*>(stack->size);
3246 result[used_slots+2] = reinterpret_cast<void*>(stack->depth);
3247 for (int d = 0; d < stack->depth; d++) {
3248 result[used_slots+3+d] = stack->stack[d];
3249 }
3250 used_slots += 3 + stack->depth;
3251 }
3252 result[used_slots] = reinterpret_cast<void*>(static_cast<uintptr_t>(0));
3253 return result;
3254 }
3255 #endif
3256
3257 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3258
3259 // TCMalloc's support for extra malloc interfaces
3260 class TCMallocImplementation : public MallocExtension {
3261 public:
3262 virtual void GetStats(char* buffer, int buffer_length) {
3263 ASSERT(buffer_length > 0);
3264 TCMalloc_Printer printer(buffer, buffer_length);
3265
3266 // Print level one stats unless lots of space is available
3267 if (buffer_length < 10000) {
3268 DumpStats(&printer, 1);
3269 } else {
3270 DumpStats(&printer, 2);
3271 }
3272 }
3273
3274 virtual void** ReadStackTraces() {
3275 return DumpStackTraces();
3276 }
3277
3278 virtual bool GetNumericProperty(const char* name, size_t* value) {
3279 ASSERT(name != NULL);
3280
3281 if (strcmp(name, "generic.current_allocated_bytes") == 0) {
3282 TCMallocStats stats;
3283 ExtractStats(&stats, NULL);
3284 *value = stats.system_bytes
3285 - stats.thread_bytes
3286 - stats.central_bytes
3287 - stats.pageheap_bytes;
3288 return true;
3289 }
3290
3291 if (strcmp(name, "generic.heap_size") == 0) {
3292 TCMallocStats stats;
3293 ExtractStats(&stats, NULL);
3294 *value = stats.system_bytes;
3295 return true;
3296 }
3297
3298 if (strcmp(name, "tcmalloc.slack_bytes") == 0) {
3299 // We assume that bytes in the page heap are not fragmented too
3300 // badly, and are therefore available for allocation.
3301 SpinLockHolder l(&pageheap_lock);
3302 *value = pageheap->FreeBytes();
3303 return true;
3304 }
3305
3306 if (strcmp(name, "tcmalloc.max_total_thread_cache_bytes") == 0) {
3307 SpinLockHolder l(&pageheap_lock);
3308 *value = overall_thread_cache_size;
3309 return true;
3310 }
3311
3312 if (strcmp(name, "tcmalloc.current_total_thread_cache_bytes") == 0) {
3313 TCMallocStats stats;
3314 ExtractStats(&stats, NULL);
3315 *value = stats.thread_bytes;
3316 return true;
3317 }
3318
3319 return false;
3320 }
3321
3322 virtual bool SetNumericProperty(const char* name, size_t value) {
3323 ASSERT(name != NULL);
3324
3325 if (strcmp(name, "tcmalloc.max_total_thread_cache_bytes") == 0) {
3326 // Clip the value to a reasonable range
3327 if (value < kMinThreadCacheSize) value = kMinThreadCacheSize;
3328 if (value > (1<<30)) value = (1<<30); // Limit to 1GB
3329
3330 SpinLockHolder l(&pageheap_lock);
3331 overall_thread_cache_size = static_cast<size_t>(value);
3332 TCMalloc_ThreadCache::RecomputeThreadCacheSize();
3333 return true;
3334 }
3335
3336 return false;
3337 }
3338
3339 virtual void MarkThreadIdle() {
3340 TCMalloc_ThreadCache::BecomeIdle();
3341 }
3342
3343 virtual void ReleaseFreeMemory() {
3344 SpinLockHolder h(&pageheap_lock);
3345 pageheap->ReleaseFreePages();
3346 }
3347 };
3348 #endif
3349
3350 // The constructor allocates an object to ensure that initialization
3351 // runs before main(), and therefore we do not have a chance to become
3352 // multi-threaded before initialization. We also create the TSD key
3353 // here. Presumably by the time this constructor runs, glibc is in
3354 // good enough shape to handle pthread_key_create().
3355 //
3356 // The constructor also takes the opportunity to tell STL to use
3357 // tcmalloc. We want to do this early, before construct time, so
3358 // all user STL allocations go through tcmalloc (which works really
3359 // well for STL).
3360 //
3361 // The destructor prints stats when the program exits.
3362 class TCMallocGuardcxx . . $ QTWTF/TCMallocGuard# {
3363 public:
3364
3365 TCMallocGuardcxx . . $ QTWTF/TCMallocGuard#TCMallocGuard(49f6e7a06ebc5aa8).() {
3366 #ifdef HAVE_TLS // this is true if the cc/ld/libc combo support TLS
3367 // Check whether the kernel also supports TLS (needs to happen at runtime)
3368 CheckIfKernelSupportsTLS();
3369 #endif
3370 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3371 #ifdef WIN32 // patch the windows VirtualAlloc, etc.
3372 PatchWindowsFunctions(); // defined in windows/patch_functions.cc
3373 #endif
3374 #endif
3375 freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`!(malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`!(1));
3376 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::InitTSDcxx . . $ QTWTF/TCMalloc_ThreadCache#InitTSD(49f6e7a06ebc5aa8).();
3377 freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`!(malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`!(1));
3378 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3379 MallocExtension::Register(new TCMallocImplementation);
3380 #endif
3381 }
3382
3383 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3384 ~TCMallocGuard() {
3385 const char* env = getenv("MALLOCSTATS");
3386 if (env != NULL) {
3387 int level = atoi(env);
3388 if (level < 1) level = 1;
3389 PrintStats(level);
3390 }
3391 #ifdef WIN32
3392 UnpatchWindowsFunctions();
3393 #endif
3394 }
3395 #endif
3396 };
3397
3398 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3399 static TCMallocGuard module_enter_exit_hook;
3400 #endif
3401
3402
3403 //-------------------------------------------------------------------
3404 // Helpers for the exported routines below
3405 //-------------------------------------------------------------------
3406
3407 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3408
3409 static Span* DoSampledAllocation(size_t size) {
3410
3411 // Grab the stack trace outside the heap lock
3412 StackTrace tmp;
3413 tmp.depth = GetStackTrace(tmp.stack, kMaxStackDepth, 1);
3414 tmp.size = size;
3415
3416 SpinLockHolder h(&pageheap_lock);
3417 // Allocate span
3418 Span *span = pageheap->New(pages(size == 0 ? 1 : size));
3419 if (span == NULL) {
3420 return NULL;
3421 }
3422
3423 // Allocate stack trace
3424 StackTrace *stack = stacktrace_allocator.New();
3425 if (stack == NULL) {
3426 // Sampling failed because of lack of memory
3427 return span;
3428 }
3429
3430 *stack = tmp;
3431 span->sample = 1;
3432 span->objects = stack;
3433 DLL_Prepend(&sampled_objects, span);
3434
3435 return span;
3436 }
3437 #endif
3438
3439 static inline bool CheckCachedSizeClasscxx . . $ QTWTF/CheckCachedSizeClass(db00c6a08f501612).(void *ptr) {
3440 PageIDcxx . . $ QTWTF/PageID# p = reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(ptr) >> kPageShiftcxx . . $ QTWTF/kPageShift.;
3441 size_t cached_value = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetSizeClassIfCachedcxx . . $ QTWTF/TCMalloc_PageHeap#GetSizeClassIfCached(611be0c07d97f8b8).(p);
3442 return cached_value == 0 ||
3443 cached_value == pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p)->sizeclasscxx . . $ QTWTF/Span#sizeclass.;
3444 }
3445
3446 static inline void* CheckedMallocResultcxx . . $ QTWTF/CheckedMallocResult(9f162e79bfc6c74).(void *result)
3447 {
3448 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(result == 0 || CheckCachedSizeClass(result));
3449 return result;
3450 }
3451
3452 static inline void* SpanToMallocResultcxx . . $ QTWTF/SpanToMallocResult(ab46850b0bd8bfcb).(Spancxx . . $ QTWTF/Span# *span) {
3453 ASSERT_SPAN_COMMITTEDcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1077:9`!(span);
3454 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->CacheSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#CacheSizeClass(c652d5d4e23f3c95).(span->startcxx . . $ QTWTF/Span#start., 0);
3455 return
3456 CheckedMallocResultcxx . . $ QTWTF/CheckedMallocResult(9f162e79bfc6c74).(reinterpret_cast<void*>(span->startcxx . . $ QTWTF/Span#start. << kPageShiftcxx . . $ QTWTF/kPageShift.));
3457 }
3458
3459 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3460 template <bool crashOnFailure>
3461 #endif
3462 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void* do_malloccxx . . $ QTWTF/do_malloc(bfcfa4d6b7f7ef64).(size_t size) {
3463 void* ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
3464
3465 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3466 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!isForbidden());
3467 #endif
3468
3469 // The following call forces module initialization
3470 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap = TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::GetCachecxx . . $ QTWTF/TCMalloc_ThreadCache#GetCache(89f09ab4cfc717c4).();
3471 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3472 if ((FLAGS_tcmalloc_sample_parameter > 0) && heap->SampleAllocation(size)) {
3473 Span* span = DoSampledAllocation(size);
3474 if (span != NULL) {
3475 ret = SpanToMallocResult(span);
3476 }
3477 } else
3478 #endif
3479 if (size > kMaxSizecxx . . $ QTWTF/kMaxSize.) {
3480 // Use page-level allocator
3481 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
3482 Spancxx . . $ QTWTF/Span#* span = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->Newcxx . . $ QTWTF/TCMalloc_PageHeap#New(25d23c4f8e1d4247).(pagescxx . . $ QTWTF/pages(ecdaa1632f49f591).(size));
3483 if (span != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
3484 ret = SpanToMallocResultcxx . . $ QTWTF/SpanToMallocResult(ab46850b0bd8bfcb).(span);
3485 }
3486 } else {
3487 // The common case, and also the simplest. This just pops the
3488 // size-appropriate freelist, afer replenishing it if it's empty.
3489 ret = CheckedMallocResultcxx . . $ QTWTF/CheckedMallocResult(9f162e79bfc6c74).(heap->Allocatecxx . . $ QTWTF/TCMalloc_ThreadCache#Allocate(bfcfa4d6b7f7ef64).(size));
3490 }
3491 if (!ret) {
3492 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3493 if (crashOnFailure) // This branch should be optimized out by the compiler.
3494 CRASHcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:160:9`!();
3495 #else
3496 errno = ENOMEM;
3497 #endif
3498 }
3499 return ret;
3500 }
3501
3502 static ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void do_freecxx . . $ QTWTF/do_free(5d22bdacc48458e8).(void* ptr) {
3503 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) return;
3504 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(pageheap != NULL); // Should not call free() before malloc()
3505 const PageIDcxx . . $ QTWTF/PageID# p = reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(ptr) >> kPageShiftcxx . . $ QTWTF/kPageShift.;
3506 Spancxx . . $ QTWTF/Span#* span = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
3507 size_t cl = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetSizeClassIfCachedcxx . . $ QTWTF/TCMalloc_PageHeap#GetSizeClassIfCached(611be0c07d97f8b8).(p);
3508
3509 if (cl == 0) {
3510 span = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p);
3511 cl = span->sizeclasscxx . . $ QTWTF/Span#sizeclass.;
3512 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->CacheSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#CacheSizeClass(c652d5d4e23f3c95).(p, cl);
3513 }
3514 if (cl != 0) {
3515 #ifndef NO_TCMALLOC_SAMPLEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:88:9`!
3516 ASSERT(!pageheap->GetDescriptor(p)->sample);
3517 #endif
3518 TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* heap = TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::GetCacheIfPresentcxx . . $ QTWTF/TCMalloc_ThreadCache#GetCacheIfPresent(89f09ab4cfc717c4).();
3519 if (heap != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
3520 heap->Deallocatecxx . . $ QTWTF/TCMalloc_ThreadCache#Deallocate(5500c4293b1bbef0).(ptr, cl);
3521 } else {
3522 // Delete directly into central cache
3523 SLL_SetNextcxx . . $ QTWTF/SLL_SetNext(6c58c5e2437d25a2).(ptr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
3524 central_cachecxx . . $ QTWTF/central_cache.[cl].InsertRangecxx . . $ QTWTF/TCMalloc_Central_FreeList#InsertRange(5be095a8278d2bf5).(ptr, ptr, 1);
3525 }
3526 } else {
3527 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
3528 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(reinterpret_cast<uintptr_t>(ptr) % kPageSize == 0);
3529 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span != NULL && span->start == p);
3530 #ifndef NO_TCMALLOC_SAMPLEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:88:9`!
3531 if (span->sample) {
3532 DLL_Remove(span);
3533 stacktrace_allocator.Delete(reinterpret_cast<StackTrace*>(span->objects));
3534 span->objects = NULL;
3535 }
3536 #endif
3537 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->Deletecxx . . $ QTWTF/TCMalloc_PageHeap#Delete(41397daa150afe2e).(span);
3538 }
3539 }
3540
3541 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3542 // For use by exported routines below that want specific alignments
3543 //
3544 // Note: this code can be slow, and can significantly fragment memory.
3545 // The expectation is that memalign/posix_memalign/valloc/pvalloc will
3546 // not be invoked very often. This requirement simplifies our
3547 // implementation and allows us to tune for expected allocation
3548 // patterns.
3549 static void* do_memalign(size_t align, size_t size) {
3550 ASSERT((align & (align - 1)) == 0);
3551 ASSERT(align > 0);
3552 if (pageheap == NULL) TCMalloc_ThreadCache::InitModule();
3553
3554 // Allocate at least one byte to avoid boundary conditions below
3555 if (size == 0) size = 1;
3556
3557 if (size <= kMaxSize && align < kPageSize) {
3558 // Search through acceptable size classes looking for one with
3559 // enough alignment. This depends on the fact that
3560 // InitSizeClasses() currently produces several size classes that
3561 // are aligned at powers of two. We will waste time and space if
3562 // we miss in the size class array, but that is deemed acceptable
3563 // since memalign() should be used rarely.
3564 size_t cl = SizeClass(size);
3565 while (cl < kNumClasses && ((class_to_size[cl] & (align - 1)) != 0)) {
3566 cl++;
3567 }
3568 if (cl < kNumClasses) {
3569 TCMalloc_ThreadCache* heap = TCMalloc_ThreadCache::GetCache();
3570 return CheckedMallocResult(heap->Allocate(class_to_size[cl]));
3571 }
3572 }
3573
3574 // We will allocate directly from the page heap
3575 SpinLockHolder h(&pageheap_lock);
3576
3577 if (align <= kPageSize) {
3578 // Any page-level allocation will be fine
3579 // TODO: We could put the rest of this page in the appropriate
3580 // TODO: cache but it does not seem worth it.
3581 Span* span = pageheap->New(pages(size));
3582 return span == NULL ? NULL : SpanToMallocResult(span);
3583 }
3584
3585 // Allocate extra pages and carve off an aligned portion
3586 const Length alloc = pages(size + align);
3587 Span* span = pageheap->New(alloc);
3588 if (span == NULL) return NULL;
3589
3590 // Skip starting portion so that we end up aligned
3591 Length skip = 0;
3592 while ((((span->start+skip) << kPageShift) & (align - 1)) != 0) {
3593 skip++;
3594 }
3595 ASSERT(skip < alloc);
3596 if (skip > 0) {
3597 Span* rest = pageheap->Split(span, skip);
3598 pageheap->Delete(span);
3599 span = rest;
3600 }
3601
3602 // Skip trailing portion that we do not need to return
3603 const Length needed = pages(size);
3604 ASSERT(span->length >= needed);
3605 if (span->length > needed) {
3606 Span* trailer = pageheap->Split(span, needed);
3607 pageheap->Delete(trailer);
3608 }
3609 return SpanToMallocResult(span);
3610 }
3611 #endif
3612
3613 // Helpers for use by exported routines below:
3614
3615 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3616 static inline void do_malloc_stats() {
3617 PrintStats(1);
3618 }
3619 #endif
3620
3621 static inline int do_malloptcxx . . $ QTWTF/do_mallopt(9b79fb6aee4c0440).(int, int) {
3622 return 1; // Indicates error
3623 }
3624
3625 #ifdef HAVE_STRUCT_MALLINFO // mallinfo isn't defined on freebsd, for instance
3626 static inline struct mallinfo do_mallinfo() {
3627 TCMallocStats stats;
3628 ExtractStats(&stats, NULL);
3629
3630 // Just some of the fields are filled in.
3631 struct mallinfo info;
3632 memset(&info, 0, sizeof(info));
3633
3634 // Unfortunately, the struct contains "int" field, so some of the
3635 // size values will be truncated.
3636 info.arena = static_cast<int>(stats.system_bytes);
3637 info.fsmblks = static_cast<int>(stats.thread_bytes
3638 + stats.central_bytes
3639 + stats.transfer_bytes);
3640 info.fordblks = static_cast<int>(stats.pageheap_bytes);
3641 info.uordblks = static_cast<int>(stats.system_bytes
3642 - stats.thread_bytes
3643 - stats.central_bytes
3644 - stats.transfer_bytes
3645 - stats.pageheap_bytes);
3646
3647 return info;
3648 }
3649 #endif
3650
3651 //-------------------------------------------------------------------
3652 // Exported routines
3653 //-------------------------------------------------------------------
3654
3655 // CAVEAT: The code structure below ensures that MallocHook methods are always
3656 // called from the stack frame of the invoked allocation function.
3657 // heap-checker.cc depends on this to start a stack trace from
3658 // the call to the (de)allocation function.
3659
3660 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3661 extern "C"
3662 #else
3663 #define do_malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:3663:9`! do_malloc<crashOnFailure>
3664
3665 template <bool crashOnFailure>
3666 void* malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`!(size_t);
3667
3668 void* fastMalloccxx . . $ QTWTF/fastMalloc(bfcfa4d6b7f7ef64).(size_t size)
3669 {
3670 return malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`!<true>(size);
3671 }
3672
3673 TryMallocReturnValuecxx . . $ QTWTF/TryMallocReturnValue# tryFastMalloccxx . . $ QTWTF/tryFastMalloc(a199d47e2bcba94).(size_t size)
3674 {
3675 returncxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(1f58393e1bf9b27e). malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`!<false>(size);
3676 }
3677
3678 template <bool crashOnFailure>
3679 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`!
3680 #endif
3681 void* malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:443:9`!(size_t size) {
3682 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3683 if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= size) // If overflow would occur...
3684 return 0;
3685 size += sizeof(AllocAlignmentInteger);
3686 void* result = do_malloc(size);
3687 if (!result)
3688 return 0;
3689
3690 *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
3691 result = static_cast<AllocAlignmentInteger*>(result) + 1;
3692 #else
3693 void* result = do_malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:3663:9`!(size);
3694 #endif
3695
3696 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3697 MallocHook::InvokeNewHook(result, size);
3698 #endif
3699 return result;
3700 }
3701
3702 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3703 extern "C"
3704 #endif
3705 void freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`!(void* ptr) {
3706 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3707 MallocHook::InvokeDeleteHook(ptr);
3708 #endif
3709
3710 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3711 if (!ptr)
3712 return;
3713
3714 AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(ptr);
3715 if (*header != Internal::AllocTypeMalloc)
3716 Internal::fastMallocMatchFailed(ptr);
3717 do_free(header);
3718 #else
3719 do_freecxx . . $ QTWTF/do_free(5d22bdacc48458e8).(ptr);
3720 #endif
3721 }
3722
3723 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3724 extern "C"
3725 #else
3726 template <bool crashOnFailure>
3727 void* calloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:444:9`!(size_t, size_t);
3728
3729 void* fastCalloccxx . . $ QTWTF/fastCalloc(63a7bf2941bfcd7a).(size_t n, size_t elem_size)
3730 {
3731 return calloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:444:9`!<true>(n, elem_size);
3732 }
3733
3734 TryMallocReturnValuecxx . . $ QTWTF/TryMallocReturnValue# tryFastCalloccxx . . $ QTWTF/tryFastCalloc(a4dbf2e2356fd5e4).(size_t n, size_t elem_size)
3735 {
3736 returncxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(1f58393e1bf9b27e). calloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:444:9`!<false>(n, elem_size);
3737 }
3738
3739 template <bool crashOnFailure>
3740 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`!
3741 #endif
3742 void* calloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:444:9`!(size_t n, size_t elem_size) {
3743 size_t totalBytes = n * elem_size;
3744
3745 // Protect against overflow
3746 if (n > 1 && elem_size && (totalBytes / elem_size) != n)
3747 return 0;
3748
3749 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3750 if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= totalBytes) // If overflow would occur...
3751 return 0;
3752
3753 totalBytes += sizeof(AllocAlignmentInteger);
3754 void* result = do_malloc(totalBytes);
3755 if (!result)
3756 return 0;
3757
3758 memset(result, 0, totalBytes);
3759 *static_cast<AllocAlignmentInteger*>(result) = Internal::AllocTypeMalloc;
3760 result = static_cast<AllocAlignmentInteger*>(result) + 1;
3761 #else
3762 void* result = do_malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:3663:9`!(totalBytes);
3763 if (result != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
3764 memset(result, 0, totalBytes);
3765 }
3766 #endif
3767
3768 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3769 MallocHook::InvokeNewHook(result, totalBytes);
3770 #endif
3771 return result;
3772 }
3773
3774 // Since cfree isn't used anywhere, we don't compile it in.
3775 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3776 #ifndef WTF_CHANGES
3777 extern "C"
3778 #endif
3779 void cfree(void* ptr) {
3780 #ifndef WTF_CHANGES
3781 MallocHook::InvokeDeleteHook(ptr);
3782 #endif
3783 do_free(ptr);
3784 }
3785 #endif
3786
3787 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3788 extern "C"
3789 #else
3790 template <bool crashOnFailure>
3791 void* realloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:446:9`!(void*, size_t);
3792
3793 void* fastRealloccxx . . $ QTWTF/fastRealloc(417ab160f6baadc6).(void* old_ptr, size_t new_size)
3794 {
3795 return realloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:446:9`!<true>(old_ptr, new_size);
3796 }
3797
3798 TryMallocReturnValuecxx . . $ QTWTF/TryMallocReturnValue# tryFastRealloccxx . . $ QTWTF/tryFastRealloc(6696b16547a81308).(void* old_ptr, size_t new_size)
3799 {
3800 returncxx . . $ QTWTF/TryMallocReturnValue#TryMallocReturnValue(1f58393e1bf9b27e). realloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:446:9`!<false>(old_ptr, new_size);
3801 }
3802
3803 template <bool crashOnFailure>
3804 ALWAYS_INLINEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`!
3805 #endif
3806 void* realloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:446:9`!(void* old_ptr, size_t new_size) {
3807 if (old_ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
3808 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3809 void* result = malloc(new_size);
3810 #else
3811 void* result = do_malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:3663:9`!(new_size);
3812 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3813 MallocHook::InvokeNewHook(result, new_size);
3814 #endif
3815 #endif
3816 return result;
3817 }
3818 if (new_size == 0) {
3819 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3820 MallocHook::InvokeDeleteHook(old_ptr);
3821 #endif
3822 freecxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:445:9`!(old_ptr);
3823 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
3824 }
3825
3826 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3827 if (std::numeric_limits<size_t>::max() - sizeof(AllocAlignmentInteger) <= new_size) // If overflow would occur...
3828 return 0;
3829 new_size += sizeof(AllocAlignmentInteger);
3830 AllocAlignmentInteger* header = Internal::fastMallocMatchValidationValue(old_ptr);
3831 if (*header != Internal::AllocTypeMalloc)
3832 Internal::fastMallocMatchFailed(old_ptr);
3833 old_ptr = header;
3834 #endif
3835
3836 // Get the size of the old entry
3837 const PageIDcxx . . $ QTWTF/PageID# p = reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(old_ptr) >> kPageShiftcxx . . $ QTWTF/kPageShift.;
3838 size_t cl = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetSizeClassIfCachedcxx . . $ QTWTF/TCMalloc_PageHeap#GetSizeClassIfCached(611be0c07d97f8b8).(p);
3839 Spancxx . . $ QTWTF/Span# *span = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
3840 size_t old_size;
3841 if (cl == 0) {
3842 span = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->GetDescriptorcxx . . $ QTWTF/TCMalloc_PageHeap#GetDescriptor(1d98660613472621).(p);
3843 cl = span->sizeclasscxx . . $ QTWTF/Span#sizeclass.;
3844 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->CacheSizeClasscxx . . $ QTWTF/TCMalloc_PageHeap#CacheSizeClass(c652d5d4e23f3c95).(p, cl);
3845 }
3846 if (cl != 0) {
3847 old_size = ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(cl);
3848 } else {
3849 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(span != NULL);
3850 old_size = span->lengthcxx . . $ QTWTF/Span#length. << kPageShiftcxx . . $ QTWTF/kPageShift.;
3851 }
3852
3853 // Reallocate if the new size is larger than the old size,
3854 // or if the new size is significantly smaller than the old size.
3855 if ((new_size > old_size) || (AllocationSizecxx . . $ QTWTF/AllocationSize(ecdaa1632f49f591).(new_size) < old_size)) {
3856 // Need to reallocate
3857 void* new_ptr = do_malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:3663:9`!(new_size);
3858 if (new_ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
3859 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
3860 }
3861 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3862 MallocHook::InvokeNewHook(new_ptr, new_size);
3863 #endif
3864 memcpy(new_ptr, old_ptr, ((old_size < new_size) ? old_size : new_size));
3865 #ifndef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3866 MallocHook::InvokeDeleteHook(old_ptr);
3867 #endif
3868 // We could use a variant of do_free() that leverages the fact
3869 // that we already know the sizeclass of old_ptr. The benefit
3870 // would be small, so don't bother.
3871 do_freecxx . . $ QTWTF/do_free(5d22bdacc48458e8).(old_ptr);
3872 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3873 new_ptr = static_cast<AllocAlignmentInteger*>(new_ptr) + 1;
3874 #endif
3875 return new_ptr;
3876 } else {
3877 #if ENABLEcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:57:9`!(FAST_MALLOC_MATCH_VALIDATION)
3878 old_ptr = static_cast<AllocAlignmentInteger*>(old_ptr) + 1; // Set old_ptr back to the user pointer.
3879 #endif
3880 return old_ptr;
3881 }
3882 }
3883
3884 #ifdef WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
3885 #undef do_malloccxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:3663:9`!
3886 #else
3887
3888 static SpinLock set_new_handler_lock = SPINLOCK_INITIALIZER;
3889
3890 static inline void* cpp_alloc(size_t size, bool nothrow) {
3891 for (;;) {
3892 void* p = do_malloc(size);
3893 #ifdef PREANSINEW
3894 return p;
3895 #else
3896 if (p == NULL) { // allocation failed
3897 // Get the current new handler. NB: this function is not
3898 // thread-safe. We make a feeble stab at making it so here, but
3899 // this lock only protects against tcmalloc interfering with
3900 // itself, not with other libraries calling set_new_handler.
3901 std::new_handler nh;
3902 {
3903 SpinLockHolder h(&set_new_handler_lock);
3904 nh = std::set_new_handler(0);
3905 (void) std::set_new_handler(nh);
3906 }
3907 // If no new_handler is established, the allocation failed.
3908 if (!nh) {
3909 if (nothrow) return 0;
3910 throw std::bad_alloc();
3911 }
3912 // Otherwise, try the new_handler. If it returns, retry the
3913 // allocation. If it throws std::bad_alloc, fail the allocation.
3914 // if it throws something else, don't interfere.
3915 try {
3916 (*nh)();
3917 } catch (const std::bad_alloc&) {
3918 if (!nothrow) throw;
3919 return p;
3920 }
3921 } else { // allocation success
3922 return p;
3923 }
3924 #endif
3925 }
3926 }
3927
3928 void* operator new(size_t size) {
3929 void* p = cpp_alloc(size, false);
3930 // We keep this next instruction out of cpp_alloc for a reason: when
3931 // it's in, and new just calls cpp_alloc, the optimizer may fold the
3932 // new call into cpp_alloc, which messes up our whole section-based
3933 // stacktracing (see ATTRIBUTE_SECTION, above). This ensures cpp_alloc
3934 // isn't the last thing this fn calls, and prevents the folding.
3935 MallocHook::InvokeNewHook(p, size);
3936 return p;
3937 }
3938
3939 void* operator new(size_t size, const std::nothrow_t&) __THROW {
3940 void* p = cpp_alloc(size, true);
3941 MallocHook::InvokeNewHook(p, size);
3942 return p;
3943 }
3944
3945 void operator delete(void* p) __THROW {
3946 MallocHook::InvokeDeleteHook(p);
3947 do_free(p);
3948 }
3949
3950 void operator delete(void* p, const std::nothrow_t&) __THROW {
3951 MallocHook::InvokeDeleteHook(p);
3952 do_free(p);
3953 }
3954
3955 void* operator new[](size_t size) {
3956 void* p = cpp_alloc(size, false);
3957 // We keep this next instruction out of cpp_alloc for a reason: when
3958 // it's in, and new just calls cpp_alloc, the optimizer may fold the
3959 // new call into cpp_alloc, which messes up our whole section-based
3960 // stacktracing (see ATTRIBUTE_SECTION, above). This ensures cpp_alloc
3961 // isn't the last thing this fn calls, and prevents the folding.
3962 MallocHook::InvokeNewHook(p, size);
3963 return p;
3964 }
3965
3966 void* operator new[](size_t size, const std::nothrow_t&) __THROW {
3967 void* p = cpp_alloc(size, true);
3968 MallocHook::InvokeNewHook(p, size);
3969 return p;
3970 }
3971
3972 void operator delete[](void* p) __THROW {
3973 MallocHook::InvokeDeleteHook(p);
3974 do_free(p);
3975 }
3976
3977 void operator delete[](void* p, const std::nothrow_t&) __THROW {
3978 MallocHook::InvokeDeleteHook(p);
3979 do_free(p);
3980 }
3981
3982 extern "C" void* memalign(size_t align, size_t size) __THROW {
3983 void* result = do_memalign(align, size);
3984 MallocHook::InvokeNewHook(result, size);
3985 return result;
3986 }
3987
3988 extern "C" int posix_memalign(void** result_ptr, size_t align, size_t size)
3989 __THROW {
3990 if (((align % sizeof(void*)) != 0) ||
3991 ((align & (align - 1)) != 0) ||
3992 (align == 0)) {
3993 return EINVAL;
3994 }
3995
3996 void* result = do_memalign(align, size);
3997 MallocHook::InvokeNewHook(result, size);
3998 if (result == NULL) {
3999 return ENOMEM;
4000 } else {
4001 *result_ptr = result;
4002 return 0;
4003 }
4004 }
4005
4006 static size_t pagesize = 0;
4007
4008 extern "C" void* valloc(size_t size) __THROW {
4009 // Allocate page-aligned object of length >= size bytes
4010 if (pagesize == 0) pagesize = getpagesize();
4011 void* result = do_memalign(pagesize, size);
4012 MallocHook::InvokeNewHook(result, size);
4013 return result;
4014 }
4015
4016 extern "C" void* pvalloc(size_t size) __THROW {
4017 // Round up size to a multiple of pagesize
4018 if (pagesize == 0) pagesize = getpagesize();
4019 size = (size + pagesize - 1) & ~(pagesize - 1);
4020 void* result = do_memalign(pagesize, size);
4021 MallocHook::InvokeNewHook(result, size);
4022 return result;
4023 }
4024
4025 extern "C" void malloc_stats(void) {
4026 do_malloc_stats();
4027 }
4028
4029 extern "C" int mallopt(int cmd, int value) {
4030 return do_mallopt(cmd, value);
4031 }
4032
4033 #ifdef HAVE_STRUCT_MALLINFO
4034 extern "C" struct mallinfo mallinfo(void) {
4035 return do_mallinfo();
4036 }
4037 #endif
4038
4039 //-------------------------------------------------------------------
4040 // Some library routines on RedHat 9 allocate memory using malloc()
4041 // and free it using __libc_free() (or vice-versa). Since we provide
4042 // our own implementations of malloc/free, we need to make sure that
4043 // the __libc_XXX variants (defined as part of glibc) also point to
4044 // the same implementations.
4045 //-------------------------------------------------------------------
4046
4047 #if defined(__GLIBC__)
4048 extern "C" {
4049 #if COMPILER(GCC) && !defined(__MACH__) && defined(HAVE___ATTRIBUTE__)
4050 // Potentially faster variants that use the gcc alias extension.
4051 // Mach-O (Darwin) does not support weak aliases, hence the __MACH__ check.
4052 # define ALIAS(x) __attribute__ ((weak, alias (x)))
4053 void* __libc_malloc(size_t size) ALIAS("malloc");
4054 void __libc_free(void* ptr) ALIAS("free");
4055 void* __libc_realloc(void* ptr, size_t size) ALIAS("realloc");
4056 void* __libc_calloc(size_t n, size_t size) ALIAS("calloc");
4057 void __libc_cfree(void* ptr) ALIAS("cfree");
4058 void* __libc_memalign(size_t align, size_t s) ALIAS("memalign");
4059 void* __libc_valloc(size_t size) ALIAS("valloc");
4060 void* __libc_pvalloc(size_t size) ALIAS("pvalloc");
4061 int __posix_memalign(void** r, size_t a, size_t s) ALIAS("posix_memalign");
4062 # undef ALIAS
4063 # else /* not __GNUC__ */
4064 // Portable wrappers
4065 void* __libc_malloc(size_t size) { return malloc(size); }
4066 void __libc_free(void* ptr) { free(ptr); }
4067 void* __libc_realloc(void* ptr, size_t size) { return realloc(ptr, size); }
4068 void* __libc_calloc(size_t n, size_t size) { return calloc(n, size); }
4069 void __libc_cfree(void* ptr) { cfree(ptr); }
4070 void* __libc_memalign(size_t align, size_t s) { return memalign(align, s); }
4071 void* __libc_valloc(size_t size) { return valloc(size); }
4072 void* __libc_pvalloc(size_t size) { return pvalloc(size); }
4073 int __posix_memalign(void** r, size_t a, size_t s) {
4074 return posix_memalign(r, a, s);
4075 }
4076 # endif /* __GNUC__ */
4077 }
4078 #endif /* __GLIBC__ */
4079
4080 // Override __libc_memalign in libc on linux boxes specially.
4081 // They have a bug in libc that causes them to (very rarely) allocate
4082 // with __libc_memalign() yet deallocate with free() and the
4083 // definitions above don't catch it.
4084 // This function is an exception to the rule of calling MallocHook method
4085 // from the stack frame of the allocation function;
4086 // heap-checker handles this special case explicitly.
4087 static void *MemalignOverride(size_t align, size_t size, const void *caller)
4088 __THROW {
4089 void* result = do_memalign(align, size);
4090 MallocHook::InvokeNewHook(result, size);
4091 return result;
4092 }
4093 void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride;
4094
4095 #endif
4096
4097 #if defined(WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!) && OScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h:49:9`!(DARWIN)
4098
4099 class FreeObjectFinder {
4100 const RemoteMemoryReader& m_reader;
4101 HashSet<void*> m_freeObjects;
4102
4103 public:
4104 FreeObjectFinder(const RemoteMemoryReader& reader) : m_reader(reader) { }
4105
4106 void visit(void* ptr) { m_freeObjects.add(ptr); }
4107 bool isFreeObject(void* ptr) const { return m_freeObjects.contains(ptr); }
4108 bool isFreeObject(vm_address_t ptr) const { return isFreeObject(reinterpret_cast<void*>(ptr)); }
4109 size_t freeObjectCount() const { return m_freeObjects.size(); }
4110
4111 void findFreeObjects(TCMalloc_ThreadCache* threadCache)
4112 {
4113 for (; threadCache; threadCache = (threadCache->next_ ? m_reader(threadCache->next_) : 0))
4114 threadCache->enumerateFreeObjects(*this, m_reader);
4115 }
4116
4117 void findFreeObjects(TCMalloc_Central_FreeListPadded* centralFreeList, size_t numSizes, TCMalloc_Central_FreeListPadded* remoteCentralFreeList)
4118 {
4119 for (unsigned i = 0; i < numSizes; i++)
4120 centralFreeList[i].enumerateFreeObjects(*this, m_reader, remoteCentralFreeList + i);
4121 }
4122 };
4123
4124 class PageMapFreeObjectFinder {
4125 const RemoteMemoryReader& m_reader;
4126 FreeObjectFinder& m_freeObjectFinder;
4127
4128 public:
4129 PageMapFreeObjectFinder(const RemoteMemoryReader& reader, FreeObjectFinder& freeObjectFinder)
4130 : m_reader(reader)
4131 , m_freeObjectFinder(freeObjectFinder)
4132 { }
4133
4134 int visit(void* ptr) const
4135 {
4136 if (!ptr)
4137 return 1;
4138
4139 Span* span = m_reader(reinterpret_cast<Span*>(ptr));
4140 if (span->free) {
4141 void* ptr = reinterpret_cast<void*>(span->start << kPageShift);
4142 m_freeObjectFinder.visit(ptr);
4143 } else if (span->sizeclass) {
4144 // Walk the free list of the small-object span, keeping track of each object seen
4145 for (void* nextObject = span->objects; nextObject; nextObject = *m_reader(reinterpret_cast<void**>(nextObject)))
4146 m_freeObjectFinder.visit(nextObject);
4147 }
4148 return span->length;
4149 }
4150 };
4151
4152 class PageMapMemoryUsageRecorder {
4153 task_t m_task;
4154 void* m_context;
4155 unsigned m_typeMask;
4156 vm_range_recorder_t* m_recorder;
4157 const RemoteMemoryReader& m_reader;
4158 const FreeObjectFinder& m_freeObjectFinder;
4159
4160 HashSet<void*> m_seenPointers;
4161 Vector<Span*> m_coalescedSpans;
4162
4163 public:
4164 PageMapMemoryUsageRecorder(task_t task, void* context, unsigned typeMask, vm_range_recorder_t* recorder, const RemoteMemoryReader& reader, const FreeObjectFinder& freeObjectFinder)
4165 : m_task(task)
4166 , m_context(context)
4167 , m_typeMask(typeMask)
4168 , m_recorder(recorder)
4169 , m_reader(reader)
4170 , m_freeObjectFinder(freeObjectFinder)
4171 { }
4172
4173 ~PageMapMemoryUsageRecorder()
4174 {
4175 ASSERT(!m_coalescedSpans.size());
4176 }
4177
4178 void recordPendingRegions()
4179 {
4180 Span* lastSpan = m_coalescedSpans[m_coalescedSpans.size() - 1];
4181 vm_range_t ptrRange = { m_coalescedSpans[0]->start << kPageShift, 0 };
4182 ptrRange.size = (lastSpan->start << kPageShift) - ptrRange.address + (lastSpan->length * kPageSize);
4183
4184 // Mark the memory region the spans represent as a candidate for containing pointers
4185 if (m_typeMask & MALLOC_PTR_REGION_RANGE_TYPE)
4186 (*m_recorder)(m_task, m_context, MALLOC_PTR_REGION_RANGE_TYPE, &ptrRange, 1);
4187
4188 if (!(m_typeMask & MALLOC_PTR_IN_USE_RANGE_TYPE)) {
4189 m_coalescedSpans.clear();
4190 return;
4191 }
4192
4193 Vector<vm_range_t, 1024> allocatedPointers;
4194 for (size_t i = 0; i < m_coalescedSpans.size(); ++i) {
4195 Span *theSpan = m_coalescedSpans[i];
4196 if (theSpan->free)
4197 continue;
4198
4199 vm_address_t spanStartAddress = theSpan->start << kPageShift;
4200 vm_size_t spanSizeInBytes = theSpan->length * kPageSize;
4201
4202 if (!theSpan->sizeclass) {
4203 // If it's an allocated large object span, mark it as in use
4204 if (!m_freeObjectFinder.isFreeObject(spanStartAddress))
4205 allocatedPointers.append((vm_range_t){spanStartAddress, spanSizeInBytes});
4206 } else {
4207 const size_t objectSize = ByteSizeForClass(theSpan->sizeclass);
4208
4209 // Mark each allocated small object within the span as in use
4210 const vm_address_t endOfSpan = spanStartAddress + spanSizeInBytes;
4211 for (vm_address_t object = spanStartAddress; object + objectSize <= endOfSpan; object += objectSize) {
4212 if (!m_freeObjectFinder.isFreeObject(object))
4213 allocatedPointers.append((vm_range_t){object, objectSize});
4214 }
4215 }
4216 }
4217
4218 (*m_recorder)(m_task, m_context, MALLOC_PTR_IN_USE_RANGE_TYPE, allocatedPointers.data(), allocatedPointers.size());
4219
4220 m_coalescedSpans.clear();
4221 }
4222
4223 int visit(void* ptr)
4224 {
4225 if (!ptr)
4226 return 1;
4227
4228 Span* span = m_reader(reinterpret_cast<Span*>(ptr));
4229 if (!span->start)
4230 return 1;
4231
4232 if (m_seenPointers.contains(ptr))
4233 return span->length;
4234 m_seenPointers.add(ptr);
4235
4236 if (!m_coalescedSpans.size()) {
4237 m_coalescedSpans.append(span);
4238 return span->length;
4239 }
4240
4241 Span* previousSpan = m_coalescedSpans[m_coalescedSpans.size() - 1];
4242 vm_address_t previousSpanStartAddress = previousSpan->start << kPageShift;
4243 vm_size_t previousSpanSizeInBytes = previousSpan->length * kPageSize;
4244
4245 // If the new span is adjacent to the previous span, do nothing for now.
4246 vm_address_t spanStartAddress = span->start << kPageShift;
4247 if (spanStartAddress == previousSpanStartAddress + previousSpanSizeInBytes) {
4248 m_coalescedSpans.append(span);
4249 return span->length;
4250 }
4251
4252 // New span is not adjacent to previous span, so record the spans coalesced so far.
4253 recordPendingRegions();
4254 m_coalescedSpans.append(span);
4255
4256 return span->length;
4257 }
4258 };
4259
4260 class AdminRegionRecorder {
4261 task_t m_task;
4262 void* m_context;
4263 unsigned m_typeMask;
4264 vm_range_recorder_t* m_recorder;
4265 const RemoteMemoryReader& m_reader;
4266
4267 Vector<vm_range_t, 1024> m_pendingRegions;
4268
4269 public:
4270 AdminRegionRecorder(task_t task, void* context, unsigned typeMask, vm_range_recorder_t* recorder, const RemoteMemoryReader& reader)
4271 : m_task(task)
4272 , m_context(context)
4273 , m_typeMask(typeMask)
4274 , m_recorder(recorder)
4275 , m_reader(reader)
4276 { }
4277
4278 void recordRegion(vm_address_t ptr, size_t size)
4279 {
4280 if (m_typeMask & MALLOC_ADMIN_REGION_RANGE_TYPE)
4281 m_pendingRegions.append((vm_range_t){ ptr, size });
4282 }
4283
4284 void visit(void *ptr, size_t size)
4285 {
4286 recordRegion(reinterpret_cast<vm_address_t>(ptr), size);
4287 }
4288
4289 void recordPendingRegions()
4290 {
4291 if (m_pendingRegions.size()) {
4292 (*m_recorder)(m_task, m_context, MALLOC_ADMIN_REGION_RANGE_TYPE, m_pendingRegions.data(), m_pendingRegions.size());
4293 m_pendingRegions.clear();
4294 }
4295 }
4296
4297 ~AdminRegionRecorder()
4298 {
4299 ASSERT(!m_pendingRegions.size());
4300 }
4301 };
4302
4303 kern_return_t FastMallocZone::enumerate(task_t task, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t reader, vm_range_recorder_t recorder)
4304 {
4305 RemoteMemoryReader memoryReader(task, reader);
4306
4307 InitSizeClasses();
4308
4309 FastMallocZone* mzone = memoryReader(reinterpret_cast<FastMallocZone*>(zoneAddress));
4310 TCMalloc_PageHeap* pageHeap = memoryReader(mzone->m_pageHeap);
4311 TCMalloc_ThreadCache** threadHeapsPointer = memoryReader(mzone->m_threadHeaps);
4312 TCMalloc_ThreadCache* threadHeaps = memoryReader(*threadHeapsPointer);
4313
4314 TCMalloc_Central_FreeListPadded* centralCaches = memoryReader(mzone->m_centralCaches, sizeof(TCMalloc_Central_FreeListPadded) * kNumClasses);
4315
4316 FreeObjectFinder finder(memoryReader);
4317 finder.findFreeObjects(threadHeaps);
4318 finder.findFreeObjects(centralCaches, kNumClasses, mzone->m_centralCaches);
4319
4320 TCMalloc_PageHeap::PageMap* pageMap = &pageHeap->pagemap_;
4321 PageMapFreeObjectFinder pageMapFinder(memoryReader, finder);
4322 pageMap->visitValues(pageMapFinder, memoryReader);
4323
4324 PageMapMemoryUsageRecorder usageRecorder(task, context, typeMask, recorder, memoryReader, finder);
4325 pageMap->visitValues(usageRecorder, memoryReader);
4326 usageRecorder.recordPendingRegions();
4327
4328 AdminRegionRecorder adminRegionRecorder(task, context, typeMask, recorder, memoryReader);
4329 pageMap->visitAllocations(adminRegionRecorder, memoryReader);
4330
4331 PageHeapAllocator<Span>* spanAllocator = memoryReader(mzone->m_spanAllocator);
4332 PageHeapAllocator<TCMalloc_ThreadCache>* pageHeapAllocator = memoryReader(mzone->m_pageHeapAllocator);
4333
4334 spanAllocator->recordAdministrativeRegions(adminRegionRecorder, memoryReader);
4335 pageHeapAllocator->recordAdministrativeRegions(adminRegionRecorder, memoryReader);
4336
4337 adminRegionRecorder.recordPendingRegions();
4338
4339 return 0;
4340 }
4341
4342 size_t FastMallocZone::size(malloc_zone_t*, const void*)
4343 {
4344 return 0;
4345 }
4346
4347 void* FastMallocZone::zoneMalloc(malloc_zone_t*, size_t)
4348 {
4349 return 0;
4350 }
4351
4352 void* FastMallocZone::zoneCalloc(malloc_zone_t*, size_t, size_t)
4353 {
4354 return 0;
4355 }
4356
4357 void FastMallocZone::zoneFree(malloc_zone_t*, void* ptr)
4358 {
4359 // Due to <rdar://problem/5671357> zoneFree may be called by the system free even if the pointer
4360 // is not in this zone. When this happens, the pointer being freed was not allocated by any
4361 // zone so we need to print a useful error for the application developer.
4362 malloc_printf("*** error for object %p: pointer being freed was not allocated\n", ptr);
4363 }
4364
4365 void* FastMallocZone::zoneRealloc(malloc_zone_t*, void*, size_t)
4366 {
4367 return 0;
4368 }
4369
4370
4371 #undef malloc
4372 #undef free
4373 #undef realloc
4374 #undef calloc
4375
4376 extern "C" {
4377 malloc_introspection_t jscore_fastmalloc_introspection = { &FastMallocZone::enumerate, &FastMallocZone::goodSize, &FastMallocZone::check, &FastMallocZone::print,
4378 &FastMallocZone::log, &FastMallocZone::forceLock, &FastMallocZone::forceUnlock, &FastMallocZone::statistics
4379
4380 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !OS(IPHONE_OS)
4381 , 0 // zone_locked will not be called on the zone unless it advertises itself as version five or higher.
4382 #endif
4383
4384 };
4385 }
4386
4387 FastMallocZone::FastMallocZone(TCMalloc_PageHeap* pageHeap, TCMalloc_ThreadCache** threadHeaps, TCMalloc_Central_FreeListPadded* centralCaches, PageHeapAllocator<Span>* spanAllocator, PageHeapAllocator<TCMalloc_ThreadCache>* pageHeapAllocator)
4388 : m_pageHeap(pageHeap)
4389 , m_threadHeaps(threadHeaps)
4390 , m_centralCaches(centralCaches)
4391 , m_spanAllocator(spanAllocator)
4392 , m_pageHeapAllocator(pageHeapAllocator)
4393 {
4394 memset(&m_zone, 0, sizeof(m_zone));
4395 m_zone.version = 4;
4396 m_zone.zone_name = "JavaScriptCore FastMalloc";
4397 m_zone.size = &FastMallocZone::size;
4398 m_zone.malloc = &FastMallocZone::zoneMalloc;
4399 m_zone.calloc = &FastMallocZone::zoneCalloc;
4400 m_zone.realloc = &FastMallocZone::zoneRealloc;
4401 m_zone.free = &FastMallocZone::zoneFree;
4402 m_zone.valloc = &FastMallocZone::zoneValloc;
4403 m_zone.destroy = &FastMallocZone::zoneDestroy;
4404 m_zone.introspect = &jscore_fastmalloc_introspection;
4405 malloc_zone_register(&m_zone);
4406 }
4407
4408
4409 void FastMallocZone::init()
4410 {
4411 static FastMallocZone zone(pageheap, &thread_heaps, static_cast<TCMalloc_Central_FreeListPadded*>(central_cache), &span_allocator, &threadheap_allocator);
4412 }
4413
4414 #endif
4415
4416 #if WTF_CHANGEScxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/config.h:63:9`!
4417 void releaseFastMallocFreeMemorycxx . . $ QTWTF/releaseFastMallocFreeMemory(49f6e7a06ebc5aa8).()
4418 {
4419 // Flush free pages in the current thread cache back to the page heap.
4420 // Low watermark mechanism in Scavenge() prevents full return on the first pass.
4421 // The second pass flushes everything.
4422 if (TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* threadCache = TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#::GetCacheIfPresentcxx . . $ QTWTF/TCMalloc_ThreadCache#GetCacheIfPresent(89f09ab4cfc717c4).()) {
4423 threadCache->Scavengecxx . . $ QTWTF/TCMalloc_ThreadCache#Scavenge(49f6e7a06ebc5aa8).();
4424 threadCache->Scavengecxx . . $ QTWTF/TCMalloc_ThreadCache#Scavenge(49f6e7a06ebc5aa8).();
4425 }
4426
4427 SpinLockHoldercxx . . $ SpinLockHolder# hcxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
4428 pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->ReleaseFreePagescxx . . $ QTWTF/TCMalloc_PageHeap#ReleaseFreePages(49f6e7a06ebc5aa8).();
4429 }
4430
4431 FastMallocStatisticscxx . . $ QTWTF/FastMallocStatistics# fastMallocStatisticscxx . . $ QTWTF/fastMallocStatistics(a25cc48d49a9dad9).()
4432 {
4433 FastMallocStatisticscxx . . $ QTWTF/FastMallocStatistics# statistics;
4434 {
4435 SpinLockHoldercxx . . $ SpinLockHolder# lockHoldercxx . . $ TCMalloc_SpinLockHolder#TCMalloc_SpinLockHolder(e57db43ff00669e).(&pageheap_lockcxx . . $ QTWTF/pageheap_lock.);
4436 statistics.heapSizecxx . . $ QTWTF/FastMallocStatistics#heapSize. = static_cast<size_t>(pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->SystemBytescxx . . $ QTWTF/TCMalloc_PageHeap#SystemBytes(fe4d2d262d4164a8).());
4437 statistics.freeSizeInHeapcxx . . $ QTWTF/FastMallocStatistics#freeSizeInHeap. = static_cast<size_t>(pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->FreeBytescxx . . $ QTWTF/TCMalloc_PageHeap#FreeBytes(fe4d2d262d4164a8).());
4438 statistics.returnedSizecxx . . $ QTWTF/FastMallocStatistics#returnedSize. = pageheapcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2336:9`!->ReturnedBytescxx . . $ QTWTF/TCMalloc_PageHeap#ReturnedBytes(fe4d2d262d4164a8).();
4439 statistics.freeSizeInCachescxx . . $ QTWTF/FastMallocStatistics#freeSizeInCaches. = 0;
4440 for (TCMalloc_ThreadCachecxx . . $ QTWTF/TCMalloc_ThreadCache#* threadCache = thread_heapscxx . . $ QTWTF/thread_heaps.; threadCache ; threadCache = threadCache->next_cxx . . $ QTWTF/TCMalloc_ThreadCache#next_.)
4441 statistics.freeSizeInCachescxx . . $ QTWTF/FastMallocStatistics#freeSizeInCaches. += threadCache->Sizecxx . . $ QTWTF/TCMalloc_ThreadCache#Size(fe4d2d262d4164a8).();
4442 }
4443 for (unsigned cl = 0; cl < kNumClassescxx . . $ QTWTF/kNumClasses.; ++cl) {
4444 const int length = central_cachecxx . . $ QTWTF/central_cache.[cl].lengthcxx . . $ QTWTF/TCMalloc_Central_FreeList#length(f708dce9a8856c70).();
4445 const int tc_length = central_cachecxx . . $ QTWTF/central_cache.[cl].tc_lengthcxx . . $ QTWTF/TCMalloc_Central_FreeList#tc_length(b126dc7c1de90089).();
4446 statistics.freeSizeInCachescxx . . $ QTWTF/FastMallocStatistics#freeSizeInCaches. += ByteSizeForClasscxx . . $ QTWTF/ByteSizeForClass(ecdaa1632f49f591).(cl) * (length + tc_length);
4447 }
4448 return statistics;
4449 }
4450
4451 } // namespace WTF
4452 #endif
4453
4454 #endif // FORCE_SYSTEM_MALLOC