/[pcre]/code/tags/pcre-8.37/pcre_jit_compile.c
ViewVC logotype

Diff of /code/tags/pcre-8.37/pcre_jit_compile.c

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

revision 1221 by ph10, Sun Nov 11 20:27:03 2012 UTC revision 1244 by zherczeg, Tue Feb 5 12:03:43 2013 UTC
# Line 2573  DEFINE_COMPILER; Line 2573  DEFINE_COMPILER;
2573  struct sljit_label *start;  struct sljit_label *start;
2574  struct sljit_jump *quit;  struct sljit_jump *quit;
2575  pcre_uint32 chars[MAX_N_CHARS * 2];  pcre_uint32 chars[MAX_N_CHARS * 2];
2576  pcre_uchar *cc = common->start + 1 + IMM2_SIZE;  pcre_uchar *cc = common->start + 1 + LINK_SIZE;
2577  int location = 0;  int location = 0;
2578  pcre_int32 len, c, bit, caseless;  pcre_int32 len, c, bit, caseless;
2579  int must_stop;  int must_stop;
# Line 2696  if (firstline) Line 2696  if (firstline)
2696    {    {
2697    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
2698    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
2699    OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, (location >> 1) - 1);    OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
2700    }    }
2701  else  else
2702    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, (location >> 1) - 1);    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
2703    
2704  start = LABEL();  start = LABEL();
2705  quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
# Line 2728  JUMPHERE(quit); Line 2728  JUMPHERE(quit);
2728  if (firstline)  if (firstline)
2729    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
2730  else  else
2731    OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, (location >> 1) - 1);    OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
2732  return TRUE;  return TRUE;
2733  }  }
2734    
# Line 2877  if (firstline) Line 2877  if (firstline)
2877    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
2878  }  }
2879    
2880    static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, jump_list **backtracks);
2881    
2882  static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, sljit_uw start_bits, BOOL firstline)  static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, sljit_uw start_bits, BOOL firstline)
2883  {  {
2884  DEFINE_COMPILER;  DEFINE_COMPILER;
2885  struct sljit_label *start;  struct sljit_label *start;
2886  struct sljit_jump *quit;  struct sljit_jump *quit;
2887  struct sljit_jump *found;  struct sljit_jump *found = NULL;
2888    jump_list *matches = NULL;
2889    pcre_uint8 inverted_start_bits[32];
2890    int i;
2891  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
2892  struct sljit_jump *jump;  struct sljit_jump *jump;
2893  #endif  #endif
2894    
2895    for (i = 0; i < 32; ++i)
2896      inverted_start_bits[i] = ~(((pcre_uint8*)start_bits)[i]);
2897    
2898  if (firstline)  if (firstline)
2899    {    {
2900    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
# Line 2901  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_P Line 2909  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_P
2909  if (common->utf)  if (common->utf)
2910    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
2911  #endif  #endif
2912    
2913    if (!check_class_ranges(common, inverted_start_bits, (inverted_start_bits[31] & 0x80) != 0, &matches))
2914      {
2915  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
2916  jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255);
2917  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 255);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 255);
2918  JUMPHERE(jump);    JUMPHERE(jump);
2919  #endif  #endif
2920  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
2921  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
2922  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);
2923  OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
2924  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
2925  found = JUMP(SLJIT_C_NOT_ZERO);    found = JUMP(SLJIT_C_NOT_ZERO);
2926      }
2927    
2928  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
2929  if (common->utf)  if (common->utf)
# Line 2939  if (common->utf) Line 2951  if (common->utf)
2951  #endif /* COMPILE_PCRE[8|16] */  #endif /* COMPILE_PCRE[8|16] */
2952  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
2953  JUMPTO(SLJIT_JUMP, start);  JUMPTO(SLJIT_JUMP, start);
2954  JUMPHERE(found);  if (found != NULL)
2955      JUMPHERE(found);
2956    if (matches != NULL)
2957      set_jumps(matches, LABEL());
2958  JUMPHERE(quit);  JUMPHERE(quit);
2959    
2960  if (firstline)  if (firstline)
# Line 3577  do Line 3592  do
3592  #endif  #endif
3593    
3594    context->length -= IN_UCHARS(1);    context->length -= IN_UCHARS(1);
3595  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED) && (defined COMPILE_PCRE8 || defined COMPILE_PCRE16)
3596    
3597    /* Unaligned read is supported. */    /* Unaligned read is supported. */
3598    if (othercasebit != 0 && othercasechar == cc)    if (othercasebit != 0 && othercasechar == cc)
# Line 3594  do Line 3609  do
3609    
3610  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
3611    if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))    if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
3612  #elif defined COMPILE_PCRE16  #else
3613    if (context->ucharptr >= 2 || context->length == 0)    if (context->ucharptr >= 2 || context->length == 0)
 #elif defined COMPILE_PCRE32  
   if (1 /* context->ucharptr >= 1 || context->length == 0 */)  
3614  #endif  #endif
3615      {      {
 #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16  
3616      if (context->length >= 4)      if (context->length >= 4)
3617        OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
 #if defined COMPILE_PCRE8  
3618      else if (context->length >= 2)      else if (context->length >= 2)
3619        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
3620    #if defined COMPILE_PCRE8
3621      else if (context->length >= 1)      else if (context->length >= 1)
3622        OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
3623  #elif defined COMPILE_PCRE16  #endif /* COMPILE_PCRE8 */
     else if (context->length >= 2)  
       OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);  
 #endif /* COMPILE_PCRE[8|16] */  
 #elif defined COMPILE_PCRE32  
     OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);  
 #endif /* COMPILE_PCRE[8|16|32] */  
3624      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
3625    
3626      switch(context->ucharptr)      switch(context->ucharptr)
# Line 3625  do Line 3631  do
3631        add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));        add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));
3632        break;        break;
3633    
 #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16  
3634        case 2 / sizeof(pcre_uchar):        case 2 / sizeof(pcre_uchar):
3635        if (context->oc.asushort != 0)        if (context->oc.asushort != 0)
3636          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asushort);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asushort);
# Line 3640  do Line 3645  do
3645        break;        break;
3646  #endif  #endif
3647    
 #endif /* COMPILE_PCRE[8|16] */  
   
3648        default:        default:
3649        SLJIT_ASSERT_STOP();        SLJIT_ASSERT_STOP();
3650        break;        break;
# Line 3651  do Line 3654  do
3654    
3655  #else  #else
3656    
3657    /* Unaligned read is unsupported. */    /* Unaligned read is unsupported or in 32 bit mode. */
3658    if (context->length > 0)    if (context->length >= 1)
3659      OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
3660    
3661    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;

Legend:
Removed from v.1221  
changed lines
  Added in v.1244

  ViewVC Help
Powered by ViewVC 1.1.5