Changes in libcfa/src/heap.cfa [578ec01c:7dd98b6]
- File:
-
- 1 edited
-
libcfa/src/heap.cfa (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/heap.cfa
r578ec01c r7dd98b6 10 10 // Created On : Tue Dec 19 21:58:35 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 2 23:29:41 202213 // Update Count : 10 5812 // Last Modified On : Mon Aug 9 19:03:02 2021 13 // Update Count : 1040 14 14 // 15 15 … … 263 263 #ifdef __STATISTICS__ 264 264 // Heap statistics counters. 265 static unsigned int malloc_ calls, malloc_0_calls;266 static unsigned long long int malloc_storage _request, malloc_storage_alloc;267 static unsigned int aalloc_ calls, aalloc_0_calls;268 static unsigned long long int aalloc_storage _request, aalloc_storage_alloc;269 static unsigned int calloc_ calls, calloc_0_calls;270 static unsigned long long int calloc_storage _request, calloc_storage_alloc;271 static unsigned int memalign_ calls, memalign_0_calls;272 static unsigned long long int memalign_storage _request, memalign_storage_alloc;273 static unsigned int amemalign_ calls, amemalign_0_calls;274 static unsigned long long int amemalign_storage _request, amemalign_storage_alloc;275 static unsigned int cmemalign_ calls, cmemalign_0_calls;276 static unsigned long long int cmemalign_storage _request, cmemalign_storage_alloc;277 static unsigned int resize_ calls, resize_0_calls;278 static unsigned long long int resize_storage _request, resize_storage_alloc;279 static unsigned int realloc_ calls, realloc_0_calls;280 static unsigned long long int realloc_storage _request, realloc_storage_alloc;281 static unsigned int free_ calls, free_null_calls;282 static unsigned long long int free_storage _request, free_storage_alloc;265 static unsigned int malloc_zero_calls, malloc_calls; 266 static unsigned long long int malloc_storage; 267 static unsigned int aalloc_zero_calls, aalloc_calls; 268 static unsigned long long int aalloc_storage; 269 static unsigned int calloc_zero_calls, calloc_calls; 270 static unsigned long long int calloc_storage; 271 static unsigned int memalign_zero_calls, memalign_calls; 272 static unsigned long long int memalign_storage; 273 static unsigned int amemalign_zero_calls, amemalign_calls; 274 static unsigned long long int amemalign_storage; 275 static unsigned int cmemalign_zero_calls, cmemalign_calls; 276 static unsigned long long int cmemalign_storage; 277 static unsigned int resize_zero_calls, resize_calls; 278 static unsigned long long int resize_storage; 279 static unsigned int realloc_zero_calls, realloc_calls; 280 static unsigned long long int realloc_storage; 281 static unsigned int free_zero_calls, free_calls; 282 static unsigned long long int free_storage; 283 283 static unsigned int mmap_calls; 284 static unsigned long long int mmap_storage _request, mmap_storage_alloc;284 static unsigned long long int mmap_storage; 285 285 static unsigned int munmap_calls; 286 static unsigned long long int munmap_storage _request, munmap_storage_alloc;286 static unsigned long long int munmap_storage; 287 287 static unsigned int sbrk_calls; 288 288 static unsigned long long int sbrk_storage; … … 294 294 char helpText[1024]; 295 295 __cfaabi_bits_print_buffer( STDERR_FILENO, helpText, sizeof(helpText), 296 "\nHeap statistics: (storage request / allocation + header)\n"297 " malloc >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"298 " aalloc >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"299 " calloc >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"300 " memalign >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"301 " amemalign >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"302 " cmemalign >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"303 " resize >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"304 " realloc >0 calls %'u; 0 calls %'u; storage %'llu /%'llu bytes\n"305 " free !null calls %'u; null calls %'u; storage %'llu /%'llu bytes\n"306 " sbrkcalls %'u; storage %'llu bytes\n"307 " m map calls %'u; storage %'llu /%'llu bytes\n"308 " munmap calls %'u; storage %'llu /%'llu bytes\n",309 malloc_ calls, malloc_0_calls, malloc_storage_request, malloc_storage_alloc,310 aalloc_ calls, aalloc_0_calls, aalloc_storage_request, aalloc_storage_alloc,311 calloc_ calls, calloc_0_calls, calloc_storage_request, calloc_storage_alloc,312 memalign_ calls, memalign_0_calls, memalign_storage_request, memalign_storage_alloc,313 amemalign_ calls, amemalign_0_calls, amemalign_storage_request, amemalign_storage_alloc,314 cmemalign_ calls, cmemalign_0_calls, cmemalign_storage_request, cmemalign_storage_alloc,315 resize_ calls, resize_0_calls, resize_storage_request, resize_storage_alloc,316 realloc_ calls, realloc_0_calls, realloc_storage_request, realloc_storage_alloc,317 free_ calls, free_null_calls, free_storage_request, free_storage_alloc,318 sbrk_calls, sbrk_storage,319 m map_calls, mmap_storage_request, mmap_storage_alloc,320 munmap_calls, munmap_storage_request, munmap_storage_alloc296 "\nHeap statistics:\n" 297 " malloc 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 298 " aalloc 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 299 " calloc 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 300 " memalign 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 301 " amemalign 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 302 " cmemalign 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 303 " resize 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 304 " realloc 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 305 " free 0-calls %'u; >0-calls %'u; storage %'llu bytes\n" 306 " mmap calls %'u; storage %'llu bytes\n" 307 " munmap calls %'u; storage %'llu bytes\n" 308 " sbrk calls %'u; storage %'llu bytes\n", 309 malloc_zero_calls, malloc_calls, malloc_storage, 310 aalloc_zero_calls, aalloc_calls, aalloc_storage, 311 calloc_zero_calls, calloc_calls, calloc_storage, 312 memalign_zero_calls, memalign_calls, memalign_storage, 313 amemalign_zero_calls, amemalign_calls, amemalign_storage, 314 cmemalign_zero_calls, cmemalign_calls, cmemalign_storage, 315 resize_zero_calls, resize_calls, resize_storage, 316 realloc_zero_calls, realloc_calls, realloc_storage, 317 free_zero_calls, free_calls, free_storage, 318 mmap_calls, mmap_storage, 319 munmap_calls, munmap_storage, 320 sbrk_calls, sbrk_storage 321 321 ); 322 322 } // printStats … … 329 329 "<sizes>\n" 330 330 "</sizes>\n" 331 "<total type=\"malloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 332 "<total type=\"aalloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 333 "<total type=\"calloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 334 "<total type=\"memalign\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 335 "<total type=\"amemalign\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 336 "<total type=\"cmemalign\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 337 "<total type=\"resize\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 338 "<total type=\"realloc\" >0 count=\"%'u;\" 0 count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 339 "<total type=\"free\" !null=\"%'u;\" 0 null=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n" 331 "<total type=\"malloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 332 "<total type=\"aalloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 333 "<total type=\"calloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 334 "<total type=\"memalign\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 335 "<total type=\"amemalign\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 336 "<total type=\"cmemalign\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 337 "<total type=\"resize\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 338 "<total type=\"realloc\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 339 "<total type=\"free\" 0 count=\"%'u;\" >0 count=\"%'u;\" size=\"%'llu\"/> bytes\n" 340 "<total type=\"mmap\" count=\"%'u;\" size=\"%'llu\"/> bytes\n" 341 "<total type=\"munmap\" count=\"%'u;\" size=\"%'llu\"/> bytes\n" 340 342 "<total type=\"sbrk\" count=\"%'u;\" size=\"%'llu\"/> bytes\n" 341 "<total type=\"mmap\" count=\"%'u;\" size=\"%'llu / %'llu\" / > bytes\n"342 "<total type=\"munmap\" count=\"%'u;\" size=\"%'llu / %'llu\"/> bytes\n"343 343 "</malloc>", 344 malloc_ calls, malloc_0_calls, malloc_storage_request, malloc_storage_alloc,345 aalloc_ calls, aalloc_0_calls, aalloc_storage_request, aalloc_storage_alloc,346 calloc_ calls, calloc_0_calls, calloc_storage_request, calloc_storage_alloc,347 memalign_ calls, memalign_0_calls, memalign_storage_request, memalign_storage_alloc,348 amemalign_ calls, amemalign_0_calls, amemalign_storage_request, amemalign_storage_alloc,349 cmemalign_ calls, cmemalign_0_calls, cmemalign_storage_request, cmemalign_storage_alloc,350 resize_ calls, resize_0_calls, resize_storage_request, resize_storage_alloc,351 realloc_ calls, realloc_0_calls, realloc_storage_request, realloc_storage_alloc,352 free_ calls, free_null_calls, free_storage_request, free_storage_alloc,353 sbrk_calls, sbrk_storage,354 m map_calls, mmap_storage_request, mmap_storage_alloc,355 munmap_calls, munmap_storage_request, munmap_storage_alloc344 malloc_zero_calls, malloc_calls, malloc_storage, 345 aalloc_zero_calls, aalloc_calls, aalloc_storage, 346 calloc_zero_calls, calloc_calls, calloc_storage, 347 memalign_zero_calls, memalign_calls, memalign_storage, 348 amemalign_zero_calls, amemalign_calls, amemalign_storage, 349 cmemalign_zero_calls, cmemalign_calls, cmemalign_storage, 350 resize_zero_calls, resize_calls, resize_storage, 351 realloc_zero_calls, realloc_calls, realloc_storage, 352 free_zero_calls, free_calls, free_storage, 353 mmap_calls, mmap_storage, 354 munmap_calls, munmap_storage, 355 sbrk_calls, sbrk_storage 356 356 ); 357 357 __cfaabi_bits_write( fileno( stream ), helpText, len ); // ensures all bytes written or exit … … 577 577 #ifdef __STATISTICS__ 578 578 __atomic_add_fetch( &mmap_calls, 1, __ATOMIC_SEQ_CST ); 579 __atomic_add_fetch( &mmap_storage_request, size, __ATOMIC_SEQ_CST ); 580 __atomic_add_fetch( &mmap_storage_alloc, tsize, __ATOMIC_SEQ_CST ); 579 __atomic_add_fetch( &mmap_storage, tsize, __ATOMIC_SEQ_CST ); 581 580 #endif // __STATISTICS__ 582 581 … … 627 626 #ifdef __STATISTICS__ 628 627 __atomic_add_fetch( &munmap_calls, 1, __ATOMIC_SEQ_CST ); 629 __atomic_add_fetch( &munmap_storage_request, header->kind.real.size, __ATOMIC_SEQ_CST ); 630 __atomic_add_fetch( &munmap_storage_alloc, size, __ATOMIC_SEQ_CST ); 628 __atomic_add_fetch( &munmap_storage, size, __ATOMIC_SEQ_CST ); 631 629 #endif // __STATISTICS__ 632 630 if ( munmap( header, size ) == -1 ) { … … 644 642 #ifdef __STATISTICS__ 645 643 __atomic_add_fetch( &free_calls, 1, __ATOMIC_SEQ_CST ); 646 __atomic_add_fetch( &free_storage_request, header->kind.real.size, __ATOMIC_SEQ_CST ); 647 __atomic_add_fetch( &free_storage_alloc, size, __ATOMIC_SEQ_CST ); 644 __atomic_add_fetch( &free_storage, size, __ATOMIC_SEQ_CST ); 648 645 #endif // __STATISTICS__ 649 646 … … 822 819 if ( likely( size > 0 ) ) { 823 820 __atomic_add_fetch( &malloc_calls, 1, __ATOMIC_SEQ_CST ); 824 __atomic_add_fetch( &malloc_storage _request, size, __ATOMIC_SEQ_CST );821 __atomic_add_fetch( &malloc_storage, size, __ATOMIC_SEQ_CST ); 825 822 } else { 826 __atomic_add_fetch( &malloc_ 0_calls, 1, __ATOMIC_SEQ_CST );823 __atomic_add_fetch( &malloc_zero_calls, 1, __ATOMIC_SEQ_CST ); 827 824 } // if 828 825 #endif // __STATISTICS__ … … 838 835 if ( likely( size > 0 ) ) { 839 836 __atomic_add_fetch( &aalloc_calls, 1, __ATOMIC_SEQ_CST ); 840 __atomic_add_fetch( &aalloc_storage _request, size, __ATOMIC_SEQ_CST );837 __atomic_add_fetch( &aalloc_storage, size, __ATOMIC_SEQ_CST ); 841 838 } else { 842 __atomic_add_fetch( &aalloc_ 0_calls, 1, __ATOMIC_SEQ_CST );839 __atomic_add_fetch( &aalloc_zero_calls, 1, __ATOMIC_SEQ_CST ); 843 840 } // if 844 841 #endif // __STATISTICS__ … … 853 850 if ( unlikely( size ) == 0 ) { // 0 BYTE ALLOCATION RETURNS NULL POINTER 854 851 #ifdef __STATISTICS__ 855 __atomic_add_fetch( &calloc_ 0_calls, 1, __ATOMIC_SEQ_CST );852 __atomic_add_fetch( &calloc_zero_calls, 1, __ATOMIC_SEQ_CST ); 856 853 #endif // __STATISTICS__ 857 854 return 0p; … … 859 856 #ifdef __STATISTICS__ 860 857 __atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST ); 861 __atomic_add_fetch( &calloc_storage _request, dim * elemSize, __ATOMIC_SEQ_CST );858 __atomic_add_fetch( &calloc_storage, dim * elemSize, __ATOMIC_SEQ_CST ); 862 859 #endif // __STATISTICS__ 863 860 … … 894 891 if ( unlikely( size == 0 ) ) { // special cases 895 892 #ifdef __STATISTICS__ 896 __atomic_add_fetch( &resize_ 0_calls, 1, __ATOMIC_SEQ_CST );893 __atomic_add_fetch( &resize_zero_calls, 1, __ATOMIC_SEQ_CST ); 897 894 #endif // __STATISTICS__ 898 895 free( oaddr ); … … 905 902 if ( unlikely( oaddr == 0p ) ) { 906 903 #ifdef __STATISTICS__ 907 __atomic_add_fetch( &resize_storage _request, size, __ATOMIC_SEQ_CST );904 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST ); 908 905 #endif // __STATISTICS__ 909 906 return mallocNoStats( size ); … … 924 921 925 922 #ifdef __STATISTICS__ 926 __atomic_add_fetch( &resize_storage _request, size, __ATOMIC_SEQ_CST );923 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST ); 927 924 #endif // __STATISTICS__ 928 925 … … 939 936 if ( unlikely( size == 0 ) ) { // special cases 940 937 #ifdef __STATISTICS__ 941 __atomic_add_fetch( &realloc_ 0_calls, 1, __ATOMIC_SEQ_CST );938 __atomic_add_fetch( &realloc_zero_calls, 1, __ATOMIC_SEQ_CST ); 942 939 #endif // __STATISTICS__ 943 940 free( oaddr ); … … 950 947 if ( unlikely( oaddr == 0p ) ) { 951 948 #ifdef __STATISTICS__ 952 __atomic_add_fetch( &realloc_storage _request, size, __ATOMIC_SEQ_CST );949 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST ); 953 950 #endif // __STATISTICS__ 954 951 return mallocNoStats( size ); … … 972 969 973 970 #ifdef __STATISTICS__ 974 __atomic_add_fetch( &realloc_storage _request, size, __ATOMIC_SEQ_CST );971 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST ); 975 972 #endif // __STATISTICS__ 976 973 … … 1003 1000 if ( likely( size > 0 ) ) { 1004 1001 __atomic_add_fetch( &memalign_calls, 1, __ATOMIC_SEQ_CST ); 1005 __atomic_add_fetch( &memalign_storage _request, size, __ATOMIC_SEQ_CST );1002 __atomic_add_fetch( &memalign_storage, size, __ATOMIC_SEQ_CST ); 1006 1003 } else { 1007 __atomic_add_fetch( &memalign_ 0_calls, 1, __ATOMIC_SEQ_CST );1004 __atomic_add_fetch( &memalign_zero_calls, 1, __ATOMIC_SEQ_CST ); 1008 1005 } // if 1009 1006 #endif // __STATISTICS__ … … 1019 1016 if ( likely( size > 0 ) ) { 1020 1017 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST ); 1021 __atomic_add_fetch( &cmemalign_storage _request, size, __ATOMIC_SEQ_CST );1018 __atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST ); 1022 1019 } else { 1023 __atomic_add_fetch( &cmemalign_ 0_calls, 1, __ATOMIC_SEQ_CST );1020 __atomic_add_fetch( &cmemalign_zero_calls, 1, __ATOMIC_SEQ_CST ); 1024 1021 } // if 1025 1022 #endif // __STATISTICS__ … … 1034 1031 if ( unlikely( size ) == 0 ) { // 0 BYTE ALLOCATION RETURNS NULL POINTER 1035 1032 #ifdef __STATISTICS__ 1036 __atomic_add_fetch( &cmemalign_ 0_calls, 1, __ATOMIC_SEQ_CST );1033 __atomic_add_fetch( &cmemalign_zero_calls, 1, __ATOMIC_SEQ_CST ); 1037 1034 #endif // __STATISTICS__ 1038 1035 return 0p; … … 1040 1037 #ifdef __STATISTICS__ 1041 1038 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST ); 1042 __atomic_add_fetch( &cmemalign_storage _request, dim * elemSize, __ATOMIC_SEQ_CST );1039 __atomic_add_fetch( &cmemalign_storage, dim * elemSize, __ATOMIC_SEQ_CST ); 1043 1040 #endif // __STATISTICS__ 1044 1041 … … 1104 1101 if ( unlikely( addr == 0p ) ) { // special case 1105 1102 #ifdef __STATISTICS__ 1106 __atomic_add_fetch( &free_ null_calls, 1, __ATOMIC_SEQ_CST );1103 __atomic_add_fetch( &free_zero_calls, 1, __ATOMIC_SEQ_CST ); 1107 1104 #endif // __STATISTICS__ 1108 1105 … … 1283 1280 if ( unlikely( size == 0 ) ) { // special cases 1284 1281 #ifdef __STATISTICS__ 1285 __atomic_add_fetch( &resize_ 0_calls, 1, __ATOMIC_SEQ_CST );1282 __atomic_add_fetch( &resize_zero_calls, 1, __ATOMIC_SEQ_CST ); 1286 1283 #endif // __STATISTICS__ 1287 1284 free( oaddr ); … … 1297 1294 #ifdef __STATISTICS__ 1298 1295 __atomic_add_fetch( &resize_calls, 1, __ATOMIC_SEQ_CST ); 1299 __atomic_add_fetch( &resize_storage _request, size, __ATOMIC_SEQ_CST );1296 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST ); 1300 1297 #endif // __STATISTICS__ 1301 1298 return memalignNoStats( nalign, size ); … … 1332 1329 1333 1330 #ifdef __STATISTICS__ 1334 __atomic_add_fetch( &resize_storage _request, size, __ATOMIC_SEQ_CST );1331 __atomic_add_fetch( &resize_storage, size, __ATOMIC_SEQ_CST ); 1335 1332 #endif // __STATISTICS__ 1336 1333 … … 1345 1342 if ( unlikely( size == 0 ) ) { // special cases 1346 1343 #ifdef __STATISTICS__ 1347 __atomic_add_fetch( &realloc_ 0_calls, 1, __ATOMIC_SEQ_CST );1344 __atomic_add_fetch( &realloc_zero_calls, 1, __ATOMIC_SEQ_CST ); 1348 1345 #endif // __STATISTICS__ 1349 1346 free( oaddr ); … … 1359 1356 #ifdef __STATISTICS__ 1360 1357 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 1361 __atomic_add_fetch( &realloc_storage _request, size, __ATOMIC_SEQ_CST );1358 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST ); 1362 1359 #endif // __STATISTICS__ 1363 1360 return memalignNoStats( nalign, size ); … … 1383 1380 #ifdef __STATISTICS__ 1384 1381 __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST ); 1385 __atomic_add_fetch( &realloc_storage _request, size, __ATOMIC_SEQ_CST );1382 __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST ); 1386 1383 #endif // __STATISTICS__ 1387 1384
Note:
See TracChangeset
for help on using the changeset viewer.