Move context argument to last in pcre2_jit_stack_create().
This commit is contained in:
parent
9fcdf2cc6f
commit
161cd17ba0
|
@ -19,18 +19,18 @@ SYNOPSIS
|
|||
<b>#include <pcre2.h></b>
|
||||
</P>
|
||||
<P>
|
||||
<b>pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *<i>gcontext</i>,</b>
|
||||
<b> PCRE2_SIZE <i>startsize</i>, PCRE2_SIZE <i>maxsize</i>);</b>
|
||||
<b>pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE <i>startsize</i>,</b>
|
||||
<b> PCRE2_SIZE <i>maxsize</i>, pcre2_general_context *<i>gcontext</i>);</b>
|
||||
</P>
|
||||
<br><b>
|
||||
DESCRIPTION
|
||||
</b><br>
|
||||
<P>
|
||||
This function is used to create a stack for use by the code compiled by the JIT
|
||||
compiler. The first argument is a general context, for memory allocation
|
||||
functions, or NULL for standard memory allocation. The remaining arguments are
|
||||
a starting size for the stack, and a maximum size to which it is allowed to
|
||||
grow. The result can be passed to the JIT run-time code by calling
|
||||
compiler. The first two arguments are a starting size for the stack, and a
|
||||
maximum size to which it is allowed to grow. The final argument is a general
|
||||
context, for memory allocation functions, or NULL for standard memory
|
||||
allocation. The result can be passed to the JIT run-time code by calling
|
||||
<b>pcre2_jit_stack_assign()</b> to associate the stack with a compiled pattern,
|
||||
which can then be processed by <b>pcre2_match()</b>. If the "fast path" JIT
|
||||
matcher, <b>pcre2_jit_match()</b> is used, the stack can be passed directly as
|
||||
|
|
|
@ -22,7 +22,7 @@ SYNOPSIS
|
|||
<b>int pcre2_substitute(const pcre2_code *<i>code</i>, PCRE2_SPTR <i>subject</i>,</b>
|
||||
<b> PCRE2_SIZE <i>length</i>, PCRE2_SIZE <i>startoffset</i>,</b>
|
||||
<b> uint32_t <i>options</i>, pcre2_match_data *<i>match_data</i>,</b>
|
||||
<b> pcre2_match_context *<i>mcontext</i>, PCRE2_SPTR \fIreplacementzfP,</b>
|
||||
<b> pcre2_match_context *<i>mcontext</i>, PCRE2_SPTR <i>replacement</i>,</b>
|
||||
<b> PCRE2_SIZE <i>rlength</i>, PCRE2_UCHAR *<i>outputbuffer</i>,</b>
|
||||
<b> PCRE2_SIZE *<i>outlengthptr</i>);</b>
|
||||
</P>
|
||||
|
|
|
@ -250,8 +250,8 @@ document for an overview of all the PCRE2 documentation.
|
|||
<b>void pcre2_jit_free_unused_memory(pcre2_general_context *<i>gcontext</i>);</b>
|
||||
<br>
|
||||
<br>
|
||||
<b>pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *<i>gcontext</i>,</b>
|
||||
<b> PCRE2_SIZE <i>startsize</i>, PCRE2_SIZE <i>maxsize</i>);</b>
|
||||
<b>pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE <i>startsize</i>,</b>
|
||||
<b> PCRE2_SIZE <i>maxsize</i>, pcre2_general_context *<i>gcontext</i>);</b>
|
||||
<br>
|
||||
<br>
|
||||
<b>void pcre2_jit_stack_assign(pcre2_match_context *<i>mcontext</i>,</b>
|
||||
|
@ -1308,8 +1308,8 @@ textual error message from any error code.
|
|||
<b>void pcre2_jit_free_unused_memory(pcre2_general_context *<i>gcontext</i>);</b>
|
||||
<br>
|
||||
<br>
|
||||
<b>pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *<i>gcontext</i>,</b>
|
||||
<b> PCRE2_SIZE <i>startsize</i>, PCRE2_SIZE <i>maxsize</i>);</b>
|
||||
<b>pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE <i>startsize</i>,</b>
|
||||
<b> PCRE2_SIZE <i>maxsize</i>, pcre2_general_context *<i>gcontext</i>);</b>
|
||||
<br>
|
||||
<br>
|
||||
<b>void pcre2_jit_stack_assign(pcre2_match_context *<i>mcontext</i>,</b>
|
||||
|
@ -2681,7 +2681,7 @@ Cambridge, England.
|
|||
</P>
|
||||
<br><a name="SEC37" href="#TOC1">REVISION</a><br>
|
||||
<P>
|
||||
Last updated: 26 November 2014
|
||||
Last updated: 27 November 2014
|
||||
<br>
|
||||
Copyright © 1997-2014 University of Cambridge.
|
||||
<br>
|
||||
|
|
|
@ -177,8 +177,8 @@ below.
|
|||
</P>
|
||||
<P>
|
||||
The <b>pcre2_jit_stack_create()</b> function creates a JIT stack. Its arguments
|
||||
are a general context (for memory allocation functions, or NULL for standard
|
||||
memory allocation), a starting size and a maximum size, and it returns a
|
||||
are a starting size, a maximum size, and a general context (for memory
|
||||
allocation functions, or NULL for standard memory allocation). It returns a
|
||||
pointer to an opaque structure of type <b>pcre2_jit_stack</b>, or NULL if there
|
||||
is an error. The <b>pcre2_jit_stack_free()</b> function is used to free a stack
|
||||
that is no longer needed. (For the technically minded: the address space is
|
||||
|
@ -360,7 +360,7 @@ calls.
|
|||
&errornumber, &erroffset, NULL);
|
||||
rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE);
|
||||
mcontext = pcre2_match_context_create(NULL);
|
||||
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 512*1024);
|
||||
jit_stack = pcre2_jit_stack_create(32*1024, 512*1024, NULL);
|
||||
pcre2_jit_stack_assign(mcontext, NULL, jit_stack);
|
||||
match_data = pcre2_match_data_create(re, 10);
|
||||
rc = pcre2_match(re, subject, length, 0, 0, match_data, mcontext);
|
||||
|
@ -418,7 +418,7 @@ Cambridge, England.
|
|||
</P>
|
||||
<br><a name="SEC13" href="#TOC1">REVISION</a><br>
|
||||
<P>
|
||||
Last updated: 23 November 2014
|
||||
Last updated: 27 November 2014
|
||||
<br>
|
||||
Copyright © 1997-2014 University of Cambridge.
|
||||
<br>
|
||||
|
|
145
doc/pcre2.txt
145
doc/pcre2.txt
|
@ -334,8 +334,8 @@ PCRE2 NATIVE API JIT FUNCTIONS
|
|||
|
||||
void pcre2_jit_free_unused_memory(pcre2_general_context *gcontext);
|
||||
|
||||
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *gcontext,
|
||||
PCRE2_SIZE startsize, PCRE2_SIZE maxsize);
|
||||
pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE startsize,
|
||||
PCRE2_SIZE maxsize, pcre2_general_context *gcontext);
|
||||
|
||||
void pcre2_jit_stack_assign(pcre2_match_context *mcontext,
|
||||
pcre2_jit_callback callback_function, void *callback_data);
|
||||
|
@ -1337,8 +1337,8 @@ JUST-IN-TIME (JIT) COMPILATION
|
|||
|
||||
void pcre2_jit_free_unused_memory(pcre2_general_context *gcontext);
|
||||
|
||||
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *gcontext,
|
||||
PCRE2_SIZE startsize, PCRE2_SIZE maxsize);
|
||||
pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE startsize,
|
||||
PCRE2_SIZE maxsize, pcre2_general_context *gcontext);
|
||||
|
||||
void pcre2_jit_stack_assign(pcre2_match_context *mcontext,
|
||||
pcre2_jit_callback callback_function, void *callback_data);
|
||||
|
@ -2622,7 +2622,7 @@ AUTHOR
|
|||
|
||||
REVISION
|
||||
|
||||
Last updated: 26 November 2014
|
||||
Last updated: 27 November 2014
|
||||
Copyright (c) 1997-2014 University of Cambridge.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
@ -3647,19 +3647,18 @@ CONTROLLING THE JIT STACK
|
|||
the section entitled "JIT stack FAQ" below.
|
||||
|
||||
The pcre2_jit_stack_create() function creates a JIT stack. Its argu-
|
||||
ments are a general context (for memory allocation functions, or NULL
|
||||
for standard memory allocation), a starting size and a maximum size,
|
||||
and it returns a pointer to an opaque structure of type
|
||||
pcre2_jit_stack, or NULL if there is an error. The
|
||||
pcre2_jit_stack_free() function is used to free a stack that is no
|
||||
longer needed. (For the technically minded: the address space is allo-
|
||||
cated by mmap or VirtualAlloc.)
|
||||
ments are a starting size, a maximum size, and a general context (for
|
||||
memory allocation functions, or NULL for standard memory allocation).
|
||||
It returns a pointer to an opaque structure of type pcre2_jit_stack, or
|
||||
NULL if there is an error. The pcre2_jit_stack_free() function is used
|
||||
to free a stack that is no longer needed. (For the technically minded:
|
||||
the address space is allocated by mmap or VirtualAlloc.)
|
||||
|
||||
JIT uses far less memory for recursion than the interpretive code, and
|
||||
a maximum stack size of 512K to 1M should be more than enough for any
|
||||
JIT uses far less memory for recursion than the interpretive code, and
|
||||
a maximum stack size of 512K to 1M should be more than enough for any
|
||||
pattern.
|
||||
|
||||
The pcre2_jit_stack_assign() function specifies which stack JIT code
|
||||
The pcre2_jit_stack_assign() function specifies which stack JIT code
|
||||
should use. Its arguments are as follows:
|
||||
|
||||
pcre2_match_context *mcontext
|
||||
|
@ -3668,7 +3667,7 @@ CONTROLLING THE JIT STACK
|
|||
|
||||
The first argument is a pointer to a match context. When this is subse-
|
||||
quently passed to a matching function, its information determines which
|
||||
JIT stack is used. There are three cases for the values of the other
|
||||
JIT stack is used. There are three cases for the values of the other
|
||||
two options:
|
||||
|
||||
(1) If callback is NULL and data is NULL, an internal 32K block
|
||||
|
@ -3686,30 +3685,30 @@ CONTROLLING THE JIT STACK
|
|||
return value must be a valid JIT stack, the result of calling
|
||||
pcre2_jit_stack_create().
|
||||
|
||||
A callback function is obeyed whenever JIT code is about to be run; it
|
||||
A callback function is obeyed whenever JIT code is about to be run; it
|
||||
is not obeyed when pcre2_match() is called with options that are incom-
|
||||
patible for JIT matching. A callback function can therefore be used to
|
||||
determine whether a match operation was executed by JIT or by the
|
||||
patible for JIT matching. A callback function can therefore be used to
|
||||
determine whether a match operation was executed by JIT or by the
|
||||
interpreter.
|
||||
|
||||
You may safely use the same JIT stack for more than one pattern (either
|
||||
by assigning directly or by callback), as long as the patterns are all
|
||||
matched sequentially in the same thread. In a multithread application,
|
||||
if you do not specify a JIT stack, or if you assign or pass back NULL
|
||||
from a callback, that is thread-safe, because each thread has its own
|
||||
machine stack. However, if you assign or pass back a non-NULL JIT
|
||||
stack, this must be a different stack for each thread so that the
|
||||
by assigning directly or by callback), as long as the patterns are all
|
||||
matched sequentially in the same thread. In a multithread application,
|
||||
if you do not specify a JIT stack, or if you assign or pass back NULL
|
||||
from a callback, that is thread-safe, because each thread has its own
|
||||
machine stack. However, if you assign or pass back a non-NULL JIT
|
||||
stack, this must be a different stack for each thread so that the
|
||||
application is thread-safe.
|
||||
|
||||
Strictly speaking, even more is allowed. You can assign the same non-
|
||||
NULL stack to a match context that is used by any number of patterns,
|
||||
as long as they are not used for matching by multiple threads at the
|
||||
same time. For example, you could use the same stack in all compiled
|
||||
patterns, with a global mutex in the callback to wait until the stack
|
||||
Strictly speaking, even more is allowed. You can assign the same non-
|
||||
NULL stack to a match context that is used by any number of patterns,
|
||||
as long as they are not used for matching by multiple threads at the
|
||||
same time. For example, you could use the same stack in all compiled
|
||||
patterns, with a global mutex in the callback to wait until the stack
|
||||
is available for use. However, this is an inefficient solution, and not
|
||||
recommended.
|
||||
|
||||
This is a suggestion for how a multithreaded program that needs to set
|
||||
This is a suggestion for how a multithreaded program that needs to set
|
||||
up non-default JIT stacks might operate:
|
||||
|
||||
During thread initalization
|
||||
|
@ -3721,7 +3720,7 @@ CONTROLLING THE JIT STACK
|
|||
Use a one-line callback function
|
||||
return thread_local_var
|
||||
|
||||
All the functions described in this section do nothing if JIT is not
|
||||
All the functions described in this section do nothing if JIT is not
|
||||
available.
|
||||
|
||||
|
||||
|
@ -3730,20 +3729,20 @@ JIT STACK FAQ
|
|||
(1) Why do we need JIT stacks?
|
||||
|
||||
PCRE2 (and JIT) is a recursive, depth-first engine, so it needs a stack
|
||||
where the local data of the current node is pushed before checking its
|
||||
where the local data of the current node is pushed before checking its
|
||||
child nodes. Allocating real machine stack on some platforms is diffi-
|
||||
cult. For example, the stack chain needs to be updated every time if we
|
||||
extend the stack on PowerPC. Although it is possible, its updating
|
||||
extend the stack on PowerPC. Although it is possible, its updating
|
||||
time overhead decreases performance. So we do the recursion in memory.
|
||||
|
||||
(2) Why don't we simply allocate blocks of memory with malloc()?
|
||||
|
||||
Modern operating systems have a nice feature: they can reserve an
|
||||
Modern operating systems have a nice feature: they can reserve an
|
||||
address space instead of allocating memory. We can safely allocate mem-
|
||||
ory pages inside this address space, so the stack could grow without
|
||||
ory pages inside this address space, so the stack could grow without
|
||||
moving memory data (this is important because of pointers). Thus we can
|
||||
allocate 1M address space, and use only a single memory page (usually
|
||||
4K) if that is enough. However, we can still grow up to 1M anytime if
|
||||
allocate 1M address space, and use only a single memory page (usually
|
||||
4K) if that is enough. However, we can still grow up to 1M anytime if
|
||||
needed.
|
||||
|
||||
(3) Who "owns" a JIT stack?
|
||||
|
@ -3751,8 +3750,8 @@ JIT STACK FAQ
|
|||
The owner of the stack is the user program, not the JIT studied pattern
|
||||
or anything else. The user program must ensure that if a stack is being
|
||||
used by pcre2_match(), (that is, it is assigned to a match context that
|
||||
is passed to the pattern currently running), that stack must not be
|
||||
used by any other threads (to avoid overwriting the same memory area).
|
||||
is passed to the pattern currently running), that stack must not be
|
||||
used by any other threads (to avoid overwriting the same memory area).
|
||||
The best practice for multithreaded programs is to allocate a stack for
|
||||
each thread, and return this stack through the JIT callback function.
|
||||
|
||||
|
@ -3760,36 +3759,36 @@ JIT STACK FAQ
|
|||
|
||||
You can free a JIT stack at any time, as long as it will not be used by
|
||||
pcre2_match() again. When you assign the stack to a match context, only
|
||||
a pointer is set. There is no reference counting or any other magic.
|
||||
a pointer is set. There is no reference counting or any other magic.
|
||||
You can free compiled patterns, contexts, and stacks in any order, any-
|
||||
time. Just do not call pcre2_match() with a match context pointing to
|
||||
time. Just do not call pcre2_match() with a match context pointing to
|
||||
an already freed stack, as that will cause SEGFAULT. (Also, do not free
|
||||
a stack currently used by pcre2_match() in another thread). You can
|
||||
also replace the stack in a context at any time when it is not in use.
|
||||
a stack currently used by pcre2_match() in another thread). You can
|
||||
also replace the stack in a context at any time when it is not in use.
|
||||
You should free the previous stack before assigning a replacement.
|
||||
|
||||
(5) Should I allocate/free a stack every time before/after calling
|
||||
(5) Should I allocate/free a stack every time before/after calling
|
||||
pcre2_match()?
|
||||
|
||||
No, because this is too costly in terms of resources. However, you
|
||||
could implement some clever idea which release the stack if it is not
|
||||
used in let's say two minutes. The JIT callback can help to achieve
|
||||
No, because this is too costly in terms of resources. However, you
|
||||
could implement some clever idea which release the stack if it is not
|
||||
used in let's say two minutes. The JIT callback can help to achieve
|
||||
this without keeping a list of patterns.
|
||||
|
||||
(6) OK, the stack is for long term memory allocation. But what happens
|
||||
if a pattern causes stack overflow with a stack of 1M? Is that 1M kept
|
||||
(6) OK, the stack is for long term memory allocation. But what happens
|
||||
if a pattern causes stack overflow with a stack of 1M? Is that 1M kept
|
||||
until the stack is freed?
|
||||
|
||||
Especially on embedded sytems, it might be a good idea to release mem-
|
||||
ory sometimes without freeing the stack. There is no API for this at
|
||||
the moment. Probably a function call which returns with the currently
|
||||
allocated memory for any stack and another which allows releasing mem-
|
||||
Especially on embedded sytems, it might be a good idea to release mem-
|
||||
ory sometimes without freeing the stack. There is no API for this at
|
||||
the moment. Probably a function call which returns with the currently
|
||||
allocated memory for any stack and another which allows releasing mem-
|
||||
ory (shrinking the stack) would be a good idea if someone needs this.
|
||||
|
||||
(7) This is too much of a headache. Isn't there any better solution for
|
||||
JIT stack handling?
|
||||
|
||||
No, thanks to Windows. If POSIX threads were used everywhere, we could
|
||||
No, thanks to Windows. If POSIX threads were used everywhere, we could
|
||||
throw out this complicated API.
|
||||
|
||||
|
||||
|
@ -3798,18 +3797,18 @@ FREEING JIT SPECULATIVE MEMORY
|
|||
void pcre2_jit_free_unused_memory(pcre2_general_context *gcontext);
|
||||
|
||||
The JIT executable allocator does not free all memory when it is possi-
|
||||
ble. It expects new allocations, and keeps some free memory around to
|
||||
improve allocation speed. However, in low memory conditions, it might
|
||||
be better to free all possible memory. You can cause this to happen by
|
||||
calling pcre2_jit_free_unused_memory(). Its argument is a general con-
|
||||
ble. It expects new allocations, and keeps some free memory around to
|
||||
improve allocation speed. However, in low memory conditions, it might
|
||||
be better to free all possible memory. You can cause this to happen by
|
||||
calling pcre2_jit_free_unused_memory(). Its argument is a general con-
|
||||
text, for custom memory management, or NULL for standard memory manage-
|
||||
ment.
|
||||
|
||||
|
||||
EXAMPLE CODE
|
||||
|
||||
This is a single-threaded example that specifies a JIT stack without
|
||||
using a callback. A real program should include error checking after
|
||||
This is a single-threaded example that specifies a JIT stack without
|
||||
using a callback. A real program should include error checking after
|
||||
all the function calls.
|
||||
|
||||
int rc;
|
||||
|
@ -3822,7 +3821,7 @@ EXAMPLE CODE
|
|||
&errornumber, &erroffset, NULL);
|
||||
rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE);
|
||||
mcontext = pcre2_match_context_create(NULL);
|
||||
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 512*1024);
|
||||
jit_stack = pcre2_jit_stack_create(32*1024, 512*1024, NULL);
|
||||
pcre2_jit_stack_assign(mcontext, NULL, jit_stack);
|
||||
match_data = pcre2_match_data_create(re, 10);
|
||||
rc = pcre2_match(re, subject, length, 0, 0, match_data, mcontext);
|
||||
|
@ -3837,28 +3836,28 @@ EXAMPLE CODE
|
|||
JIT FAST PATH API
|
||||
|
||||
Because the API described above falls back to interpreted matching when
|
||||
JIT is not available, it is convenient for programs that are written
|
||||
JIT is not available, it is convenient for programs that are written
|
||||
for general use in many environments. However, calling JIT via
|
||||
pcre2_match() does have a performance impact. Programs that are written
|
||||
for use where JIT is known to be available, and which need the best
|
||||
possible performance, can instead use a "fast path" API to call JIT
|
||||
matching directly instead of calling pcre2_match() (obviously only for
|
||||
for use where JIT is known to be available, and which need the best
|
||||
possible performance, can instead use a "fast path" API to call JIT
|
||||
matching directly instead of calling pcre2_match() (obviously only for
|
||||
patterns that have been successfully processed by pcre2_jit_compile()).
|
||||
|
||||
The fast path function is called pcre2_jit_match(), and it takes
|
||||
The fast path function is called pcre2_jit_match(), and it takes
|
||||
exactly the same arguments as pcre2_match(). The return values are also
|
||||
the same, plus PCRE2_ERROR_JIT_BADOPTION if a matching mode (partial or
|
||||
complete) is requested that was not compiled. Unsupported option bits
|
||||
complete) is requested that was not compiled. Unsupported option bits
|
||||
(for example, PCRE2_ANCHORED) are ignored.
|
||||
|
||||
When you call pcre2_match(), as well as testing for invalid options, a
|
||||
When you call pcre2_match(), as well as testing for invalid options, a
|
||||
number of other sanity checks are performed on the arguments. For exam-
|
||||
ple, if the subject pointer is NULL, an immediate error is given. Also,
|
||||
unless PCRE2_NO_UTF_CHECK is set, a UTF subject string is tested for
|
||||
validity. In the interests of speed, these checks do not happen on the
|
||||
unless PCRE2_NO_UTF_CHECK is set, a UTF subject string is tested for
|
||||
validity. In the interests of speed, these checks do not happen on the
|
||||
JIT fast path, and if invalid data is passed, the result is undefined.
|
||||
|
||||
Bypassing the sanity checks and the pcre2_match() wrapping can give
|
||||
Bypassing the sanity checks and the pcre2_match() wrapping can give
|
||||
speedups of more than 10%.
|
||||
|
||||
|
||||
|
@ -3876,7 +3875,7 @@ AUTHOR
|
|||
|
||||
REVISION
|
||||
|
||||
Last updated: 23 November 2014
|
||||
Last updated: 27 November 2014
|
||||
Copyright (c) 1997-2014 University of Cambridge.
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -7,18 +7,18 @@ PCRE2 - Perl-compatible regular expressions (revised API)
|
|||
.B #include <pcre2.h>
|
||||
.PP
|
||||
.nf
|
||||
.B pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *\fIgcontext\fP,
|
||||
.B " PCRE2_SIZE \fIstartsize\fP, PCRE2_SIZE \fImaxsize\fP);"
|
||||
.B pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE \fIstartsize\fP,
|
||||
.B " PCRE2_SIZE \fImaxsize\fP, pcre2_general_context *\fIgcontext\fP);"
|
||||
.fi
|
||||
.
|
||||
.SH DESCRIPTION
|
||||
.rs
|
||||
.sp
|
||||
This function is used to create a stack for use by the code compiled by the JIT
|
||||
compiler. The first argument is a general context, for memory allocation
|
||||
functions, or NULL for standard memory allocation. The remaining arguments are
|
||||
a starting size for the stack, and a maximum size to which it is allowed to
|
||||
grow. The result can be passed to the JIT run-time code by calling
|
||||
compiler. The first two arguments are a starting size for the stack, and a
|
||||
maximum size to which it is allowed to grow. The final argument is a general
|
||||
context, for memory allocation functions, or NULL for standard memory
|
||||
allocation. The result can be passed to the JIT run-time code by calling
|
||||
\fBpcre2_jit_stack_assign()\fP to associate the stack with a compiled pattern,
|
||||
which can then be processed by \fBpcre2_match()\fP. If the "fast path" JIT
|
||||
matcher, \fBpcre2_jit_match()\fP is used, the stack can be passed directly as
|
||||
|
|
|
@ -10,7 +10,7 @@ PCRE2 - Perl-compatible regular expressions (revised API)
|
|||
.B int pcre2_substitute(const pcre2_code *\fIcode\fP, PCRE2_SPTR \fIsubject\fP,
|
||||
.B " PCRE2_SIZE \fIlength\fP, PCRE2_SIZE \fIstartoffset\fP,"
|
||||
.B " uint32_t \fIoptions\fP, pcre2_match_data *\fImatch_data\fP,"
|
||||
.B " pcre2_match_context *\fImcontext\fP, PCRE2_SPTR \fIreplacementzfP,"
|
||||
.B " pcre2_match_context *\fImcontext\fP, PCRE2_SPTR \fIreplacement\fP,"
|
||||
.B " PCRE2_SIZE \fIrlength\fP, PCRE2_UCHAR *\fIoutputbuffer\fP,"
|
||||
.B " PCRE2_SIZE *\fIoutlengthptr\fP);"
|
||||
.fi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH PCRE2API 3 "26 November 2014" "PCRE2 10.00"
|
||||
.TH PCRE2API 3 "27 November 2014" "PCRE2 10.00"
|
||||
.SH NAME
|
||||
PCRE2 - Perl-compatible regular expressions (revised API)
|
||||
.sp
|
||||
|
@ -195,8 +195,8 @@ document for an overview of all the PCRE2 documentation.
|
|||
.sp
|
||||
.B void pcre2_jit_free_unused_memory(pcre2_general_context *\fIgcontext\fP);
|
||||
.sp
|
||||
.B pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *\fIgcontext\fP,
|
||||
.B " PCRE2_SIZE \fIstartsize\fP, PCRE2_SIZE \fImaxsize\fP);"
|
||||
.B pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE \fIstartsize\fP,
|
||||
.B " PCRE2_SIZE \fImaxsize\fP, pcre2_general_context *\fIgcontext\fP);"
|
||||
.sp
|
||||
.B void pcre2_jit_stack_assign(pcre2_match_context *\fImcontext\fP,
|
||||
.B " pcre2_jit_callback \fIcallback_function\fP, void *\fIcallback_data\fP);"
|
||||
|
@ -1300,8 +1300,8 @@ textual error message from any error code.
|
|||
.sp
|
||||
.B void pcre2_jit_free_unused_memory(pcre2_general_context *\fIgcontext\fP);
|
||||
.sp
|
||||
.B pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *\fIgcontext\fP,
|
||||
.B " PCRE2_SIZE \fIstartsize\fP, PCRE2_SIZE \fImaxsize\fP);"
|
||||
.B pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE \fIstartsize\fP,
|
||||
.B " PCRE2_SIZE \fImaxsize\fP, pcre2_general_context *\fIgcontext\fP);"
|
||||
.sp
|
||||
.B void pcre2_jit_stack_assign(pcre2_match_context *\fImcontext\fP,
|
||||
.B " pcre2_jit_callback \fIcallback_function\fP, void *\fIcallback_data\fP);"
|
||||
|
@ -2731,6 +2731,6 @@ Cambridge, England.
|
|||
.rs
|
||||
.sp
|
||||
.nf
|
||||
Last updated: 26 November 2014
|
||||
Last updated: 27 November 2014
|
||||
Copyright (c) 1997-2014 University of Cambridge.
|
||||
.fi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH PCRE2JIT 3 "23 November 2014" "PCRE2 10.00"
|
||||
.TH PCRE2JIT 3 "27 November 2014" "PCRE2 10.00"
|
||||
.SH NAME
|
||||
PCRE2 - Perl-compatible regular expressions (revised API)
|
||||
.SH "PCRE2 JUST-IN-TIME COMPILER SUPPORT"
|
||||
|
@ -163,8 +163,8 @@ about the use of JIT stacks in the section entitled
|
|||
below.
|
||||
.P
|
||||
The \fBpcre2_jit_stack_create()\fP function creates a JIT stack. Its arguments
|
||||
are a general context (for memory allocation functions, or NULL for standard
|
||||
memory allocation), a starting size and a maximum size, and it returns a
|
||||
are a starting size, a maximum size, and a general context (for memory
|
||||
allocation functions, or NULL for standard memory allocation). It returns a
|
||||
pointer to an opaque structure of type \fBpcre2_jit_stack\fP, or NULL if there
|
||||
is an error. The \fBpcre2_jit_stack_free()\fP function is used to free a stack
|
||||
that is no longer needed. (For the technically minded: the address space is
|
||||
|
@ -336,7 +336,7 @@ calls.
|
|||
&errornumber, &erroffset, NULL);
|
||||
rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE);
|
||||
mcontext = pcre2_match_context_create(NULL);
|
||||
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 512*1024);
|
||||
jit_stack = pcre2_jit_stack_create(32*1024, 512*1024, NULL);
|
||||
pcre2_jit_stack_assign(mcontext, NULL, jit_stack);
|
||||
match_data = pcre2_match_data_create(re, 10);
|
||||
rc = pcre2_match(re, subject, length, 0, 0, match_data, mcontext);
|
||||
|
@ -398,6 +398,6 @@ Cambridge, England.
|
|||
.rs
|
||||
.sp
|
||||
.nf
|
||||
Last updated: 23 November 2014
|
||||
Last updated: 27 November 2014
|
||||
Copyright (c) 1997-2014 University of Cambridge.
|
||||
.fi
|
||||
|
|
|
@ -472,8 +472,8 @@ PCRE2_EXP_DECL int pcre2_jit_match(const pcre2_code *, \
|
|||
pcre2_match_data *, pcre2_match_context *); \
|
||||
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_general_context *); \
|
||||
PCRE2_EXP_DECL \
|
||||
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *, \
|
||||
PCRE2_SIZE, PCRE2_SIZE); \
|
||||
pcre2_jit_stack *pcre2_jit_stack_create(PCRE2_SIZE, PCRE2_SIZE, \
|
||||
pcre2_general_context *); \
|
||||
PCRE2_EXP_DECL void pcre2_jit_stack_assign(pcre2_match_context *, \
|
||||
pcre2_jit_callback, void *); \
|
||||
PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_jit_stack *);
|
||||
|
|
|
@ -97,8 +97,8 @@ sljit_free_unused_memory_exec();
|
|||
*************************************************/
|
||||
|
||||
PCRE2_EXP_DEFN pcre2_jit_stack * PCRE2_CALL_CONVENTION
|
||||
pcre2_jit_stack_create(pcre2_general_context *gcontext, size_t startsize,
|
||||
size_t maxsize)
|
||||
pcre2_jit_stack_create(size_t startsize, size_t maxsize,
|
||||
pcre2_general_context *gcontext)
|
||||
{
|
||||
#ifndef SUPPORT_JIT
|
||||
|
||||
|
|
|
@ -854,7 +854,7 @@ static pcre2_jit_stack_8 *stack8;
|
|||
static pcre2_jit_stack_8 *getstack8(void)
|
||||
{
|
||||
if (!stack8)
|
||||
stack8 = pcre2_jit_stack_create_8(NULL, 1, 1024 * 1024);
|
||||
stack8 = pcre2_jit_stack_create_8(1, 1024 * 1024, NULL);
|
||||
return stack8;
|
||||
}
|
||||
|
||||
|
@ -877,7 +877,7 @@ static pcre2_jit_stack_16 *stack16;
|
|||
static pcre2_jit_stack_16 *getstack16(void)
|
||||
{
|
||||
if (!stack16)
|
||||
stack16 = pcre2_jit_stack_create_16(NULL, 1, 1024 * 1024);
|
||||
stack16 = pcre2_jit_stack_create_16(1, 1024 * 1024, NULL);
|
||||
return stack16;
|
||||
}
|
||||
|
||||
|
@ -900,7 +900,7 @@ static pcre2_jit_stack_32 *stack32;
|
|||
static pcre2_jit_stack_32 *getstack32(void)
|
||||
{
|
||||
if (!stack32)
|
||||
stack32 = pcre2_jit_stack_create_32(NULL, 1, 1024 * 1024);
|
||||
stack32 = pcre2_jit_stack_create_32(1, 1024 * 1024, NULL);
|
||||
return stack32;
|
||||
}
|
||||
|
||||
|
|
|
@ -3115,7 +3115,7 @@ for (fn = pattern_files; fn != NULL; fn = fn->next)
|
|||
|
||||
#ifdef SUPPORT_PCRE2GREP_JIT
|
||||
if (use_jit)
|
||||
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 1024*1024);
|
||||
jit_stack = pcre2_jit_stack_create(32*1024, 1024*1024, NULL);
|
||||
#endif
|
||||
|
||||
for (j = 1, cp = patterns; cp != NULL; j++, cp = cp->next)
|
||||
|
|
|
@ -4731,7 +4731,7 @@ if (dat_datctl.jitstack != 0)
|
|||
if (dat_datctl.jitstack != jit_stack_size)
|
||||
{
|
||||
PCRE2_JIT_STACK_FREE(jit_stack);
|
||||
PCRE2_JIT_STACK_CREATE(jit_stack, NULL, 1, dat_datctl.jitstack * 1024);
|
||||
PCRE2_JIT_STACK_CREATE(jit_stack, 1, dat_datctl.jitstack * 1024, NULL);
|
||||
jit_stack_size = dat_datctl.jitstack;
|
||||
}
|
||||
PCRE2_JIT_STACK_ASSIGN(dat_context, jit_callback, jit_stack);
|
||||
|
|
Loading…
Reference in New Issue