示例#1
0
bool JSStack::growSlowCase(Register* newTopOfStack)
{
    Register* newTopOfStackWithReservedZone = newTopOfStack - m_reservedZoneSizeInRegisters;

    // If we have already committed enough memory to satisfy this request,
    // just update the end pointer and return.
    if (newTopOfStackWithReservedZone >= m_commitTop) {
        setStackLimit(newTopOfStack);
        return true;
    }

    // Compute the chunk size of additional memory to commit, and see if we
    // have it is still within our budget. If not, we'll fail to grow and
    // return false.
    ptrdiff_t delta = reinterpret_cast<char*>(m_commitTop) - reinterpret_cast<char*>(newTopOfStackWithReservedZone);
    delta = WTF::roundUpToMultipleOf(commitSize, delta);
    Register* newCommitTop = m_commitTop - (delta / sizeof(Register));
    if (newCommitTop < reservationTop())
        return false;

    // Otherwise, the growth is still within our budget. Go ahead and commit
    // it and return true.
    m_reservation.commit(newCommitTop, delta);
    addToCommittedByteCount(delta);
    m_commitTop = newCommitTop;
    setStackLimit(newTopOfStack);
    return true;
}
示例#2
0
文件: setLimit.c 项目: AbheekG/chapel
int
main(int argc, char *argv[]) {
  int newlim = argc > 1 ? atoi(argv[1]) : 10;
  printf("%d\n", getThreadLimit());
  setThreadLimit(newlim);
  printf("%d\n", getThreadLimit());
  newlim = argc > 2 ? atoi(argv[2]) : 10;
  printf("%d\n", getStackLimit());
  setStackLimit(newlim);
  printf("%d\n", getStackLimit());
  return 0;
}
示例#3
0
JSStack::JSStack(VM& vm)
    : m_vm(vm)
    , m_topCallFrame(vm.topCallFrame)
#if ENABLE(LLINT_C_LOOP)
    , m_end(0)
    , m_reservedZoneSizeInRegisters(0)
#endif
{
#if ENABLE(LLINT_C_LOOP)
    size_t capacity = Options::maxPerThreadStackUsage();
    ASSERT(capacity && isPageAligned(capacity));

    m_reservation = PageReservation::reserve(WTF::roundUpToMultipleOf(commitSize, capacity), OSAllocator::JSVMStackPages);
    setStackLimit(highAddress());
    m_commitTop = highAddress();
    
    m_lastStackTop = baseOfStack();
#endif // ENABLE(LLINT_C_LOOP)

    m_topCallFrame = 0;
}