Lines Matching refs:mem3
22346 } mem3 = { 97535575 }; variable
22348 #define mem3 GLOBAL(struct Mem3Global, mem3) macro
22355 u32 next = mem3.aPool[i].u.list.next; in memsys3UnlinkFromList()
22356 u32 prev = mem3.aPool[i].u.list.prev; in memsys3UnlinkFromList()
22357 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3UnlinkFromList()
22361 mem3.aPool[prev].u.list.next = next; in memsys3UnlinkFromList()
22364 mem3.aPool[next].u.list.prev = prev; in memsys3UnlinkFromList()
22366 mem3.aPool[i].u.list.next = 0; in memsys3UnlinkFromList()
22367 mem3.aPool[i].u.list.prev = 0; in memsys3UnlinkFromList()
22376 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Unlink()
22377 assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 ); in memsys3Unlink()
22379 size = mem3.aPool[i-1].u.hdr.size4x/4; in memsys3Unlink()
22380 assert( size==mem3.aPool[i+size-1].u.hdr.prevSize ); in memsys3Unlink()
22383 memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]); in memsys3Unlink()
22386 memsys3UnlinkFromList(i, &mem3.aiHash[hash]); in memsys3Unlink()
22395 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3LinkIntoList()
22396 mem3.aPool[i].u.list.next = *pRoot; in memsys3LinkIntoList()
22397 mem3.aPool[i].u.list.prev = 0; in memsys3LinkIntoList()
22399 mem3.aPool[*pRoot].u.list.prev = i; in memsys3LinkIntoList()
22410 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Link()
22412 assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 ); in memsys3Link()
22413 size = mem3.aPool[i-1].u.hdr.size4x/4; in memsys3Link()
22414 assert( size==mem3.aPool[i+size-1].u.hdr.prevSize ); in memsys3Link()
22417 memsys3LinkIntoList(i, &mem3.aiSmall[size-2]); in memsys3Link()
22420 memsys3LinkIntoList(i, &mem3.aiHash[hash]); in memsys3Link()
22430 if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){ in memsys3Enter()
22431 mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); in memsys3Enter()
22433 sqlite3_mutex_enter(mem3.mutex); in memsys3Enter()
22436 sqlite3_mutex_leave(mem3.mutex); in memsys3Leave()
22443 if( !mem3.alarmBusy ){ in memsys3OutOfMemory()
22444 mem3.alarmBusy = 1; in memsys3OutOfMemory()
22445 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3OutOfMemory()
22446 sqlite3_mutex_leave(mem3.mutex); in memsys3OutOfMemory()
22448 sqlite3_mutex_enter(mem3.mutex); in memsys3OutOfMemory()
22449 mem3.alarmBusy = 0; in memsys3OutOfMemory()
22461 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Checkout()
22463 assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ); in memsys3Checkout()
22464 assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock ); in memsys3Checkout()
22465 x = mem3.aPool[i-1].u.hdr.size4x; in memsys3Checkout()
22466 mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2); in memsys3Checkout()
22467 mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock; in memsys3Checkout()
22468 mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2; in memsys3Checkout()
22469 return &mem3.aPool[i]; in memsys3Checkout()
22478 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3FromMaster()
22479 assert( mem3.szMaster>=nBlock ); in memsys3FromMaster()
22480 if( nBlock>=mem3.szMaster-1 ){ in memsys3FromMaster()
22482 void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster); in memsys3FromMaster()
22483 mem3.iMaster = 0; in memsys3FromMaster()
22484 mem3.szMaster = 0; in memsys3FromMaster()
22485 mem3.mnMaster = 0; in memsys3FromMaster()
22490 newi = mem3.iMaster + mem3.szMaster - nBlock; in memsys3FromMaster()
22491 assert( newi > mem3.iMaster+1 ); in memsys3FromMaster()
22492 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock; in memsys3FromMaster()
22493 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2; in memsys3FromMaster()
22494 mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1; in memsys3FromMaster()
22495 mem3.szMaster -= nBlock; in memsys3FromMaster()
22496 mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster; in memsys3FromMaster()
22497 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; in memsys3FromMaster()
22498 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; in memsys3FromMaster()
22499 if( mem3.szMaster < mem3.mnMaster ){ in memsys3FromMaster()
22500 mem3.mnMaster = mem3.szMaster; in memsys3FromMaster()
22502 return (void*)&mem3.aPool[newi]; in memsys3FromMaster()
22525 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3Merge()
22527 iNext = mem3.aPool[i].u.list.next; in memsys3Merge()
22528 size = mem3.aPool[i-1].u.hdr.size4x; in memsys3Merge()
22532 assert( i > mem3.aPool[i-1].u.hdr.prevSize ); in memsys3Merge()
22533 prev = i - mem3.aPool[i-1].u.hdr.prevSize; in memsys3Merge()
22535 iNext = mem3.aPool[prev].u.list.next; in memsys3Merge()
22539 x = mem3.aPool[prev-1].u.hdr.size4x & 2; in memsys3Merge()
22540 mem3.aPool[prev-1].u.hdr.size4x = size*4 | x; in memsys3Merge()
22541 mem3.aPool[prev+size-1].u.hdr.prevSize = size; in memsys3Merge()
22547 if( size>mem3.szMaster ){ in memsys3Merge()
22548 mem3.iMaster = i; in memsys3Merge()
22549 mem3.szMaster = size; in memsys3Merge()
22566 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3MallocUnsafe()
22581 i = mem3.aiSmall[nBlock-2]; in memsys3MallocUnsafe()
22583 memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]); in memsys3MallocUnsafe()
22588 for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){ in memsys3MallocUnsafe()
22589 if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){ in memsys3MallocUnsafe()
22590 memsys3UnlinkFromList(i, &mem3.aiHash[hash]); in memsys3MallocUnsafe()
22600 if( mem3.szMaster>=nBlock ){ in memsys3MallocUnsafe()
22612 for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){ in memsys3MallocUnsafe()
22614 if( mem3.iMaster ){ in memsys3MallocUnsafe()
22615 memsys3Link(mem3.iMaster); in memsys3MallocUnsafe()
22616 mem3.iMaster = 0; in memsys3MallocUnsafe()
22617 mem3.szMaster = 0; in memsys3MallocUnsafe()
22620 memsys3Merge(&mem3.aiHash[i]); in memsys3MallocUnsafe()
22623 memsys3Merge(&mem3.aiSmall[i]); in memsys3MallocUnsafe()
22625 if( mem3.szMaster ){ in memsys3MallocUnsafe()
22626 memsys3Unlink(mem3.iMaster); in memsys3MallocUnsafe()
22627 if( mem3.szMaster>=nBlock ){ in memsys3MallocUnsafe()
22647 assert( sqlite3_mutex_held(mem3.mutex) ); in memsys3FreeUnsafe()
22648 assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] ); in memsys3FreeUnsafe()
22649 i = p - mem3.aPool; in memsys3FreeUnsafe()
22650 assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 ); in memsys3FreeUnsafe()
22651 size = mem3.aPool[i-1].u.hdr.size4x/4; in memsys3FreeUnsafe()
22652 assert( i+size<=mem3.nPool+1 ); in memsys3FreeUnsafe()
22653 mem3.aPool[i-1].u.hdr.size4x &= ~1; in memsys3FreeUnsafe()
22654 mem3.aPool[i+size-1].u.hdr.prevSize = size; in memsys3FreeUnsafe()
22655 mem3.aPool[i+size-1].u.hdr.size4x &= ~2; in memsys3FreeUnsafe()
22659 if( mem3.iMaster ){ in memsys3FreeUnsafe()
22660 while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){ in memsys3FreeUnsafe()
22661 size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize; in memsys3FreeUnsafe()
22662 mem3.iMaster -= size; in memsys3FreeUnsafe()
22663 mem3.szMaster += size; in memsys3FreeUnsafe()
22664 memsys3Unlink(mem3.iMaster); in memsys3FreeUnsafe()
22665 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; in memsys3FreeUnsafe()
22666 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; in memsys3FreeUnsafe()
22667 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; in memsys3FreeUnsafe()
22669 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; in memsys3FreeUnsafe()
22670 while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){ in memsys3FreeUnsafe()
22671 memsys3Unlink(mem3.iMaster+mem3.szMaster); in memsys3FreeUnsafe()
22672 mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4; in memsys3FreeUnsafe()
22673 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; in memsys3FreeUnsafe()
22674 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; in memsys3FreeUnsafe()
22767 mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap; in memsys3Init()
22768 mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2; in memsys3Init()
22771 mem3.szMaster = mem3.nPool; in memsys3Init()
22772 mem3.mnMaster = mem3.szMaster; in memsys3Init()
22773 mem3.iMaster = 1; in memsys3Init()
22774 mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2; in memsys3Init()
22775 mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool; in memsys3Init()
22776 mem3.aPool[mem3.nPool].u.hdr.size4x = 1; in memsys3Init()
22786 mem3.mutex = 0; in memsys3Shutdown()
22813 for(i=1; i<=mem3.nPool; i+=size/4){ in sqlite3Memsys3Dump()
22814 size = mem3.aPool[i-1].u.hdr.size4x; in sqlite3Memsys3Dump()
22816 fprintf(out, "%p size error\n", &mem3.aPool[i]); in sqlite3Memsys3Dump()
22820 if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){ in sqlite3Memsys3Dump()
22821 fprintf(out, "%p tail size does not match\n", &mem3.aPool[i]); in sqlite3Memsys3Dump()
22825 if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){ in sqlite3Memsys3Dump()
22826 fprintf(out, "%p tail checkout bit is incorrect\n", &mem3.aPool[i]); in sqlite3Memsys3Dump()
22831 fprintf(out, "%p %6d bytes checked out\n", &mem3.aPool[i], (size/4)*8-8); in sqlite3Memsys3Dump()
22833 fprintf(out, "%p %6d bytes free%s\n", &mem3.aPool[i], (size/4)*8-8, in sqlite3Memsys3Dump()
22834 i==mem3.iMaster ? " **master**" : ""); in sqlite3Memsys3Dump()
22838 if( mem3.aiSmall[i]==0 ) continue; in sqlite3Memsys3Dump()
22840 for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){ in sqlite3Memsys3Dump()
22841 fprintf(out, " %p(%d)", &mem3.aPool[j], in sqlite3Memsys3Dump()
22842 (mem3.aPool[j-1].u.hdr.size4x/4)*8-8); in sqlite3Memsys3Dump()
22847 if( mem3.aiHash[i]==0 ) continue; in sqlite3Memsys3Dump()
22849 for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){ in sqlite3Memsys3Dump()
22850 fprintf(out, " %p(%d)", &mem3.aPool[j], in sqlite3Memsys3Dump()
22851 (mem3.aPool[j-1].u.hdr.size4x/4)*8-8); in sqlite3Memsys3Dump()
22855 fprintf(out, "master=%d\n", mem3.iMaster); in sqlite3Memsys3Dump()
22856 fprintf(out, "nowUsed=%d\n", mem3.nPool*8 - mem3.szMaster*8); in sqlite3Memsys3Dump()
22857 fprintf(out, "mxUsed=%d\n", mem3.nPool*8 - mem3.mnMaster*8); in sqlite3Memsys3Dump()
22858 sqlite3_mutex_leave(mem3.mutex); in sqlite3Memsys3Dump()