From 3e87c7abebfeeffe4f7de5c6b18f221aab9ba8c4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 6 Jan 2003 23:54:05 +0000 Subject: [PATCH] Remove unnecessary code from the VDBE. (CVS 814) FossilOrigin-Name: b96ec281ff29aad8af340b30c6ff4e129ffeeefb --- manifest | 12 ++++----- manifest.uuid | 2 +- src/vdbe.c | 73 +++------------------------------------------------ 3 files changed, 10 insertions(+), 77 deletions(-) diff --git a/manifest b/manifest index 755ddfae7b..4f07f20259 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\soptimizations.\s(CVS\s813) -D 2003-01-05T21:41:41 +C Remove\sunnecessary\scode\sfrom\sthe\sVDBE.\s(CVS\s814) +D 2003-01-06T23:54:06 F Makefile.in 868c17a1ae1c07603d491274cc8f86c04acf2a1e F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -52,7 +52,7 @@ F src/tokenize.c 75e3bb37305b64e118e709752066f494c4f93c30 F src/trigger.c 5ba917fc226b96065108da28186c2efaec53e481 F src/update.c 881e4c8e7c786545da4fd2d95da19252b2e31137 F src/util.c e2d108842e02810d3d3242cac0e024b09cdb3c4a -F src/vdbe.c dfcb470866708946dc67028359c3128876ad2297 +F src/vdbe.c 1d396c7029487630b16b8a310a8c5440d05945dd F src/vdbe.h 754eba497cfe0c3e352b9c101ab2f811f10d0a55 F src/where.c af235636b7bc7f7f42ee1c7162d1958ad0102cab F test/all.test 873d30e25a41b3aa48fec5633a7ec1816e107029 @@ -152,7 +152,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218 -P 6c304024bbd21a1886a57ada795531349aa627d7 -R fea26809e1516d4617eda0cb040e2e8f +P 5809132f5bf40bae2331f887e87fe5baecc15c46 +R b3c7a57b7ec1a787dd9ebcc0f7db6f34 U drh -Z 448bc2108caef81c9e7977f7eeab8964 +Z 5f8c0999fff5fe3e4b7d38d837b9f84a diff --git a/manifest.uuid b/manifest.uuid index e769f7a6dd..30143d64b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5809132f5bf40bae2331f887e87fe5baecc15c46 \ No newline at end of file +b96ec281ff29aad8af340b30c6ff4e129ffeeefb \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index bc3b74d02e..335884776f 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -36,7 +36,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.190 2003/01/05 21:41:42 drh Exp $ +** $Id: vdbe.c,v 1.191 2003/01/06 23:54:06 drh Exp $ */ #include "sqliteInt.h" #include @@ -932,46 +932,6 @@ static void PopStack(Vdbe *p, int N){ if( aStack[p->tos].flags & STK_Dyn ) sqliteFree(zStack[p->tos]); \ p->tos--; -/* -** Make sure space has been allocated to hold at least N -** stack elements. Allocate additional stack space if -** necessary. -** -** Return 0 on success and non-zero if there are memory -** allocation errors. -*/ -#define NeedStack(P,N) (((P)->nStackAlloc<=(N)) ? hardNeedStack(P,N) : 0) -static int hardNeedStack(Vdbe *p, int N){ - int oldAlloc; - int i; - if( N>=p->nStackAlloc ){ - Stack *aNew; - char **zNew; - oldAlloc = p->nStackAlloc; - p->nStackAlloc = N + 20; - aNew = sqliteRealloc(p->aStack, p->nStackAlloc*sizeof(p->aStack[0])); - zNew = aNew ? sqliteRealloc(p->zStack, p->nStackAlloc*sizeof(char*)) : 0; - if( zNew==0 ){ - sqliteFree(aNew); - sqliteFree(p->aStack); - sqliteFree(p->zStack); - p->aStack = 0; - p->zStack = 0; - p->nStackAlloc = 0; - p->aStack = 0; - p->zStack = 0; - return 1; - } - p->aStack = aNew; - p->zStack = zNew; - for(i=oldAlloc; inStackAlloc; i++){ - p->zStack[i] = 0; - p->aStack[i].flags = 0; - } - } - return 0; -} - /* ** Return TRUE if zNum is a floating-point or integer number. */ @@ -1414,9 +1374,8 @@ int sqliteVdbeExec( ** ** Allocation all the stack space we will ever need. */ - NeedStack(p, p->nOp); - zStack = p->zStack; - aStack = p->aStack; + zStack = p->zStack = sqliteMalloc( p->nOp*sizeof(zStack[0]) ); + aStack = p->aStack = sqliteMalloc( p->nOp*sizeof(aStack[0]) ); p->tos = -1; #ifdef VDBE_PROFILE { @@ -1588,7 +1547,6 @@ case OP_Halt: { */ case OP_Integer: { int i = ++p->tos; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) aStack[i].i = pOp->p1; aStack[i].flags = STK_Int; if( pOp->p3 ){ @@ -1607,7 +1565,6 @@ case OP_Integer: { case OP_String: { int i = ++p->tos; char *z; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) z = pOp->p3; if( z==0 ){ zStack[i] = 0; @@ -1650,7 +1607,6 @@ case OP_Dup: { int i = p->tos - pOp->p1; int j = ++p->tos; VERIFY( if( i<0 ) goto not_enough_stack; ) - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) memcpy(&aStack[j], &aStack[i], sizeof(aStack[i])-NBFS); if( aStack[j].flags & STK_Str ){ int isStatic = (aStack[j].flags & STK_Static)!=0; @@ -1778,7 +1734,6 @@ case OP_Callback: { int i = p->tos - pOp->p1 + 1; int j; VERIFY( if( i<0 ) goto not_enough_stack; ) - VERIFY( if( NeedStack(p, p->tos+2) ) goto no_mem; ) for(j=i; j<=p->tos; j++){ if( aStack[j].flags & STK_Null ){ zStack[j] = 0; @@ -1866,7 +1821,6 @@ case OP_Concat: { } if( nByte<0 ){ if( pOp->p2==0 ) PopStack(p, nField); - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos].flags = STK_Null; zStack[p->tos] = 0; @@ -1887,7 +1841,6 @@ case OP_Concat: { } zNew[j] = 0; if( pOp->p2==0 ) PopStack(p, nField); - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos].n = nByte; aStack[p->tos].flags = STK_Str|STK_Dyn; @@ -2042,7 +1995,6 @@ case OP_Function: { ctx.isStep = 0; (*ctx.pFunc->xFunc)(&ctx, n, (const char**)&zStack[p->tos-n+1]); PopStack(p, n); - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos] = ctx.s; if( ctx.s.flags & STK_Dyn ){ @@ -2818,7 +2770,6 @@ case OP_MakeRecord: { } } PopStack(p, nField); - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos].n = nByte; aStack[p->tos].flags = STK_Str | STK_Dyn; @@ -2964,7 +2915,6 @@ case OP_MakeKey: { }else{ if( pOp->p2==0 ) PopStack(p, nField+addRowid); } - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos].n = nByte; aStack[p->tos].flags = STK_Str|STK_Dyn; @@ -3130,7 +3080,6 @@ case OP_ReadCookie: { int i = ++p->tos; int aMeta[SQLITE_N_BTREE_META]; assert( pOp->p2tos) ) goto no_mem; ) rc = sqliteBtreeGetMeta(pBt, aMeta); aStack[i].i = aMeta[1+pOp->p2]; aStack[i].flags = STK_Int; @@ -3587,7 +3536,6 @@ case OP_IsUnique: { ** violates a UNIQUE constraint.) */ p->tos++; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) aStack[tos].i = v; aStack[tos].flags = STK_Int; } @@ -3723,7 +3671,6 @@ case OP_NewRecno: { } pC->recnoIsValid = 0; } - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos].i = v; aStack[p->tos].flags = STK_Int; @@ -3851,7 +3798,6 @@ case OP_Column: { int idxWidth; unsigned char aHdr[10]; - VERIFY( if( NeedStack(p, tos+1) ) goto no_mem; ) if( i<0 ){ VERIFY( if( tos+i<0 ) goto bad_instruction; ) VERIFY( if( (aStack[tos+i].flags & STK_Str)==0 ) goto bad_instruction; ) @@ -3958,7 +3904,6 @@ case OP_Recno: { int tos = ++p->tos; BtCursor *pCrsr; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) if( VERIFY( i>=0 && inCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ int v; if( p->aCsr[i].recnoIsValid ){ @@ -3990,7 +3935,6 @@ case OP_FullKey: { int tos = ++p->tos; BtCursor *pCrsr; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) VERIFY( if( !p->aCsr[i].keyAsData ) goto bad_instruction; ) if( VERIFY( i>=0 && inCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ int amt; @@ -4204,7 +4148,6 @@ case OP_IdxRecno: { int tos = ++p->tos; BtCursor *pCrsr; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) if( VERIFY( i>=0 && inCursor && ) (pCrsr = p->aCsr[i].pCursor)!=0 ){ int v; int sz; @@ -4332,7 +4275,6 @@ case OP_CreateIndex: case OP_CreateTable: { int i = ++p->tos; int pgno; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) assert( pOp->p3!=0 && pOp->p3type==P3_POINTER ); if( pOp->opcode==OP_CreateTable ){ rc = sqliteBtreeCreateTable(pOp->p2 ? db->pBeTemp : pBt, &pgno); @@ -4373,7 +4315,6 @@ case OP_IntegrityCk: { char *z; VERIFY( if( iSet<0 || iSet>=p->nSet ) goto bad_instruction; ) - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) pSet = &p->aSet[iSet]; nRoot = sqliteHashCount(&pSet->hash); aRoot = sqliteMalloc( sizeof(int)*(nRoot+1) ); @@ -4445,7 +4386,6 @@ case OP_ListRead: { || pKeylist->nRead>=pKeylist->nKey ) goto bad_instruction; ) p->tos++; - if( NeedStack(p, p->tos) ) goto no_mem; aStack[p->tos].i = pKeylist->aKey[pKeylist->nRead++]; aStack[p->tos].flags = STK_Int; zStack[p->tos] = 0; @@ -4573,7 +4513,6 @@ case OP_SortMakeRec: { } } PopStack(p, nField); - VERIFY( NeedStack(p, p->tos+1); ) p->tos++; aStack[p->tos].n = nByte; zStack[p->tos] = (char*)azArg; @@ -4632,7 +4571,6 @@ case OP_SortMakeKey: { zNewKey[j] = 0; assert( jtos+1); ) p->tos++; aStack[p->tos].n = nByte; aStack[p->tos].flags = STK_Str|STK_Dyn; @@ -4689,7 +4627,6 @@ case OP_SortNext: { if( pSorter!=0 ){ p->pSort = pSorter->pNext; p->tos++; - VERIFY( NeedStack(p, p->tos); ) zStack[p->tos] = pSorter->pData; aStack[p->tos].n = pSorter->nData; aStack[p->tos].flags = STK_Str|STK_Dyn; @@ -4874,7 +4811,6 @@ fileread_jump: case OP_FileColumn: { int i = pOp->p1; char *z; - VERIFY( if( NeedStack(p, p->tos+1) ) goto no_mem; ) if( VERIFY( i>=0 && inField && ) p->azField ){ z = p->azField[i]; }else{ @@ -4972,7 +4908,6 @@ case OP_MemStore: { case OP_MemLoad: { int tos = ++p->tos; int i = pOp->p1; - VERIFY( if( NeedStack(p, tos) ) goto no_mem; ) VERIFY( if( i<0 || i>=p->nMem ) goto bad_instruction; ) memcpy(&aStack[tos], &p->aMem[i].s, sizeof(aStack[tos])-NBFS);; if( aStack[tos].flags & STK_Str ){ @@ -5158,7 +5093,6 @@ case OP_AggGet: { AggElem *pFocus = AggInFocus(p->agg); int i = pOp->p2; int tos = ++p->tos; - VERIFY( if( NeedStack(p, tos) ) goto no_mem; ) if( pFocus==0 ) goto no_mem; if( VERIFY( i>=0 && ) iagg.nMem ){ Mem *pMem = &pFocus->aMem[i]; @@ -5330,7 +5264,6 @@ case OP_SetNext: { } } tos = ++p->tos; - VERIFY( if( NeedStack(p, p->tos) ) goto no_mem; ) zStack[tos] = sqliteHashKey(pSet->prev); aStack[tos].n = sqliteHashKeysize(pSet->prev); aStack[tos].flags = STK_Str | STK_Ephem;