Lines Matching refs:mem3
18742 } mem3 = { 97535575 }; variable
18744 #define mem3 GLOBAL(struct Mem3Global, mem3) macro
18751 u32 next = mem3.aPool[i].u.list.next; in memsys3UnlinkFromList()
18752 u32 prev = mem3.aPool[i].u.list.prev; in memsys3UnlinkFromList()
18753 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3UnlinkFromList()
18757 mem3.aPool[prev].u.list.next = next; in memsys3UnlinkFromList()
18760 mem3.aPool[next].u.list.prev = prev; in memsys3UnlinkFromList()
18762 mem3.aPool[i].u.list.next = 0; in memsys3UnlinkFromList()
18763 mem3.aPool[i].u.list.prev = 0; in memsys3UnlinkFromList()
18772 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Unlink()
18773 assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 ); in memsys3Unlink()
18775 size = mem3.aPool[i-1].u.hdr.size4x/4; in memsys3Unlink()
18776 assert( size==mem3.aPool[i+size-1].u.hdr.prevSize ); in memsys3Unlink()
18779 memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]); in memsys3Unlink()
18782 memsys3UnlinkFromList(i, &mem3.aiHash[hash]); in memsys3Unlink()
18791 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3LinkIntoList()
18792 mem3.aPool[i].u.list.next = *pRoot; in memsys3LinkIntoList()
18793 mem3.aPool[i].u.list.prev = 0; in memsys3LinkIntoList()
18795 mem3.aPool[*pRoot].u.list.prev = i; in memsys3LinkIntoList()
18806 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Link()
18808 assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 ); in memsys3Link()
18809 size = mem3.aPool[i-1].u.hdr.size4x/4; in memsys3Link()
18810 assert( size==mem3.aPool[i+size-1].u.hdr.prevSize ); in memsys3Link()
18813 memsys3LinkIntoList(i, &mem3.aiSmall[size-2]); in memsys3Link()
18816 memsys3LinkIntoList(i, &mem3.aiHash[hash]); in memsys3Link()
18826 if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){ in memsys3Enter()
18827 mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); in memsys3Enter()
18829 sqlite3_mutex_enter(mem3.mutex); in memsys3Enter()
18832 sqlite3_mutex_leave(mem3.mutex); in memsys3Leave()
18839 if( !mem3.alarmBusy ){ in memsys3OutOfMemory()
18840 mem3.alarmBusy = 1; in memsys3OutOfMemory()
18841 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3OutOfMemory()
18842 sqlite3_mutex_leave(mem3.mutex); in memsys3OutOfMemory()
18844 sqlite3_mutex_enter(mem3.mutex); in memsys3OutOfMemory()
18845 mem3.alarmBusy = 0; in memsys3OutOfMemory()
18857 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Checkout()
18859 assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ); in memsys3Checkout()
18860 assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock ); in memsys3Checkout()
18861 x = mem3.aPool[i-1].u.hdr.size4x; in memsys3Checkout()
18862 mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2); in memsys3Checkout()
18863 mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock; in memsys3Checkout()
18864 mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2; in memsys3Checkout()
18865 return &mem3.aPool[i]; in memsys3Checkout()
18874 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3FromMaster()
18875 assert( mem3.szMaster>=nBlock ); in memsys3FromMaster()
18876 if( nBlock>=mem3.szMaster-1 ){ in memsys3FromMaster()
18878 void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster); in memsys3FromMaster()
18879 mem3.iMaster = 0; in memsys3FromMaster()
18880 mem3.szMaster = 0; in memsys3FromMaster()
18881 mem3.mnMaster = 0; in memsys3FromMaster()
18886 newi = mem3.iMaster + mem3.szMaster - nBlock; in memsys3FromMaster()
18887 assert( newi > mem3.iMaster+1 ); in memsys3FromMaster()
18888 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock; in memsys3FromMaster()
18889 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2; in memsys3FromMaster()
18890 mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1; in memsys3FromMaster()
18891 mem3.szMaster -= nBlock; in memsys3FromMaster()
18892 mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster; in memsys3FromMaster()
18893 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; in memsys3FromMaster()
18894 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; in memsys3FromMaster()
18895 if( mem3.szMaster < mem3.mnMaster ){ in memsys3FromMaster()
18896 mem3.mnMaster = mem3.szMaster; in memsys3FromMaster()
18898 return (void*)&mem3.aPool[newi]; in memsys3FromMaster()
18921 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Merge()
18923 iNext = mem3.aPool[i].u.list.next; in memsys3Merge()
18924 size = mem3.aPool[i-1].u.hdr.size4x; in memsys3Merge()
18928 assert( i > mem3.aPool[i-1].u.hdr.prevSize ); in memsys3Merge()
18929 prev = i - mem3.aPool[i-1].u.hdr.prevSize; in memsys3Merge()
18931 iNext = mem3.aPool[prev].u.list.next; in memsys3Merge()
18935 x = mem3.aPool[prev-1].u.hdr.size4x & 2; in memsys3Merge()
18936 mem3.aPool[prev-1].u.hdr.size4x = size*4 | x; in memsys3Merge()
18937 mem3.aPool[prev+size-1].u.hdr.prevSize = size; in memsys3Merge()
18943 if( size>mem3.szMaster ){ in memsys3Merge()
18944 mem3.iMaster = i; in memsys3Merge()
18945 mem3.szMaster = size; in memsys3Merge()
18962 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3MallocUnsafe()
18977 i = mem3.aiSmall[nBlock-2]; in memsys3MallocUnsafe()
18979 memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]); in memsys3MallocUnsafe()
18984 for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){ in memsys3MallocUnsafe()
18985 if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){ in memsys3MallocUnsafe()
18986 memsys3UnlinkFromList(i, &mem3.aiHash[hash]); in memsys3MallocUnsafe()
18996 if( mem3.szMaster>=nBlock ){ in memsys3MallocUnsafe()
19008 for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){ in memsys3MallocUnsafe()
19010 if( mem3.iMaster ){ in memsys3MallocUnsafe()
19011 memsys3Link(mem3.iMaster); in memsys3MallocUnsafe()
19012 mem3.iMaster = 0; in memsys3MallocUnsafe()
19013 mem3.szMaster = 0; in memsys3MallocUnsafe()
19016 memsys3Merge(&mem3.aiHash[i]); in memsys3MallocUnsafe()
19019 memsys3Merge(&mem3.aiSmall[i]); in memsys3MallocUnsafe()
19021 if( mem3.szMaster ){ in memsys3MallocUnsafe()
19022 memsys3Unlink(mem3.iMaster); in memsys3MallocUnsafe()
19023 if( mem3.szMaster>=nBlock ){ in memsys3MallocUnsafe()
19043 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3FreeUnsafe()
19044 assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] ); in memsys3FreeUnsafe()
19045 i = p - mem3.aPool; in memsys3FreeUnsafe()
19046 assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 ); in memsys3FreeUnsafe()
19047 size = mem3.aPool[i-1].u.hdr.size4x/4; in memsys3FreeUnsafe()
19048 assert( i+size<=mem3.nPool+1 ); in memsys3FreeUnsafe()
19049 mem3.aPool[i-1].u.hdr.size4x &= ~1; in memsys3FreeUnsafe()
19050 mem3.aPool[i+size-1].u.hdr.prevSize = size; in memsys3FreeUnsafe()
19051 mem3.aPool[i+size-1].u.hdr.size4x &= ~2; in memsys3FreeUnsafe()
19055 if( mem3.iMaster ){ in memsys3FreeUnsafe()
19056 while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){ in memsys3FreeUnsafe()
19057 size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize; in memsys3FreeUnsafe()
19058 mem3.iMaster -= size; in memsys3FreeUnsafe()
19059 mem3.szMaster += size; in memsys3FreeUnsafe()
19060 memsys3Unlink(mem3.iMaster); in memsys3FreeUnsafe()
19061 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; in memsys3FreeUnsafe()
19062 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; in memsys3FreeUnsafe()
19063 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; in memsys3FreeUnsafe()
19065 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; in memsys3FreeUnsafe()
19066 while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){ in memsys3FreeUnsafe()
19067 memsys3Unlink(mem3.iMaster+mem3.szMaster); in memsys3FreeUnsafe()
19068 mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4; in memsys3FreeUnsafe()
19069 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; in memsys3FreeUnsafe()
19070 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; in memsys3FreeUnsafe()
19163 mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap; in memsys3Init()
19164 mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2; in memsys3Init()
19167 mem3.szMaster = mem3.nPool; in memsys3Init()
19168 mem3.mnMaster = mem3.szMaster; in memsys3Init()
19169 mem3.iMaster = 1; in memsys3Init()
19170 mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2; in memsys3Init()
19171 mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool; in memsys3Init()
19172 mem3.aPool[mem3.nPool].u.hdr.size4x = 1; in memsys3Init()
19182 mem3.mutex = 0; in memsys3Shutdown()
19209 for(i=1; i<=mem3.nPool; i+=size/4){ in sqlite3Memsys3Dump()
19210 size = mem3.aPool[i-1].u.hdr.size4x; in sqlite3Memsys3Dump()
19212 fprintf(out, "%p size error\n", &mem3.aPool[i]); in sqlite3Memsys3Dump()
19216 if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){ in sqlite3Memsys3Dump()
19217 fprintf(out, "%p tail size does not match\n", &mem3.aPool[i]); in sqlite3Memsys3Dump()
19221 if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){ in sqlite3Memsys3Dump()
19222 fprintf(out, "%p tail checkout bit is incorrect\n", &mem3.aPool[i]); in sqlite3Memsys3Dump()
19227 fprintf(out, "%p %6d bytes checked out\n", &mem3.aPool[i], (size/4)*8-8); in sqlite3Memsys3Dump()
19229 fprintf(out, "%p %6d bytes free%s\n", &mem3.aPool[i], (size/4)*8-8, in sqlite3Memsys3Dump()
19230 i==mem3.iMaster ? " **master**" : ""); in sqlite3Memsys3Dump()
19234 if( mem3.aiSmall[i]==0 ) continue; in sqlite3Memsys3Dump()
19236 for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){ in sqlite3Memsys3Dump()
19237 fprintf(out, " %p(%d)", &mem3.aPool[j], in sqlite3Memsys3Dump()
19238 (mem3.aPool[j-1].u.hdr.size4x/4)*8-8); in sqlite3Memsys3Dump()
19243 if( mem3.aiHash[i]==0 ) continue; in sqlite3Memsys3Dump()
19245 for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){ in sqlite3Memsys3Dump()
19246 fprintf(out, " %p(%d)", &mem3.aPool[j], in sqlite3Memsys3Dump()
19247 (mem3.aPool[j-1].u.hdr.size4x/4)*8-8); in sqlite3Memsys3Dump()
19251 fprintf(out, "master=%d\n", mem3.iMaster); in sqlite3Memsys3Dump()
19252 fprintf(out, "nowUsed=%d\n", mem3.nPool*8 - mem3.szMaster*8); in sqlite3Memsys3Dump()
19253 fprintf(out, "mxUsed=%d\n", mem3.nPool*8 - mem3.mnMaster*8); in sqlite3Memsys3Dump()
19254 sqlite3_mutex_leave(mem3.mutex); in sqlite3Memsys3Dump()