Remove the VdbeOp.opflags field and its associated initialization overhead.
Update mkopcodeh.tcl to reorder opcode numbers to help the resolveP2Values() routine run faster. FossilOrigin-Name: 099478fa7521ba52262ef2bf24dd8f0114ce92e1
This commit is contained in:
+62
-51
@@ -545,73 +545,84 @@ int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
|
||||
** (4) Initialize the p4.xAdvance pointer on opcodes that use it.
|
||||
**
|
||||
** (5) Reclaim the memory allocated for storing labels.
|
||||
**
|
||||
** This routine will only function correctly if the mkopcodeh.tcl generator
|
||||
** script numbers the opcodes correctly. Changes to this routine must be
|
||||
** coordinated with changes to mkopcodeh.tcl.
|
||||
*/
|
||||
static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
|
||||
int i;
|
||||
int nMaxArgs = *pMaxFuncArgs;
|
||||
Op *pOp;
|
||||
Parse *pParse = p->pParse;
|
||||
int *aLabel = pParse->aLabel;
|
||||
p->readOnly = 1;
|
||||
p->bIsReader = 0;
|
||||
for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){
|
||||
u8 opcode = pOp->opcode;
|
||||
pOp = &p->aOp[p->nOp-1];
|
||||
while(1){
|
||||
|
||||
/* NOTE: Be sure to update mkopcodeh.tcl when adding or removing
|
||||
** cases from this switch! */
|
||||
switch( opcode ){
|
||||
case OP_Transaction: {
|
||||
if( pOp->p2!=0 ) p->readOnly = 0;
|
||||
/* fall thru */
|
||||
}
|
||||
case OP_AutoCommit:
|
||||
case OP_Savepoint: {
|
||||
p->bIsReader = 1;
|
||||
break;
|
||||
}
|
||||
/* Only JUMP opcodes and the short list of special opcodes in the switch
|
||||
** below need to be considered. The mkopcodeh.tcl generator script groups
|
||||
** all these opcodes together near the front of the opcode list. Skip
|
||||
** any opcode that does not need processing by virtual of the fact that
|
||||
** it is larger than OP_MX_JUMP, as a performance optimization.
|
||||
*/
|
||||
if( pOp->opcode<=OP_MX_JUMP ){
|
||||
/* NOTE: Be sure to update mkopcodeh.tcl when adding or removing
|
||||
** cases from this switch! */
|
||||
switch( pOp->opcode ){
|
||||
case OP_Transaction: {
|
||||
if( pOp->p2!=0 ) p->readOnly = 0;
|
||||
/* fall thru */
|
||||
}
|
||||
case OP_AutoCommit:
|
||||
case OP_Savepoint: {
|
||||
p->bIsReader = 1;
|
||||
break;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
case OP_Checkpoint:
|
||||
case OP_Checkpoint:
|
||||
#endif
|
||||
case OP_Vacuum:
|
||||
case OP_JournalMode: {
|
||||
p->readOnly = 0;
|
||||
p->bIsReader = 1;
|
||||
break;
|
||||
}
|
||||
case OP_Vacuum:
|
||||
case OP_JournalMode: {
|
||||
p->readOnly = 0;
|
||||
p->bIsReader = 1;
|
||||
break;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
case OP_VUpdate: {
|
||||
if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
|
||||
break;
|
||||
}
|
||||
case OP_VFilter: {
|
||||
int n;
|
||||
assert( p->nOp - i >= 3 );
|
||||
assert( pOp[-1].opcode==OP_Integer );
|
||||
n = pOp[-1].p1;
|
||||
if( n>nMaxArgs ) nMaxArgs = n;
|
||||
break;
|
||||
}
|
||||
case OP_VUpdate: {
|
||||
if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
|
||||
break;
|
||||
}
|
||||
case OP_VFilter: {
|
||||
int n;
|
||||
assert( (pOp - p->aOp) >= 3 );
|
||||
assert( pOp[-1].opcode==OP_Integer );
|
||||
n = pOp[-1].p1;
|
||||
if( n>nMaxArgs ) nMaxArgs = n;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case OP_Next:
|
||||
case OP_NextIfOpen:
|
||||
case OP_SorterNext: {
|
||||
pOp->p4.xAdvance = sqlite3BtreeNext;
|
||||
pOp->p4type = P4_ADVANCE;
|
||||
break;
|
||||
case OP_Next:
|
||||
case OP_NextIfOpen:
|
||||
case OP_SorterNext: {
|
||||
pOp->p4.xAdvance = sqlite3BtreeNext;
|
||||
pOp->p4type = P4_ADVANCE;
|
||||
break;
|
||||
}
|
||||
case OP_Prev:
|
||||
case OP_PrevIfOpen: {
|
||||
pOp->p4.xAdvance = sqlite3BtreePrevious;
|
||||
pOp->p4type = P4_ADVANCE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case OP_Prev:
|
||||
case OP_PrevIfOpen: {
|
||||
pOp->p4.xAdvance = sqlite3BtreePrevious;
|
||||
pOp->p4type = P4_ADVANCE;
|
||||
break;
|
||||
if( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 && pOp->p2<0 ){
|
||||
assert( ADDR(pOp->p2)<pParse->nLabel );
|
||||
pOp->p2 = aLabel[ADDR(pOp->p2)];
|
||||
}
|
||||
}
|
||||
|
||||
pOp->opflags = sqlite3OpcodeProperty[opcode];
|
||||
if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){
|
||||
assert( ADDR(pOp->p2)<pParse->nLabel );
|
||||
pOp->p2 = aLabel[ADDR(pOp->p2)];
|
||||
}
|
||||
if( pOp==p->aOp ) break;
|
||||
pOp--;
|
||||
}
|
||||
sqlite3DbFree(p->db, pParse->aLabel);
|
||||
pParse->aLabel = 0;
|
||||
|
||||
Reference in New Issue
Block a user