diff --git a/src/pcre2.h.in b/src/pcre2.h.in index 7a550d1..6e93a76 100644 --- a/src/pcre2.h.in +++ b/src/pcre2.h.in @@ -453,8 +453,7 @@ PCRE2_EXP_DECL int pcre2_substring_list_get(pcre2_match_data *, \ PCRE2_EXP_DECL int pcre2_jit_compile(pcre2_code *, uint32_t); \ PCRE2_EXP_DECL int pcre2_jit_match(const pcre2_code *, \ PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, \ - pcre2_match_data *, pcre2_match_context *, \ - pcre2_jit_stack *); \ + 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 *, \ diff --git a/src/pcre2_context.c b/src/pcre2_context.c index 5b9b2f3..9c0b324 100644 --- a/src/pcre2_context.c +++ b/src/pcre2_context.c @@ -161,6 +161,10 @@ const pcre2_match_context PRIV(default_match_context) = { { default_malloc, default_free, NULL }, #ifdef HEAP_MATCH_RECURSE { default_malloc, default_free, NULL }, +#endif +#ifdef SUPPORT_JIT + NULL, + NULL, #endif NULL, NULL, diff --git a/src/pcre2_intmodedep.h b/src/pcre2_intmodedep.h index cbc0fbb..75e0099 100644 --- a/src/pcre2_intmodedep.h +++ b/src/pcre2_intmodedep.h @@ -573,14 +573,14 @@ typedef struct pcre2_real_match_context { #ifdef HEAP_MATCH_RECURSE pcre2_memctl stack_memctl; #endif - int (*callout)(pcre2_callout_block *); - void *callout_data; - uint32_t match_limit; - uint32_t recursion_limit; #ifdef SUPPORT_JIT pcre2_jit_callback jit_callback; void *jit_callback_data; #endif + int (*callout)(pcre2_callout_block *); + void *callout_data; + uint32_t match_limit; + uint32_t recursion_limit; } pcre2_real_match_context; /* The real compiled code structure */ diff --git a/src/pcre2_jit_match.c b/src/pcre2_jit_match.c index f2baa50..2f59031 100644 --- a/src/pcre2_jit_match.c +++ b/src/pcre2_jit_match.c @@ -87,7 +87,7 @@ Returns: > 0 => success; value is the number of ovector pairs filled PCRE2_EXP_DEFN int PCRE2_CALL_CONVENTION pcre2_jit_match(const pcre2_code *code, PCRE2_SPTR subject, PCRE2_SIZE length, PCRE2_SIZE start_offset, uint32_t options, pcre2_match_data *match_data, - pcre2_match_context *mcontext, pcre2_jit_stack *jit_stack) + pcre2_match_context *mcontext) { #ifndef SUPPORT_JIT @@ -105,6 +105,7 @@ return PCRE2_ERROR_JIT_BADOPTION; pcre2_real_code *re = (pcre2_real_code *)code; executable_functions *functions = (executable_functions *)re->executable_jit; +pcre2_jit_stack *jit_stack; uint32_t oveccount = match_data->oveccount; uint32_t max_oveccount; union { @@ -158,8 +159,10 @@ if (oveccount > max_oveccount) oveccount = max_oveccount; arguments.oveccount = oveccount << 1; -if (jit_stack == NULL && mcontext->jit_callback != NULL) +if (mcontext->jit_callback != NULL) jit_stack = mcontext->jit_callback(mcontext->jit_callback_data); +else + jit_stack = (pcre2_jit_stack *)mcontext->jit_callback_data; convert_executable_func.executable_func = functions->executable_funcs[index]; if (jit_stack != NULL) diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c index 7daa8cb..a4b0b43 100644 --- a/src/pcre2_jit_test.c +++ b/src/pcre2_jit_test.c @@ -1295,8 +1295,9 @@ static int regression_tests(void) return_value8[0] = pcre2_match_8(re8, (PCRE2_SPTR8)current->input, strlen(current->input), current->start_offset & OFFSET_MASK, current->match_options, mdata8_1, mcontext8); } else { + pcre2_jit_stack_assign_8(mcontext8, NULL, getstack8()); return_value8[0] = pcre2_jit_match_8(re8, (PCRE2_SPTR8)current->input, strlen(current->input), - current->start_offset & OFFSET_MASK, current->match_options, mdata8_1, mcontext8, getstack8()); + current->start_offset & OFFSET_MASK, current->match_options, mdata8_1, mcontext8); } } #endif @@ -1338,8 +1339,9 @@ static int regression_tests(void) return_value16[0] = pcre2_match_16(re16, regtest_buf16, length16, current->start_offset & OFFSET_MASK, current->match_options, mdata16_1, mcontext16); } else { + pcre2_jit_stack_assign_16(mcontext16, NULL, getstack16()); return_value16[0] = pcre2_jit_match_16(re16, regtest_buf16, length16, - current->start_offset & OFFSET_MASK, current->match_options, mdata16_1, mcontext16, getstack16()); + current->start_offset & OFFSET_MASK, current->match_options, mdata16_1, mcontext16); } } #endif @@ -1381,8 +1383,9 @@ static int regression_tests(void) return_value32[0] = pcre2_match_32(re32, regtest_buf32, length32, current->start_offset & OFFSET_MASK, current->match_options, mdata32_1, mcontext32); } else { + pcre2_jit_stack_assign_32(mcontext32, NULL, getstack32()); return_value32[0] = pcre2_jit_match_32(re32, regtest_buf32, length32, - current->start_offset & OFFSET_MASK, current->match_options, mdata32_1, mcontext32, getstack32()); + current->start_offset & OFFSET_MASK, current->match_options, mdata32_1, mcontext32); } } #endif diff --git a/src/pcre2_match.c b/src/pcre2_match.c index b66dd35..a949aae 100644 --- a/src/pcre2_match.c +++ b/src/pcre2_match.c @@ -6492,7 +6492,7 @@ selected normal or partial matching mode was not compiled). */ if (re->executable_jit != NULL && (options & ~PUBLIC_JIT_MATCH_OPTIONS) == 0) { rc = pcre2_jit_match(code, subject, length, start_offset, options, - match_data, mcontext, NULL); + match_data, mcontext); if (rc != PCRE2_ERROR_JIT_BADOPTION) return rc; } #endif