m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU M4 source repository branch, branch-1.6, updated. v1.5.89a-40-


From: Eric Blake
Subject: [SCM] GNU M4 source repository branch, branch-1.6, updated. v1.5.89a-40-g38a274a
Date: Wed, 23 Jul 2008 13:30:00 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU M4 source repository".

http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=38a274a6e3c1e13e2d9d1c803d64b1a5414ff603

The branch, branch-1.6 has been updated
       via  38a274a6e3c1e13e2d9d1c803d64b1a5414ff603 (commit)
       via  0735b27919f180fcbc03e90681c0c849f40a63c5 (commit)
       via  b114f1366e41ef3d7f8eee84034eb2b87eca5013 (commit)
      from  37a774c7298a6d8e05e5678a78957ac4c4e71e46 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 38a274a6e3c1e13e2d9d1c803d64b1a5414ff603
Author: Eric Blake <address@hidden>
Date:   Tue Jul 22 17:18:10 2008 -0600

    Make symbol table opaque.
    
    * src/m4.h (symtab, hash_table_size): No longer export.
    (symtab_init): Add parameter.
    * src/symtab.c (symtab): Make static, so we can later change
    implementations.
    (hash_table_size): New private size variable.
    (symtab_init): Take size hint, rather than reading a global.
    * src/m4.c (hash_table_size): Delete.
    (main): Track -H as local variable instead.
    * src/freeze.c (dump_symbol_CB): New function, extracted from...
    (produce_frozen_state): ...here, to use hack_all_symbols rather
    than raw traversal.
    
    Signed-off-by: Eric Blake <address@hidden>

commit 0735b27919f180fcbc03e90681c0c849f40a63c5
Author: Eric Blake <address@hidden>
Date:   Tue Jul 22 16:58:26 2008 -0600

    Backport faster hash lookups of pushdef stack collisions.
    
    * src/m4.h (struct symbol): Replace shadowed bit by stack field.
    (SYMBOL_SHADOWED): Delete.
    * src/symtab.c (lookup_symbol): Manage pushdef stacks
    independently from hash buckets, so that collisions with large
    pushdef stacks can be quickly skipped over.
    (symtab_print_list): Adjust caller.
    * src/builtin.c (dump_symbol): Likewise.
    * src/freeze.c (reverse_symbol_list, produce_frozen_state):
    Likewise.
    * doc/m4.texinfo (Using frozen files): Test the change.
    
    Signed-off-by: Eric Blake <address@hidden>

commit b114f1366e41ef3d7f8eee84034eb2b87eca5013
Author: Eric Blake <address@hidden>
Date:   Tue Jul 22 06:49:03 2008 -0600

    Mention patch to make earlier autoconf happy.
    
    * NEWS: Give URL to autoconf patch to avoid undefined popdef.
    
    Signed-off-by: Eric Blake <address@hidden>

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog      |   30 ++++++++++++++
 NEWS           |    4 ++
 doc/m4.texinfo |   16 ++++++++
 src/builtin.c  |    2 +-
 src/freeze.c   |  118 +++++++++++++++++++++++++++++--------------------------
 src/m4.c       |    7 +--
 src/m4.h       |   12 ++----
 src/symtab.c   |   94 ++++++++++++++++++++++++++------------------
 8 files changed, 175 insertions(+), 108 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6b55a4e..ed2acce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2008-07-22  Eric Blake  <address@hidden>
+
+       Make symbol table opaque.
+       * src/m4.h (symtab, hash_table_size): No longer export.
+       (symtab_init): Add parameter.
+       * src/symtab.c (symtab): Make static, so we can later change
+       implementations.
+       (hash_table_size): New private size variable.
+       (symtab_init): Take size hint, rather than reading a global.
+       * src/m4.c (hash_table_size): Delete.
+       (main): Track -H as local variable instead.
+       * src/freeze.c (dump_symbol_CB): New function, extracted from...
+       (produce_frozen_state): ...here, to use hack_all_symbols rather
+       than raw traversal.
+
+       Backport faster hash lookups of pushdef stack collisions.
+       * src/m4.h (struct symbol): Replace shadowed bit by stack field.
+       (SYMBOL_SHADOWED): Delete.
+       * src/symtab.c (lookup_symbol): Manage pushdef stacks
+       independently from hash buckets, so that collisions with large
+       pushdef stacks can be quickly skipped over.
+       (symtab_print_list): Adjust caller.
+       * src/builtin.c (dump_symbol): Likewise.
+       * src/freeze.c (reverse_symbol_list, produce_frozen_state):
+       Likewise.
+       * doc/m4.texinfo (Using frozen files): Test the change.
+
+       Mention patch to make earlier autoconf happy.
+       * NEWS: Give URL to autoconf patch to avoid undefined popdef.
+
 2008-07-18  Eric Blake  <address@hidden>
 
        Add __m4_version__.
