Make the generated parse tables const, so that the data are pushed
to text segment. The difference is quite significant - for example, the tables are about 20K for gawk, 40K for nawk, couple of KB for /bin/sh.
This commit is contained in:
parent
e82124d4fa
commit
0e4f8029c1
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: output.c,v 1.8 2000/10/11 14:46:24 is Exp $ */
|
||||
/* $NetBSD: output.c,v 1.9 2001/01/23 22:31:40 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: output.c,v 1.8 2000/10/11 14:46:24 is Exp $");
|
||||
__RCSID("$NetBSD: output.c,v 1.9 2001/01/23 22:31:40 jdolecek Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -186,7 +186,7 @@ output_rule_data()
|
|||
int j;
|
||||
|
||||
|
||||
fprintf(output_file, "short %slhs[] = {%42d,", symbol_prefix,
|
||||
fprintf(output_file, "const short %slhs[] = {%42d,", symbol_prefix,
|
||||
symbol_value[start_symbol]);
|
||||
|
||||
j = 10;
|
||||
|
@ -206,7 +206,7 @@ output_rule_data()
|
|||
if (!rflag) outline += 2;
|
||||
fprintf(output_file, "\n};\n");
|
||||
|
||||
fprintf(output_file, "short %slen[] = {%42d,", symbol_prefix, 2);
|
||||
fprintf(output_file, "const short %slen[] = {%42d,", symbol_prefix, 2);
|
||||
|
||||
j = 10;
|
||||
for (i = 3; i < nrules; i++)
|
||||
|
@ -231,7 +231,7 @@ output_yydefred()
|
|||
{
|
||||
int i, j;
|
||||
|
||||
fprintf(output_file, "short %sdefred[] = {%39d,", symbol_prefix,
|
||||
fprintf(output_file, "const short %sdefred[] = {%39d,", symbol_prefix,
|
||||
(defred[0] ? defred[0] - 2 : 0));
|
||||
|
||||
j = 10;
|
||||
|
@ -374,7 +374,7 @@ goto_actions()
|
|||
state_count = NEW2(nstates, short);
|
||||
|
||||
k = default_goto(start_symbol + 1);
|
||||
fprintf(output_file, "short %sdgoto[] = {%40d,", symbol_prefix, k);
|
||||
fprintf(output_file, "const short %sdgoto[] = {%40d,", symbol_prefix, k);
|
||||
save_column(start_symbol + 1, k);
|
||||
|
||||
j = 10;
|
||||
|
@ -700,7 +700,8 @@ output_base()
|
|||
{
|
||||
int i, j;
|
||||
|
||||
fprintf(output_file, "short %ssindex[] = {%39d,", symbol_prefix, base[0]);
|
||||
fprintf(output_file, "const short %ssindex[] = {%39d,", symbol_prefix,
|
||||
base[0]);
|
||||
|
||||
j = 10;
|
||||
for (i = 1; i < nstates; i++)
|
||||
|
@ -718,7 +719,7 @@ output_base()
|
|||
}
|
||||
|
||||
if (!rflag) outline += 2;
|
||||
fprintf(output_file, "\n};\nshort %srindex[] = {%39d,", symbol_prefix,
|
||||
fprintf(output_file, "\n};\nconst short %srindex[] = {%39d,", symbol_prefix,
|
||||
base[nstates]);
|
||||
|
||||
j = 10;
|
||||
|
@ -737,7 +738,7 @@ output_base()
|
|||
}
|
||||
|
||||
if (!rflag) outline += 2;
|
||||
fprintf(output_file, "\n};\nshort %sgindex[] = {%39d,", symbol_prefix,
|
||||
fprintf(output_file, "\n};\nconst short %sgindex[] = {%39d,", symbol_prefix,
|
||||
base[2*nstates]);
|
||||
|
||||
j = 10;
|
||||
|
@ -769,7 +770,7 @@ output_table()
|
|||
|
||||
++outline;
|
||||
fprintf(code_file, "#define YYTABLESIZE %d\n", high);
|
||||
fprintf(output_file, "short %stable[] = {%40d,", symbol_prefix,
|
||||
fprintf(output_file, "const short %stable[] = {%40d,", symbol_prefix,
|
||||
table[0]);
|
||||
|
||||
j = 10;
|
||||
|
@ -799,7 +800,7 @@ output_check()
|
|||
int i;
|
||||
int j;
|
||||
|
||||
fprintf(output_file, "short %scheck[] = {%40d,", symbol_prefix,
|
||||
fprintf(output_file, "const short %scheck[] = {%40d,", symbol_prefix,
|
||||
check[0]);
|
||||
|
||||
j = 10;
|
||||
|
@ -971,7 +972,8 @@ output_debug()
|
|||
symnam[0] = "end-of-file";
|
||||
|
||||
if (!rflag) ++outline;
|
||||
fprintf(output_file, "#if YYDEBUG\nconst char *%sname[] = {", symbol_prefix);
|
||||
fprintf(output_file, "#if YYDEBUG\nconst char * const %sname[] = {",
|
||||
symbol_prefix);
|
||||
j = 80;
|
||||
for (i = 0; i <= max; ++i)
|
||||
{
|
||||
|
@ -1097,7 +1099,7 @@ output_debug()
|
|||
FREE(symnam);
|
||||
|
||||
if (!rflag) ++outline;
|
||||
fprintf(output_file, "const char *%srule[] = {\n", symbol_prefix);
|
||||
fprintf(output_file, "const char * const %srule[] = {\n", symbol_prefix);
|
||||
for (i = 2; i < nrules; ++i)
|
||||
{
|
||||
fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: skeleton.c,v 1.19 2001/01/23 15:35:01 jdolecek Exp $ */
|
||||
/* $NetBSD: skeleton.c,v 1.20 2001/01/23 22:31:40 jdolecek Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)skeleton.c 5.8 (Berkeley) 4/29/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: skeleton.c,v 1.19 2001/01/23 15:35:01 jdolecek Exp $");
|
||||
__RCSID("$NetBSD: skeleton.c,v 1.20 2001/01/23 22:31:40 jdolecek Exp $");
|
||||
#endif /* 0 */
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -67,7 +67,7 @@ const char * const banner[] =
|
|||
"static char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";",
|
||||
"#else",
|
||||
"#if defined(__NetBSD__) && defined(__IDSTRING)",
|
||||
"__IDSTRING(yyrcsid, \"$NetBSD: skeleton.c,v 1.19 2001/01/23 15:35:01 jdolecek Exp $\");",
|
||||
"__IDSTRING(yyrcsid, \"$NetBSD: skeleton.c,v 1.20 2001/01/23 22:31:40 jdolecek Exp $\");",
|
||||
"#endif /* __NetBSD__ && __IDSTRING */",
|
||||
"#endif /* 0 */",
|
||||
"#endif /* lint */",
|
||||
|
@ -86,18 +86,18 @@ const char * const banner[] =
|
|||
|
||||
const char * const tables[] =
|
||||
{
|
||||
"extern short yylhs[];",
|
||||
"extern short yylen[];",
|
||||
"extern short yydefred[];",
|
||||
"extern short yydgoto[];",
|
||||
"extern short yysindex[];",
|
||||
"extern short yyrindex[];",
|
||||
"extern short yygindex[];",
|
||||
"extern short yytable[];",
|
||||
"extern short yycheck[];",
|
||||
"extern const short yylhs[];",
|
||||
"extern const short yylen[];",
|
||||
"extern const short yydefred[];",
|
||||
"extern const short yydgoto[];",
|
||||
"extern const short yysindex[];",
|
||||
"extern const short yyrindex[];",
|
||||
"extern const short yygindex[];",
|
||||
"extern const short yytable[];",
|
||||
"extern const short yycheck[];",
|
||||
"#if YYDEBUG",
|
||||
"extern const char *yyname[];",
|
||||
"extern const char *yyrule[];",
|
||||
"extern const char * const yyname[];",
|
||||
"extern const char * const yyrule[];",
|
||||
"#endif",
|
||||
0
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue