Home | History | Annotate | Download | only in dist

Lines Matching defs:mem5

16677 /************** Begin file mem5.c ********************************************/
16750 ** Maximum size of any allocation is ((1<<LOGMAX)*mem5.szAtom). Since
16751 ** mem5.szAtom is always at least 8 and 32-bit integers are used,
16757 ** Masks used for mem5.aCtrl[] elements.
16764 ** into a single structure named "mem5". This is to keep the
16795 ** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2.
16806 } mem5;
16811 #define mem5 GLOBAL(struct Mem5Global, mem5)
16814 ** Assuming mem5.zPool is divided up into an array of Mem5Link
16817 #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom]))
16820 ** Unlink the chunk at mem5.aPool[i] from list it is currently
16821 ** on. It should be found on mem5.aiFreelist[iLogsize].
16825 assert( i>=0 && i<mem5.nBlock );
16827 assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );
16832 mem5.aiFreelist[iLogsize] = next;
16842 ** Link the chunk at mem5.aPool[i] so that is on the iLogsize
16847 assert( sqlite3_mutex_held(mem5.mutex) );
16848 assert( i>=0 && i<mem5.nBlock );
16850 assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize );
16852 x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize];
16855 assert( x<mem5.nBlock );
16858 mem5.aiFreelist[iLogsize] = i;
16867 sqlite3_mutex_enter(mem5.mutex);
16870 sqlite3_mutex_leave(mem5.mutex);
16881 int i = ((u8 *)p-mem5.zPool)/mem5.szAtom;
16882 assert( i>=0 && i<mem5.nBlock );
16883 iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE));
16897 i = iFirst = mem5.aiFreelist[iLogsize];
16918 int i; /* Index of a mem5.aPool[] slot */
16919 int iBin; /* Index into mem5.aiFreelist[] */
16928 if( (u32)nByte>mem5.maxRequest ){
16929 mem5.maxRequest = nByte;
16940 for(iFullSz=mem5.szAtom, iLogsize=0; iFullSz<nByte; iFullSz *= 2, iLogsize++){}
16942 /* Make sure mem5.aiFreelist[iLogsize] contains at least one free
16946 for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){}
16958 mem5.aCtrl[i+newSize] = CTRL_FREE | iBin;
16961 mem5.aCtrl[i] = iLogsize;
16964 mem5.nAlloc++;
16965 mem5.totalAlloc += iFullSz;
16966 mem5.totalExcess += iFullSz - nByte;
16967 mem5.currentCount++;
16968 mem5.currentOut += iFullSz;
16969 if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount;
16970 if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut;
16973 return (void*)&mem5.zPool[i*mem5.szAtom];
16984 ** the array of mem5.szAtom byte blocks pointed to by mem5.zPool.
16986 iBlock = ((u8 *)pOld-mem5.zPool)/mem5.szAtom;
16989 assert( iBlock>=0 && iBlock<mem5.nBlock );
16990 assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 );
16991 assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 );
16993 iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE;
16995 assert( iBlock+size-1<(u32)mem5.nBlock );
16997 mem5.aCtrl[iBlock] |= CTRL_FREE;
16998 mem5.aCtrl[iBlock+size-1] |= CTRL_FREE;
16999 assert( mem5.currentCount>0 );
17000 assert( mem5.currentOut>=(size*mem5.szAtom) );
17001 mem5.currentCount--;
17002 mem5.currentOut -= size*mem5.szAtom;
17003 assert( mem5.currentOut>0 || mem5.currentCount==0 );
17004 assert( mem5.currentCount>0 || mem5.currentOut==0 );
17006 mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;
17015 if( (iBuddy+(1<<iLogsize))>mem5.nBlock ) break;
17016 if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break;
17020 mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize;
17021 mem5.aCtrl[iBlock] = 0;
17024 mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize;
17025 mem5.aCtrl[iBuddy] = 0;
17105 for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2);
17136 int iOffset; /* An offset into mem5.aCtrl[] */
17141 mem5.mutex = 0;
17154 mem5.szAtom = (1<<nMinLog);
17155 while( (int)sizeof(Mem5Link)>mem5.szAtom ){
17156 mem5.szAtom = mem5.szAtom << 1;
17159 mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8)));
17160 mem5.zPool = zByte;
17161 mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom];
17164 mem5.aiFreelist[ii] = -1;
17170 if( (iOffset+nAlloc)<=mem5.nBlock ){
17171 mem5.aCtrl[iOffset] = ii | CTRL_FREE;
17175 assert((iOffset+nAlloc)>mem5.nBlock);
17180 mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
17191 mem5.mutex = 0;
17216 nMinLog = memsys5Log(mem5.szAtom);
17218 for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){}
17219 fprintf(out, "freelist items of size %d: %d\n", mem5.szAtom << i, n);
17221 fprintf(out, "mem5.nAlloc = %llu\n", mem5.nAlloc);
17222 fprintf(out, "mem5.totalAlloc = %llu\n", mem5.totalAlloc);
17223 fprintf(out, "mem5.totalExcess = %llu\n", mem5.totalExcess);
17224 fprintf(out, "mem5.currentOut = %u\n", mem5.currentOut);
17225 fprintf(out, "mem5.currentCount = %u\n", mem5.currentCount);
17226 fprintf(out, "mem5.maxOut = %u\n", mem5.maxOut);
17227 fprintf(out, "mem5.maxCount = %u\n", mem5.maxCount);
17228 fprintf(out, "mem5.maxRequest = %u\n", mem5.maxRequest);
17259 /************** End of mem5.c ************************************************/
112889 ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor