grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.14-14-gb06f7a2


From: Paolo Bonzini
Subject: grep branch, master, updated. v2.14-14-gb06f7a2
Date: Sat, 10 Nov 2012 01:19:49 +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 "grep".

The branch, master has been updated
       via  b06f7a29a58bbdd5866afc1e92dba3fdc9e2ed59 (commit)
      from  cbf738c8d0b148b7d5e43ebb19dd683891cbefac (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 -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=b06f7a29a58bbdd5866afc1e92dba3fdc9e2ed59


commit b06f7a29a58bbdd5866afc1e92dba3fdc9e2ed59
Author: Paolo Bonzini <address@hidden>
Date:   Sat Nov 10 02:15:51 2012 +0100

    pcre: add PCRE-JIT support for grep
    
    * NEWS: Document new feature.
    * src/pcresearch.c [PCRE_STUDY_JIT_COMPILE] (jit_stack): New.
    [PCRE_STUDY_JIT_COMPILE] (Pcompile): JIT-compile the regular expression
    and allocate a stack for it.  Based on a patch from Zoltan Herczeg.
    * THANKS: Add Zoltan to the list.

diff --git a/NEWS b/NEWS
index 052cd81..e43e06a 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,13 @@ GNU grep NEWS                                    -*- outline 
-*-
   to match multibyte characters against some regular expressions, especially
   those including the '.' or '\p' metacharacters.
 
+** New features
+
+  grep -P can now use a just-in-time compiler to greatly speed up matches,
+  This feature is transparent to the user; no flag is required to enable
+  it.  It is only available if the corresponding support in the PCRE
+  library is detected when grep is compiled.
+
 
 * Noteworthy changes in release 2.14 (2012-08-20) [stable]
 
diff --git a/THANKS b/THANKS
index 1720232..fd6aeef 100644
--- a/THANKS
+++ b/THANKS
@@ -99,3 +99,4 @@ Volker Borchert            <address@hidden>
 Wichert Akkerman           <address@hidden>
 William Bader              <address@hidden>
 Wolfgang Schludi           <address@hidden>
+Zoltan Herczeg             <address@hidden>
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 2e95f2d..89bfbec 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -35,6 +35,12 @@ static pcre *cre;
 
 /* Additional information about the pattern.  */
 static pcre_extra *extra;
+
+#ifdef PCRE_STUDY_JIT_COMPILE
+static pcre_jit_stack *jit_stack;
+#else
+#define PCRE_STUDY_JIT_COMPILE 0
+#endif
 #endif
 
 void
@@ -101,12 +107,27 @@ Pcompile (char const *pattern, size_t size)
   if (!cre)
     error (EXIT_TROUBLE, 0, "%s", ep);
 
-  extra = pcre_study (cre, 0, &ep);
+  extra = pcre_study (cre, PCRE_STUDY_JIT_COMPILE, &ep);
   if (ep)
     error (EXIT_TROUBLE, 0, "%s", ep);
 
+#if PCRE_STUDY_JIT_COMPILE
+  if (pcre_fullinfo(cre, extra, PCRE_INFO_JIT, &e))
+    error (EXIT_TROUBLE, 0, "Internal error (should never happen).");
+
+  if (e)
+    {
+      /* A 32K stack is allocated for the machine code by default, which
+         can grow to 512K if necessary. Since JIT uses far less memory
+         than the interpreter, this should be enough in practice. */
+      jit_stack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
+      if (!jit_stack)
+        error (EXIT_TROUBLE, 0, "Cannot allocate memory for the JIT stack.");
+      pcre_assign_jit_stack(extra, NULL, jit_stack);
+    }
   free (re);
 #endif
+#endif
 }
 
 size_t

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

Summary of changes:
 NEWS             |    7 +++++++
 THANKS           |    1 +
 src/pcresearch.c |   23 ++++++++++++++++++++++-
 3 files changed, 30 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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