void Fragmento::pagesGrow(int32_t count) { NanoAssert(!_pageList); MMGC_MEM_TYPE("NanojitFragmentoMem"); 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); // convert _max_pages to gc page count int32_t gcpages = (count*NJ_PAGE_SIZE) / _gcHeap->kNativePageSize; MMGC_MEM_TYPE("NanoJitMem"); memory = (Page*)_gcHeap->Alloc(gcpages); #ifdef MEMORY_INFO ChangeSizeExplicit("NanoJitMem", 1, _gcHeap->Size(memory)); #endif NanoAssert((int*)memory == pageTop(memory)); //fprintf(stderr,"head alloc of %d at %x of %d pages using nj page size of %d\n", gcpages, (intptr_t)memory, (intptr_t)_gcHeap->kNativePageSize, NJ_PAGE_SIZE); _allocList.add(memory); Page* page = memory; _pageList = page; _stats.pages += count; _stats.freePages += count; trackFree(0); while(--count > 0) { Page *next = page + 1; //fprintf(stderr,"Fragmento::pageGrow adding page %x ; %d\n", (intptr_t)page, count); page->next = next; page = next; } page->next = 0; NanoAssert(pageCount()==_stats.freePages); //fprintf(stderr,"Fragmento::pageGrow adding page %x ; %d\n", (intptr_t)page, count); } }
void ScriptObject::setAtomProperty(Atom name, Atom value) { if (traits()->needsHashtable()) { Stringp s = core()->atomToString(name); AvmAssert(s->isInterned()); Atom ival = s->getIntAtom(); if (ival) { name = ival; } MMGC_MEM_TYPE(this); getTable()->add (name, value); MMGC_MEM_TYPE(NULL); } else { throwWriteSealedError(name); } }
void ScriptObject::initHashtable(int capacity /*=InlineHashtable::kDefaultCapacity*/) { AvmAssert(vtable->traits->isDictionary() == 0); //should not be called DictionaryObject uses HeapHashtable MMGC_MEM_TYPE(this); union { uint8_t* p; InlineHashtable* iht; }; p = (uint8_t*)this + vtable->traits->getHashtableOffset(); iht->initializeWithDontEnumSupport(this->gc(), capacity); }
void ScriptObject::setUintProperty(uint32_t i, Atom value) { AvmCore* core = this->core(); if (!(i&MAX_INTEGER_MASK)) { Atom name = core->uintToAtom (i); if (traits()->needsHashtable()) { MMGC_MEM_TYPE(this); getTable()->add(name, value); MMGC_MEM_TYPE(NULL); } else { throwWriteSealedError(core->internUint32(i)->atom()); } } else { setAtomProperty(core->internUint32(i)->atom(), value); } }