INNER CODE UNIT · JavaScript

heap_size_addr

FStarLang/karamel · krmllib/js/loader.js:168

    let heap_size_addr = m32.byteLength/4 - 1;
    let heap_size = m32[heap_size_addr];
    // Size of stack + size of heap + desired allocation + 4 for allocator bump
    // pointer + 8 for rounding on a 64-bit boundary + 8 for header.
    if (m32[0] + heap_size + sz + 20 > memSize)
      throw new Error("malloc: out of memory (TODO: resize & move)");

    // Header.
    //   First four bytes are allocation size, next four bytes are
    //   reserved. Data follows.
    my_print("malloc: requested " + p32(sz) + " bytes");
    sz += 8;

    // Tentative pointer.
    let p = (memSize - 4) - heap_size - sz;
    // Adjusted to fall on a 64-bit boundary; header is 64 bits so data is
    // aligned, too.
    p -= (p % 8);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…