/ Check-in [32380dca]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Register-ify the OP_ForceInt opcode. (CVS 4684)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 32380dcabcd3839e79f91430b0c250d6e02d9243
User & Date: drh 2008-01-05 05:38:21
Context
2008-01-05
06:51
Expression code generator takes advantage of recent opcode changes. (CVS 4685) check-in: 6c78d2a4 user: drh tags: trunk
05:38
Register-ify the OP_ForceInt opcode. (CVS 4684) check-in: 32380dca user: drh tags: trunk
05:20
Register-ify the OP_AddImm and all casting opcodes. Omit the OP_MemIncr opcode. (CVS 4683) check-in: 3e8a07dd user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

    39     39   **
    40     40   ** Various scripts scan this source file in order to generate HTML
    41     41   ** documentation, headers files, or other derived files.  The formatting
    42     42   ** of the code in this file is, therefore, important.  See other comments
    43     43   ** in this file for details.  If in doubt, do not deviate from existing
    44     44   ** commenting and indentation practices when changing or adding code.
    45     45   **
    46         -** $Id: vdbe.c,v 1.681 2008/01/05 05:20:10 drh Exp $
           46  +** $Id: vdbe.c,v 1.682 2008/01/05 05:38:21 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #include <ctype.h>
    50     50   #include "vdbeInt.h"
    51     51   
    52     52   /*
    53     53   ** The following global variable is incremented every time a cursor
................................................................................
  1610   1610   case OP_AddImm: {            /* no-push, in1 */
  1611   1611     nPop = 0;
  1612   1612     sqlite3VdbeMemIntegerify(pIn1);
  1613   1613     pIn1->u.i += pOp->p2;
  1614   1614     break;
  1615   1615   }
  1616   1616   
  1617         -/* Opcode: ForceInt P1 P2 *
         1617  +/* Opcode: ForceInt P1 P2 P3 * *
  1618   1618   **
  1619         -** Convert the top of the stack into an integer.  If the current top of
  1620         -** the stack is not numeric (meaning that is is a NULL or a string that
  1621         -** does not look like an integer or floating point number) then pop the
  1622         -** stack and jump to P2.  If the top of the stack is numeric then
         1619  +** Convert value in register P1 into an integer.  If the value 
         1620  +** in P1 is not numeric (meaning that is is a NULL or a string that
         1621  +** does not look like an integer or floating point number) then
         1622  +** jump to P2.  If the value in P1 is numeric then
  1623   1623   ** convert it into the least integer that is greater than or equal to its
  1624         -** current value if P1==0, or to the least integer that is strictly
  1625         -** greater than its current value if P1==1.
         1624  +** current value if P3==0, or to the least integer that is strictly
         1625  +** greater than its current value if P3==1.
  1626   1626   */
  1627         -case OP_ForceInt: {            /* no-push, jump */
         1627  +case OP_ForceInt: {            /* no-push, jump, in1 */
  1628   1628     i64 v;
  1629         -  assert( pTos>=p->aStack );
  1630         -  applyAffinity(pTos, SQLITE_AFF_NUMERIC, encoding);
  1631         -  if( (pTos->flags & (MEM_Int|MEM_Real))==0 ){
  1632         -    Release(pTos);
  1633         -    pTos--;
         1629  +  applyAffinity(pIn1, SQLITE_AFF_NUMERIC, encoding);
         1630  +  if( (pIn1->flags & (MEM_Int|MEM_Real))==0 ){
  1634   1631       pc = pOp->p2 - 1;
  1635   1632       break;
  1636   1633     }
  1637         -  if( pTos->flags & MEM_Int ){
  1638         -    v = pTos->u.i + (pOp->p1!=0);
         1634  +  nPop = 0;
         1635  +  if( pIn1->flags & MEM_Int ){
         1636  +    v = pIn1->u.i + (pOp->p3!=0);
  1639   1637     }else{
  1640         -    /* FIX ME:  should this not be assert( pTos->flags & MEM_Real ) ??? */
  1641         -    sqlite3VdbeMemRealify(pTos);
  1642         -    v = (int)pTos->r;
  1643         -    if( pTos->r>(double)v ) v++;
  1644         -    if( pOp->p1 && pTos->r==(double)v ) v++;
         1638  +    assert( pIn1->flags & MEM_Real );
         1639  +    v = (sqlite3_int64)pIn1->r;
         1640  +    if( pIn1->r>(double)v ) v++;
         1641  +    if( pOp->p3 && pIn1->r==(double)v ) v++;
  1645   1642     }
  1646         -  Release(pTos);
  1647         -  pTos->u.i = v;
  1648         -  pTos->flags = MEM_Int;
         1643  +  Release(pIn1);
         1644  +  pIn1->u.i = v;
         1645  +  pIn1->flags = MEM_Int;
  1649   1646     break;
  1650   1647   }
  1651   1648   
  1652   1649   /* Opcode: MustBeInt P1 P2 P3
  1653   1650   ** 
  1654   1651   ** Force the top of the stack to be an integer.  If the top of the
  1655   1652   ** stack is not an integer and cannot be converted into an integer

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is reponsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.274 2008/01/05 04:06:04 drh Exp $
           19  +** $Id: where.c,v 1.275 2008/01/05 05:38:21 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
    25     25   */
    26     26   #define BMS  (sizeof(Bitmask)*8)
................................................................................
  2344   2344         }
  2345   2345         if( pStart ){
  2346   2346           Expr *pX;
  2347   2347           pX = pStart->pExpr;
  2348   2348           assert( pX!=0 );
  2349   2349           assert( pStart->leftCursor==iCur );
  2350   2350           sqlite3ExprCode(pParse, pX->pRight, 0);
  2351         -        sqlite3VdbeAddOp2(v, OP_ForceInt, pX->op==TK_LE || pX->op==TK_GT, brk);
         2351  +        sqlite3VdbeAddOp3(v, OP_ForceInt, 0, brk, 
         2352  +                             pX->op==TK_LE || pX->op==TK_GT);
  2352   2353           sqlite3VdbeAddOp2(v, bRev ? OP_MoveLt : OP_MoveGe, iCur, brk);
  2353   2354           VdbeComment((v, "pk"));
  2354   2355           disableTerm(pLevel, pStart);
  2355   2356         }else{
  2356   2357           sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, brk);
  2357   2358         }
  2358   2359         if( pEnd ){