Update pcre2test with JIT features (untested)
This commit is contained in:
parent
63d812ff0e
commit
313245365d
143
src/pcre2test.c
143
src/pcre2test.c
|
@ -595,8 +595,11 @@ static FILE *infile;
|
||||||
static FILE *outfile;
|
static FILE *outfile;
|
||||||
|
|
||||||
static const void *last_callout_mark;
|
static const void *last_callout_mark;
|
||||||
|
static PCRE2_JIT_STACK *jit_stack = NULL;
|
||||||
|
static size_t jit_stack_size = 0;
|
||||||
|
|
||||||
static BOOL first_callout;
|
static BOOL first_callout;
|
||||||
|
static BOOL jit_was_used;
|
||||||
static BOOL restrict_for_perl_test = FALSE;
|
static BOOL restrict_for_perl_test = FALSE;
|
||||||
static BOOL show_memory = FALSE;
|
static BOOL show_memory = FALSE;
|
||||||
|
|
||||||
|
@ -772,6 +775,30 @@ are supported. */
|
||||||
else if (test_mode == PCRE16_MODE) pcre2_jit_compile_16(G(a,16),b,G(c,16)); \
|
else if (test_mode == PCRE16_MODE) pcre2_jit_compile_16(G(a,16),b,G(c,16)); \
|
||||||
else pcre2_jit_compile_32(G(a,32),b,G(c,32))
|
else pcre2_jit_compile_32(G(a,32),b,G(c,32))
|
||||||
|
|
||||||
|
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
|
||||||
|
if (test_mode == PCRE8_MODE) \
|
||||||
|
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_8(b,c,d); \
|
||||||
|
else if (test_mode == PCRE16_MODE) \
|
||||||
|
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_16(b,c,d); \
|
||||||
|
else \
|
||||||
|
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_32(b,c,d);
|
||||||
|
|
||||||
|
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
|
||||||
|
if (test_mode == PCRE8_MODE) \
|
||||||
|
pcre2_jit_stack_assign_8(G(a,8),(pcre2_jit_callback_8)b,c); \
|
||||||
|
else if (test_mode == PCRE16_MODE) \
|
||||||
|
pcre2_jit_stack_assign_16(G(a,16),(pcre2_jit_callback_16)b,c); \
|
||||||
|
else \
|
||||||
|
pcre2_jit_stack_assign_32(G(a,32),(pcre2_jit_callback_32)b,c);
|
||||||
|
|
||||||
|
#define PCRE2_JIT_STACK_FREE(a) \
|
||||||
|
if (test_mode == PCRE8_MODE) \
|
||||||
|
pcre2_jit_stack_free_8((pcre2_jit_stack_8 *)a); \
|
||||||
|
else if (test_mode == PCRE16_MODE) \
|
||||||
|
pcre2_jit_stack_free_16((pcre2_jit_stack_16 *)a); \
|
||||||
|
else \
|
||||||
|
pcre2_jit_stack_free_32((pcre2_jit_stack_32 *)a);
|
||||||
|
|
||||||
#define PCRE2_MAKETABLES(a) \
|
#define PCRE2_MAKETABLES(a) \
|
||||||
if (test_mode == PCRE8_MODE) a = pcre2_maketables_8(NULL); \
|
if (test_mode == PCRE8_MODE) a = pcre2_maketables_8(NULL); \
|
||||||
else if (test_mode == PCRE16_MODE) a = pcre2_maketables_16(NULL); \
|
else if (test_mode == PCRE16_MODE) a = pcre2_maketables_16(NULL); \
|
||||||
|
@ -1060,6 +1087,24 @@ the three different cases. */
|
||||||
else \
|
else \
|
||||||
G(pcre2_jit_compile_,BITTWO)(G(a,BITTWO),b,G(c,BITTWO))
|
G(pcre2_jit_compile_,BITTWO)(G(a,BITTWO),b,G(c,BITTWO))
|
||||||
|
|
||||||
|
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
|
||||||
|
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
||||||
|
a = (PCRE2_JIT_STACK *)G(pcre2_jit_stack_alloc_,BITONE)(b,c,d); \
|
||||||
|
else \
|
||||||
|
a = (PCRE2_JIT_STACK *)G(pcre2_jit_stack_alloc_,BITTWO)(b,c,d); \
|
||||||
|
|
||||||
|
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
|
||||||
|
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
||||||
|
G(pcre2_jit_stack_assign_,BITONE)(G(a,BITONE),(G(pcre2_jit_callback_,BITONE))b,c); \
|
||||||
|
else \
|
||||||
|
G(pcre2_jit_stack_assign_,BITTWO)(G(a,BITTWO),(G(pcre2_jit_callback_,BITTWO))b,c);
|
||||||
|
|
||||||
|
#define PCRE2_JIT_STACK_FREE(a) \
|
||||||
|
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
||||||
|
G(pcre2_jit_stack_free_,BITONE)((G(pcre2_jit_stack_,BITONE) *)a); \
|
||||||
|
else \
|
||||||
|
G(pcre2_jit_stack_free_,BITWO)((G(pcre2_jit_stack_,BITTWO) *)a);
|
||||||
|
|
||||||
#define PCRE2_MAKETABLES(a) \
|
#define PCRE2_MAKETABLES(a) \
|
||||||
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
|
||||||
a = G(pcre2_maketables_,BITONE)(NULL); \
|
a = G(pcre2_maketables_,BITONE)(NULL); \
|
||||||
|
@ -1253,6 +1298,11 @@ the three different cases. */
|
||||||
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
|
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
|
||||||
r = pcre2_get_error_message_8(a,G(b,8),G(G(b,8),_size))
|
r = pcre2_get_error_message_8(a,G(b,8),G(G(b,8),_size))
|
||||||
#define PCRE2_JIT_COMPILE(a,b,c) pcre2_jit_compile_8(G(a,8),b,G(c,8))
|
#define PCRE2_JIT_COMPILE(a,b,c) pcre2_jit_compile_8(G(a,8),b,G(c,8))
|
||||||
|
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
|
||||||
|
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_8(b,c,d);
|
||||||
|
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
|
||||||
|
pcre2_jit_stack_assign_8(G(a,8),(pcre2_jit_callback_8)b,c);
|
||||||
|
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_8((pcre2_jit_stack_8 *)a);
|
||||||
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
|
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
|
||||||
a = pcre2_match_8(G(b,8),(PCRE2_SPTR8)c,d,e,f,G(g,8),G(h,8))
|
a = pcre2_match_8(G(b,8),(PCRE2_SPTR8)c,d,e,f,G(g,8),G(h,8))
|
||||||
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_8(NULL)
|
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_8(NULL)
|
||||||
|
@ -1312,6 +1362,11 @@ the three different cases. */
|
||||||
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
|
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
|
||||||
r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size))
|
r = pcre2_get_error_message_16(a,G(b,16),G(G(b,16),_size))
|
||||||
#define PCRE2_JIT_COMPILE(a,b,c) pcre2_jit_compile_16(G(a,16),b,G(c,16))
|
#define PCRE2_JIT_COMPILE(a,b,c) pcre2_jit_compile_16(G(a,16),b,G(c,16))
|
||||||
|
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
|
||||||
|
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_16(b,c,d);
|
||||||
|
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
|
||||||
|
pcre2_jit_stack_assign_16(G(a,16),(pcre2_jit_callback_16)b,c);
|
||||||
|
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_16((pcre2_jit_stack_16 *)a);
|
||||||
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_16(NULL)
|
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_16(NULL)
|
||||||
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
|
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
|
||||||
a = pcre2_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),G(h,16))
|
a = pcre2_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),G(h,16))
|
||||||
|
@ -1371,6 +1426,11 @@ the three different cases. */
|
||||||
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
|
#define PCRE2_GET_ERROR_MESSAGE(r,a,b) \
|
||||||
r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size))
|
r = pcre2_get_error_message_32(a,G(b,32),G(G(b,32),_size))
|
||||||
#define PCRE2_JIT_COMPILE(a,b,c) pcre2_jit_compile_32(G(a,32),b,G(c,32))
|
#define PCRE2_JIT_COMPILE(a,b,c) pcre2_jit_compile_32(G(a,32),b,G(c,32))
|
||||||
|
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
|
||||||
|
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_32(b,c,d);
|
||||||
|
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
|
||||||
|
pcre2_jit_stack_assign_32(G(a,32),(pcre2_jit_callback_32)b,c);
|
||||||
|
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_32((pcre2_jit_stack_32 *)a);
|
||||||
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
|
#define PCRE2_MATCH(a,b,c,d,e,f,g,h) \
|
||||||
a = pcre2_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),g(h,32))
|
a = pcre2_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),g(h,32))
|
||||||
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_32(NULL)
|
#define PCRE2_MAKETABLES(a) a = pcre2_maketables_32(NULL)
|
||||||
|
@ -1807,6 +1867,18 @@ return depth > pat_patctl.stackguard_test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
* JIT memory callback *
|
||||||
|
*************************************************/
|
||||||
|
|
||||||
|
static PCRE2_JIT_STACK*
|
||||||
|
jit_callback(void *arg)
|
||||||
|
{
|
||||||
|
jit_was_used = TRUE;
|
||||||
|
return (PCRE2_JIT_STACK *)arg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
* Convert UTF-8 character to code point *
|
* Convert UTF-8 character to code point *
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
@ -3641,7 +3713,9 @@ if (TEST(compiled_code, ==, NULL))
|
||||||
/* Call the JIT compiler if requested. */
|
/* Call the JIT compiler if requested. */
|
||||||
|
|
||||||
if (pat_patctl.jit != 0)
|
if (pat_patctl.jit != 0)
|
||||||
{ PCRE2_JIT_COMPILE(compiled_code, pat_patctl.jit, dat_context); }
|
{
|
||||||
|
PCRE2_JIT_COMPILE(compiled_code, pat_patctl.jit, dat_context);
|
||||||
|
}
|
||||||
|
|
||||||
/* Output code size and other information if requested. */
|
/* Output code size and other information if requested. */
|
||||||
|
|
||||||
|
@ -4329,24 +4403,43 @@ if ((dat_datctl.control & CTL_ANYGLOB) != 0 && dat_datctl.oveccount < 1)
|
||||||
|
|
||||||
show_memory = (dat_datctl.control & CTL_MEMORY) != 0;
|
show_memory = (dat_datctl.control & CTL_MEMORY) != 0;
|
||||||
|
|
||||||
/* Ensure that there is a JIT callback if we want to verify that JIT was
|
/* Create and assign a JIT stack if requested. */
|
||||||
actually used. If jit_stack == NULL, no stack has yet been assigned. */
|
|
||||||
|
if (dat_datctl.jitstack != 0)
|
||||||
|
{
|
||||||
|
if (dat_datctl.jitstack != jit_stack_size)
|
||||||
|
{
|
||||||
|
PCRE2_JIT_STACK_FREE(jit_stack);
|
||||||
|
PCRE2_JIT_STACK_ALLOC(jit_stack, NULL, 1, dat_datctl.jitstack * 1024);
|
||||||
|
jit_stack_size = dat_datctl.jitstack;
|
||||||
|
}
|
||||||
|
PCRE2_JIT_STACK_ASSIGN(compiled_code, jit_callback, jit_stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Or de-assign */
|
||||||
|
|
||||||
|
else if (jit_stack != NULL)
|
||||||
|
{
|
||||||
|
PCRE2_JIT_STACK_ASSIGN(compiled_code, NULL, NULL);
|
||||||
|
PCRE2_JIT_STACK_FREE(jit_stack);
|
||||||
|
jit_stack = NULL;
|
||||||
|
jit_stack_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When no JIT stack is assigned, we must ensure that there is a JIT callback
|
||||||
|
if we want to verify that JIT was actually used. */
|
||||||
|
|
||||||
#ifdef FIXME
|
|
||||||
if ((dat_datctl.control & CTL_JITVERIFY) != 0 && jit_stack == NULL)
|
if ((dat_datctl.control & CTL_JITVERIFY) != 0 && jit_stack == NULL)
|
||||||
{ PCRE2_JIT_STACK_ASSIGN(compiled_code, jit_callback, jit_stack); }
|
{
|
||||||
#endif
|
PCRE2_JIT_STACK_ASSIGN(compiled_code, jit_callback, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Loop for global matching */
|
/* Loop for global matching */
|
||||||
|
|
||||||
for (gmatched = 0;; gmatched++)
|
for (gmatched = 0;; gmatched++)
|
||||||
{
|
{
|
||||||
int capcount;
|
int capcount;
|
||||||
|
|
||||||
#ifdef FIXME
|
|
||||||
jit_was_used = FALSE;
|
jit_was_used = FALSE;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Adjust match_data according to size of offsets required. */
|
/* Adjust match_data according to size of offsets required. */
|
||||||
|
|
||||||
|
@ -4536,9 +4629,8 @@ for (gmatched = 0;; gmatched++)
|
||||||
PCHARSV(pp, start, end - start, utf, outfile);
|
PCHARSV(pp, start, end - start, utf, outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef FIXME
|
if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used)
|
||||||
if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
|
fprintf(outfile, " (JIT)");
|
||||||
#endif
|
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
|
|
||||||
if (showallused)
|
if (showallused)
|
||||||
|
@ -4754,11 +4846,8 @@ for (gmatched = 0;; gmatched++)
|
||||||
|
|
||||||
fprintf(outfile, ": ");
|
fprintf(outfile, ": ");
|
||||||
PCHARSV(pp, leftchar, ulen - leftchar, utf, outfile);
|
PCHARSV(pp, leftchar, ulen - leftchar, utf, outfile);
|
||||||
|
if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used)
|
||||||
#ifdef FIXME
|
fprintf(outfile, " (JIT)");
|
||||||
if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
break; /* Out of the /g loop */
|
break; /* Out of the /g loop */
|
||||||
} /* End of handling partial match */
|
} /* End of handling partial match */
|
||||||
|
@ -4829,11 +4918,8 @@ for (gmatched = 0;; gmatched++)
|
||||||
fprintf(outfile, ", mark = ");
|
fprintf(outfile, ", mark = ");
|
||||||
PCHARSV(CASTFLD(void *, match_data, mark), 0, -1, utf, outfile);
|
PCHARSV(CASTFLD(void *, match_data, mark), 0, -1, utf, outfile);
|
||||||
}
|
}
|
||||||
|
if ((pat_patctl.control & CTL_JITVERIFY) != 0 && jit_was_used)
|
||||||
#ifdef FIXME
|
fprintf(outfile, " (JIT)");
|
||||||
if (verify_jit && jit_was_used) fprintf(outfile, " (JIT)");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(outfile, "\n");
|
fprintf(outfile, "\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5150,8 +5236,6 @@ BOOL skipping = FALSE;
|
||||||
char *arg_subject = NULL;
|
char *arg_subject = NULL;
|
||||||
char *arg_pattern = NULL;
|
char *arg_pattern = NULL;
|
||||||
|
|
||||||
PCRE2_JIT_STACK *jit_stack = NULL;
|
|
||||||
|
|
||||||
/* The offsets to the options and control bits fields of the pattern and data
|
/* The offsets to the options and control bits fields of the pattern and data
|
||||||
control blocks must be the same so that common options and controls such as
|
control blocks must be the same so that common options and controls such as
|
||||||
"anchored" or "memory" can work for either of them from a single table entry.
|
"anchored" or "memory" can work for either of them from a single table entry.
|
||||||
|
@ -5580,6 +5664,11 @@ free((void *)locale_tables);
|
||||||
PCRE2_MATCH_DATA_FREE(match_data);
|
PCRE2_MATCH_DATA_FREE(match_data);
|
||||||
SUB1(pcre2_code_free, compiled_code);
|
SUB1(pcre2_code_free, compiled_code);
|
||||||
|
|
||||||
|
if (jit_stack != NULL)
|
||||||
|
{
|
||||||
|
PCRE2_JIT_STACK_FREE(jit_stack);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SUPPORT_PCRE2_8
|
#ifdef SUPPORT_PCRE2_8
|
||||||
regfree(&preg);
|
regfree(&preg);
|
||||||
pcre2_general_context_free_8(general_context8);
|
pcre2_general_context_free_8(general_context8);
|
||||||
|
@ -5611,10 +5700,6 @@ pcre2_match_context_free_32(default_dat_context32);
|
||||||
yield = SS$_NORMAL; /* Return values via DCL symbols */
|
yield = SS$_NORMAL; /* Return values via DCL symbols */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FIXME: temp avoid compiler warnings. */
|
|
||||||
|
|
||||||
(void)jit_stack;
|
|
||||||
|
|
||||||
return yield;
|
return yield;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue