Home | History | Annotate | Download | only in dist

Lines Matching refs:mem5

15558 /************** Begin file mem5.c ********************************************/
15631 ** Maximum size of any allocation is ((1<<LOGMAX)*mem5.szAtom). Since
15632 ** mem5.szAtom is always at least 8 and 32-bit integers are used,
15638 ** Masks used for mem5.aCtrl[] elements.
15645 ** into a single structure named "mem5". This is to keep the
15676 ** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2.
15687 } mem5 = { 0 };
15692 #define mem5 GLOBAL(struct Mem5Global, mem5)
15695 ** Assuming mem5.zPool is divided up into an array of Mem5Link
15698 #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))
15701 ** Unlink the chunk at mem5.aPool[i] from list it is currently
15702 ** on. It should be found on mem5.aiFreelist[iLogsize].
15706 assert( i>=0 && i<mem5.nBlock );
15708 assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );
15713 mem5.aiFreelist[iLogsize] = next;
15723 ** Link the chunk at mem5.aPool[i] so that is on the iLogsize
15728 assert( sqlite3_mutex_held(mem5.mutex) );
15729 assert( i>=0 && i<mem5.nBlock );
15731 assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );
15733 x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize];
15736 assert( x<mem5.nBlock );
15739 mem5.aiFreelist[iLogsize] = i;
15748 sqlite3_mutex_enter(mem5.mutex);
15751 sqlite3_mutex_leave(mem5.mutex);
15762 int i = ((u8 *)p-mem5.zPool)/mem5.szAtom;
15763 assert( i>=0 && i<mem5.nBlock );
15764 iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));
15778 i = iFirst = mem5.aiFreelist[iLogsize];
15799 mem5.aPool[] slot */
15800 int iBin; /* Index into mem5.aiFreelist[] */
15809 if( (u32)nByte>mem5.maxRequest ){
15810 mem5.maxRequest = nByte;
15821 for(iFullSz=mem5.szAtom, iLogsize=0; iFullSz<nByte; iFullSz *= 2, iLogsize++){}
15823 /* Make sure mem5.aiFreelist[iLogsize] contains at least one free
15827 for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){}
15839 mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;
15842 mem5.aCtrl[i] = iLogsize;
15845 mem5.nAlloc++;
15846 mem5.totalAlloc += iFullSz;
15847 mem5.totalExcess += iFullSz - nByte;
15848 mem5.currentCount++;
15849 mem5.currentOut += iFullSz;
15850 if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount;
15851 if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut;
15854 return (void*)&mem5.zPool[i*mem5.szAtom];
15865 ** the array of mem5.szAtom byte blocks pointed to by mem5.zPool.
15867 iBlock = ((u8 *)pOld-mem5.zPool)/mem5.szAtom;
15870 assert( iBlock>=0 && iBlock<mem5.nBlock );
15871 assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 );
15872 assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 );
15874 iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;
15876 assert( iBlock+size-1<(u32)mem5.nBlock );
15878 mem5.aCtrl[iBlock] |= CTRL_FREE;
15879 mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;
15880 assert( mem5.currentCount>0 );
15881 assert( mem5.currentOut>=(size*mem5.szAtom) );
15882 mem5.currentCount--;
15883 mem5.currentOut -= size*mem5.szAtom;
15884 assert( mem5.currentOut>0 || mem5.currentCount==0 );
15885 assert( mem5.currentCount>0 || mem5.currentOut==0 );
15887 mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;
15896 if( (iBuddy+(1<<iLogsize))>mem5.nBlock ) break;
15897 if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break;
15901 mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize;
15902 mem5.aCtrl[iBlock] = 0;
15905 mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;
15906 mem5.aCtrl[iBuddy] = 0;
15986 for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);
16017 int iOffset; /* An offset into mem5.aCtrl[] */
16022 mem5.mutex = 0;
16034 mem5.szAtom = (1<<nMinLog);
16035 while( (int)sizeof(Mem5Link)>mem5.szAtom ){
16036 mem5.szAtom = mem5.szAtom << 1;
16039 mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8)));
16040 mem5.zPool = zByte;
16041 mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom];
16044 mem5.aiFreelist[ii] = -1;
16050 if( (iOffset+nAlloc)<=mem5.nBlock ){
16051 mem5.aCtrl[iOffset] = ii | CTRL_FREE;
16055 assert((iOffset+nAlloc)>mem5.nBlock);
16060 mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
16071 mem5.mutex = 0;
16096 nMinLog = memsys5Log(mem5.szAtom);
16098 for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){}
16099 fprintf(out, "freelist items of size %d: %d\n", mem5.szAtom << i, n);
16101 fprintf(out, "mem5.nAlloc = %llu\n", mem5.nAlloc);
16102 fprintf(out, "mem5.totalAlloc = %llu\n", mem5.totalAlloc);
16103 fprintf(out, "mem5.totalExcess = %llu\n", mem5.totalExcess);
16104 fprintf(out, "mem5.currentOut = %u\n", mem5.currentOut);
16105 fprintf(out, "mem5.currentCount = %u\n", mem5.currentCount);
16106 fprintf(out, "mem5.maxOut = %u\n", mem5.maxOut);
16107 fprintf(out, "mem5.maxCount = %u\n", mem5.maxCount);
16108 fprintf(out, "mem5.maxRequest = %u\n", mem5.maxRequest);
16139 /************** End of mem5.c ************************************************/
105201 ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor