/[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 1051 by zherczeg, Tue Oct 2 08:18:24 2012 UTC revision 1052 by zherczeg, Wed Oct 3 11:36:18 2012 UTC
# Line 1692  SLJIT_ASSERT(cc == ccend && stackptr == Line 1692  SLJIT_ASSERT(cc == ccend && stackptr ==
1692  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2A  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
1693  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2B  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
1694    
1695  static SLJIT_INLINE BOOL ispowerof2(unsigned int value)  static SLJIT_INLINE BOOL is_powerof2(unsigned int value)
1696  {  {
1697  return (value & (value - 1)) == 0;  return (value & (value - 1)) == 0;
1698  }  }
# Line 1998  if (c <= 127 && bit == 0x20) Line 1998  if (c <= 127 && bit == 0x20)
1998    return (0 << 8) | 0x20;    return (0 << 8) | 0x20;
1999    
2000  /* Since c != oc, they must have at least 1 bit difference. */  /* Since c != oc, they must have at least 1 bit difference. */
2001  if (!ispowerof2(bit))  if (!is_powerof2(bit))
2002    return 0;    return 0;
2003    
2004  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
# Line 2765  if (first_char == oc) Line 2765  if (first_char == oc)
2765  else  else
2766    {    {
2767    bit = first_char ^ oc;    bit = first_char ^ oc;
2768    if (ispowerof2(bit))    if (is_powerof2(bit))
2769      {      {
2770      OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);
2771      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, first_char | bit);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, first_char | bit);
# Line 2983  if (req_char == oc) Line 2983  if (req_char == oc)
2983  else  else
2984    {    {
2985    bit = req_char ^ oc;    bit = req_char ^ oc;
2986    if (ispowerof2(bit))    if (is_powerof2(bit))
2987      {      {
2988      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);
2989      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, req_char | bit);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, req_char | bit);
# Line 3213  switch(ranges[0]) Line 3213  switch(ranges[0])
3213        }        }
3214      return TRUE;      return TRUE;
3215      }      }
3216    if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4]) && ispowerof2(ranges[4] - ranges[2]))    if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4]) && is_powerof2(ranges[4] - ranges[2]))
3217      {      {
3218      if (readch)      if (readch)
3219        read_char(common);        read_char(common);
# Line 4019  while (*cc != XCL_END) Line 4019  while (*cc != XCL_END)
4019        case PT_CLIST:        case PT_CLIST:
4020        other_cases = PRIV(ucd_caseless_sets) + cc[1];        other_cases = PRIV(ucd_caseless_sets) + cc[1];
4021    
4022        /* At least two characters are required. */        /* At least three characters are required.
4023        SLJIT_ASSERT(other_cases[0] != NOTACHAR && other_cases[1] != NOTACHAR);           Otherwise this case would be handled by the normal code path. */
4024          SLJIT_ASSERT(other_cases[0] != NOTACHAR && other_cases[1] != NOTACHAR && other_cases[2] != NOTACHAR);
4025          SLJIT_ASSERT(other_cases[0] < other_cases[1] && other_cases[1] < other_cases[2]);
4026    
4027        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);        /* Optimizing character pairs, if their difference is power of 2. */
4028        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);        if (is_powerof2(other_cases[1] ^ other_cases[0]))
4029            {
4030            if (charoffset == 0)
4031              OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4032            else
4033              {
4034              OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_w)charoffset);
4035              OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4036              }
4037            OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[1]);
4038            COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
4039            other_cases += 2;
4040            }
4041          else if (is_powerof2(other_cases[2] ^ other_cases[1]))
4042            {
4043            if (charoffset == 0)
4044              OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);
4045            else
4046              {
4047              OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_w)charoffset);
4048              OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4049              }
4050            OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]);
4051            COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
4052    
4053            OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, other_cases[0] - charoffset);
4054            COND_VALUE(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, SLJIT_C_EQUAL);
4055    
4056            other_cases += 3;
4057            }
4058          else
4059            {
4060            OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);
4061            COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
4062            }
4063    
4064        do        while (*other_cases != NOTACHAR)
4065          {          {
4066          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);
4067          COND_VALUE(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, SLJIT_C_EQUAL);          COND_VALUE(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, SLJIT_C_EQUAL);
4068          }          }
       while (*other_cases != NOTACHAR);  
4069        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4070        break;        break;
4071        }        }
# Line 4458  switch(type) Line 4493  switch(type)
4493      }      }
4494    oc = char_othercase(common, c);    oc = char_othercase(common, c);
4495    bit = c ^ oc;    bit = c ^ oc;
4496    if (ispowerof2(bit))    if (is_powerof2(bit))
4497      {      {
4498      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);
4499      add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));      add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));
# Line 4519  switch(type) Line 4554  switch(type)
4554      {      {
4555      oc = char_othercase(common, c);      oc = char_othercase(common, c);
4556      bit = c ^ oc;      bit = c ^ oc;
4557      if (ispowerof2(bit))      if (is_powerof2(bit))
4558        {        {
4559        OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);        OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);
4560        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));

Legend:
Removed from v.1051  
changed lines
  Added in v.1052

  ViewVC Help
Powered by ViewVC 1.1.5