/[pcre]/code/trunk/pcre_jit_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_jit_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 914 by zherczeg, Mon Feb 13 06:04:50 2012 UTC revision 915 by zherczeg, Tue Feb 14 13:05:39 2012 UTC
# Line 163  typedef struct jit_arguments { Line 163  typedef struct jit_arguments {
163  } jit_arguments;  } jit_arguments;
164    
165  typedef struct executable_functions {  typedef struct executable_functions {
166    void *executable_funcs[JIT_NUMBER_OF_COMPILE_TYPES];    void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];
167    PUBL(jit_callback) callback;    PUBL(jit_callback) callback;
168    void *userdata;    void *userdata;
169    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_TYPES];    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
170  } executable_functions;  } executable_functions;
171    
172  typedef struct jump_list {  typedef struct jump_list {
# Line 2590  const pcre_uchar *end2 = args->end; Line 2590  const pcre_uchar *end2 = args->end;
2590  while (src1 < end1)  while (src1 < end1)
2591    {    {
2592    if (src2 >= end2)    if (src2 >= end2)
2593      return 0;      return (pcre_uchar*)1;
2594    GETCHARINC(c1, src1);    GETCHARINC(c1, src1);
2595    GETCHARINC(c2, src2);    GETCHARINC(c2, src2);
2596    if (c1 != c2 && c1 != UCD_OTHERCASE(c2)) return 0;    if (c1 != c2 && c1 != UCD_OTHERCASE(c2)) return NULL;
2597    }    }
2598  return src2;  return src2;
2599  }  }
# Line 3288  switch(type) Line 3288  switch(type)
3288    
3289    OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
3290    JUMPHERE(jump[0]);    JUMPHERE(jump[0]);
3291      if (common->mode == JIT_PARTIAL_HARD_COMPILE)
3292        {
3293        jump[0] = CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0);
3294        check_partial(common);
3295        JUMPHERE(jump[0]);
3296        }
3297    return cc;    return cc;
3298  #endif  #endif
3299    
# Line 3727  static pcre_uchar *compile_ref_hotpath(c Line 3733  static pcre_uchar *compile_ref_hotpath(c
3733  DEFINE_COMPILER;  DEFINE_COMPILER;
3734  int offset = GET2(cc, 1) << 1;  int offset = GET2(cc, 1) << 1;
3735  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
3736    struct sljit_jump *partial;
3737    struct sljit_jump *nopartial;
3738    
3739  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
3740  /* OVECTOR(1) contains the "string begin - 1" constant. */  /* OVECTOR(1) contains the "string begin - 1" constant. */
# Line 3741  if (common->utf && *cc == OP_REFI) Line 3749  if (common->utf && *cc == OP_REFI)
3749    if (withchecks)    if (withchecks)
3750      jump = CMP(SLJIT_C_EQUAL, TMP1, 0, TMP2, 0);      jump = CMP(SLJIT_C_EQUAL, TMP1, 0, TMP2, 0);
3751    
   if (common->mode != JIT_COMPILE)  
     fallback_at_str_end(common, fallbacks);  
   
3752    /* Needed to save important temporary registers. */    /* Needed to save important temporary registers. */
3753    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
3754    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, ARGUMENTS, 0);    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, ARGUMENTS, 0);
3755    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), SLJIT_OFFSETOF(jit_arguments, ptr), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), SLJIT_OFFSETOF(jit_arguments, ptr), STR_PTR, 0);
3756    sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp));    sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp));
3757    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
3758    add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));    if (common->mode == JIT_COMPILE)
3759        add_jump(compiler, fallbacks, CMP(SLJIT_C_LESS_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1));
3760      else
3761        {
3762        add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));
3763        nopartial = CMP(SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
3764        check_partial(common);
3765        add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3766        JUMPHERE(nopartial);
3767        }
3768    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0);    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0);
3769    }    }
3770  else  else
# Line 3760  else Line 3774  else
3774    if (withchecks)    if (withchecks)
3775      jump = JUMP(SLJIT_C_ZERO);      jump = JUMP(SLJIT_C_ZERO);
3776    
   if (common->mode != JIT_COMPILE)  
     fallback_at_str_end(common, fallbacks);  
   
3777    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
3778      partial = CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0);
3779      if (common->mode == JIT_COMPILE)
3780        add_jump(compiler, fallbacks, partial);
3781    
   add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));  
3782    add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
3783    add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));    add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
3784    
3785      if (common->mode != JIT_COMPILE)
3786        {
3787        nopartial = JUMP(SLJIT_JUMP);
3788        JUMPHERE(partial);
3789        /* TMP2 -= STR_END - STR_PTR */
3790        OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, STR_PTR, 0);
3791        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, STR_END, 0);
3792        partial = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0);
3793        OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0);
3794        add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
3795        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
3796        JUMPHERE(partial);
3797        check_partial(common);
3798        add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3799        JUMPHERE(nopartial);
3800        }
3801    }    }
3802    
3803  if (jump != NULL)  if (jump != NULL)
# Line 7027  PRIV(jit_free)(void *executable_funcs) Line 7057  PRIV(jit_free)(void *executable_funcs)
7057  {  {
7058  int i;  int i;
7059  executable_functions *functions = (executable_functions *)executable_funcs;  executable_functions *functions = (executable_functions *)executable_funcs;
7060  for (i = 0; i < JIT_NUMBER_OF_COMPILE_TYPES; i++)  for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
7061    {    {
7062    if (functions->executable_funcs[i] != NULL)    if (functions->executable_funcs[i] != NULL)
7063      sljit_free_code(functions->executable_funcs[i]);      sljit_free_code(functions->executable_funcs[i]);

Legend:
Removed from v.914  
changed lines
  Added in v.915

  ViewVC Help
Powered by ViewVC 1.1.5