1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Improvements to the initialization of the push-down automoton for the

Lemon-generated parser.  Smaller and faster.

FossilOrigin-Name: 3b28b68e232060f8b2fe2fe6fa478280da2006ff
This commit is contained in:
drh
2016-05-24 00:40:54 +00:00
parent 118ab65859
commit abecc0b883
3 changed files with 20 additions and 35 deletions

View File

@ -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. C Improvements\sto\sthe\sinitialization\sof\sthe\spush-down\sautomoton\sfor\sthe\nLemon-generated\sparser.\s\sSmaller\sand\sfaster.
D 2016-05-23T21:56:24.427 D 2016-05-24T00:40:54.799
F Makefile.in f59e0763ff448719fc1bd25513882b0567286317 F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7 F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
@ -1422,7 +1422,7 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39 F tool/lemon.c b4da2f0181b4defe538eb437eb96c721cf342d39
F tool/lempar.c 872383ebf36c13fdaff0f3692d4ff60e64ec49e2 F tool/lempar.c 8569dd3e4c22831e08e441ab7a0eb6bbefa1d38a
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862 F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7 F tool/mkautoconfamal.sh e855df211ecbcc7131dee817110ff386cfb112f7
@ -1493,7 +1493,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 276e92f5b4c1ee49eabb738b24d73d7af90fb13c P 3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68
R f3a217ca3fc6adf56f5cf5443069e03b R f0cfba4e984837df73820e425fc5291f
U drh U drh
Z babb89b922e84c6e93d4048989d7622c Z 2da99ff99cbfd3def15eb678236b100e

View File

@ -1 +1 @@
3c2a770549d5bb65fcd6cc684e0a0ae6d641ac68 3b28b68e232060f8b2fe2fe6fa478280da2006ff

View File

@ -275,12 +275,15 @@ static const char *const yyRuleName[] = {
*/ */
static void yyGrowStack(yyParser *p){ static void yyGrowStack(yyParser *p){
int newSize; int newSize;
int idx;
yyStackEntry *pNew; yyStackEntry *pNew;
newSize = p->yystksz*2 + 100; newSize = p->yystksz*2 + 100;
idx = p->yytos ? (int)(p->yytos - p->yystack) : 0;
pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); pNew = realloc(p->yystack, newSize*sizeof(pNew[0]));
if( pNew ){ if( pNew ){
p->yystack = pNew; p->yystack = pNew;
p->yytos = &p->yystack[idx];
p->yystksz = newSize; p->yystksz = newSize;
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
@ -317,15 +320,18 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
yyParser *pParser; yyParser *pParser;
pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) );
if( pParser ){ if( pParser ){
pParser->yytos = 0;
#ifdef YYTRACKMAXSTACKDEPTH #ifdef YYTRACKMAXSTACKDEPTH
pParser->yyhwm = 0; pParser->yyhwm = 0;
#endif #endif
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
pParser->yytos = NULL;
pParser->yystack = NULL; pParser->yystack = NULL;
pParser->yystksz = 0; pParser->yystksz = 0;
yyGrowStack(pParser); yyGrowStack(pParser);
#endif #endif
pParser->yytos = pParser->yystack;
pParser->yystack[0].stateno = 0;
pParser->yystack[0].major = 0;
} }
return pParser; return pParser;
} }
@ -397,7 +403,7 @@ void ParseFree(
#ifndef YYPARSEFREENEVERNULL #ifndef YYPARSEFREENEVERNULL
if( pParser==0 ) return; if( pParser==0 ) return;
#endif #endif
while( pParser->yytos>=pParser->yystack ) yy_pop_parser_stack(pParser); while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser);
#if YYSTACKDEPTH<=0 #if YYSTACKDEPTH<=0
free(pParser->yystack); free(pParser->yystack);
#endif #endif
@ -522,7 +528,7 @@ static void yyStackOverflow(yyParser *yypParser){
fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt);
} }
#endif #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 /* Here code is inserted which will execute if the parser
** stack every overflows */ ** stack every overflows */
/******** Begin %stack_overflow code ******************************************/ /******** Begin %stack_overflow code ******************************************/
@ -695,8 +701,7 @@ static void yy_parse_failed(
fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt);
} }
#endif #endif
while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
yypParser->yytos = 0;
/* Here code is inserted which will be executed whenever the /* Here code is inserted which will be executed whenever the
** parser fails */ ** parser fails */
/************ Begin %parse_failure code ***************************************/ /************ Begin %parse_failure code ***************************************/
@ -734,8 +739,7 @@ static void yy_accept(
fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt);
} }
#endif #endif
while( yypParser->yytos>=yypParser->yystack ) yy_pop_parser_stack(yypParser); while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser);
yypParser->yytos = 0;
/* Here code is inserted which will be executed whenever the /* Here code is inserted which will be executed whenever the
** parser accepts */ ** parser accepts */
/*********** Begin %parse_accept code *****************************************/ /*********** Begin %parse_accept code *****************************************/
@ -781,26 +785,7 @@ void Parse(
/* (re)initialize the parser, if necessary */ /* (re)initialize the parser, if necessary */
yypParser = (yyParser*)yyp; yypParser = (yyParser*)yyp;
if( yypParser->yytos==0 ){ assert( 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
}
#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
yyendofinput = (yymajor==0); yyendofinput = (yymajor==0);
#endif #endif
@ -921,7 +906,7 @@ void Parse(
yymajor = YYNOCODE; yymajor = YYNOCODE;
#endif #endif
} }
}while( yymajor!=YYNOCODE && yypParser->yytos>=yypParser->yystack ); }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack );
#ifndef NDEBUG #ifndef NDEBUG
if( yyTraceFILE ){ if( yyTraceFILE ){
yyStackEntry *i; yyStackEntry *i;