]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Rearrange integer token values in the parser and logic in the
authordrh <drh@noemail.net>
Wed, 2 Aug 2017 11:04:00 +0000 (11:04 +0000)
committerdrh <drh@noemail.net>
Wed, 2 Aug 2017 11:04:00 +0000 (11:04 +0000)
resolveP2Values() routine for a small size reduction and performance increase.

FossilOrigin-Name: 1cad2926ad88b83becab1326bd189d7bac8ba6d470b36ba5d29af5c9fb016014

manifest
manifest.uuid
src/parse.y
src/vdbeaux.c

index 501e03b52d824c28983dd589242984e88bd2c6e7..3324ec61929cb9f8876077543aee63bd4a3dbf78 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Show\swhich\sopcodes\sare\sjumps\sin\sthe\scomments\swhen\sgenerating\s\nthe\sopcodes.h\sheader\sfile.
-D 2017-08-02T03:21:52.265
+C Rearrange\sinteger\stoken\svalues\sin\sthe\sparser\sand\slogic\sin\sthe\nresolveP2Values()\sroutine\sfor\sa\ssmall\ssize\sreduction\sand\sperformance\sincrease.
+D 2017-08-02T11:04:00.914
 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016
@@ -441,7 +441,7 @@ F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a
 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
 F src/pager.c 1e63b0299cf123cf38c48413ec03190f56c1e7d0ccc6573c467d8ac240b898e9
 F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa
-F src/parse.y e384cb73f99e1b074085c974b37f4d830e885359e4b60837e30f7d67c16ba65b
+F src/parse.y 52ef3cecd0934e9da4a45b585883a03243ad615d338ad94f44501a05891dcdfa
 F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870
 F src/pcache.h 521bb9610d38ef17a3cc9b5ddafd4546c2ea67fa3d0e464823d73c2a28d50e11
 F src/pcache1.c 1195a21fe28e223e024f900b2011e80df53793f0356a24caace4188b098540dc
@@ -524,7 +524,7 @@ F src/vdbe.c 5752a157cfb2898d154ecdd4a805135d2e9b1708084a3205dbc379af3ae8ef07
 F src/vdbe.h d50cadf12bcf9fb99117ef392ce1ea283aa429270481426b6e8b0280c101fd97
 F src/vdbeInt.h ff2b7db0968d20e6184aee256d2e535d565f5a172e3588a78adb166a41fc4911
 F src/vdbeapi.c 0823531191f9d5588a245ed5b39306798681814e9e8099d54a3213a13a28fbe7
-F src/vdbeaux.c dc26b755caab4dca108ec128c1857a0a9601685e0c964f4a8abe78bdd033cd75
+F src/vdbeaux.c 5feca7a5f38a0bd154d8f68710e3afffdb9a83d7b56350497fdd316eb1dd6775
 F src/vdbeblob.c db3cf91060f6f4b2f1358a4200e844697990752177784c7c95da00b7ac9f1c7b
 F src/vdbemem.c 9ca2854976f35db40341977e688a08204c96427505f5b90215dc7970f6ea42c4
 F src/vdbesort.c f512c68d0bf7e0105316a5594c4329358c8ee9cae3b25138df041d97516c0372
@@ -1640,7 +1640,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P a6e4c5ae8f29bc2e7f2088426341254e9281d19db9dc9a14abc376d56dad4c4b
-R 83878328873cb9656e064240517b699e
+P eef643a369250f1acac4c01a9b3d29068a510e5bf7fa843d565df5e2523e4dd9
+R b94c57abdcf7a3520bf08721f05c19bd
 U drh
-Z 946736871cc1f941ca94f168defb031e
+Z e85c953fd1ca1658c90aad1eff95f349
index aeaa589a45d235bb556107f73efa510a5f96f7e6..2d2988ab276f9f7ede08c63ede0c6003f91e4eb1 100644 (file)
@@ -1 +1 @@
-eef643a369250f1acac4c01a9b3d29068a510e5bf7fa843d565df5e2523e4dd9
\ No newline at end of file
+1cad2926ad88b83becab1326bd189d7bac8ba6d470b36ba5d29af5c9fb016014
\ No newline at end of file
index 129686ad575ad9499e7f38beb1b0b05186a1d8cb..a8d080eed30cf51cbc2559f421b8f72f4e11c1b4 100644 (file)
@@ -192,6 +192,19 @@ columnlist ::= columnlist COMMA columnname carglist.
 columnlist ::= columnname carglist.
 columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,&A,&Y);}
 
+// Declare some tokens early in order to influence their values, to 
+// improve performance and reduce the executable size.  The goal here is
+// to get the "jump" operations in ISNULL through ESCAPE to have numeric
+// values that are early enough so that all jump operations are clustered
+// at the beginning, but also so that the comparison tokens NE through GE
+// are as large as possible so that they are near to FUNCTION, which is a
+// token synthesized by addopcodes.tcl.
+//
+%token ABORT ACTION AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST.
+%token CONFLICT DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL.
+%token OR AND NOT IS MATCH LIKE_KW BETWEEN IN ISNULL NOTNULL NE EQ.
+%token GT LE LT GE ESCAPE.
+
 // The following directive causes tokens ABORT, AFTER, ASC, etc. to
 // fallback to ID if they will not parse as their original value.
 // This obviates the need for the "id" nonterminal.
index a4b01c4308a6ba303b0f387b1302a2d4f7e2162b..38b870a72230bf4481a29d0faa407b35365c5beb 100644 (file)
@@ -597,6 +597,27 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
           p->bIsReader = 1;
           break;
         }
+        case OP_Next:
+        case OP_NextIfOpen:
+        case OP_SorterNext: {
+          pOp->p4.xAdvance = sqlite3BtreeNext;
+          pOp->p4type = P4_ADVANCE;
+          /* The code generator never codes any of these opcodes as a jump
+          ** to a label.  They are always coded as a jump backwards to a 
+          ** known address */
+          assert( pOp->p2>=0 );
+          break;
+        }
+        case OP_Prev:
+        case OP_PrevIfOpen: {
+          pOp->p4.xAdvance = sqlite3BtreePrevious;
+          pOp->p4type = P4_ADVANCE;
+          /* The code generator never codes any of these opcodes as a jump
+          ** to a label.  They are always coded as a jump backwards to a 
+          ** known address */
+          assert( pOp->p2>=0 );
+          break;
+        }
 #ifndef SQLITE_OMIT_VIRTUALTABLE
         case OP_VUpdate: {
           if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
@@ -608,27 +629,25 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
           assert( pOp[-1].opcode==OP_Integer );
           n = pOp[-1].p1;
           if( n>nMaxArgs ) nMaxArgs = n;
-          break;
+          /* Fall through into the default case */
         }
 #endif
-        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;
+        default: {
+          if( pOp->p2<0 ){
+            /* The mkopcodeh.tcl script has so arranged things that the only
+            ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
+            ** have non-negative values for P2. */
+            assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );
+            assert( ADDR(pOp->p2)<pParse->nLabel );
+            pOp->p2 = aLabel[ADDR(pOp->p2)];
+          }
           break;
         }
       }
-      if( pOp->p2<0 && (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ){
-        assert( ADDR(pOp->p2)<pParse->nLabel );
-        pOp->p2 = aLabel[ADDR(pOp->p2)];
-      }
+      /* The mkopcodeh.tcl script has so arranged things that the only
+      ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
+      ** have non-negative values for P2. */
+      assert( (sqlite3OpcodeProperty[pOp->opcode]&OPFLG_JUMP)==0 || pOp->p2>=0);
     }
     if( pOp==p->aOp ) break;
     pOp--;