[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bison-1_29-branch] Optimizations.
From: |
Pascal Bart |
Subject: |
[Bison-1_29-branch] Optimizations. |
Date: |
Thu, 27 Sep 2001 00:19:48 +0000 (GMT) |
Hello,
This patch is ugly, because it's a mixing of various optimizations,
so I'm sorry about it. I'm waiting your comments about it, I leave Paris
tomorrow, so I won't be able to apply it before Monday.
Sincerely.
Pascal Bart (address@hidden)
Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.173.2.55
diff -u -r1.173.2.55 ChangeLog
--- ChangeLog 2001/09/25 18:35:04 1.173.2.55
+++ ChangeLog 2001/09/26 22:09:18
@@ -1,3 +1,18 @@
+2001-09-27 Pascal Bart <address@hidden>
+
+ * src/nullable.c (set_nullable): Change variables declarations.
+ * src/files.c: Staticfy src_extension and header_extension.
+ * src/conflicts.c: Move globals variables src_total, rrc_total...
+ (print_conflicts): here.
+ * src/lex.c (token_obstack): Become static.
+ * src/symtab.c (hash): Inline function.
+ * src/reader.c: Initialize globals variables.
+ (reader): Delete globals pointers initialization.
+ * src/output.c (action_row): Change variables declarations.
+ Move gloval variable lowzero...
+ (pack_vector): here.
+ (output): Free global variable user_toknums.
+
2001-09-25 Akim Demaille <address@hidden>
* src/system.h: Include `xalloc.h'.
Index: src/conflicts.c
===================================================================
RCS file: /cvsroot/bison/bison/src/conflicts.c,v
retrieving revision 1.22.2.3
diff -u -r1.22.2.3 conflicts.c
--- src/conflicts.c 2001/09/25 18:35:04 1.22.2.3
+++ src/conflicts.c 2001/09/26 22:09:19
@@ -35,8 +35,7 @@
static unsigned *shiftset = NULL;
static unsigned *lookaheadset = NULL;
-static int src_total;
-static int rrc_total;
+
static int src_count;
static int rrc_count;
@@ -460,9 +459,8 @@
print_conflicts (FILE *out)
{
int i;
-
- src_total = 0;
- rrc_total = 0;
+ int src_total = 0;
+ int rrc_total = 0;
/* Count the total number of conflicts, and if wanted, give a
detailed report in FOUTPUT. */
Index: src/files.c
===================================================================
RCS file: /cvsroot/bison/bison/src/files.c,v
retrieving revision 1.51.2.8
diff -u -r1.51.2.8 files.c
--- src/files.c 2001/09/25 18:35:04 1.51.2.8
+++ src/files.c 2001/09/26 22:09:19
@@ -48,9 +48,9 @@
static char *short_base_name = NULL;
/* C source file extension (the parser source). */
-const char *src_extension = NULL;
+static const char *src_extension = NULL;
/* Header file extension (if option ``-d'' is specified). */
-const char *header_extension = NULL;
+static const char *header_extension = NULL;
/*--------------------------.
Index: src/lex.c
===================================================================
RCS file: /cvsroot/bison/bison/src/lex.c,v
retrieving revision 1.33.2.5
diff -u -r1.33.2.5 lex.c
--- src/lex.c 2001/09/25 18:35:04 1.33.2.5
+++ src/lex.c 2001/09/26 22:09:19
@@ -29,7 +29,7 @@
#include "quote.h"
/* Buffer for storing the current token. */
-struct obstack token_obstack;
+static struct obstack token_obstack;
const char *token_buffer = NULL;
bucket *symval;
Index: src/nullable.c
===================================================================
RCS file: /cvsroot/bison/bison/src/nullable.c,v
retrieving revision 1.10.2.1
diff -u -r1.10.2.1 nullable.c
--- src/nullable.c 2001/09/25 18:35:04 1.10.2.1
+++ src/nullable.c 2001/09/26 22:09:19
@@ -45,7 +45,6 @@
shorts **rsets;
shorts *relts;
char any_tokens;
- short *r1;
#ifdef TRACE
fprintf (stderr, _("Entering set_nullable"));
@@ -78,7 +77,7 @@
}
else
{
- r1 = r;
+ short *r1 = r;
any_tokens = 0;
for (symbol = *r++; symbol > 0; symbol = *r++)
{
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.39.2.4
diff -u -r1.39.2.4 output.c
--- src/output.c 2001/09/25 18:35:04 1.39.2.4
+++ src/output.c 2001/09/26 22:09:20
@@ -106,7 +106,6 @@
extern void berror PARAMS((const char *));
-
static int nvectors;
static int nentries;
static short **froms = NULL;
@@ -120,11 +119,9 @@
static short *pos = NULL;
static short *table = NULL;
static short *check = NULL;
-static int lowzero;
static int high;
-
static inline void
output_short_or_char_table (struct obstack *oout,
const char *comment,
@@ -500,24 +497,15 @@
static int
action_row (int state)
{
- int i;
- int j;
- int k;
+ int i, j, k;
int m = 0;
int n = 0;
- int count;
int default_rule;
int nreds;
- int max;
int rule;
- int shift_state;
int symbol;
- unsigned mask;
- unsigned *wordp;
reductions *redp;
- shifts *shiftp;
- errs *errp;
- int nodefault = 0; /* set nonzero to inhibit having any default
reduction */
+ int nodefault = 0; /* set nonzero to inhibit having any default reduction */
for (i = 0; i < ntokens; i++)
actrow[i] = 0;
@@ -529,7 +517,7 @@
if (redp)
{
nreds = redp->nreds;
-
+
if (nreds >= 1)
{
/* loop over all the rules available here which require
@@ -539,12 +527,12 @@
for (i = n - 1; i >= m; i--)
{
- rule = -LAruleno[i];
- wordp = LA + i * tokensetsize;
- mask = 1;
+ unsigned mask = 1;
+ unsigned *wordp = LA + i * tokensetsize;
+ rule = -LAruleno[i];
/* and find each token which the rule finds acceptable
- to come next */
+ to come next */
for (j = 0; j < ntokens; j++)
{
/* and record this rule as the rule to use if that
@@ -562,53 +550,54 @@
}
}
}
-
- shiftp = shift_table[state];
-
- /* Now see which tokens are allowed for shifts in this state. For
- them, record the shift as the thing to do. So shift is preferred
- to reduce. */
-
- if (shiftp)
- {
- k = shiftp->nshifts;
+ {
+ shifts *shiftp = shift_table[state];
- for (i = 0; i < k; i++)
- {
- shift_state = shiftp->shifts[i];
- if (!shift_state)
- continue;
+ /* Now see which tokens are allowed for shifts in this state. For
+ them, record the shift as the thing to do. So shift is preferred
+ to reduce. */
- symbol = accessing_symbol[shift_state];
+ if (shiftp)
+ {
+ k = shiftp->nshifts;
- if (ISVAR (symbol))
- break;
+ for (i = 0; i < k; i++)
+ {
+ int shift_state = shiftp->shifts[i];
+ if (!shift_state)
+ continue;
- actrow[symbol] = shift_state;
+ symbol = accessing_symbol[shift_state];
- /* Do not use any default reduction if there is a shift for
- error */
- if (symbol == error_token_number)
- nodefault = 1;
- }
- }
+ if (ISVAR (symbol))
+ break;
- errp = err_table[state];
+ actrow[symbol] = shift_state;
- /* See which tokens are an explicit error in this state (due to
- %nonassoc). For them, record MINSHORT as the action. */
+ /* Do not use any default reduction if there is a shift for
+ error */
+ if (symbol == error_token_number)
+ nodefault = 1;
+ }
+ }
+ }
+ {
+ errs *errp = err_table[state];
- if (errp)
- {
- k = errp->nerrs;
+ /* See which tokens are an explicit error in this state (due to
+ %nonassoc). For them, record MINSHORT as the action. */
- for (i = 0; i < k; i++)
- {
- symbol = errp->errs[i];
- actrow[symbol] = MINSHORT;
- }
- }
+ if (errp)
+ {
+ k = errp->nerrs;
+ for (i = 0; i < k; i++)
+ {
+ symbol = errp->errs[i];
+ actrow[symbol] = MINSHORT;
+ }
+ }
+ }
/* Now find the most common reduction and make it the default action
for this state. */
@@ -618,10 +607,10 @@
default_rule = redp->rules[0];
else
{
- max = 0;
+ int max = 0;
for (i = m; i < n; i++)
{
- count = 0;
+ int count = 0;
rule = -LAruleno[i];
for (j = 0; j < ntokens; j++)
@@ -966,6 +955,7 @@
int ok;
short *from;
short *to;
+ int lowzero = 0;
i = order[vector];
t = tally[i];
@@ -1031,7 +1021,6 @@
table = XCALLOC (short, MAXTABLE);
check = XCALLOC (short, MAXTABLE);
- lowzero = 0;
high = 0;
for (i = 0; i < nvectors; i++)
@@ -1343,6 +1332,7 @@
if (semantic_parser)
output_stos ();
output_rule_data ();
+ XFREE (user_toknums);
output_actions ();
if (!no_parser_flag)
output_parser ();
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.72.2.9
diff -u -r1.72.2.9 reader.c
--- src/reader.c 2001/09/25 18:35:04 1.72.2.9
+++ src/reader.c 2001/09/26 22:09:20
@@ -48,19 +48,19 @@
int lineno;
char **tags;
short *user_toknums;
-static symbol_list *grammar;
-static int start_flag;
-static bucket *startval;
+static symbol_list *grammar = NULL;
+static int start_flag = 0;
+static bucket *startval = NULL;
/* Nonzero if components of semantic values are used, implying
they must be unions. */
-static int value_components_used;
+static int value_components_used = 0;
/* Nonzero if %union has been seen. */
-static int typed;
+static int typed = 0;
/* Incremented for each %left, %right or %nonassoc seen */
-static int lastprec;
+static int lastprec = 0;
static bucket *errtoken;
static bucket *undeftoken;
@@ -1893,9 +1893,6 @@
void
reader (void)
{
- start_flag = 0;
- startval = NULL; /* start symbol not specified yet. */
-
nsyms = 1;
nvars = 0;
nrules = 0;
@@ -1903,13 +1900,8 @@
rline_allocated = 10;
rline = XCALLOC (short, rline_allocated);
- typed = 0;
- lastprec = 0;
-
semantic_parser = 0;
pure_parser = 0;
-
- grammar = NULL;
lex_init ();
lineno = 1;
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.13.2.2
diff -u -r1.13.2.2 symtab.c
--- src/symtab.c 2001/09/25 18:35:04 1.13.2.2
+++ src/symtab.c 2001/09/26 22:09:20
@@ -28,7 +28,7 @@
static bucket *lastsymbol;
static bucket **symtab;
-static int
+static inline int
hash (const char *key)
{
const char *cp;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bison-1_29-branch] Optimizations.,
Pascal Bart <=