[Pcre-svn] [100] code/trunk/src: Support for JIT code free a…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [100] code/trunk/src: Support for JIT code free and small partial match optimization.
Revision: 100
          http://www.exim.org/viewvc/pcre2?view=rev&revision=100
Author:   zherczeg
Date:     2014-10-09 11:06:19 +0100 (Thu, 09 Oct 2014)


Log Message:
-----------
Support for JIT code free and small partial match optimization.

Modified Paths:
--------------
    code/trunk/src/pcre2_compile.c
    code/trunk/src/pcre2_internal.h
    code/trunk/src/pcre2_jit_compile.c
    code/trunk/src/pcre2_jit_misc.c


Modified: code/trunk/src/pcre2_compile.c
===================================================================
--- code/trunk/src/pcre2_compile.c    2014-10-08 08:57:26 UTC (rev 99)
+++ code/trunk/src/pcre2_compile.c    2014-10-09 10:06:19 UTC (rev 100)
@@ -677,7 +677,8 @@
 {
 if (code != NULL) 
   {
-  if (code->executable_jit != NULL) PRIV(jit_free(code->executable_jit)); 
+  if (code->executable_jit != NULL)
+    PRIV(jit_free)(code->executable_jit, &code->memctl);
   code->memctl.free(code, code->memctl.memory_data);
   } 
 }


Modified: code/trunk/src/pcre2_internal.h
===================================================================
--- code/trunk/src/pcre2_internal.h    2014-10-08 08:57:26 UTC (rev 99)
+++ code/trunk/src/pcre2_internal.h    2014-10-09 10:06:19 UTC (rev 100)
@@ -1878,7 +1878,7 @@
 extern PCRE2_SPTR _pcre2_find_bracket(PCRE2_SPTR, BOOL, int);
 extern BOOL  _pcre2_is_newline(PCRE2_SPTR, uint32_t, PCRE2_SPTR, uint32_t *,
                BOOL);
-extern void  _pcre2_jit_free(void *);                
+extern void  _pcre2_jit_free(void *, pcre2_memctl *);
 extern size_t _pcre2_jit_get_size(void *);
 extern void  _pcre2_match_context_init(pcre2_match_context *, BOOL);
 extern void  *_pcre2_memctl_malloc(size_t, pcre2_memctl *);


Modified: code/trunk/src/pcre2_jit_compile.c
===================================================================
--- code/trunk/src/pcre2_jit_compile.c    2014-10-08 08:57:26 UTC (rev 99)
+++ code/trunk/src/pcre2_jit_compile.c    2014-10-09 10:06:19 UTC (rev 100)
@@ -352,6 +352,8 @@
   int cbra_ptr;
   /* Output vector starting point. Must be divisible by 2. */
   int ovector_start;
+  /* Points to the starting character of the current match. */
+  int start_ptr;
   /* Last known position of the requested byte. */
   int req_char_ptr;
   /* Head of the last recursion. */
@@ -369,8 +371,6 @@
   int control_head_ptr;
   /* Points to the last matched capture block index. */
   int capture_last_ptr;
-  /* Points to the starting position of the current match. */
-  int start_ptr;


/* Flipped and lower case tables. */
const sljit_ub *fcc;
@@ -2271,7 +2271,7 @@

OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP),
- common->mode == PCRE2_JIT_PARTIAL_SOFT ? (common->hit_start + sizeof(sljit_sw)) : common->start_ptr);
+ common->mode == PCRE2_JIT_PARTIAL_SOFT ? common->hit_start : common->start_ptr);
OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE2_ERROR_PARTIAL);

 /* Store match begin and end. */
@@ -9851,7 +9851,7 @@
   if (mode == PCRE2_JIT_PARTIAL_SOFT)
     {
     common->hit_start = common->ovector_start;
-    common->ovector_start += 2 * sizeof(sljit_sw);
+    common->ovector_start += sizeof(sljit_sw);
     }
   }
 if ((re->overall_options & PCRE2_FIRSTLINE) != 0)
@@ -10015,7 +10015,6 @@
   {
   jump = CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, -1);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
-  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start + sizeof(sljit_sw), STR_PTR, 0);
   JUMPHERE(jump);
   }
 else if (mode == PCRE2_JIT_PARTIAL_HARD)
@@ -10080,7 +10079,7 @@
   {
   /* Update hit_start only in the first time. */
   jump = CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);
-  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr);
+  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, TMP1, 0);
   JUMPHERE(jump);
@@ -10305,6 +10304,7 @@
 else
   mode = (mode == PCRE2_JIT_PARTIAL_SOFT) ? 1 : 2;


+SLJIT_ASSERT(mode >= 0 && mode < JIT_NUMBER_OF_COMPILE_MODES);
functions->executable_funcs[mode] = executable_func;
functions->read_only_data[mode] = common->read_only_data;
functions->executable_sizes[mode] = executable_size;

Modified: code/trunk/src/pcre2_jit_misc.c
===================================================================
--- code/trunk/src/pcre2_jit_misc.c    2014-10-08 08:57:26 UTC (rev 99)
+++ code/trunk/src/pcre2_jit_misc.c    2014-10-09 10:06:19 UTC (rev 100)
@@ -50,15 +50,27 @@
 *************************************************/


void
-PRIV(jit_free)(void *executable_jit)
+PRIV(jit_free)(void *executable_jit, pcre2_memctl *memctl)
{
#ifndef SUPPORT_JIT
(void)executable_jit;
+(void)memctl;
#else /* SUPPORT_JIT */

-/* Dummy code */
-(void)executable_jit;
+executable_functions *functions = (executable_functions *)executable_jit;
+void *allocator_data = memctl;
+int i;

+for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
+  {
+  if (functions->executable_funcs[i] != NULL)
+    sljit_free_code(functions->executable_funcs[i]);
+  if (functions->read_only_data[i] != NULL)
+    SLJIT_FREE(functions->read_only_data[i], allocator_data);
+  }
+
+SLJIT_FREE(functions, allocator_data);
+
 #endif /* SUPPORT_JIT */
 }


@@ -192,6 +204,7 @@
#else /* SUPPORT_JIT */

sljit_uw *executable_sizes = ((executable_functions *)executable_jit)->executable_sizes;
+SLJIT_COMPILE_ASSERT(JIT_NUMBER_OF_COMPILE_MODES == 3, number_of_compile_modes_changed);
return executable_sizes[0] + executable_sizes[1] + executable_sizes[2];

#endif