From: drh Date: Tue, 1 Apr 2008 00:36:10 +0000 (+0000) Subject: Break up the implementation of OP_Move, OP_Copy, and OP_SCopy to reduce X-Git-Tag: version-3.6.10~1232 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e1349cb0f0d2178fa584d2e16dde7b35eeefcbd0;p=thirdparty%2Fsqlite.git Break up the implementation of OP_Move, OP_Copy, and OP_SCopy to reduce the number of branch instructions. (CVS 4945) FossilOrigin-Name: 53e533d3a764d1973c24bffaacc505ea4b61a2b9 --- diff --git a/manifest b/manifest index a49a7e5251..71cda47697 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sveryquick.test\sscript\sfor\sa\svery\sfast\soverview\stest\sthat\somits\nall\si/o\sand\smalloc\stesting.\s(CVS\s4944) -D 2008-03-31T23:51:35 +C Break\sup\sthe\simplementation\sof\sOP_Move,\sOP_Copy,\sand\sOP_SCopy\sto\sreduce\nthe\snumber\sof\sbranch\sinstructions.\s(CVS\s4945) +D 2008-04-01T00:36:10 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -174,7 +174,7 @@ F src/update.c e23e83cf481b25d5fc7beb92efbb71d297712fd3 F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b F src/util.c dba9e04121eb17ec4643d6ca231ff859452cf0e2 F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30 -F src/vdbe.c 07f500db3880a8555f7d76ef5f3cc405725ae9b8 +F src/vdbe.c 1a8f3ececaa93d4932d27ba87946a6907625338c F src/vdbe.h f72201a0657d5f3d6cc008d1f8d9cc65768518c9 F src/vdbeInt.h 0b96efdeecb0803e504bf1c16b198f87c91d6019 F src/vdbeapi.c ab6e99f8a6b7fcb82c2c698da7a36762a7593f0a @@ -620,7 +620,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P c29ee0fed23dcdbd9dde6b1e42b603100ea2389c -R ea5dee7bb1231c90f372bc524dc68887 +P f61df8daa89f07dad2a0ded00c326ef35dead257 +R 70671ac2da4a3b5255caf0a8bf9dc874 U drh -Z 9099251370f41c7219918acc2b43b496 +Z cb426daa3c0350483da8130288b38568 diff --git a/manifest.uuid b/manifest.uuid index b195260ad3..8ffb8a4ad3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f61df8daa89f07dad2a0ded00c326ef35dead257 \ No newline at end of file +53e533d3a764d1973c24bffaacc505ea4b61a2b9 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index f969bbcd56..b9e2d1aa41 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,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.723 2008/03/31 18:19:54 drh Exp $ +** $Id: vdbe.c,v 1.724 2008/04/01 00:36:10 drh Exp $ */ #include "sqliteInt.h" #include @@ -971,6 +971,24 @@ case OP_Variable: { /* out2-prerelease */ ** is left holding a NULL. It is an error for P1 and P2 to be the ** same register. */ +case OP_Move: { + char *zMalloc; + assert( pOp->p1>0 ); + assert( pOp->p1<=p->nMem ); + pIn1 = &p->aMem[pOp->p1]; + REGISTER_TRACE(pOp->p1, pIn1); + assert( pOp->p2>0 ); + assert( pOp->p2<=p->nMem ); + pOut = &p->aMem[pOp->p2]; + assert( pOut!=pIn1 ); + zMalloc = pOut->zMalloc; + pOut->zMalloc = 0; + sqlite3VdbeMemMove(pOut, pIn1); + pIn1->zMalloc = zMalloc; + REGISTER_TRACE(pOp->p2, pOut); + break; +} + /* Opcode: Copy P1 P2 * * * ** ** Make a copy of register P1 into register P2. @@ -978,6 +996,21 @@ case OP_Variable: { /* out2-prerelease */ ** This instruction makes a deep copy of the value. A duplicate ** is made of any string or blob constant. See also OP_SCopy. */ +case OP_Copy: { + assert( pOp->p1>0 ); + assert( pOp->p1<=p->nMem ); + pIn1 = &p->aMem[pOp->p1]; + REGISTER_TRACE(pOp->p1, pIn1); + assert( pOp->p2>0 ); + assert( pOp->p2<=p->nMem ); + pOut = &p->aMem[pOp->p2]; + assert( pOut!=pIn1 ); + sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); + Deephemeralize(pOut); + REGISTER_TRACE(pOp->p2, pOut); + break; +} + /* Opcode: SCopy P1 P2 * * * ** ** Make a shallow copy of register P1 into register P2. @@ -990,8 +1023,6 @@ case OP_Variable: { /* out2-prerelease */ ** during the lifetime of the copy. Use OP_Copy to make a complete ** copy. */ -case OP_Move: -case OP_Copy: case OP_SCopy: { assert( pOp->p1>0 ); assert( pOp->p1<=p->nMem ); @@ -1001,17 +1032,7 @@ case OP_SCopy: { assert( pOp->p2<=p->nMem ); pOut = &p->aMem[pOp->p2]; assert( pOut!=pIn1 ); - if( pOp->opcode==OP_Move ){ - char *zMalloc = pOut->zMalloc; - pOut->zMalloc = 0; - sqlite3VdbeMemMove(pOut, pIn1); - pIn1->zMalloc = zMalloc; - }else{ - sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); - if( pOp->opcode==OP_Copy ){ - Deephemeralize(pOut); - } - } + sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); REGISTER_TRACE(pOp->p2, pOut); break; }