From c0e4e9fd845e218ac42e4a95f6b1a754357c317b Mon Sep 17 00:00:00 2001 From: zherczeg Date: Sat, 4 Oct 2014 17:05:21 +0000 Subject: [PATCH] Minor fixes. RunTest 1 now works with JIT. --- src/pcre2_jit_compile.c | 34 +++++++++++++++++----------------- src/pcre2_jit_match.c | 5 ++--- src/pcre2_jit_misc.c | 1 + 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c index ae4e649..2828fc0 100644 --- a/src/pcre2_jit_compile.c +++ b/src/pcre2_jit_compile.c @@ -68,7 +68,7 @@ return allocator->malloc(size, allocator->memory_data); static void pcre2_jit_free(void *ptr, void *allocator_data) { pcre2_memctl *allocator = ((pcre2_memctl*)allocator_data); -return allocator->free(ptr, allocator->memory_data); +allocator->free(ptr, allocator->memory_data); } #include "sljit/sljitLir.c" @@ -182,7 +182,6 @@ typedef struct jit_arguments { void *callout_data; /* Everything else after. */ sljit_ui limit_match; - uint32_t real_oveccount; uint32_t oveccount; sljit_ub notbol; sljit_ub noteol; @@ -2245,7 +2244,7 @@ OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif SLJIT_ASSERT(sizeof(PCRE2_SIZE) == 4 || sizeof(PCRE2_SIZE) == 8); if (sizeof(PCRE2_SIZE) == 4) - OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_R2), sizeof(PCRE2_SIZE), SLJIT_S1, 0); + OP1(SLJIT_MOVU_UI, SLJIT_MEM1(SLJIT_R2), sizeof(PCRE2_SIZE), SLJIT_S1, 0); else OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_R2), sizeof(PCRE2_SIZE), SLJIT_S1, 0); OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1); @@ -2272,7 +2271,7 @@ else static SLJIT_INLINE void return_with_partial_match(compiler_common *common, struct sljit_label *quit) { DEFINE_COMPILER; -struct sljit_jump *jump; +sljit_si mov_opcode; SLJIT_COMPILE_ASSERT(STR_END == SLJIT_S1, str_end_must_be_saved_reg2); SLJIT_ASSERT(common->start_used_ptr != 0 && common->start_ptr != 0 @@ -2280,33 +2279,33 @@ SLJIT_ASSERT(common->start_used_ptr != 0 && common->start_ptr != 0 OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE2_ERROR_PARTIAL); -OP1(SLJIT_MOV_SI, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, real_oveccount)); -CMPTO(SLJIT_SIG_LESS, SLJIT_R2, 0, SLJIT_IMM, 2, quit); +OP1(SLJIT_MOV_SI, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, oveccount)); +CMPTO(SLJIT_SIG_LESS, SLJIT_R2, 0, SLJIT_IMM, 1, quit); /* Store match begin and end. */ OP1(SLJIT_MOV, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, begin)); OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, ovector)); -jump = CMP(SLJIT_SIG_LESS, SLJIT_R2, 0, SLJIT_IMM, 3); +mov_opcode = (sizeof(PCRE2_SIZE) == 4) ? SLJIT_MOV_UI : SLJIT_MOV; + OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == PCRE2_JIT_PARTIAL_HARD ? common->start_ptr : (common->hit_start + (int)sizeof(sljit_sw)), SLJIT_S0, 0); #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 OP2(SLJIT_ASHR, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), 2 * sizeof(int), SLJIT_R2, 0); -JUMPHERE(jump); +OP1(mov_opcode, SLJIT_MEM1(SLJIT_R1), 2 * sizeof(PCRE2_SIZE), SLJIT_R2, 0); OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == PCRE2_JIT_PARTIAL_HARD ? common->start_used_ptr : common->hit_start); OP2(SLJIT_SUB, SLJIT_S1, 0, STR_END, 0, SLJIT_S0, 0); #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), sizeof(int), SLJIT_S1, 0); +OP1(mov_opcode, SLJIT_MEM1(SLJIT_R1), sizeof(PCRE2_SIZE), SLJIT_S1, 0); OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_S0, 0); #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 OP2(SLJIT_ASHR, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, UCHAR_SHIFT); #endif -OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R2, 0); +OP1(mov_opcode, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R2, 0); JUMPTO(SLJIT_JUMP, quit); } @@ -6316,7 +6315,7 @@ int i; if (arguments->callout == NULL) return 0; -callout_block->version = 2; +callout_block->version = 0; callout_block->callout_data = arguments->callout_data; /* Offsets in subject. */ @@ -6338,9 +6337,10 @@ for (i = 2; i < oveccount; i += 2) callout_block->capture_top = (callout_block->capture_top >> 1) + 1; if (oveccount > 0) + { ovector[0] = PCRE2_UNSET; -if (oveccount > 1) ovector[1] = PCRE2_UNSET; + } return (arguments->callout)(callout_block); } @@ -10317,7 +10317,7 @@ else return PCRE2_ERROR_NOMEMORY; } memset(functions, 0, sizeof(executable_functions)); - functions->top_bracket = (re->top_bracket + 1) * 2; + functions->top_bracket = re->top_bracket + 1; functions->limit_match = re->limit_match; re->executable_jit = functions; } @@ -10377,21 +10377,21 @@ if ((options & ~PUBLIC_JIT_COMPILE_OPTIONS) != 0) functions = (executable_functions *)re->executable_jit; if ((options & PCRE2_JIT_COMPLETE) != 0 && (functions == NULL - || functions->executable_funcs[PCRE2_JIT_COMPLETE] == NULL)) { + || functions->executable_funcs[0] == NULL)) { result = jit_compile(code, PCRE2_JIT_COMPLETE); if (result != 0) return result; } if ((options & PCRE2_JIT_PARTIAL_SOFT) != 0 && (functions == NULL - || functions->executable_funcs[PCRE2_JIT_PARTIAL_SOFT] == NULL)) { + || functions->executable_funcs[1] == NULL)) { result = jit_compile(code, PCRE2_JIT_PARTIAL_SOFT); if (result != 0) return result; } if ((options & PCRE2_JIT_PARTIAL_HARD) != 0 && (functions == NULL - || functions->executable_funcs[PCRE2_JIT_PARTIAL_HARD] == NULL)) { + || functions->executable_funcs[2] == NULL)) { result = jit_compile(code, PCRE2_JIT_PARTIAL_HARD); if (result != 0) return result; diff --git a/src/pcre2_jit_match.c b/src/pcre2_jit_match.c index d110c0d..6b960f7 100644 --- a/src/pcre2_jit_match.c +++ b/src/pcre2_jit_match.c @@ -143,7 +143,6 @@ if (mcontext != NULL) arguments.callout = mcontext->callout; arguments.callout_data = mcontext->callout_data; } -arguments.real_oveccount = oveccount; /* pcre_exec() rounds offset_count to a multiple of 3, and then uses only 2/3 of the output vector for storing captured strings, with the remainder used as @@ -154,7 +153,7 @@ gets the same result with and without JIT. */ max_oveccount = functions->top_bracket; if (oveccount > max_oveccount) oveccount = max_oveccount; -arguments.oveccount = oveccount; +arguments.oveccount = oveccount << 1; convert_executable_func.executable_func = functions->executable_funcs[index]; if (jit_stack != NULL) @@ -165,7 +164,7 @@ if (jit_stack != NULL) else rc = jit_machine_stack_exec(&arguments, convert_executable_func.call_executable_func); -if (rc * 2 > oveccount) +if (rc > (int)oveccount) rc = 0; match_data->code = re; match_data->subject = subject; diff --git a/src/pcre2_jit_misc.c b/src/pcre2_jit_misc.c index f681007..f797ee0 100644 --- a/src/pcre2_jit_misc.c +++ b/src/pcre2_jit_misc.c @@ -62,6 +62,7 @@ pcre2_jit_free_unused_memory(pcre2_general_context *gcontext) #else /* SUPPORT_JIT */ /* Dummy code */ +SLJIT_UNUSED_ARG(gcontext); sljit_free_unused_memory_exec(); #endif /* SUPPORT_JIT */