diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index a15eae45a42..d3e05da0332 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -2211,7 +2211,6 @@ js_InitJIT(JSTraceMonitor *tm) Fragmento* fragmento = new (&gc) Fragmento(core, 24); verbose_only(fragmento->labels = new (&gc) LabelMap(core, NULL);) fragmento->assm()->setCallTable(builtins); - fragmento->pageFree(fragmento->pageAlloc()); // FIXME: prime page cache tm->fragmento = fragmento; tm->globalSlots = new (&gc) SlotList(); tm->globalTypeMap = new (&gc) TypeMap(); diff --git a/js/src/nanojit/Fragmento.cpp b/js/src/nanojit/Fragmento.cpp index 8de38cea2ee..bfb27e25ec8 100644 --- a/js/src/nanojit/Fragmento.cpp +++ b/js/src/nanojit/Fragmento.cpp @@ -65,6 +65,7 @@ namespace nanojit GC *gc = core->GetGC(); _frags = new (gc) FragmentMap(gc, 128); _assm = new (gc) nanojit::Assembler(this); + _pageGrowth = 1; verbose_only( enterCounts = new (gc) BlockHist(gc); ) verbose_only( mergeCounts = new (gc) BlockHist(gc); ) } @@ -101,8 +102,11 @@ namespace nanojit Page* Fragmento::pageAlloc() { NanoAssert(sizeof(Page) == NJ_PAGE_SIZE); - if (!_pageList) - pagesGrow(_max_pages); // try to get more mem + if (!_pageList) { + pagesGrow(_pageGrowth); // try to get more mem + if ((_pageGrowth << 1) < _max_pages) + _pageGrowth <<= 1; + } Page *page = _pageList; if (page) { @@ -132,6 +136,11 @@ namespace nanojit Page* memory = 0; if (_stats.pages < _max_pages) { + // make sure we don't grow beyond _max_pages + if (_stats.pages + count > _max_pages) + count = _max_pages - _stats.pages; + if (count < 0) + count = 0; // @todo nastiness that needs a fix'n _gcHeap = _core->GetGC()->GetGCHeap(); NanoAssert(int32_t(NJ_PAGE_SIZE)<=_gcHeap->kNativePageSize); diff --git a/js/src/nanojit/Fragmento.h b/js/src/nanojit/Fragmento.h index d0e0c3c5435..cab2f6e2acc 100644 --- a/js/src/nanojit/Fragmento.h +++ b/js/src/nanojit/Fragmento.h @@ -138,6 +138,7 @@ namespace nanojit DWB(Assembler*) _assm; DWB(FragmentMap*) _frags; /* map from ip -> Fragment ptr */ Page* _pageList; + uint32_t _pageGrowth; /* unmanaged mem */ AllocList _allocList;