]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improvements to the initialization of the push-down automoton for the
authordrh <drh@noemail.net>
Tue, 24 May 2016 00:40:54 +0000 (00:40 +0000)
committerdrh <drh@noemail.net>
Tue, 24 May 2016 00:40:54 +0000 (00:40 +0000)
Lemon-generated parser.  Smaller and faster.

FossilOrigin-Name: 3b28b68e232060f8b2fe2fe6fa478280da2006ff

manifest
manifest.uuid
tool/lempar.c

index 8f4a53f747ab9d41b5d85db388962d83e678ac9b..2f83cec78812e4d8ca845bbe7a4e00ad33541919 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Use\sa\spointer\sto\sthe\stop\sof\sthe\sstack\srather\sthan\san\sindex\sinto\sthe\sstack\nin\sthe\sLemon-generated\sparser\stemplate,\sfor\sabout\s6.6%\sparser\sperformance\sgain.
-D 2016-05-23T21:56:24.427
+C Improvements\sto\sthe\sinitialization\sof\sthe\spush-down\sautomoton\sfor\sthe\nLemon-generated\sparser.\s\sSmaller\sand\sfaster.
+D 2016-05-24T00:40:54.799
 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
@@ -1422,7 +1422,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
 F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39
-F tool/lempar.c 872383ebf36c13fdaff0f3692d4ff60e64ec49e2
+F tool/lempar.c 8569dd3e4c22831e08e441ab7a0eb6bbefa1d38a
 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
 F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
 F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7
@@ -1493,7 +1493,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 276e92f5b4c1ee49eabb738b24d73d7af90fb13c
-R f3a217ca3fc6adf56f5cf5443069e03b
+P 3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68
+R f0cfba4e984837df73820e425fc5291f
 U drh
-Z babb89b922e84c6e93d4048989d7622c
+Z 2da99ff99cbfd3def15eb678236b100e
index 9a4a91d8af63c390a6f21bd14b9d70beabe1a2d8..0635c8e25098e6d36941ffe1c71636d133b19edf 100644 (file)
@@ -1 +1 @@
-3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68
\ No newline at end of file
+3b28b68e232060f8b2fe2fe6fa478280da2006ff
\ No newline at end of file
index b02fd21b77feef8ef28540e2d236ef8fd2534e78..7fb5fe2d0c3c2809d1144e9948c705dbc7e4990d 100644 (file)
@@ -275,12 +275,15 @@ static const char *const yyRuleName[] = {
 */
 static void yyGrowStack(yyParser *p){
   int newSize;
+  int idx;
   yyStackEntry *pNew;
 
   newSize = p->yystksz*2 + 100;
+  idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
   pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
   if( pNew ){
     p->yystack = pNew;
+    p->yytos = &p->yystack[idx];
     p->yystksz = newSize;
 #ifndef NDEBUG
     if( yyTraceFILE ){
@@ -317,15 +320,18 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
   yyParser *pParser;
   pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
   if( pParser ){
-    pParser->yytos = 0;
 #ifdef YYTRACKMAXSTACKDEPTH
     pParser->yyhwm = 0;
 #endif
 #if YYSTACKDEPTH<=0
+    pParser->yytos = NULL;
     pParser->yystack = NULL;
     pParser->yystksz = 0;
     yyGrowStack(pParser);
 #endif
+    pParser->yytos = pParser->yystack;
+    pParser->yystack[0].stateno = 0;
+    pParser->yystack[0].major = 0;
   }
   return pParser;
 }
@@ -397,7 +403,7 @@ void ParseFree(
 #ifndef YYPARSEFREENEVERNULL
   if( pParser==0 ) return;
 #endif
-  while( pParser->yytos>=pParser->yystack ) yy_pop_parser_stack(pParser);
+  while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
 #if YYSTACKDEPTH<=0
   free(pParser->yystack);
 #endif
@@ -522,7 +528,7 @@ static void yyStackOverflow(yyParser *yypParser){
      fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
    }
 #endif
-   while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser);
+   while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
    /* Here code is inserted which will execute if the parser
    ** stack every overflows */
 /******** Begin %stack_overflow code ******************************************/
@@ -695,8 +701,7 @@ static void yy_parse_failed(
     fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
   }
 #endif
-  while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser);
-  yypParser->yytos = 0;
+  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
   /* Here code is inserted which will be executed whenever the
   ** parser fails */
 /************ Begin %parse_failure code ***************************************/
@@ -734,8 +739,7 @@ static void yy_accept(
     fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
   }
 #endif
-  while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser);
-  yypParser->yytos = 0;
+  while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
   /* Here code is inserted which will be executed whenever the
   ** parser accepts */
 /*********** Begin %parse_accept code *****************************************/
@@ -781,26 +785,7 @@ void Parse(
 
   /* (re)initialize the parser, if necessary */
   yypParser = (yyParser*)yyp;
-  if( yypParser->yytos==0 ){
-#if YYSTACKDEPTH<=0
-    if( yypParser->yystksz <=0 ){
-      yyStackOverflow(yypParser);
-      return;
-    }
-#endif
-    yypParser->yytos = yypParser->yystack;
-#ifndef YYNOERRORRECOVERY
-    yypParser->yyerrcnt = -1;
-#endif
-    yypParser->yystack[0].stateno = 0;
-    yypParser->yystack[0].major = 0;
-#ifndef NDEBUG
-    if( yyTraceFILE ){
-      fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n",
-              yyTracePrompt);
-    }
-#endif
-  }
+  assert( yypParser->yytos!=0 );
 #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
   yyendofinput = (yymajor==0);
 #endif
@@ -921,7 +906,7 @@ void Parse(
       yymajor = YYNOCODE;
 #endif
     }
-  }while( yymajor!=YYNOCODE && yypParser->yytos>=yypParser->yystack );
+  }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
 #ifndef NDEBUG
   if( yyTraceFILE ){
     yyStackEntry *i;