[Pcre-svn] [923] code/trunk: Make it possible for pcretest t…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [923] code/trunk: Make it possible for pcretest to select which JIT compile options are used .
Revision: 923
          http://vcs.pcre.org/viewvc?view=rev&revision=923
Author:   ph10
Date:     2012-02-21 13:25:05 +0000 (Tue, 21 Feb 2012)


Log Message:
-----------
Make it possible for pcretest to select which JIT compile options are used.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/doc/pcretest.1
    code/trunk/pcretest.c
    code/trunk/testdata/testinput12
    code/trunk/testdata/testoutput12


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2012-02-20 18:44:42 UTC (rev 922)
+++ code/trunk/ChangeLog    2012-02-21 13:25:05 UTC (rev 923)
@@ -38,6 +38,9 @@
     caller. This bit is checked by pcretest if JIT is requested by /S++ or -s++ 
     (instead of just /S+ or -s+) and the text "(JIT)" added to the output if 
     the bit is set.   
+    
+7.  Individual JIT compile options can be set in pcretest by following -s+[+] 
+    or /S+[+] with a digit between 1 and 7.



Version 8.30 04-February-2012

Modified: code/trunk/doc/pcretest.1
===================================================================
--- code/trunk/doc/pcretest.1    2012-02-20 18:44:42 UTC (rev 922)
+++ code/trunk/doc/pcretest.1    2012-02-21 13:25:05 UTC (rev 923)
@@ -131,9 +131,20 @@
 Behave as if each pattern has the \fB/S\fP modifier; in other words, force each
 pattern to be studied. If \fB-s+\fP is used, all the JIT compile options are
 passed to \fBpcre[16]_study()\fP, causing just-in-time optimization to be set
-up if it is available, for both full and partial matching. If \fB-s++\fP is 
-used, the text "(JIT)" is added to the first output line after a match or no 
-match when JIT-compiled code was actually used.
+up if it is available, for both full and partial matching. Specific JIT compile 
+options can be selected by following \fB-s+\fP with a digit in the range 1 to 
+7, which selects the JIT compile modes as follows:
+.sp
+  1  normal match only
+  2  soft partial match only
+  3  normal match and soft partial match
+  4  hard partial match only
+  6  soft and hard partial match
+  7  all three modes (default)
+.sp        
+If \fB-s++\fP is used instead of \fB-s+\fP (with or without a following digit),
+the text "(JIT)" is added to the first output line after a match or no match
+when JIT-compiled code was actually used.
 .P
 If the \fB/I\fP or \fB/D\fP option is present on a pattern (requesting output
 about the compiled pattern), information about the result of studying is not
@@ -389,13 +400,28 @@
 files in a few cases where the output is different when the pattern is studied.
 .P
 If the \fB/S\fP modifier is immediately followed by a + character, the call to
-\fBpcre[16]_study()\fP is made with the PCRE_STUDY_JIT_COMPILE option,
-requesting just-in-time optimization support if it is available. Note that
-there is also a \fB/+\fP modifier; it must not be given immediately after
-\fB/S\fP because this will be misinterpreted. If JIT studying is successful, it
-will automatically be used when \fBpcre[16]_exec()\fP is run, except when
-incompatible run-time options are specified. These include the partial matching
-options; a complete list is given in the
+\fBpcre[16]_study()\fP is made with all the JIT study options, requesting
+just-in-time optimization support if it is available, for both normal and
+partial matching. If you want to restrict the JIT compiling modes, you can 
+follow \fB/S+\fP with a digit in the range 1 to 7:
+.sp
+  1  normal match only
+  2  soft partial match only
+  3  normal match and soft partial match
+  4  hard partial match only
+  6  soft and hard partial match
+  7  all three modes (default)
+.sp        
+If \fB/S++\fP is used instead of \fB/S+\fP (with or without a following digit),
+the text "(JIT)" is added to the first output line after a match or no match
+when JIT-compiled code was actually used.
+.P
+Note that there is also an independent \fB/+\fP modifier; it must not be given
+immediately after \fB/S\fP or \fB/S+\fP because this will be misinterpreted. 
+.P
+If JIT studying is successful, the compiled JIT code will automatically be used
+when \fBpcre[16]_exec()\fP is run, except when incompatible run-time options
+are specified. For more details, see the
 .\" HREF
 \fBpcrejit\fP
 .\"
@@ -940,6 +966,6 @@
 .rs
 .sp
 .nf
-Last updated: 20 February 2012
+Last updated: 21 February 2012
 Copyright (c) 1997-2012 University of Cambridge.
 .fi


Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2012-02-20 18:44:42 UTC (rev 922)
+++ code/trunk/pcretest.c    2012-02-21 13:25:05 UTC (rev 923)
@@ -674,6 +674,20 @@
 static int use_pcre16 = 1;
 #endif


