/[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 726 by zherczeg, Sun Oct 9 18:53:25 2011 UTC revision 736 by zherczeg, Sun Oct 16 15:48:03 2011 UTC
# Line 467  switch(*cc) Line 467  switch(*cc)
467    case OP_SKIPZERO:    case OP_SKIPZERO:
468    return cc + 1;    return cc + 1;
469    
470      case OP_ANYBYTE:
471    #ifdef SUPPORT_UTF8
472      if (common->utf8) return NULL;
473    #endif
474      return cc + 1;
475    
476    case OP_CHAR:    case OP_CHAR:
477    case OP_CHARI:    case OP_CHARI:
478    case OP_NOT:    case OP_NOT:
# Line 1336  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(ST Line 1342  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(ST
1342  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1343  if (common->utf8)  if (common->utf8)
1344    {    {
1345    /* Should not found a value between 128 and 192 here. */    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
   jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 192);  
1346    add_jump(compiler, &common->utf8readchar, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->utf8readchar, JUMP(SLJIT_FAST_CALL));
1347    JUMPHERE(jump);    JUMPHERE(jump);
1348    }    }
# Line 1358  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(ST Line 1363  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(ST
1363  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1364  if (common->utf8)  if (common->utf8)
1365    {    {
1366    /* Should not found a value between 128 and 192 here. */    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
   jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 192);  
1367    add_jump(compiler, &common->utf8readchar, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->utf8readchar, JUMP(SLJIT_FAST_CALL));
1368    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
1369    JUMPHERE(jump);    JUMPHERE(jump);
# Line 1383  if (common->utf8) Line 1387  if (common->utf8)
1387    /* This can be an extra read in some situations, but hopefully    /* This can be an extra read in some situations, but hopefully
1388    it is a clever early read in most cases. */    it is a clever early read in most cases. */
1389    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
1390    /* Should not found a value between 128 and 192 here. */    jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0);
   jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 192);  
1391    add_jump(compiler, &common->utf8readtype8, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->utf8readtype8, JUMP(SLJIT_FAST_CALL));
1392    JUMPHERE(jump);    JUMPHERE(jump);
1393    return;    return;
# Line 1444  else Line 1447  else
1447  static void do_utf8readchar(compiler_common *common)  static void do_utf8readchar(compiler_common *common)
1448  {  {
1449  /* Fast decoding an utf8 character. TMP1 contains the first byte  /* Fast decoding an utf8 character. TMP1 contains the first byte
1450  of the character (>= 192). Return char value in TMP1, length - 1 in TMP2. */  of the character (>= 0xc0). Return char value in TMP1, length - 1 in TMP2. */
1451  DEFINE_COMPILER;  DEFINE_COMPILER;
1452  struct sljit_jump *jump;  struct sljit_jump *jump;
1453    
# Line 1527  sljit_emit_fast_return(compiler, RETURN_ Line 1530  sljit_emit_fast_return(compiler, RETURN_
1530  static void do_utf8readtype8(compiler_common *common)  static void do_utf8readtype8(compiler_common *common)
1531  {  {
1532  /* Fast decoding an utf8 character type. TMP2 contains the first byte  /* Fast decoding an utf8 character type. TMP2 contains the first byte
1533  of the character (>= 192) and TMP1 is destroyed. Return value in TMP1. */  of the character (>= 0xc0) and TMP1 is destroyed. Return value in TMP1. */
1534  DEFINE_COMPILER;  DEFINE_COMPILER;
1535  struct sljit_jump *jump;  struct sljit_jump *jump;
1536  struct sljit_jump *compare;  struct sljit_jump *compare;
# Line 1553  sljit_emit_fast_return(compiler, RETURN_ Line 1556  sljit_emit_fast_return(compiler, RETURN_
1556  JUMPHERE(jump);  JUMPHERE(jump);
1557    
1558  /* We only have types for characters less than 256. */  /* We only have types for characters less than 256. */
1559  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_w)_pcre_utf8_char_sizes);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_w)_pcre_utf8_char_sizes - 0xc0);
 OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);  
