Initialize emmalloc during static initialization. See system/lib/README.md for static constructor ordering.
| 546 | // Initialize emmalloc during static initialization. |
| 547 | // See system/lib/README.md for static constructor ordering. |
| 548 | __attribute__((constructor(47))) |
| 549 | static void initialize_emmalloc_heap() { |
| 550 | // Initialize circular doubly linked lists representing free space |
| 551 | // Never useful to unroll this for loop, just takes up code size. |
| 552 | #pragma clang loop unroll(disable) |
| 553 | for (int i = 0; i < NUM_FREE_BUCKETS; ++i) { |
| 554 | freeRegionBuckets[i].prev = freeRegionBuckets[i].next = &freeRegionBuckets[i]; |
| 555 | } |
| 556 | |
| 557 | #ifdef EMMALLOC_VERBOSE |
| 558 | MAIN_THREAD_ASYNC_EM_ASM(out('initialize_emmalloc_heap()')); |
| 559 | #endif |
| 560 | |
| 561 | // Start with a tiny dynamic region. |
| 562 | claim_more_memory(3*sizeof(Region)); |
| 563 | } |
| 564 | |
| 565 | void emmalloc_blank_slate_from_orbit() { |
| 566 | MALLOC_ACQUIRE(); |
no test coverage detected