+/* JIT study options for -s+n and /S+n where '1' <= n <= '7'. */
+
+static int jit_study_bits[] =
+  { 
+  PCRE_STUDY_JIT_COMPILE, 
+  PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,
+  PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE,
+  PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE, 
+  PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE, 
+  PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE + PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE, 
+  PCRE_STUDY_JIT_COMPILE + PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE + 
+    PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE 
+};   
+
 /* Textual explanations for runtime error codes */


 static const char *errtexts[] = {
@@ -2133,6 +2147,9 @@
 printf("  -s       force each pattern to be studied at basic level\n"
        "  -s+      force each pattern to be studied, using JIT if available\n"
        "  -s++     ditto, verifying when JIT was actually used\n" 
+       "  -s+n     force each pattern to be studied, using JIT if available,\n"
+       "             where 1 <= n <= 7 selects JIT options\n"  
+       "  -s++n    ditto, verifying when JIT was actually used\n" 
        "  -t       time compilation and execution\n");
 printf("  -t <n>   time compilation and execution, repeating <n> times\n");
 printf("  -tm      time execution (matching) only\n");
@@ -2244,13 +2261,12 @@
     {
     arg += 3;
     if (*arg == '+') { arg++; verify_jit = TRUE; }
-
-    if (*arg != 0) goto BAD_ARG;
- 
     force_study = 1;
-    force_study_options = PCRE_STUDY_JIT_COMPILE
-                        | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE
-                        | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;
+    if (*arg == 0)
+      force_study_options = jit_study_bits[6]; 
+    else if (*arg >= '1' && *arg <= '7')
+      force_study_options = jit_study_bits[*arg - '1']; 
+    else goto BAD_ARG;
     }
   else if (strcmp(arg, "-16") == 0)
     {
@@ -2785,9 +2801,10 @@
             verify_jit = TRUE;
             pp++;  
             }  
-          study_options |= PCRE_STUDY_JIT_COMPILE
-                        | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE
-                        | PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE;
+          if (*pp >= '1' && *pp <= '7')
+            study_options |= jit_study_bits[*pp++ - '1'];
+          else 
+            study_options |= jit_study_bits[6];     
           }
         }
       else
@@ -4208,6 +4225,7 @@
           PCHARSV(bptr, use_offsets[0], use_offsets[1] - use_offsets[0],
             outfile);
           }
+        if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");  
         fprintf(outfile, "\n");
         break;  /* Out of the /g loop */
         }


Modified: code/trunk/testdata/testinput12
===================================================================
--- code/trunk/testdata/testinput12    2012-02-20 18:44:42 UTC (rev 922)
+++ code/trunk/testdata/testinput12    2012-02-21 13:25:05 UTC (rev 923)
@@ -16,8 +16,65 @@
 /(?(R)a*(?1)|((?R))b)/S+
     aaaabcde


+/-- Test various compile modes --/ 
+    
 /abcd/S++
     abcd
     xyz  


+/abcd/S+
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++1
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+    xyz\P
+
+/abcd/S++2
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++3
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++4
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++5
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++6
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
+/abcd/S++7
+    abcd
+    ab\P
+    ab\P\P
+    xyz
+
 /-- End of testinput12 --/


Modified: code/trunk/testdata/testoutput12
===================================================================
--- code/trunk/testdata/testoutput12    2012-02-20 18:44:42 UTC (rev 922)
+++ code/trunk/testdata/testoutput12    2012-02-21 13:25:05 UTC (rev 923)
@@ -48,10 +48,104 @@
     aaaabcde
 Error -27 (JIT stack limit reached)


+/-- Test various compile modes --/ 
+    
 /abcd/S++
     abcd
  0: abcd (JIT)
     xyz  
 No match (JIT)


+/abcd/S+
+    abcd
+ 0: abcd (JIT)
+    ab\P
+Partial match: ab (JIT)
+    ab\P\P
+Partial match: ab (JIT)
+    xyz
+No match (JIT)
+
+/abcd/S++
+    abcd
+ 0: abcd (JIT)
+    ab\P
+Partial match: ab (JIT)
+    ab\P\P
+Partial match: ab (JIT)
+    xyz
+No match (JIT)
+
+/abcd/S++1
+    abcd
+ 0: abcd (JIT)
+    ab\P
+Partial match: ab
+    ab\P\P
+Partial match: ab
+    xyz
+No match (JIT)
+    xyz\P
+No match
+
+/abcd/S++2
+    abcd
+ 0: abcd
+    ab\P
+Partial match: ab (JIT)
+    ab\P\P
+Partial match: ab
+    xyz
+No match
+
+/abcd/S++3
+    abcd
+ 0: abcd (JIT)
+    ab\P
+Partial match: ab (JIT)
+    ab\P\P
+Partial match: ab
+    xyz
+No match (JIT)
+
+/abcd/S++4
+    abcd
+ 0: abcd
+    ab\P
+Partial match: ab
+    ab\P\P
+Partial match: ab (JIT)
+    xyz
+No match
+
+/abcd/S++5
+    abcd
+ 0: abcd (JIT)
+    ab\P
+Partial match: ab
+    ab\P\P
+Partial match: ab (JIT)
+    xyz
+No match (JIT)
+
+/abcd/S++6
+    abcd
+ 0: abcd
+    ab\P
+Partial match: ab (JIT)
+    ab\P\P
+Partial match: ab (JIT)
+    xyz
+No match
+
+/abcd/S++7
+    abcd
+ 0: abcd (JIT)
+    ab\P
+Partial match: ab (JIT)
+    ab\P\P
+Partial match: ab (JIT)
+    xyz
+No match (JIT)
+
 /-- End of testinput12 --/