/[pcre]/code/trunk/doc/pcrejit.3
ViewVC logotype

Diff of /code/trunk/doc/pcrejit.3

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 683 by ph10, Tue Sep 6 10:37:15 2011 UTC revision 717 by ph10, Wed Oct 5 15:58:51 2011 UTC
# Line 28  JIT. The support is limited to the follo Line 28  JIT. The support is limited to the follo
28    ARM v5, v7, and Thumb2    ARM v5, v7, and Thumb2
29    Intel x86 32-bit and 64-bit    Intel x86 32-bit and 64-bit
30    MIPS 32-bit    MIPS 32-bit
31    Power PC 32-bit and 64-bit    Power PC 32-bit and 64-bit (experimental)
32  .sp  .sp
33  If --enable-jit is set on an unsupported platform, compilation fails.  The Power PC support is designated as experimental because it has not been
34    fully tested. If --enable-jit is set on an unsupported platform, compilation
35    fails.
36  .P  .P
37  A program can tell if JIT support is available by calling \fBpcre_config()\fP  A program can tell if JIT support is available by calling \fBpcre_config()\fP
38  with the PCRE_CONFIG_JIT option. The result is 1 when JIT is available, and 0  with the PCRE_CONFIG_JIT option. The result is 1 when JIT is available, and 0
# Line 47  You have to do two things to make use of Line 49  You have to do two things to make use of
49    (1) Call \fBpcre_study()\fP with the PCRE_STUDY_JIT_COMPILE option for    (1) Call \fBpcre_study()\fP with the PCRE_STUDY_JIT_COMPILE option for
50        each compiled pattern, and pass the resulting \fBpcre_extra\fP block to        each compiled pattern, and pass the resulting \fBpcre_extra\fP block to
51        \fBpcre_exec()\fP.        \fBpcre_exec()\fP.
52    .sp
53    (2) Use \fBpcre_free_study()\fP to free the \fBpcre_extra\fP block when it is    (2) Use \fBpcre_free_study()\fP to free the \fBpcre_extra\fP block when it is
54        no longer needed instead of just freeing it yourself. This        no longer needed instead of just freeing it yourself. This
55        ensures that any JIT data is also freed.        ensures that any JIT data is also freed.
56  .sp  .sp
57  In some circumstances you may need to call additional functions. These are  In some circumstances you may need to call additional functions. These are
# Line 75  interpretive code. Line 77  interpretive code.
77  If the JIT compiler finds an unsupported item, no JIT data is generated. You  If the JIT compiler finds an unsupported item, no JIT data is generated. You
78  can find out if JIT execution is available after studying a pattern by calling  can find out if JIT execution is available after studying a pattern by calling
79  \fBpcre_fullinfo()\fP with the PCRE_INFO_JIT option. A result of 1 means that  \fBpcre_fullinfo()\fP with the PCRE_INFO_JIT option. A result of 1 means that
80  JIT compilationw was successful. A result of 0 means that JIT support is not  JIT compilation was successful. A result of 0 means that JIT support is not
81  available, or the pattern was not studied with PCRE_STUDY_JIT_COMPILE, or the  available, or the pattern was not studied with PCRE_STUDY_JIT_COMPILE, or the
82  JIT compiler was not able to handle the pattern.  JIT compiler was not able to handle the pattern.
83    .P
84    Once a pattern has been studied, with or without JIT, it can be used as many
85    times as you like for matching different subject strings.
86  .  .
87  .  .
88  .SH "UNSUPPORTED OPTIONS AND PATTERN ITEMS"  .SH "UNSUPPORTED OPTIONS AND PATTERN ITEMS"
# Line 131  execution. Line 136  execution.
136  .rs  .rs
137  .sp  .sp
138  The code that is generated by the JIT compiler is architecture-specific, and is  The code that is generated by the JIT compiler is architecture-specific, and is
139  also position dependent. For those reasons it cannot be saved and restored like  also position dependent. For those reasons it cannot be saved (in a file or
140  the bytecode and other data of a compiled pattern. You should be able run  database) and restored later like the bytecode and other data of a compiled
141  \fBpcre_study()\fP on a saved and restored pattern, and thereby recreate the  pattern. Saving and restoring compiled patterns is not something many people
142  JIT data, but because JIT compilation uses significant resources, it is  do. More detail about this facility is given in the
143  probably not worth doing this.  .\" HREF
144    \fBpcreprecompile\fP
145    .\"
146    documentation. It should be possible to run \fBpcre_study()\fP on a saved and
147    restored pattern, and thereby recreate the JIT data, but because JIT
148    compilation uses significant resources, it is probably not worth doing this;
149    you might as well recompile the original pattern.
150  .  .
151  .  .
152  .\" HTML <a name="stackcontrol"></a>  .\" HTML <a name="stackcontrol"></a>
# Line 149  is given when there is not enough stack. Line 160  is given when there is not enough stack.
160  managing blocks of memory for use as JIT stacks.  managing blocks of memory for use as JIT stacks.
161  .P  .P
162  The \fBpcre_jit_stack_alloc()\fP function creates a JIT stack. Its arguments  The \fBpcre_jit_stack_alloc()\fP function creates a JIT stack. Its arguments
163  are a starting size and a maximum size, and it returns an opaque value  are a starting size and a maximum size, and it returns a pointer to an opaque
164  of type \fBpcre_jit_stack\fP that represents a JIT stack, or NULL if there is  structure of type \fBpcre_jit_stack\fP, or NULL if there is an error. The
165  an error. The \fBpcre_jit_stack_free()\fP function can be used to free a stack  \fBpcre_jit_stack_free()\fP function can be used to free a stack that is no
166  that is no longer needed. (For the technically minded: the address space is  longer needed. (For the technically minded: the address space is allocated by
167  allocated by mmap or VirtualAlloc.)  mmap or VirtualAlloc.)
168  .P  .P
169  JIT uses far less memory for recursion than the interpretive code,  JIT uses far less memory for recursion than the interpretive code,
170  and a maximum stack size of 512K to 1M should be more than enough for any  and a maximum stack size of 512K to 1M should be more than enough for any
171  pattern.  pattern.
172  .P  .P
# Line 197  This is a suggestion for how a typical m Line 208  This is a suggestion for how a typical m
208  .sp  .sp
209    During thread initalization    During thread initalization
210      thread_local_var = pcre_jit_stack_alloc(...)      thread_local_var = pcre_jit_stack_alloc(...)
211    .sp
212    During thread exit    During thread exit
213      pcre_jit_stack_free(thread_local_var)      pcre_jit_stack_free(thread_local_var)
214    .sp
215    Use a one-line callback function    Use a one-line callback function
216      return thread_local_var      return thread_local_var
217  .sp  .sp
# Line 214  successful study with PCRE_STUDY_JIT_COM Line 225  successful study with PCRE_STUDY_JIT_COM
225  .rs  .rs
226  .sp  .sp
227  This is a single-threaded example that specifies a JIT stack without using a  This is a single-threaded example that specifies a JIT stack without using a
228  callback.  callback.
229  .sp  .sp
230    int rc;    int rc;
231    int ovector[30];    int ovector[30];
# Line 232  callback. Line 243  callback.
243    /* Check results */    /* Check results */
244    pcre_free(re);    pcre_free(re);
245    pcre_free_study(extra);    pcre_free_study(extra);
246      pcre_jit_stack_free(jit_stack);
247  .sp  .sp
248  .  .
249  .  .
# Line 255  Cambridge CB2 3QH, England. Line 267  Cambridge CB2 3QH, England.
267  .rs  .rs
268  .sp  .sp
269  .nf  .nf
270  Last updated: 06 September 2011  Last updated: 05 October 2011
271  Copyright (c) 1997-2011 University of Cambridge.  Copyright (c) 1997-2011 University of Cambridge.
272  .fi  .fi

Legend:
Removed from v.683  
changed lines
  Added in v.717

  ViewVC Help
Powered by ViewVC 1.1.5