diff --git a/NEWS b/NEWS
index 47e0af4..bea5f07 100644
--- a/NEWS
+++ b/NEWS
@@ -67,6 +67,10 @@ Foundation, Inc.
      define(`_undefine', `ifdef(`$1', `builtin(`undefine', `$1')')ifelse(`$#',
                 `1', `', `$0(shift($@))')')
 
+   Additionally, if you want to install Autoconf 2.62 or earlier, then
+   apply this patch:
+     http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=c4a32a009
+
 ** Enhance the `indir' builtin to trace indirect macros, where the trace
    is requested via `traceon' or the command-line option `-t'.  Previously,
    it was impossible to trace macro names such as `foo-bar' which could
diff --git a/doc/m4.texinfo b/doc/m4.texinfo
index 79ea41d..e78061c 100644
--- a/doc/m4.texinfo
+++ b/doc/m4.texinfo
@@ -7084,6 +7084,22 @@ traceon(`undefined')dnl
 
 @c Make sure freezing is successful.
 
address@hidden
+ifdef(`__unix__', ,
+      `errprint(` skipping: syscmd does not have unix semantics
+')m4exit(`77')')dnl
+changequote(`[', `]')dnl
+syscmd([echo 'changequote([,])pushdef([divnum],[hi])dnl' \
+       | ]__program__[ -F in.m4f \
+     && echo 'divnum popdef([divnum])divnum' \
+       | ]__program__[ -R in.m4f \
+     && rm in.m4f])status sysval
address@hidden 0
address@hidden 0
address@hidden example
+
address@hidden Detect inability to freeze.
+
 @comment options: -F /none/such
 @comment status: 1
 @example
diff --git a/src/builtin.c b/src/builtin.c
index 0ea814a..f8a3f3c 100644
--- a/src/builtin.c
+++ b/src/builtin.c
@@ -826,7 +826,7 @@ static void
 dump_symbol (symbol *sym, void *arg)
 {
   struct dump_symbol_data *data = (struct dump_symbol_data *) arg;
-  if (!SYMBOL_SHADOWED (sym) && SYMBOL_TYPE (sym) != TOKEN_VOID)
+  if (SYMBOL_TYPE (sym) != TOKEN_VOID)
     {
       obstack_blank (data->obs, sizeof (symbol *));
       data->base = (symbol **) obstack_base (data->obs);
diff --git a/src/freeze.c b/src/freeze.c
index 5e35c81..3a48b03 100644
--- a/src/freeze.c
+++ b/src/freeze.c
@@ -36,14 +36,73 @@ reverse_symbol_list (symbol *sym)
   result = NULL;
   while (sym)
     {
-      next = SYMBOL_NEXT (sym);
-      SYMBOL_NEXT (sym) = result;
+      next = sym->stack;
+      sym->stack = result;
       result = sym;
       sym = next;
     }
   return result;
 }
 
+/*-------------------------------------------------------------------.
+| Dump a stack of pushdef references to the stream F.  Designed as a |
+| callback for hack_all_symbols.                                     |
+`-------------------------------------------------------------------*/
+
+static void
+dump_symbol_CB (symbol *sym, void *f)
+{
+  FILE *file = (FILE *) f;
+  symbol *stack;
+  const builtin *bp;
+
+  /* Process all entries in each stack from the last to the first.
+     This order ensures that, at reload time, pushdef's will be
+     executed with the oldest definitions first.  */
+  sym = stack = reverse_symbol_list (sym);
+  while (sym)
+    {
+      switch (SYMBOL_TYPE (sym))
+       {
+       case TOKEN_TEXT:
+         xfprintf (file, "T%d,%d\n",
+                   (int) SYMBOL_NAME_LEN (sym),
+                   (int) strlen (SYMBOL_TEXT (sym)));
+         fwrite (SYMBOL_NAME (sym), 1, SYMBOL_NAME_LEN (sym), file);
+         fputs (SYMBOL_TEXT (sym), file);
+         fputc ('\n', file);
+         break;
+
+       case TOKEN_FUNC:
+         bp = find_builtin_by_addr (SYMBOL_FUNC (sym));
+         if (bp == NULL)
+           {
+             assert (!"dump_symbol_CB");
+             abort ();
+           }
+         xfprintf (file, "F%d,%d\n",
+                   (int) SYMBOL_NAME_LEN (sym),
+                   (int) strlen (bp->name));
+         fwrite (SYMBOL_NAME (sym), 1, SYMBOL_NAME_LEN (sym), file);
+         fputs (bp->name, file);
+         fputc ('\n', file);
+         break;
+
+       case TOKEN_VOID:
+         /* Ignore placeholder tokens that exist due to traceon.  */
+         break;
+
+       default:
+         assert (!"dump_symbol_CB");
+         abort ();
+         break;
+       }
+      sym = sym->stack;
+    }
+  /* Reverse the stack once more, putting it back as it was.  */
+  reverse_symbol_list (stack);
+}
+
 /*------------------------------------------------.
 | Produce a frozen state to the given file NAME.  |
 `------------------------------------------------*/
@@ -52,9 +111,6 @@ void
 produce_frozen_state (const char *name)
 {
   FILE *file;
-  int h;
-  symbol *sym;
-  const builtin *bp;
 
   file = fopen (name, O_BINARY ? "wb" : "w");
   if (!file)
@@ -95,57 +151,7 @@ produce_frozen_state (const char *name)
 
   /* Dump all symbols.  */
 
-  for (h = 0; h < hash_table_size; h++)
-    {
-
-      /* Process all entries in one bucket, from the last to the first.
-        This order ensures that, at reload time, pushdef's will be
-        executed with the oldest definitions first.  */
-
-      symtab[h] = reverse_symbol_list (symtab[h]);
-      for (sym = symtab[h]; sym; sym = SYMBOL_NEXT (sym))
-       {
-         switch (SYMBOL_TYPE (sym))
-           {
-           case TOKEN_TEXT:
-             xfprintf (file, "T%d,%d\n",
-                       (int) SYMBOL_NAME_LEN (sym),
-                       (int) strlen (SYMBOL_TEXT (sym)));
-             fwrite (SYMBOL_NAME (sym), 1, SYMBOL_NAME_LEN (sym), file);
-             fputs (SYMBOL_TEXT (sym), file);
-             fputc ('\n', file);
-             break;
-
-           case TOKEN_FUNC:
-             bp = find_builtin_by_addr (SYMBOL_FUNC (sym));
-             if (bp == NULL)
-               {
-                 assert (!"produce_frozen_state");
-                 abort ();
-               }
-             xfprintf (file, "F%d,%d\n",
-                       (int) SYMBOL_NAME_LEN (sym),
-                       (int) strlen (bp->name));
-             fwrite (SYMBOL_NAME (sym), 1, SYMBOL_NAME_LEN (sym), file);
-             fputs (bp->name, file);
-             fputc ('\n', file);
-             break;
-
-           case TOKEN_VOID:
-             /* Ignore placeholder tokens that exist due to traceon.  */
-             break;
-
-           default:
-             assert (!"produce_frozen_state");
-             abort ();
-             break;
-           }
-       }
-
-      /* Reverse the bucket once more, putting it back as it was.  */
-
-      symtab[h] = reverse_symbol_list (symtab[h]);
-    }
+  hack_all_symbols (dump_symbol_CB, file);
 
   /* Let diversions be issued from output.c module, its cleaner to have this
      piece of code there.  */
diff --git a/src/m4.c b/src/m4.c
index c73e275..7f0af7e 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -38,9 +38,6 @@ int sync_output = 0;
 /* Debug (-d[flags]).  */
 int debug_level = 0;
 
-/* Hash table size (should be a prime) (-Hsize).  */
-size_t hash_table_size = HASHMAX;
-
 /* Disable GNU extensions (-G).  */
 int no_gnu_extensions = 0;
 
@@ -412,6 +409,8 @@ main (int argc, char *const *argv, char *const *envp)
   const char *frozen_file_to_read = NULL;
   const char *frozen_file_to_write = NULL;
   const char *macro_sequence = "";
+  /* Hash table size (should be a prime) (-Hsize).  */
+  size_t hash_table_size = HASHMAX;
 
   set_program_name (argv[0]);
   retcode = EXIT_SUCCESS;
@@ -592,7 +591,7 @@ main (int argc, char *const *argv, char *const *envp)
 
   input_init ();
   output_init ();
-  symtab_init ();
+  symtab_init (hash_table_size);
   set_macro_sequence (macro_sequence);
   include_env_init ();
 
diff --git a/src/m4.h b/src/m4.h
index 3afe476..011439e 100644
--- a/src/m4.h
+++ b/src/m4.h
@@ -127,7 +127,6 @@ typedef unsigned int bool_bitfield;
 /* Option flags.  */
 extern int sync_output;                        /* -s */
 extern int debug_level;                        /* -d */
-extern size_t hash_table_size;         /* -H */
 extern int no_gnu_extensions;          /* -G */
 extern int prefix_all_builtins;                /* -P */
 extern size_t max_debug_argument_length;/* -l */
@@ -417,9 +416,9 @@ enum symbol_lookup
 /* Symbol table entry.  */
 struct symbol
 {
-  struct symbol *next;
+  struct symbol *next; /* Next symbol with the same hash.  */
+  struct symbol *stack; /* Stack of shadowed symbols of the same name.  */
   bool_bitfield traced : 1;
-  bool_bitfield shadowed : 1;
   bool_bitfield macro_args : 1;
   bool_bitfield blind_no_args : 1;
   bool_bitfield deleted : 1;
@@ -432,7 +431,6 @@ struct symbol
 
 #define SYMBOL_NEXT(S)         ((S)->next)
 #define SYMBOL_TRACED(S)       ((S)->traced)
-#define SYMBOL_SHADOWED(S)     ((S)->shadowed)
 #define SYMBOL_MACRO_ARGS(S)   ((S)->macro_args)
 #define SYMBOL_BLIND_NO_ARGS(S)        ((S)->blind_no_args)
 #define SYMBOL_DELETED(S)      ((S)->deleted)
@@ -449,10 +447,8 @@ typedef void hack_symbol (symbol *, void *);
 
 #define HASHMAX 509            /* default, overridden by -Hsize */
 
-extern symbol **symtab;
-
-void free_symbol (symbol *sym);
-void symtab_init (void);
+void free_symbol (symbol *);
+void symtab_init (size_t);
 symbol *lookup_symbol (const char *, size_t, symbol_lookup);
 void hack_all_symbols (hack_symbol *, void *);
 
diff --git a/src/symtab.c b/src/symtab.c
index 7e76cfc..7420e50 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -93,18 +93,17 @@ profile_memcmp (const char *s1, const char *s2, size_t l)
 `----------------------------------------------------------------------*/
 
 /* Pointer to symbol table.  */
-symbol **symtab;
+static symbol **symtab;
+
+/* Number of buckets in symbol table.  */
+static size_t hash_table_size;
 
 void
-symtab_init (void)
+symtab_init (size_t size)
 {
-  size_t i;
-  symbol **s;
-
-  s = symtab = (symbol **) xnmalloc (hash_table_size, sizeof (symbol *));
-
-  for (i = 0; i < hash_table_size; i++)
-    s[i] = NULL;
+  hash_table_size = size;
+  symtab = (symbol **) xnmalloc (hash_table_size, sizeof *symtab);
+  memset (symtab, 0, hash_table_size * sizeof *symtab);
 
 #ifdef DEBUG_SYM
   atexit (show_profile); /* Ignore failure, since this is debug code.  */
@@ -215,7 +214,6 @@ lookup_symbol (const char *name, size_t len, symbol_lookup 
mode)
              SYMBOL_TRACED (sym) = SYMBOL_TRACED (old);
              SYMBOL_NAME (sym) = xmemdup0 (name, len);
              SYMBOL_NAME_LEN (sym) = len;
-             SYMBOL_SHADOWED (sym) = false;
              SYMBOL_MACRO_ARGS (sym) = false;
              SYMBOL_BLIND_NO_ARGS (sym) = false;
              SYMBOL_DELETED (sym) = false;
@@ -223,7 +221,9 @@ lookup_symbol (const char *name, size_t len, symbol_lookup 
mode)
 
              SYMBOL_NEXT (sym) = SYMBOL_NEXT (old);
              SYMBOL_NEXT (old) = NULL;
-             (*spp) = sym;
+             sym->stack = old->stack;
+             old->stack = NULL;
+             *spp = sym;
            }
          return sym;
        }
@@ -240,19 +240,21 @@ lookup_symbol (const char *name, size_t len, 
symbol_lookup mode)
       SYMBOL_TRACED (sym) = false;
       SYMBOL_NAME (sym) = xmemdup0 (name, len);
       SYMBOL_NAME_LEN (sym) = len;
-      SYMBOL_SHADOWED (sym) = false;
       SYMBOL_MACRO_ARGS (sym) = false;
       SYMBOL_BLIND_NO_ARGS (sym) = false;
       SYMBOL_DELETED (sym) = false;
       SYMBOL_PENDING_EXPANSIONS (sym) = 0;
 
       SYMBOL_NEXT (sym) = *spp;
-      (*spp) = sym;
+      sym->stack = NULL;
+      *spp = sym;
 
       if (mode == SYMBOL_PUSHDEF && cmp == 0)
        {
-         SYMBOL_SHADOWED (SYMBOL_NEXT (sym)) = true;
-         SYMBOL_TRACED (sym) = SYMBOL_TRACED (SYMBOL_NEXT (sym));
+         sym->stack = sym->next;
+         sym->next = sym->stack->next;
+         sym->stack->next = NULL;
+         SYMBOL_TRACED (sym) = SYMBOL_TRACED (sym->stack);
        }
       return sym;
 
@@ -270,24 +272,30 @@ lookup_symbol (const char *name, size_t len, 
symbol_lookup mode)
        return NULL;
       {
        bool traced = false;
-        symbol *result = sym;
-       if (SYMBOL_NEXT (sym) != NULL
-           && SYMBOL_SHADOWED (SYMBOL_NEXT (sym))
-           && mode == SYMBOL_POPDEF)
+       symbol *result = sym;
+       if (sym->stack && mode == SYMBOL_POPDEF)
          {
-           SYMBOL_SHADOWED (SYMBOL_NEXT (sym)) = false;
-           SYMBOL_TRACED (SYMBOL_NEXT (sym)) = SYMBOL_TRACED (sym);
+           SYMBOL_TRACED (sym->stack) = SYMBOL_TRACED (sym);
+           sym->stack->next = sym->next;
+           *spp = sym->stack;
+           sym->next = NULL;
+           sym->stack = NULL;
+           free_symbol (sym);
          }
        else
-         traced = SYMBOL_TRACED (sym);
-       do
          {
-           *spp = SYMBOL_NEXT (sym);
-           free_symbol (sym);
-           sym = *spp;
+           traced = SYMBOL_TRACED (sym);
+           *spp = sym->next;
+           do
+             {
+               symbol *old = sym;
+               sym = sym->stack;
+               old->next = NULL;
+               old->stack = NULL;
+               free_symbol (old);
+             }
+           while (sym);
          }
-       while (*spp != NULL && SYMBOL_SHADOWED (*spp)
-              && mode == SYMBOL_DELETE);
        if (traced)
          {
            sym = (symbol *) xmalloc (sizeof (symbol));
@@ -295,16 +303,16 @@ lookup_symbol (const char *name, size_t len, 
symbol_lookup mode)
            SYMBOL_TRACED (sym) = true;
            SYMBOL_NAME (sym) = xmemdup0 (name, len);
            SYMBOL_NAME_LEN (sym) = len;
-           SYMBOL_SHADOWED (sym) = false;
            SYMBOL_MACRO_ARGS (sym) = false;
            SYMBOL_BLIND_NO_ARGS (sym) = false;
            SYMBOL_DELETED (sym) = false;
            SYMBOL_PENDING_EXPANSIONS (sym) = 0;
 
            SYMBOL_NEXT (sym) = *spp;
-           (*spp) = sym;
+           sym->stack = NULL;
+           *spp = sym;
          }
-        return result;
+       return result;
       }
 
     default:
@@ -389,19 +397,27 @@ static void
 symtab_print_list (int i)
 {
   symbol *sym;
+  symbol *stack;
   size_t h;
 
   xprintf ("Symbol dump #%d:\n", i);
   for (h = 0; h < hash_table_size; h++)
     for (sym = symtab[h]; sym != NULL; sym = sym->next)
-      xprintf ("\tname %s, len %zu, bucket %lu, addr %p, next %p, "
-              "flags%s%s%s, pending %d\n",
-              SYMBOL_NAME (sym), SYMBOL_NAME_LEN (sym),
-              (unsigned long int) h, sym, SYMBOL_NEXT (sym),
-              SYMBOL_TRACED (sym) ? " traced" : "",
-              SYMBOL_SHADOWED (sym) ? " shadowed" : "",
-              SYMBOL_DELETED (sym) ? " deleted" : "",
-              SYMBOL_PENDING_EXPANSIONS (sym));
+      {
+       stack = sym;
+       do
+         {
+           xprintf ("\tname %s, len %zu, bucket %lu, addr %p, next %p, "
+                    "stack %p, flags%s%s, pending %d\n",
+                    SYMBOL_NAME (stack), SYMBOL_NAME_LEN (stack),
+                    (unsigned long int) h, stack, SYMBOL_NEXT (stack),
+                    stack->stack, SYMBOL_TRACED (stack) ? " traced" : "",
+                    SYMBOL_DELETED (stack) ? " deleted" : "",
+                    SYMBOL_PENDING_EXPANSIONS (stack));
+           stack = stack->stack;
+         }
+       while (stack);
+      }
 }
 
 #endif /* DEBUG_SYM */


hooks/post-receive
--
GNU M4 source repository




reply via email to

[Prev in Thread] Current Thread [Next in Thread]