/[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 1414 by zherczeg, Sun Dec 22 16:27:35 2013 UTC revision 1415 by zherczeg, Sun Dec 22 20:47:08 2013 UTC
# Line 306  typedef struct then_trap_backtrack { Line 306  typedef struct then_trap_backtrack {
306    int framesize;    int framesize;
307  } then_trap_backtrack;  } then_trap_backtrack;
308    
309  #define MAX_RANGE_SIZE 6  #define MAX_RANGE_SIZE 4
310    
311  typedef struct compiler_common {  typedef struct compiler_common {
312    /* The sljit ceneric compiler. */    /* The sljit ceneric compiler. */
# Line 3503  sljit_emit_fast_return(compiler, SLJIT_M Line 3503  sljit_emit_fast_return(compiler, SLJIT_M
3503  static BOOL check_ranges(compiler_common *common, int *ranges, jump_list **backtracks, BOOL readch)  static BOOL check_ranges(compiler_common *common, int *ranges, jump_list **backtracks, BOOL readch)
3504  {  {
3505  DEFINE_COMPILER;  DEFINE_COMPILER;
 struct sljit_jump *jump;  
3506    
3507  if (ranges[0] < 0)  if (ranges[0] < 0 || ranges[0] > 4)
3508    return FALSE;    return FALSE;
3509    
3510    /* No character is accepted. */
3511    if (ranges[0] == 0 && ranges[1] == 0)
3512      add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
3513    
3514    if (readch)
3515      read_char(common);
3516    
3517  switch(ranges[0])  switch(ranges[0])
3518    {    {
3519      case 0:
3520      /* When ranges[1] != 0, all characters are accepted. */
3521      return TRUE;
3522    
3523    case 1:    case 1:
   if (readch)  
     read_char(common);  
3524    add_jump(compiler, backtracks, CMP(ranges[1] == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));    add_jump(compiler, backtracks, CMP(ranges[1] == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3525    return TRUE;    return TRUE;
3526    
3527    case 2:    case 2:
   if (readch)  
     read_char(common);  
3528    if (ranges[2] + 1 != ranges[3])    if (ranges[2] + 1 != ranges[3])
3529      {      {
3530      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
# Line 3529  switch(ranges[0]) Line 3535  switch(ranges[0])
3535    return TRUE;    return TRUE;
3536    
3537    case 3:    case 3:
   if (readch)  
     read_char(common);  
3538    if (ranges[1] != 0)    if (ranges[1] != 0)
3539      {      {
3540      add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));      add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));
# Line 3541  switch(ranges[0]) Line 3545  switch(ranges[0])
3545        }        }
3546      else      else
3547        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3548        return TRUE;
3549        }
3550    
3551      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2]));
3552      if (ranges[3] + 1 != ranges[4])
3553        {
3554        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3]);
3555        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));
3556      }      }
3557    else    else
3558        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3]));
3559      return TRUE;
3560    
3561      case 4:
3562      if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4])
3563          && (ranges[2] | (ranges[4] - ranges[2])) == ranges[4]
3564          && is_powerof2(ranges[4] - ranges[2]))
3565      {      {
3566      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2]));      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[2]);
3567      if (ranges[3] + 1 != ranges[4])      if (ranges[4] + 1 != ranges[5])
3568        {        {
3569        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3]);        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]);
3570        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));        add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));
3571        }        }
3572      else      else
3573        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3]));        add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));
3574        return TRUE;
3575      }      }
   return TRUE;  
3576    
3577    case 4:    if (ranges[1] != 0)
   if (ranges[2] + 1 == ranges[3] && ranges[4] + 1 == ranges[5])  
3578      {      {
3579      if (readch)      if (ranges[2] + 1 != ranges[3])
       read_char(common);  
     if (ranges[1] != 0)  
3580        {        {
3581        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3582        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3583          ranges[4] -= ranges[2];
3584          ranges[5] -= ranges[2];
3585        }        }
3586      else      else
3587          add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3588    
3589        if (ranges[4] + 1 != ranges[5])
3590        {        {
3591        jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]);        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]);
3592        add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));
       JUMPHERE(jump);  
3593        }        }
3594        else
3595          add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));
3596      return TRUE;      return TRUE;
3597      }      }
3598    if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4]) && is_powerof2(ranges[4] - ranges[2]))  
3599      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3600      add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[2]));
3601      if (ranges[3] + 1 != ranges[4])
3602      {      {
3603      if (readch)      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]);
3604        read_char(common);      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));
     OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[2]);  
     OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]);  
     add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));  
     return TRUE;  
3605      }      }
3606    return FALSE;    else
3607        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3608      return TRUE;
3609    
3610    default:    default:
3611      SLJIT_ASSERT_STOP();
3612    return FALSE;    return FALSE;
3613    }    }
3614  }  }

Legend:
Removed from v.1414  
changed lines
  Added in v.1415

  ViewVC Help
Powered by ViewVC 1.1.5