1560  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1561  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
1562  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
# Line 1598  struct sljit_label *newlinelabel = NULL; Line 1600  struct sljit_label *newlinelabel = NULL;
1600  struct sljit_jump *start;  struct sljit_jump *start;
1601  struct sljit_jump *end = NULL;  struct sljit_jump *end = NULL;
1602  struct sljit_jump *nl = NULL;  struct sljit_jump *nl = NULL;
1603    #ifdef SUPPORT_UTF8
1604    struct sljit_jump *singlebyte;
1605    #endif
1606  jump_list *newline = NULL;  jump_list *newline = NULL;
1607  BOOL newlinecheck = FALSE;  BOOL newlinecheck = FALSE;
1608  BOOL readbyte = FALSE;  BOOL readbyte = FALSE;
# Line 1668  if (readbyte) Line 1673  if (readbyte)
1673  if (newlinecheck)  if (newlinecheck)
1674    CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, newlinelabel);    CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, newlinelabel);
1675    
1676    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
1677  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1678  if (common->utf8)  if (common->utf8)
1679    {    {
1680    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes);    singlebyte = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
1681      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes - 0xc0);
1682    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1683      JUMPHERE(singlebyte);
1684    }    }
 else  
   OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  
 #else  
 OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  
1685  #endif  #endif
1686  JUMPHERE(start);  JUMPHERE(start);
1687    
# Line 1730  else Line 1734  else
1734      }      }
1735    }    }
1736    
1737    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
1738  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1739  if (common->utf8)  if (common->utf8)
1740    {    {
1741    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
1742      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes - 0xc0);
1743    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1744    }    }
 else  
   OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  
 #else  
 OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  
1745  #endif  #endif
1746  JUMPTO(SLJIT_JUMP, start);  JUMPTO(SLJIT_JUMP, start);
1747  JUMPHERE(found);  JUMPHERE(found);
# Line 1846  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_P Line 1848  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_P
1848  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1849  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1850  if (common->utf8)  if (common->utf8)
1851    OP1(SLJIT_MOV_UB, TMP3, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
1852  #endif  #endif
1853  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
1854  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
# Line 1857  found = JUMP(SLJIT_C_NOT_ZERO); Line 1859  found = JUMP(SLJIT_C_NOT_ZERO);
1859    
1860  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1861  if (common->utf8)  if (common->utf8)
1862    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP3, 0);    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
1863  else  #endif
   OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  
 #else  
1864  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
1865    #ifdef SUPPORT_UTF8
1866    if (common->utf8)
1867      {
1868      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
1869      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes - 0xc0);
1870      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1871      }
1872  #endif  #endif
1873  JUMPTO(SLJIT_JUMP, start);  JUMPTO(SLJIT_JUMP, start);
1874  JUMPHERE(found);  JUMPHERE(found);
# Line 2788  switch(type) Line 2795  switch(type)
2795    if (common->utf8)    if (common->utf8)
2796      {      {
2797      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2798      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
2799        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2800        OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes - 0xc0);
2801      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2802        JUMPHERE(jump[0]);
2803      return cc;      return cc;
2804      }      }
2805  #endif  #endif
2806    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
2807    return cc;    return cc;
2808    
2809      case OP_ANYBYTE:
2810      check_input_end(common, fallbacks);
2811      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
2812      return cc;
2813    
2814  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2815  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2816    case OP_NOTPROP:    case OP_NOTPROP:
# Line 3042  switch(type) Line 3057  switch(type)
3057      if (c <= 127)      if (c <= 127)
3058        {        {
3059        OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);        OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
       OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes);  
3060        if (type == OP_NOT || !char_has_othercase(common, cc))        if (type == OP_NOT || !char_has_othercase(common, cc))
3061          add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c));          add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c));
3062        else        else
3063          {          {
3064          /* Since UTF8 code page is fixed, we know that c is in [a-z] or [A-Z] range. */          /* Since UTF8 code page is fixed, we know that c is in [a-z] or [A-Z] range. */
3065          OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x20);          OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x20);
3066          add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, c | 0x20));          add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, c | 0x20));
3067          }          }
3068        /* Skip the variable-length character. */        /* Skip the variable-length character. */
3069        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
3070          jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
3071          OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_char_sizes - 0xc0);
3072          OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
3073          JUMPHERE(jump[0]);
3074        return cc + length;        return cc + length;
3075        }        }
3076      else      else
# Line 4744  while (cc < ccend) Line 4762  while (cc < ccend)
4762      case OP_WORDCHAR:      case OP_WORDCHAR:
4763      case OP_ANY:      case OP_ANY:
4764      case OP_ALLANY:      case OP_ALLANY:
4765        case OP_ANYBYTE:
4766      case OP_NOTPROP:      case OP_NOTPROP:
4767      case OP_PROP:      case OP_PROP:
4768      case OP_ANYNL:      case OP_ANYNL:

Legend:
Removed from v.726  
changed lines
  Added in v.736

  ViewVC Help
Powered by ViewVC 1.1.5