mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Replace the NOPUSH_MASKs with a bit-vector mechanism that can contain
several different properties about each opcode. (CVS 4677) FossilOrigin-Name: 042dcb9621934d0318a7c6e9cd08b20a569db367
This commit is contained in:
@@ -232,48 +232,6 @@ void sqlite3VdbeResolveLabel(Vdbe *p, int x){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Return non-zero if opcode 'op' is guarenteed not to push more values
|
||||
** onto the VDBE stack than it pops off.
|
||||
*/
|
||||
static int opcodeNoPush(u8 op){
|
||||
/* The 10 NOPUSH_MASK_n constants are defined in the automatically
|
||||
** generated header file opcodes.h. Each is a 16-bit bitmask, one
|
||||
** bit corresponding to each opcode implemented by the virtual
|
||||
** machine in vdbe.c. The bit is true if the word "no-push" appears
|
||||
** in a comment on the same line as the "case OP_XXX:" in
|
||||
** sqlite3VdbeExec() in vdbe.c.
|
||||
**
|
||||
** If the bit is true, then the corresponding opcode is guarenteed not
|
||||
** to grow the stack when it is executed. Otherwise, it may grow the
|
||||
** stack by at most one entry.
|
||||
**
|
||||
** NOPUSH_MASK_0 corresponds to opcodes 0 to 15. NOPUSH_MASK_1 contains
|
||||
** one bit for opcodes 16 to 31, and so on.
|
||||
**
|
||||
** 16-bit bitmasks (rather than 32-bit) are specified in opcodes.h
|
||||
** because the file is generated by an awk program. Awk manipulates
|
||||
** all numbers as floating-point and we don't want to risk a rounding
|
||||
** error if someone builds with an awk that uses (for example) 32-bit
|
||||
** IEEE floats.
|
||||
*/
|
||||
static const u32 masks[5] = {
|
||||
NOPUSH_MASK_0 + (((unsigned)NOPUSH_MASK_1)<<16),
|
||||
NOPUSH_MASK_2 + (((unsigned)NOPUSH_MASK_3)<<16),
|
||||
NOPUSH_MASK_4 + (((unsigned)NOPUSH_MASK_5)<<16),
|
||||
NOPUSH_MASK_6 + (((unsigned)NOPUSH_MASK_7)<<16),
|
||||
NOPUSH_MASK_8 + (((unsigned)NOPUSH_MASK_9)<<16)
|
||||
};
|
||||
assert( op<32*5 );
|
||||
return (masks[op>>5] & (1<<(op&0x1F)));
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
int sqlite3VdbeOpcodeNoPush(u8 op){
|
||||
return opcodeNoPush(op);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Loop through the program looking for P2 values that are negative.
|
||||
** Each such value is a label. Resolve the label by setting the P2
|
||||
@@ -338,7 +296,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs, int *pMaxStack){
|
||||
if( n>nMaxArgs ) nMaxArgs = n;
|
||||
#endif
|
||||
}
|
||||
if( opcodeNoPush(opcode) ){
|
||||
if( !sqlite3VdbeOpcodeHasProperty(opcode, OPFLG_PUSH) ){
|
||||
nMaxStack--;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user