diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | doc/pcretest.1 | 48 | ||||
-rw-r--r-- | pcretest.c | 36 | ||||
-rw-r--r-- | testdata/testinput12 | 57 | ||||
-rw-r--r-- | testdata/testoutput12 | 94 |
5 files changed, 218 insertions, 20 deletions
@@ -38,6 +38,9 @@ Version 8.31 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 diff --git a/doc/pcretest.1 b/doc/pcretest.1 index 15bbb11..e90b0e0 100644 --- a/doc/pcretest.1 +++ b/doc/pcretest.1 @@ -131,9 +131,20 @@ megabytes. 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 @@ never studied, independently of \fB-s\fP. This feature is used in the test 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 @@ Cambridge CB2 3QH, England. .rs .sp .nf -Last updated: 20 February 2012 +Last updated: 21 February 2012 Copyright (c) 1997-2012 University of Cambridge. .fi @@ -674,6 +674,20 @@ static int use_pcre16 = 0; 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 <n> set stack size to <n> megabytes\n"); 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 @@ while (argc > 1 && argv[op][0] == '-') { 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 @@ while (!done) 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 @@ while (!done) 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 */ } diff --git a/testdata/testinput12 b/testdata/testinput12 index ab77a33..c4f5693 100644 --- a/testdata/testinput12 +++ b/testdata/testinput12 @@ -16,8 +16,65 @@ and a couple of things that are different with JIT. --/ /(?(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 --/ diff --git a/testdata/testoutput12 b/testdata/testoutput12 index 800ee82..7e173cf 100644 --- a/testdata/testoutput12 +++ b/testdata/testoutput12 @@ -48,10 +48,104 @@ Study returned NULL 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 --/ |