/[pcre]/code/branches/pcre16/pcre_jit_compile.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_jit_compile.c

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

revision 763 by zherczeg, Tue Nov 22 21:46:22 2011 UTC revision 782 by zherczeg, Sat Dec 3 23:58:37 2011 UTC
# Line 62  system files. */ Line 62  system files. */
62  #include "sljit/sljitLir.c"  #include "sljit/sljitLir.c"
63    
64  #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED  #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED
65  #error "Unsupported architecture"  #error Unsupported architecture
66  #endif  #endif
67    
68  /* Allocate memory on the stack. Fast, but limited size. */  /* Allocate memory on the stack. Fast, but limited size. */
# Line 148  Thus we can restore the locals to a part Line 148  Thus we can restore the locals to a part
148  typedef struct jit_arguments {  typedef struct jit_arguments {
149    /* Pointers first. */    /* Pointers first. */
150    struct sljit_stack *stack;    struct sljit_stack *stack;
151    PCRE_SPTR str;    const pcre_uchar *str;
152    PCRE_SPTR begin;    const pcre_uchar *begin;
153    PCRE_SPTR end;    const pcre_uchar *end;
154    int *offsets;    int *offsets;
155    pcre_uchar *ptr;    pcre_uchar *ptr;
156    /* Everything else after. */    /* Everything else after. */
# Line 298  typedef struct compiler_common { Line 298  typedef struct compiler_common {
298    jump_list *caselesscmp;    jump_list *caselesscmp;
299    BOOL jscript_compat;    BOOL jscript_compat;
300  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
301    BOOL utf8;    BOOL utf;
302  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
303    BOOL useucp;    BOOL useucp;
304  #endif  #endif
305    jump_list *utf8readchar;    jump_list *utfreadchar;
306    jump_list *utf8readtype8;  #ifdef COMPILE_PCRE8
307      jump_list *utfreadtype8;
308  #endif  #endif
309    #endif /* SUPPORT_UTF8 */
310  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
311    jump_list *getucd;    jump_list *getucd;
312  #endif  #endif
# Line 316  typedef struct compare_context { Line 318  typedef struct compare_context {
318    int length;    int length;
319    int sourcereg;    int sourcereg;
320  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
321    int byteptr;    int ucharptr;
322    union {    union {
323      int asint;      sljit_i asint;
324      short asshort;      sljit_h asshort;
325    #ifdef COMPILE_PCRE8
326      sljit_ub asbyte;      sljit_ub asbyte;
327      sljit_ub asbytes[4];      sljit_ub asuchars[4];
328    #else
329    #ifdef COMPILE_PCRE16
330        sljit_uh asuchars[2];
331    #endif
332    #endif
333    } c;    } c;
334    union {    union {
335      int asint;      sljit_i asint;
336      short asshort;      sljit_h asshort;
337    #ifdef COMPILE_PCRE8
338      sljit_ub asbyte;      sljit_ub asbyte;
339      sljit_ub asbytes[4];      sljit_ub asuchars[4];
340    #else
341    #ifdef COMPILE_PCRE16
342        sljit_uh asuchars[2];
343    #endif
344    #endif
345    } oc;    } oc;
346  #endif  #endif
347  } compare_context;  } compare_context;
# Line 363  enum { Line 377  enum {
377  /* Max limit of recursions. */  /* Max limit of recursions. */
378  #define CALL_LIMIT       (5 * sizeof(sljit_w))  #define CALL_LIMIT       (5 * sizeof(sljit_w))
379  /* Last known position of the requested byte. */  /* Last known position of the requested byte. */
380  #define REQ_BYTE_PTR     (6 * sizeof(sljit_w))  #define REQ_CHAR_PTR     (6 * sizeof(sljit_w))
381  /* End pointer of the first line. */  /* End pointer of the first line. */
382  #define FIRSTLINE_END    (7 * sizeof(sljit_w))  #define FIRSTLINE_END    (7 * sizeof(sljit_w))
383  /* The output vector is stored on the stack, and contains pointers  /* The output vector is stored on the stack, and contains pointers
# Line 373  the start pointers when the end of the c Line 387  the start pointers when the end of the c
387  #define OVECTOR_START    (8 * sizeof(sljit_w))  #define OVECTOR_START    (8 * sizeof(sljit_w))
388  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))
389  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))
390  #define PRIV(cc)         (common->localptrs[(cc) - common->start])  #define PRIV_DATA(cc)    (common->localptrs[(cc) - common->start])
391    
392    #ifdef COMPILE_PCRE8
393    #define MOV_UCHAR SLJIT_MOV_UB
394    #else
395    #ifdef COMPILE_PCRE16
396    #define MOV_UCHAR SLJIT_MOV_UH
397    #else
398    #error Unsupported compiling mode
399    #endif
400    #endif
401    
402  /* Shortcuts. */  /* Shortcuts. */
403  #define DEFINE_COMPILER \  #define DEFINE_COMPILER \
# Line 475  switch(*cc) Line 499  switch(*cc)
499    
500    case OP_ANYBYTE:    case OP_ANYBYTE:
501  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
502    if (common->utf8) return NULL;    if (common->utf) return NULL;
503  #endif  #endif
504    return cc + 1;    return cc + 1;
505    
# Line 521  switch(*cc) Line 545  switch(*cc)
545    case OP_NOTPOSPLUSI:    case OP_NOTPOSPLUSI:
546    case OP_NOTPOSQUERYI:    case OP_NOTPOSQUERYI:
547    cc += 2;    cc += 2;
548  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
549    if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
550  #endif  #endif
551    return cc;    return cc;
552    
# Line 542  switch(*cc) Line 566  switch(*cc)
566    case OP_NOTMINUPTOI:    case OP_NOTMINUPTOI:
567    case OP_NOTEXACTI:    case OP_NOTEXACTI:
568    case OP_NOTPOSUPTOI:    case OP_NOTPOSUPTOI:
569    cc += 4;    cc += 2 + IMM2_SIZE;
570  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
571    if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
572  #endif  #endif
573    return cc;    return cc;
574    
# Line 561  switch(*cc) Line 585  switch(*cc)
585    case OP_RREF:    case OP_RREF:
586    case OP_NRREF:    case OP_NRREF:
587    case OP_CLOSE:    case OP_CLOSE:
588    cc += 3;    cc += 1 + IMM2_SIZE;
589    return cc;    return cc;
590    
591    case OP_CRRANGE:    case OP_CRRANGE:
592    case OP_CRMINRANGE:    case OP_CRMINRANGE:
593    return cc + 5;    return cc + 1 + 2 * IMM2_SIZE;
594    
595    case OP_CLASS:    case OP_CLASS:
596    case OP_NCLASS:    case OP_NCLASS:
597    return cc + 33;    return cc + 1 + 32 / sizeof(pcre_uchar);
598    
599  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
600    case OP_XCLASS:    case OP_XCLASS:
601    return cc + GET(cc, 1);    return cc + GET(cc, 1);
602  #endif  #endif
# Line 602  switch(*cc) Line 626  switch(*cc)
626    case OP_CBRAPOS:    case OP_CBRAPOS:
627    case OP_SCBRA:    case OP_SCBRA:
628    case OP_SCBRAPOS:    case OP_SCBRAPOS:
629    return cc + 1 + LINK_SIZE + 2;    return cc + 1 + LINK_SIZE + IMM2_SIZE;
630    
631    default:    default:
632    return NULL;    return NULL;
# Line 635  while (cc < ccend) Line 659  while (cc < ccend)
659      case OP_CBRAPOS:      case OP_CBRAPOS:
660      case OP_SCBRAPOS:      case OP_SCBRAPOS:
661      localspace += sizeof(sljit_w);      localspace += sizeof(sljit_w);
662      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
663      break;      break;
664    
665      case OP_COND:      case OP_COND:
# Line 683  while (cc < ccend) Line 707  while (cc < ccend)
707      case OP_SCBRAPOS:      case OP_SCBRAPOS:
708      common->localptrs[cc - common->start] = localptr;      common->localptrs[cc - common->start] = localptr;
709      localptr += sizeof(sljit_w);      localptr += sizeof(sljit_w);
710      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
711      break;      break;
712    
713      case OP_COND:      case OP_COND:
# Line 739  while (cc < ccend) Line 763  while (cc < ccend)
763      case OP_SCBRA:      case OP_SCBRA:
764      case OP_SCBRAPOS:      case OP_SCBRAPOS:
765      length += 3;      length += 3;
766      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
767      break;      break;
768    
769      default:      default:
# Line 802  while (cc < ccend) Line 826  while (cc < ccend)
826      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);
827      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_w);
828    
829      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
830      break;      break;
831    
832      default:      default:
# Line 841  while (cc < ccend) Line 865  while (cc < ccend)
865      case OP_CBRA:      case OP_CBRA:
866      case OP_SCBRA:      case OP_SCBRA:
867      localsize++;      localsize++;
868      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
869      break;      break;
870    
871      case OP_CBRAPOS:      case OP_CBRAPOS:
872      case OP_SCBRAPOS:      case OP_SCBRAPOS:
873      localsize += 2;      localsize += 2;
874      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
875      break;      break;
876    
877      case OP_COND:      case OP_COND:
# Line 938  while (status != end) Line 962  while (status != end)
962        case OP_SBRAPOS:        case OP_SBRAPOS:
963        case OP_SCOND:        case OP_SCOND:
964        count = 1;        count = 1;
965        srcw[0] = PRIV(cc);        srcw[0] = PRIV_DATA(cc);
966        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
967        cc += 1 + LINK_SIZE;        cc += 1 + LINK_SIZE;
968        break;        break;
# Line 947  while (status != end) Line 971  while (status != end)
971        case OP_SCBRA:        case OP_SCBRA:
972        count = 1;        count = 1;
973        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
974        cc += 1 + LINK_SIZE + 2;        cc += 1 + LINK_SIZE + IMM2_SIZE;
975        break;        break;
976    
977        case OP_CBRAPOS:        case OP_CBRAPOS:
978        case OP_SCBRAPOS:        case OP_SCBRAPOS:
979        count = 2;        count = 2;
980        srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
981        srcw[0] = PRIV(cc);        srcw[0] = PRIV_DATA(cc);
982        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
983        cc += 1 + LINK_SIZE + 2;        cc += 1 + LINK_SIZE + IMM2_SIZE;
984        break;        break;
985    
986        case OP_COND:        case OP_COND:
# Line 965  while (status != end) Line 989  while (status != end)
989        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
990          {          {
991          count = 1;          count = 1;
992          srcw[0] = PRIV(cc);          srcw[0] = PRIV_DATA(cc);
993          SLJIT_ASSERT(srcw[0] != 0);          SLJIT_ASSERT(srcw[0] != 0);
994          }          }
995        cc += 1 + LINK_SIZE;        cc += 1 + LINK_SIZE;
# Line 1173  struct sljit_label *loop; Line 1197  struct sljit_label *loop;
1197  int i;  int i;
1198  /* At this point we can freely use all temporary registers. */  /* At this point we can freely use all temporary registers. */
1199  /* TMP1 returns with begin - 1. */  /* TMP1 returns with begin - 1. */
1200  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, 1);  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, IN_UCHARS(1));
1201  if (length < 8)  if (length < 8)
1202    {    {
1203    for (i = 0; i < length; i++)    for (i = 0; i < length; i++)
# Line 1211  loop = LABEL(); Line 1235  loop = LABEL();
1235  OP2(SLJIT_SUB, SLJIT_GENERAL_REG2, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), 0, SLJIT_TEMPORARY_REG1, 0);  OP2(SLJIT_SUB, SLJIT_GENERAL_REG2, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
1236  OP2(SLJIT_ADD, SLJIT_GENERAL_REG1, 0, SLJIT_GENERAL_REG1, 0, SLJIT_IMM, sizeof(sljit_w));  OP2(SLJIT_ADD, SLJIT_GENERAL_REG1, 0, SLJIT_GENERAL_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
1237  /* Copy the integer value to the output buffer */  /* Copy the integer value to the output buffer */
1238    #ifdef COMPILE_PCRE16
1239    OP2(SLJIT_LSHR, SLJIT_GENERAL_REG2, 0, SLJIT_GENERAL_REG2, 0, SLJIT_IMM, 1);
1240    #endif
1241  OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), sizeof(int), SLJIT_GENERAL_REG2, 0);  OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), sizeof(int), SLJIT_GENERAL_REG2, 0);
1242  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
1243  JUMPTO(SLJIT_C_NOT_ZERO, loop);  JUMPTO(SLJIT_C_NOT_ZERO, loop);
# Line 1239  static SLJIT_INLINE BOOL char_has_otherc Line 1266  static SLJIT_INLINE BOOL char_has_otherc
1266  unsigned int c;  unsigned int c;
1267    
1268  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1269  if (common->utf8)  if (common->utf)
1270    {    {
1271    GETCHAR(c, cc);    GETCHAR(c, cc);
1272    if (c > 127)    if (c > 127)
# Line 1254  if (common->utf8) Line 1281  if (common->utf8)
1281  else  else
1282  #endif  #endif
1283    c = *cc;    c = *cc;
1284  return common->fcc[c] != c;  return MAX_255(c) ? common->fcc[c] != c : FALSE;
1285  }  }
1286    
1287  static SLJIT_INLINE unsigned int char_othercase(compiler_common *common, unsigned int c)  static SLJIT_INLINE unsigned int char_othercase(compiler_common *common, unsigned int c)
1288  {  {
1289  /* Returns with the othercase. */  /* Returns with the othercase. */
1290  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1291  if (common->utf8 && c > 127)  if (common->utf && c > 127)
1292    {    {
1293  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
1294    return UCD_OTHERCASE(c);    return UCD_OTHERCASE(c);
# Line 1270  if (common->utf8 && c > 127) Line 1297  if (common->utf8 && c > 127)
1297  #endif  #endif
1298    }    }
1299  #endif  #endif
1300  return common->fcc[c];  return TABLE_GET(c, common->fcc, c);
1301  }  }
1302    
1303  static unsigned int char_get_othercase_bit(compiler_common *common, pcre_uchar* cc)  static unsigned int char_get_othercase_bit(compiler_common *common, pcre_uchar* cc)
1304  {  {
1305  /* Detects if the character and its othercase has only 1 bit difference. */  /* Detects if the character and its othercase has only 1 bit difference. */
1306  unsigned int c, oc, bit;  unsigned int c, oc, bit;
1307  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF8 && defined COMPILE_PCRE8
1308  int n;  int n;
1309  #endif  #endif
1310    
1311  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1312  if (common->utf8)  if (common->utf)
1313    {    {
1314    GETCHAR(c, cc);    GETCHAR(c, cc);
1315    if (c <= 127)    if (c <= 127)
# Line 1299  if (common->utf8) Line 1326  if (common->utf8)
1326  else  else
1327    {    {
1328    c = *cc;    c = *cc;
1329    oc = common->fcc[c];    oc = TABLE_GET(c, common->fcc, c);
1330    }    }
1331  #else  #else
1332  c = *cc;  c = *cc;
1333  oc = common->fcc[c];  oc = TABLE_GET(c, common->fcc, c);
1334  #endif  #endif
1335    
1336  SLJIT_ASSERT(c != oc);  SLJIT_ASSERT(c != oc);
# Line 1317  if (c <= 127 && bit == 0x20) Line 1344  if (c <= 127 && bit == 0x20)
1344  if (!ispowerof2(bit))  if (!ispowerof2(bit))
1345    return 0;    return 0;
1346    
1347    #ifdef COMPILE_PCRE8
1348    
1349  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1350  if (common->utf8 && c > 127)  if (common->utf && c > 127)
1351    {    {
1352    n = _pcre_utf8_table4[*cc & 0x3f];    n = GET_EXTRALEN(*cc);
1353    while ((bit & 0x3f) == 0)    while ((bit & 0x3f) == 0)
1354      {      {
1355      n--;      n--;
# Line 1328  if (common->utf8 && c > 127) Line 1357  if (common->utf8 && c > 127)
1357      }      }
1358    return (n << 8) | bit;    return (n << 8) | bit;
1359    }    }
1360  #endif  #endif /* SUPPORT_UTF8 */
1361  return (0 << 8) | bit;  return (0 << 8) | bit;
1362    
1363    #else /* COMPILE_PCRE8 */
1364    
1365    #ifdef COMPILE_PCRE16
1366    #ifdef SUPPORT_UTF16
1367    if (common->utf && c > 65535)
1368      {
1369      if (bit >= (1 << 10))
1370        bit >>= 10;
1371      else
1372        return (bit <= 255) ? ((2 << 8) | bit) : ((3 << 8) | (bit >> 8));
1373      }
1374    #endif /* SUPPORT_UTF16 */
1375    return (bit <= 255) ? ((0 << 8) | bit) : ((1 << 8) | (bit >> 8));
1376    #endif /* COMPILE_PCRE16 */
1377    
1378    #endif /* COMPILE_PCRE8 */
1379  }  }
1380    
1381  static SLJIT_INLINE void check_input_end(compiler_common *common, jump_list **fallbacks)  static SLJIT_INLINE void check_input_end(compiler_common *common, jump_list **fallbacks)
# Line 1343  static void read_char(compiler_common *c Line 1389  static void read_char(compiler_common *c
1389  /* Reads the character into TMP1, updates STR_PTR.  /* Reads the character into TMP1, updates STR_PTR.
1390  Does not check STR_END. TMP2 Destroyed. */  Does not check STR_END. TMP2 Destroyed. */
1391  DEFINE_COMPILER;  DEFINE_COMPILER;
1392  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1393  struct sljit_jump *jump;  struct sljit_jump *jump;
1394  #endif  #endif
1395    
1396  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1397  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1398  if (common->utf8)  if (common->utf)
1399    {    {
1400    #ifdef COMPILE_PCRE8
1401    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
1402    add_jump(compiler, &common->utf8readchar, JUMP(SLJIT_FAST_CALL));  #else
1403    #ifdef COMPILE_PCRE16
1404      jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
1405    #endif
1406    #endif /* COMPILE_PCRE8 */
1407      add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
1408    JUMPHERE(jump);    JUMPHERE(jump);
1409    }    }
1410  #endif  #endif
1411  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1412  }  }
1413    
1414  static void peek_char(compiler_common *common)  static void peek_char(compiler_common *common)
# Line 1364  static void peek_char(compiler_common *c Line 1416  static void peek_char(compiler_common *c
1416  /* Reads the character into TMP1, keeps STR_PTR.  /* Reads the character into TMP1, keeps STR_PTR.
1417  Does not check STR_END. TMP2 Destroyed. */  Does not check STR_END. TMP2 Destroyed. */
1418  DEFINE_COMPILER;  DEFINE_COMPILER;
1419  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1420  struct sljit_jump *jump;  struct sljit_jump *jump;
1421  #endif  #endif
1422    
1423  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1424  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1425  if (common->utf8)  if (common->utf)
1426    {    {
1427    #ifdef COMPILE_PCRE8
1428    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
1429    add_jump(compiler, &common->utf8readchar, JUMP(SLJIT_FAST_CALL));  #else
1430    #ifdef COMPILE_PCRE16
1431      jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
1432    #endif
1433    #endif /* COMPILE_PCRE8 */
1434      add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
1435    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
1436    JUMPHERE(jump);    JUMPHERE(jump);
1437    }    }
# Line 1384  static void read_char8_type(compiler_com Line 1442  static void read_char8_type(compiler_com
1442  {  {
1443  /* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. */  /* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. */
1444  DEFINE_COMPILER;  DEFINE_COMPILER;
1445  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || defined COMPILE_PCRE16
1446  struct sljit_jump *jump;  struct sljit_jump *jump;
1447  #endif  #endif
1448    
1449  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1450  if (common->utf8)  if (common->utf)
1451    {    {
1452    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
1453    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1454    #ifdef COMPILE_PCRE8
1455    /* This can be an extra read in some situations, but hopefully    /* This can be an extra read in some situations, but hopefully
1456    it is a clever early read in most cases. */    it is needed in most cases. */
1457    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
1458    jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0);    jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0);
1459    add_jump(compiler, &common->utf8readtype8, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL));
1460      JUMPHERE(jump);
1461    #else
1462    #ifdef COMPILE_PCRE16
1463      OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
1464      jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xff);
1465      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
1466    JUMPHERE(jump);    JUMPHERE(jump);
1467      /* Skip low surrogate if necessary. */
1468      OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xfc00);
1469      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xd800);
1470      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
1471      OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);
1472      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
1473    #endif
1474    #endif /* COMPILE_PCRE8 */
1475    return;    return;
1476    }    }
1477  #endif  #endif
1478  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
1479  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1480  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);  #ifdef COMPILE_PCRE16
1481    /* The ctypes array contains only 255 values. */
1482    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
1483    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xff);
1484    #endif
1485    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
1486    #ifdef COMPILE_PCRE16
1487    JUMPHERE(jump);
1488    #endif
1489  }  }
1490    
1491  static void skip_char_back(compiler_common *common)  static void skip_char_back(compiler_common *common)
1492  {  {
1493  /* Goes one character back. Only affects STR_PTR. Does not check begin. */  /* Goes one character back. Only affects STR_PTR. Does not check begin. */
1494  DEFINE_COMPILER;  DEFINE_COMPILER;
1495  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1496  struct sljit_label *label;  struct sljit_label *label;
1497    
1498  if (common->utf8)  if (common->utf)
1499    {    {
1500    label = LABEL();    label = LABEL();
1501    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
1502    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1503    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0);    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0);
1504    CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, label);    CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, label);
1505    return;    return;
1506    }    }
1507  #endif  #endif
1508  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  #if defined SUPPORT_UTF && defined COMPILE_PCRE16
1509    if (common->utf)
1510      {
1511      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
1512      OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1513      /* Skip low surrogate if necessary. */
1514      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
1515      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xdc00);
1516      COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
1517      OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
1518      OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1519      return;
1520      }
1521    #endif
1522    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1523  }  }
1524    
1525  static void check_newlinechar(compiler_common *common, int nltype, jump_list **fallbacks, BOOL jumpiftrue)  static void check_newlinechar(compiler_common *common, int nltype, jump_list **fallbacks, BOOL jumpiftrue)
# Line 1452  else Line 1547  else
1547    }    }
1548  }  }
1549    
1550  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1551  static void do_utf8readchar(compiler_common *common)  
1552    #ifdef COMPILE_PCRE8
1553    static void do_utfreadchar(compiler_common *common)
1554  {  {
1555  /* Fast decoding an utf8 character. TMP1 contains the first byte  /* Fast decoding a UTF-8 character. TMP1 contains the first byte
1556  of the character (>= 0xc0). Return char value in TMP1, length - 1 in TMP2. */  of the character (>= 0xc0). Return char value in TMP1, length - 1 in TMP2. */
1557  DEFINE_COMPILER;  DEFINE_COMPILER;
1558  struct sljit_jump *jump;  struct sljit_jump *jump;
# Line 1464  sljit_emit_fast_enter(compiler, RETURN_A Line 1561  sljit_emit_fast_enter(compiler, RETURN_A
1561  /* Searching for the first zero. */  /* Searching for the first zero. */
1562  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);
1563  jump = JUMP(SLJIT_C_NOT_ZERO);  jump = JUMP(SLJIT_C_NOT_ZERO);
1564  /* 2 byte sequence */  /* Two byte sequence. */
1565  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 1);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
1566  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1567  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1f);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1f);
1568  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
1569  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
1570  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1571  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 1);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));
1572  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1573  JUMPHERE(jump);  JUMPHERE(jump);
1574    
1575  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10);  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10);
1576  jump = JUMP(SLJIT_C_NOT_ZERO);  jump = JUMP(SLJIT_C_NOT_ZERO);
1577  /* 3 byte sequence */  /* Three byte sequence. */
1578  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 1);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
1579  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0f);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0f);
1580  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 12);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 12);
1581  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
1582  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
1583  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1584  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 2);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
1585  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 2);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
1586  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
1587  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1588  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 2);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2));
1589  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1590  JUMPHERE(jump);  JUMPHERE(jump);
1591    
1592  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x08);  /* Four byte sequence. */
1593  jump = JUMP(SLJIT_C_NOT_ZERO);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
 /* 4 byte sequence */  
 OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 1);  
1594  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x07);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x07);
1595  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 18);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 18);
1596  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
1597  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);
1598  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1599  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 2);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
1600  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
1601  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
1602  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1603  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 3);  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(3));
1604  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 3);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3));
1605  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
1606  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1607  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 3);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(3));
 sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  
 JUMPHERE(jump);  
   
 /* 5 byte sequence */  
 OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 1);  
 OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x03);  
 OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 24);  
 OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  
 OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 18);  
 OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  
 OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 2);  
 OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  
 OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);  
 OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  
 OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 3);  
 OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  
 OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  
 OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  
 OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 4);  
 OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 4);  
 OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  
 OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  
 OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 4);  
1608  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1609  }  }
1610    
1611  static void do_utf8readtype8(compiler_common *common)  static void do_utfreadtype8(compiler_common *common)
1612  {  {
1613  /* Fast decoding an utf8 character type. TMP2 contains the first byte  /* Fast decoding a UTF-8 character type. TMP2 contains the first byte
1614  of the character (>= 0xc0) and TMP1 is destroyed. Return value in TMP1. */  of the character (>= 0xc0). Return value in TMP1. */
1615  DEFINE_COMPILER;  DEFINE_COMPILER;
1616  struct sljit_jump *jump;  struct sljit_jump *jump;
1617  struct sljit_jump *compare;  struct sljit_jump *compare;
# Line 1548  sljit_emit_fast_enter(compiler, RETURN_A Line 1620  sljit_emit_fast_enter(compiler, RETURN_A
1620    
1621  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0x20);  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0x20);
1622  jump = JUMP(SLJIT_C_NOT_ZERO);  jump = JUMP(SLJIT_C_NOT_ZERO);
1623  /* 2 byte sequence */  /* Two byte sequence. */
1624  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
1625  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1626  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x1f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x1f);
1627  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
1628  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
# Line 1565  sljit_emit_fast_return(compiler, RETURN_ Line 1637  sljit_emit_fast_return(compiler, RETURN_
1637  JUMPHERE(jump);  JUMPHERE(jump);
1638    
1639  /* We only have types for characters less than 256. */  /* We only have types for characters less than 256. */
1640  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_w)_pcre_utf8_table4 - 0xc0);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_w)PRIV(utf8_table4) - 0xc0);
1641  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1642  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
1643  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1644  }  }
1645    
1646  #endif  #else /* COMPILE_PCRE8 */
1647    
1648    #ifdef COMPILE_PCRE16
1649    static void do_utfreadchar(compiler_common *common)
1650    {
1651    /* Fast decoding a UTF-16 character. TMP1 contains the first 16 bit char
1652    of the character (>= 0xd800). Return char value in TMP1, length - 1 in TMP2. */
1653    DEFINE_COMPILER;
1654    struct sljit_jump *jump;
1655    
1656    sljit_emit_fast_enter(compiler, RETURN_ADDR, 0, 1, 5, 5, common->localsize);
1657    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xdc00);
1658    /* Do nothing, only return. */
1659    sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1660    
1661    JUMPHERE(jump);
1662    /* Combine two 16 bit characters. */
1663    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 1);
1664    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1665    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff);
1666    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 10);
1667    OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3ff);
1668    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
1669    OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));
1670    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000);
1671    sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1672    }
1673    #endif /* COMPILE_PCRE16 */
1674    
1675    #endif /* COMPILE_PCRE8 */
1676    
1677    #endif /* SUPPORT_UTF */
1678    
1679  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
1680    
# Line 1589  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si Line 1692  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si
1692    
1693  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0, 1, 5, 5, common->localsize);  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0, 1, 5, 5, common->localsize);
1694  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
1695  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_w)_pcre_ucd_stage1);  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_w)PRIV(ucd_stage1));
1696  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
1697  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
1698  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
1699  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)_pcre_ucd_stage2);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_stage2));
1700  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);
1701  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)_pcre_ucd_records + SLJIT_OFFSETOF(ucd_record, chartype));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
1702  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);
1703  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1704  }  }
# Line 1609  struct sljit_label *newlinelabel = NULL; Line 1712  struct sljit_label *newlinelabel = NULL;
1712  struct sljit_jump *start;  struct sljit_jump *start;
1713  struct sljit_jump *end = NULL;  struct sljit_jump *end = NULL;
1714  struct sljit_jump *nl = NULL;  struct sljit_jump *nl = NULL;
1715  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1716  struct sljit_jump *singlebyte;  struct sljit_jump *singlechar;
1717  #endif  #endif
1718  jump_list *newline = NULL;  jump_list *newline = NULL;
1719  BOOL newlinecheck = FALSE;  BOOL newlinecheck = FALSE;
1720  BOOL readbyte = FALSE;  BOOL readuchar = FALSE;
1721    
1722  if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||  if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||
1723      common->nltype == NLTYPE_ANYCRLF || common->newline > 255))      common->nltype == NLTYPE_ANYCRLF || common->newline > 255))
# Line 1629  if (firstline) Line 1732  if (firstline)
1732    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
1733      {      {
1734      mainloop = LABEL();      mainloop = LABEL();
1735      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1736      end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);      end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1737      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -1);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
1738      OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
1739      CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);      CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);
1740      CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);      CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);
1741      OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1742      }      }
1743    else    else
1744      {      {
# Line 1659  start = JUMP(SLJIT_JUMP); Line 1762  start = JUMP(SLJIT_JUMP);
1762  if (newlinecheck)  if (newlinecheck)
1763    {    {
1764    newlinelabel = LABEL();    newlinelabel = LABEL();
1765    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1766    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1767    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1768    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);
1769    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
1770    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
# Line 1672  mainloop = LABEL(); Line 1775  mainloop = LABEL();
1775    
1776  /* Increasing the STR_PTR here requires one less jump in the most common case. */  /* Increasing the STR_PTR here requires one less jump in the most common case. */
1777  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1778  if (common->utf8) readbyte = TRUE;  if (common->utf) readuchar = TRUE;
1779  #endif  #endif
1780  if (newlinecheck) readbyte = TRUE;  if (newlinecheck) readuchar = TRUE;
1781    
1782  if (readbyte)  if (readuchar)
1783    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1784    
1785  if (newlinecheck)  if (newlinecheck)
1786    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);
1787    
1788  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1789  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1790  if (common->utf8)  if (common->utf)
1791    {    {
1792    singlebyte = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
1793    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_table4 - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);
1794      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1795      JUMPHERE(singlechar);
1796      }
1797    #endif
1798    #if defined SUPPORT_UTF && defined COMPILE_PCRE16
1799    if (common->utf)
1800      {
1801      singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
1802      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
1803      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
1804      COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
1805      OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
1806    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1807    JUMPHERE(singlebyte);    JUMPHERE(singlechar);
1808    }    }
1809  #endif  #endif
1810  JUMPHERE(start);  JUMPHERE(start);
# Line 1703  if (newlinecheck) Line 1818  if (newlinecheck)
1818  return mainloop;  return mainloop;
1819  }  }
1820    
1821  static SLJIT_INLINE void fast_forward_first_byte(compiler_common *common, pcre_uint16 firstbyte, BOOL firstline)  static SLJIT_INLINE void fast_forward_first_char(compiler_common *common, pcre_uchar firstchar, BOOL caseless, BOOL firstline)
1822  {  {
1823  DEFINE_COMPILER;  DEFINE_COMPILER;
1824  struct sljit_label *start;  struct sljit_label *start;
1825  struct sljit_jump *leave;  struct sljit_jump *leave;
1826  struct sljit_jump *found;  struct sljit_jump *found;
1827  pcre_uint16 oc, bit;  pcre_uchar oc, bit;
1828    
1829  if (firstline)  if (firstline)
1830    {    {
# Line 1719  if (firstline) Line 1834  if (firstline)
1834    
1835  start = LABEL();  start = LABEL();
1836  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1837  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1838    
1839  if ((firstbyte & REQ_CASELESS) == 0)  oc = firstchar;
1840    found = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, firstbyte & 0xff);  if (caseless)
1841      oc = TABLE_GET(firstchar, common->fcc, firstchar);
1842    if (firstchar == oc)
1843      found = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, firstchar);
1844  else  else
1845    {    {
1846    firstbyte &= 0xff;    bit = firstchar ^ oc;
   oc = common->fcc[firstbyte];  
   bit = firstbyte ^ oc;  
1847    if (ispowerof2(bit))    if (ispowerof2(bit))
1848      {      {
1849      OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);
1850      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, firstbyte | bit);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, firstchar | bit);
1851      }      }
1852    else    else
1853      {      {
1854      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, firstbyte);      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, firstchar);
1855      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
1856      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);
1857      COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);      COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);
# Line 1743  else Line 1859  else
1859      }      }
1860    }    }
1861    
1862  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1863  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
1864  if (common->utf8)  if (common->utf)
1865    {    {
1866    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
1867    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_table4 - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);
1868      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1869      }
1870    #endif
1871    #if defined SUPPORT_UTF && defined COMPILE_PCRE16
1872    if (common->utf)
1873      {
1874      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800, start);
1875      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
1876      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
1877      COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
1878      OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
1879    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1880    }    }
1881  #endif  #endif
# Line 1854  if (firstline) Line 1981  if (firstline)
1981    
1982  start = LABEL();  start = LABEL();
1983  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1984  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1985  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1986  if (common->utf8)  if (common->utf)
1987    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
1988  #endif  #endif
1989    #ifndef COMPILE_PCRE8
1990    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xff);
1991    #endif
1992  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
1993  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
1994  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);
# Line 1866  OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TM Line 1996  OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TM
1996  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);
1997  found = JUMP(SLJIT_C_NOT_ZERO);  found = JUMP(SLJIT_C_NOT_ZERO);
1998    
1999  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2000  if (common->utf8)  if (common->utf)
2001    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
2002  #endif  #endif
2003  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2004  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
2005  if (common->utf8)  if (common->utf)
2006    {    {
2007    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
2008    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_table4 - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);
2009      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2010      }
2011    #endif
2012    #if defined SUPPORT_UTF && defined COMPILE_PCRE16
2013    if (common->utf)
2014      {
2015      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800, start);
2016      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
2017      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
2018      COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
2019      OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
2020    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2021    }    }
2022  #endif  #endif
# Line 1887  if (firstline) Line 2028  if (firstline)
2028    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
2029  }  }
2030    
2031  static SLJIT_INLINE struct sljit_jump *search_requested_char(compiler_common *common, pcre_uint16 reqbyte, BOOL has_firstbyte)  static SLJIT_INLINE struct sljit_jump *search_requested_char(compiler_common *common, pcre_uchar reqchar, BOOL caseless, BOOL has_firstchar)
2032  {  {
2033  DEFINE_COMPILER;  DEFINE_COMPILER;
2034  struct sljit_label *loop;  struct sljit_label *loop;
# Line 1896  struct sljit_jump *alreadyfound; Line 2037  struct sljit_jump *alreadyfound;
2037  struct sljit_jump *found;  struct sljit_jump *found;
2038  struct sljit_jump *foundoc = NULL;  struct sljit_jump *foundoc = NULL;
2039  struct sljit_jump *notfound;  struct sljit_jump *notfound;
2040  pcre_uint16 oc, bit;  pcre_uchar oc, bit;
2041    
2042  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), REQ_BYTE_PTR);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), REQ_CHAR_PTR);
2043  OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, REQ_BYTE_MAX);  OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, REQ_BYTE_MAX);
2044  toolong = CMP(SLJIT_C_LESS, TMP1, 0, STR_END, 0);  toolong = CMP(SLJIT_C_LESS, TMP1, 0, STR_END, 0);
2045  alreadyfound = CMP(SLJIT_C_LESS, STR_PTR, 0, TMP2, 0);  alreadyfound = CMP(SLJIT_C_LESS, STR_PTR, 0, TMP2, 0);
2046    
2047  if (has_firstbyte)  if (has_firstchar)
2048    OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, 1);
2049  else  else
2050    OP1(SLJIT_MOV, TMP1, 0, STR_PTR, 0);    OP1(SLJIT_MOV, TMP1, 0, STR_PTR, 0);
# Line 1912  loop = LABEL(); Line 2053  loop = LABEL();
2053  notfound = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, STR_END, 0);  notfound = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, STR_END, 0);
2054    
2055  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), 0);  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), 0);
2056  if ((reqbyte & REQ_CASELESS) == 0)  oc = reqchar;
2057    found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqbyte & 0xff);  if (caseless)
2058      oc = TABLE_GET(reqchar, common->fcc, reqchar);
2059    if (reqchar == oc)
2060      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqchar);
2061  else  else
2062    {    {
2063    reqbyte &= 0xff;    bit = reqchar ^ oc;
   oc = common->fcc[reqbyte];  
   bit = reqbyte ^ oc;  
2064    if (ispowerof2(bit))    if (ispowerof2(bit))
2065      {      {
2066      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);
2067      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqbyte | bit);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqchar | bit);
2068      }      }
2069    else    else
2070      {      {
2071      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqbyte);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqchar);
2072      foundoc = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, oc);      foundoc = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, oc);
2073      }      }
2074    }    }
# Line 1936  JUMPTO(SLJIT_JUMP, loop); Line 2078  JUMPTO(SLJIT_JUMP, loop);
2078  JUMPHERE(found);  JUMPHERE(found);
2079  if (foundoc)  if (foundoc)
2080    JUMPHERE(foundoc);    JUMPHERE(foundoc);
2081  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), REQ_BYTE_PTR, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), REQ_CHAR_PTR, TMP1, 0);
2082  JUMPHERE(alreadyfound);  JUMPHERE(alreadyfound);
2083  JUMPHERE(toolong);  JUMPHERE(toolong);
2084  return notfound;  return notfound;
# Line 2021  else Line 2163  else
2163  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2164    /* Here LOCALS1 has already been zeroed. */    /* Here LOCALS1 has already been zeroed. */
2165    jump = NULL;    jump = NULL;
2166    if (common->utf8)    if (common->utf)
2167      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
2168  #endif  #endif
2169    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);
# Line 2060  else Line 2202  else
2202  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2203    OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);    OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);
2204    jump = NULL;    jump = NULL;
2205    if (common->utf8)    if (common->utf)
2206      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
2207  #endif  #endif
2208    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), common->ctypes);    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), common->ctypes);
# Line 2089  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSE Line 2231  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSE
2231  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);
2232  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);
2233  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2234  if (common->utf8)  if (common->utf)
2235    {    {
2236    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);
2237    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);
# Line 2113  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSE Line 2255  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSE
2255  COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);  COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);
2256  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xa0);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xa0);
2257  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2258  if (common->utf8)  if (common->utf)
2259    {    {
2260    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);
2261    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x1680);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x1680);
# Line 2147  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSE Line 2289  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSE
2289  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);
2290  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);
2291  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2292  if (common->utf8)  if (common->utf)
2293    {    {
2294    COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);    COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);
2295    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);
# Line 2257  static pcre_uchar *byte_sequence_compare Line 2399  static pcre_uchar *byte_sequence_compare
2399  {  {
2400  DEFINE_COMPILER;  DEFINE_COMPILER;
2401  unsigned int othercasebit = 0;  unsigned int othercasebit = 0;
2402  pcre_uint8 *othercasebyte = NULL;  pcre_uchar *othercasechar = NULL;
2403  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2404  int utf8length;  int utflength;
2405  #endif  #endif
2406    
2407  if (caseless && char_has_othercase(common, cc))  if (caseless && char_has_othercase(common, cc))
# Line 2267  if (caseless && char_has_othercase(commo Line 2409  if (caseless && char_has_othercase(commo
2409    othercasebit = char_get_othercase_bit(common, cc);    othercasebit = char_get_othercase_bit(common, cc);
2410    SLJIT_ASSERT(othercasebit);    SLJIT_ASSERT(othercasebit);
2411    /* Extracting bit difference info. */    /* Extracting bit difference info. */
2412    othercasebyte = cc + (othercasebit >> 8);  #ifdef COMPILE_PCRE8
2413      othercasechar = cc + (othercasebit >> 8);
2414    othercasebit &= 0xff;    othercasebit &= 0xff;
2415    #else
2416    #ifdef COMPILE_PCRE16
2417      othercasechar = cc + (othercasebit >> 9);
2418      if ((othercasebit & 0x100) != 0)
2419        othercasebit = (othercasebit & 0xff) << 8;
2420      else
2421        othercasebit &= 0xff;
2422    #endif
2423    #endif
2424    }    }
2425    
2426  if (context->sourcereg == -1)  if (context->sourcereg == -1)
2427    {    {
2428    #ifdef COMPILE_PCRE8
2429  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2430    if (context->length >= 4)    if (context->length >= 4)
2431      OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
# Line 2281  if (context->sourcereg == -1) Line 2434  if (context->sourcereg == -1)
2434    else    else
2435  #endif  #endif
2436      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2437    #else
2438    #ifdef COMPILE_PCRE16
2439    #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2440      if (context->length >= 4)
2441        OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2442      else
2443    #endif
2444        OP1(SLJIT_MOV_SH, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2445    #endif
2446    #endif /* COMPILE_PCRE8 */
2447    context->sourcereg = TMP2;    context->sourcereg = TMP2;
2448    }    }
2449    
2450  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2451  utf8length = 1;  utflength = 1;
2452  if (common->utf8 && *cc >= 0xc0)  if (common->utf && HAS_EXTRALEN(*cc))
2453    utf8length += _pcre_utf8_table4[*cc & 0x3f];    utflength += GET_EXTRALEN(*cc);
2454    
2455  do  do
2456    {    {
2457  #endif  #endif
2458    
2459    context->length--;    context->length -= IN_UCHARS(1);
2460  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2461    
2462    /* Unaligned read is supported. */    /* Unaligned read is supported. */
2463    if (othercasebit != 0 && othercasebyte == cc)    if (othercasebit != 0 && othercasechar == cc)
2464      {      {
2465      context->c.asbytes[context->byteptr] = *cc | othercasebit;      context->c.asuchars[context->ucharptr] = *cc | othercasebit;
2466      context->oc.asbytes[context->byteptr] = othercasebit;      context->oc.asuchars[context->ucharptr] = othercasebit;
2467      }      }
2468    else    else
2469      {      {
2470      context->c.asbytes[context->byteptr] = *cc;      context->c.asuchars[context->ucharptr] = *cc;
2471      context->oc.asbytes[context->byteptr] = 0;      context->oc.asuchars[context->ucharptr] = 0;
2472      }      }
2473    context->byteptr++;    context->ucharptr++;
2474    
2475    if (context->byteptr >= 4 || context->length == 0 || (context->byteptr == 2 && context->length == 1))  #ifdef COMPILE_PCRE8
2476      if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
2477    #else
2478      if (context->ucharptr >= 2 || context->length == 0)
2479    #endif
2480      {      {
2481      if (context->length >= 4)      if (context->length >= 4)
2482        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);
2483    #ifdef COMPILE_PCRE8
2484      else if (context->length >= 2)      else if (context->length >= 2)
2485        OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2486      else if (context->length >= 1)      else if (context->length >= 1)
2487        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);
2488    #else
2489        else if (context->length >= 2)
2490          OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2491    #endif
2492      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
2493    
2494      switch(context->byteptr)      switch(context->ucharptr)
2495        {        {
2496        case 4:        case 4 / sizeof(pcre_uchar):
2497        if (context->oc.asint != 0)        if (context->oc.asint != 0)
2498          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asint);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asint);
2499        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));
2500        break;        break;
2501    
2502        case 2:        case 2 / sizeof(pcre_uchar):
2503        if (context->oc.asshort != 0)        if (context->oc.asshort != 0)
2504          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asshort);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asshort);
2505        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asshort | context->oc.asshort));        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asshort | context->oc.asshort));
2506        break;        break;
2507    
2508    #ifdef COMPILE_PCRE8
2509        case 1:        case 1:
2510        if (context->oc.asbyte != 0)        if (context->oc.asbyte != 0)
2511          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asbyte);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asbyte);
2512        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asbyte | context->oc.asbyte));        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asbyte | context->oc.asbyte));
2513        break;        break;
2514    #endif
2515    
2516        default:        default:
2517        SLJIT_ASSERT_STOP();        SLJIT_ASSERT_STOP();
2518        break;        break;
2519        }        }
2520      context->byteptr = 0;      context->ucharptr = 0;
2521      }      }
2522    
2523  #else  #else
2524    
2525    /* Unaligned read is unsupported. */    /* Unaligned read is unsupported. */
2526    #ifdef COMPILE_PCRE8
2527    if (context->length > 0)    if (context->length > 0)
2528      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);
2529    #else
2530      if (context->length > 0)
2531        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2532    #endif
2533    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
2534    
2535    if (othercasebit != 0 && othercasebyte == cc)    if (othercasebit != 0 && othercasechar == cc)
2536      {      {
2537      OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);      OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);
2538      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, *cc | othercasebit));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, *cc | othercasebit));
# Line 2365  do Line 2544  do
2544    
2545    cc++;    cc++;
2546  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2547    utf8length--;    utflength--;
2548    }    }
2549  while (utf8length > 0);  while (utflength > 0);
2550  #endif  #endif
2551    
2552  return cc;  return cc;
2553  }  }
2554    
2555  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
2556    
2557  #define SET_TYPE_OFFSET(value) \  #define SET_TYPE_OFFSET(value) \
2558    if ((value) != typeoffset) \    if ((value) != typeoffset) \
# Line 2413  unsigned int typeoffset; Line 2592  unsigned int typeoffset;
2592  int invertcmp, numberofcmps;  int invertcmp, numberofcmps;
2593  unsigned int charoffset;  unsigned int charoffset;
2594    
2595  /* Although SUPPORT_UTF8 must be defined, we are not necessary in utf8 mode. */  /* Although SUPPORT_UTF must be defined, we are not necessary in utf mode. */
2596  check_input_end(common, fallbacks);  check_input_end(common, fallbacks);
2597  read_char(common);  read_char(common);
2598    
2599  if ((*cc++ & XCL_MAP) != 0)  if ((*cc++ & XCL_MAP) != 0)
2600    {    {
2601    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
2602    if (common->utf8)  #ifndef COMPILE_PCRE8
2603      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
2604    #elif defined SUPPORT_UTF8
2605      if (common->utf)
2606      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
2607    #endif
2608    
2609    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
2610    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
# Line 2430  if ((*cc++ & XCL_MAP) != 0) Line 2613  if ((*cc++ & XCL_MAP) != 0)
2613    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);
2614    add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));    add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));
2615    
2616    if (common->utf8)  #ifndef COMPILE_PCRE8
2617      JUMPHERE(jump);
2618    #elif defined SUPPORT_UTF8
2619      if (common->utf)
2620      JUMPHERE(jump);      JUMPHERE(jump);
2621    #endif
2622    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
2623  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2624    charsaved = TRUE;    charsaved = TRUE;
2625  #endif  #endif
2626    cc += 32;    cc += 32 / sizeof(pcre_uchar);
2627    }    }
2628    
2629  /* Scanning the necessary info. */  /* Scanning the necessary info. */
# Line 2448  while (*cc != XCL_END) Line 2635  while (*cc != XCL_END)
2635    if (*cc == XCL_SINGLE)    if (*cc == XCL_SINGLE)
2636      {      {
2637      cc += 2;      cc += 2;
2638  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2639      if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2640  #endif  #endif
2641  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2642      needschar = TRUE;      needschar = TRUE;
# Line 2458  while (*cc != XCL_END) Line 2645  while (*cc != XCL_END)
2645    else if (*cc == XCL_RANGE)    else if (*cc == XCL_RANGE)
2646      {      {
2647      cc += 2;      cc += 2;
2648  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2649      if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2650  #endif  #endif
2651      cc++;      cc++;
2652  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2653      if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2654  #endif  #endif
2655  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2656      needschar = TRUE;      needschar = TRUE;
# Line 2533  if (needstype || needsscript) Line 2720  if (needstype || needsscript)
2720      {      {
2721      if (scriptreg == TMP1)      if (scriptreg == TMP1)
2722        {        {
2723        OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_w)_pcre_ucd_records + SLJIT_OFFSETOF(ucd_record, script));        OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
2724        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);
2725        }        }
2726      else      else
2727        {        {
2728        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
2729        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_w)_pcre_ucd_records + SLJIT_OFFSETOF(ucd_record, script));        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
2730        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);
2731        }        }
2732      }      }
# Line 2564  while (*cc != XCL_END) Line 2751  while (*cc != XCL_END)
2751      {      {
2752      cc ++;      cc ++;
2753  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2754      if (common->utf8)      if (common->utf)
2755        {        {
2756        GETCHARINC(c, cc);        GETCHARINC(c, cc);
2757        }        }
# Line 2595  while (*cc != XCL_END) Line 2782  while (*cc != XCL_END)
2782      {      {
2783      cc ++;      cc ++;
2784  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2785      if (common->utf8)      if (common->utf)
2786        {        {
2787        GETCHARINC(c, cc);        GETCHARINC(c, cc);
2788        }        }
# Line 2604  while (*cc != XCL_END) Line 2791  while (*cc != XCL_END)
2791        c = *cc++;        c = *cc++;
2792      SET_CHAR_OFFSET(c);      SET_CHAR_OFFSET(c);
2793  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2794      if (common->utf8)      if (common->utf)
2795        {        {
2796        GETCHARINC(c, cc);        GETCHARINC(c, cc);
2797        }        }
# Line 2660  while (*cc != XCL_END) Line 2847  while (*cc != XCL_END)
2847        break;        break;
2848    
2849        case PT_GC:        case PT_GC:
2850        c = _pcre_ucp_typerange[(int)cc[1] * 2];        c = PRIV(ucp_typerange)[(int)cc[1] * 2];
2851        SET_TYPE_OFFSET(c);        SET_TYPE_OFFSET(c);
2852        jump = CMP(SLJIT_C_LESS_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, _pcre_ucp_typerange[(int)cc[1] * 2 + 1] - c);        jump = CMP(SLJIT_C_LESS_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, PRIV(ucp_typerange)[(int)cc[1] * 2 + 1] - c);
2853        break;        break;
2854    
2855        case PT_PC:        case PT_PC:
# Line 2800  switch(type) Line 2987  switch(type)
2987    
2988    case OP_ALLANY:    case OP_ALLANY:
2989    check_input_end(common, fallbacks);    check_input_end(common, fallbacks);
2990  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
2991    if (common->utf8)    if (common->utf)
2992      {      {
2993      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2994      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2995    #ifdef COMPILE_PCRE8
2996      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2997      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_table4 - 0xc0);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);
2998        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2999    #else /* COMPILE_PCRE8 */
3000    #ifdef COMPILE_PCRE16
3001        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
3002        OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
3003        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
3004        COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
3005        OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
3006      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
3007    #endif /* COMPILE_PCRE16 */
3008    #endif /* COMPILE_PCRE8 */
3009      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
3010      return cc;      return cc;
3011      }      }
3012  #endif  #endif
3013    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3014    return cc;    return cc;
3015    
3016    case OP_ANYBYTE:    case OP_ANYBYTE:
3017    check_input_end(common, fallbacks);    check_input_end(common, fallbacks);
3018    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3019    return cc;    return cc;
3020    
3021  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
# Line 3020  switch(type) Line 3218  switch(type)
3218    case OP_CHAR:    case OP_CHAR:
3219    case OP_CHARI:    case OP_CHARI:
3220    length = 1;    length = 1;
3221  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3222    if (common->utf8 && *cc >= 0xc0) length += _pcre_utf8_table4[*cc & 0x3f];    if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);
3223  #endif  #endif
3224    if (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0)    if (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0)
3225      {      {
3226      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, length);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length));
3227      add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));      add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));
3228    
3229      context.length = length;      context.length = IN_UCHARS(length);
3230      context.sourcereg = -1;      context.sourcereg = -1;
3231  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
3232      context.byteptr = 0;      context.ucharptr = 0;
3233  #endif  #endif
3234      return byte_sequence_compare(common, type == OP_CHARI, cc, &context, fallbacks);      return byte_sequence_compare(common, type == OP_CHARI, cc, &context, fallbacks);
3235      }      }
3236    add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));    check_input_end(common, fallbacks);
3237    read_char(common);    read_char(common);
3238  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3239    if (common->utf8)    if (common->utf)
3240      {      {
3241      GETCHAR(c, cc);      GETCHAR(c, cc);
3242      }      }
# Line 3054  switch(type) Line 3252  switch(type)
3252    
3253    case OP_NOT:    case OP_NOT:
3254    case OP_NOTI:    case OP_NOTI:
3255    length = 1;  #ifdef SUPPORT_UTF
3256  #ifdef SUPPORT_UTF8    if (common->utf)
   if (common->utf8)  
3257      {      {
3258      if (*cc >= 0xc0) length += _pcre_utf8_table4[*cc & 0x3f];      length = 1;
3259        if (HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);
3260    
3261      check_input_end(common, fallbacks);      check_input_end(common, fallbacks);
3262      GETCHAR(c, cc);      GETCHAR(c, cc);
# Line 3077  switch(type) Line 3275  switch(type)
3275        /* Skip the variable-length character. */        /* Skip the variable-length character. */
3276        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
3277        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
3278        OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)_pcre_utf8_table4 - 0xc0);  #ifdef COMPILE_PCRE8
3279          OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);
3280    #endif
3281        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
3282        JUMPHERE(jump[0]);        JUMPHERE(jump[0]);
3283        return cc + length;        return cc + length;
# Line 3088  switch(type) Line 3288  switch(type)
3288    else    else
3289  #endif  #endif
3290      {      {
3291      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3292      add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));      add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));
3293      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -1);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
3294      c = *cc;      c = *cc;
3295      }      }
3296    
# Line 3111  switch(type) Line 3311  switch(type)
3311        add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, oc));        add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, oc));
3312        }        }
3313      }      }
3314    return cc + length;    return cc + 1;
3315    
3316    case OP_CLASS:    case OP_CLASS:
3317    case OP_NCLASS:    case OP_NCLASS:
3318    check_input_end(common, fallbacks);    check_input_end(common, fallbacks);
3319    read_char(common);    read_char(common);
3320  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3321    jump[0] = NULL;    jump[0] = NULL;
3322    if (common->utf8)  #ifdef SUPPORT_UTF8
3323      /* This check can only be skipped in pure 8 bit mode. */
3324      if (common->utf)
3325    #endif
3326      {      {
3327      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
3328      if (type == OP_CLASS)      if (type == OP_CLASS)
# Line 3135  switch(type) Line 3338  switch(type)
3338    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
3339    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);
3340    add_jump(compiler, fallbacks, JUMP(SLJIT_C_ZERO));    add_jump(compiler, fallbacks, JUMP(SLJIT_C_ZERO));
3341  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3342    if (jump[0] != NULL)    if (jump[0] != NULL)
3343      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
3344  #endif  #endif
3345    return cc + 32;    return cc + 32 / sizeof(pcre_uchar);
3346    
3347  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || defined COMPILE_PCRE16
3348    case OP_XCLASS:    case OP_XCLASS:
3349    compile_xclass_hotpath(common, cc + LINK_SIZE, fallbacks);    compile_xclass_hotpath(common, cc + LINK_SIZE, fallbacks);
3350    return cc + GET(cc, 0) - 1;    return cc + GET(cc, 0) - 1;
# Line 3153  switch(type) Line 3356  switch(type)
3356    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
3357    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
3358  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3359    if (common->utf8)    if (common->utf)
3360      {      {
3361      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, length);      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, length);
3362      label = LABEL();      label = LABEL();
# Line 3190  do Line 3393  do
3393    if (*cc == OP_CHAR)    if (*cc == OP_CHAR)
3394      {      {
3395      size = 1;      size = 1;
3396  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3397      if (common->utf8 && cc[1] >= 0xc0)      if (common->utf && HAS_EXTRALEN(cc[1]))
3398        size += _pcre_utf8_table4[cc[1] & 0x3f];        size += GET_EXTRALEN(cc[1]);
3399  #endif  #endif
3400      }      }
3401    else if (*cc == OP_CHARI)    else if (*cc == OP_CHARI)
3402      {      {
3403      size = 1;      size = 1;
3404  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
3405      if (common->utf8)      if (common->utf)
3406        {        {
3407        if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)        if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
3408          size = 0;          size = 0;
3409        else if (cc[1] >= 0xc0)        else if (HAS_EXTRALEN(cc[1]))
3410          size += _pcre_utf8_table4[cc[1] & 0x3f];          size += GET_EXTRALEN(cc[1]);
3411        }        }
3412      else      else
3413  #endif  #endif
# Line 3215  do Line 3418  do
3418      size = 0;      size = 0;
3419    
3420    cc += 1 + size;    cc += 1 + size;
3421    context.length += size;    context.length += IN_UCHARS(size);
3422    }    }
3423  while (size > 0 && context.length <= 128);  while (size > 0 && context.length <= 128);
3424    
# Line 3228  if (context.length > 0) Line 3431  if (context.length > 0)
3431    
3432    context.sourcereg = -1;    context.sourcereg = -1;
3433  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
3434    context.byteptr = 0;    context.ucharptr = 0;
3435  #endif  #endif
3436    do cc = byte_sequence_compare(common, *cc == OP_CHARI, cc + 1, &context, fallbacks); while (context.length > 0);    do cc = byte_sequence_compare(common, *cc == OP_CHARI, cc + 1, &context, fallbacks); while (context.length > 0);
3437    return cc;    return cc;
# Line 3303  if (withchecks && !common->jscript_compa Line 3506  if (withchecks && !common->jscript_compa
3506    
3507  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3508  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
3509  if (common->utf8 && *cc == OP_REFI)  if (common->utf && *cc == OP_REFI)
3510    {    {
3511    SLJIT_ASSERT(TMP1 == SLJIT_TEMPORARY_REG1 && STACK_TOP == SLJIT_TEMPORARY_REG2 && TMP2 == SLJIT_TEMPORARY_REG3);    SLJIT_ASSERT(TMP1 == SLJIT_TEMPORARY_REG1 && STACK_TOP == SLJIT_TEMPORARY_REG2 && TMP2 == SLJIT_TEMPORARY_REG3);
3512    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
# Line 3340  if (jump != NULL) Line 3543  if (jump != NULL)
3543    else    else
3544      JUMPHERE(jump);      JUMPHERE(jump);
3545    }    }
3546  return cc + 3;  return cc + 1 + IMM2_SIZE;
3547  }  }
3548    
3549  static SLJIT_INLINE pcre_uchar *compile_ref_iterator_hotpath(compiler_common *common, pcre_uchar *cc, fallback_common *parent)  static SLJIT_INLINE pcre_uchar *compile_ref_iterator_hotpath(compiler_common *common, pcre_uchar *cc, fallback_common *parent)
# Line 3357  BOOL minimize; Line 3560  BOOL minimize;
3560    
3561  PUSH_FALLBACK(sizeof(iterator_fallback), cc, NULL);  PUSH_FALLBACK(sizeof(iterator_fallback), cc, NULL);
3562    
3563  type = cc[3];  type = cc[1 + IMM2_SIZE];
3564  minimize = (type & 0x1) != 0;  minimize = (type & 0x1) != 0;
3565  switch(type)  switch(type)
3566    {    {
# Line 3365  switch(type) Line 3568  switch(type)
3568    case OP_CRMINSTAR:    case OP_CRMINSTAR:
3569    min = 0;    min = 0;
3570    max = 0;    max = 0;
3571    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3572    break;    break;
3573    case OP_CRPLUS:    case OP_CRPLUS:
3574    case OP_CRMINPLUS:    case OP_CRMINPLUS:
3575    min = 1;    min = 1;
3576    max = 0;    max = 0;
3577    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3578    break;    break;
3579    case OP_CRQUERY:    case OP_CRQUERY:
3580    case OP_CRMINQUERY:    case OP_CRMINQUERY:
3581    min = 0;    min = 0;
3582    max = 1;    max = 1;
3583    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3584    break;    break;
3585    case OP_CRRANGE:    case OP_CRRANGE:
3586    case OP_CRMINRANGE:    case OP_CRMINRANGE:
3587    min = GET2(cc, 3 + 1);    min = GET2(cc, 1 + IMM2_SIZE + 1);
3588    max = GET2(cc, 3 + 3);    max = GET2(cc, 1 + IMM2_SIZE + 1 + IMM2_SIZE);
3589    cc += 8;    cc += 1 + IMM2_SIZE + 1 + 2 * IMM2_SIZE;
3590    break;    break;
3591    default:    default:
3592    SLJIT_ASSERT_STOP();    SLJIT_ASSERT_STOP();
# Line 3557  if (*cc == OP_BRAZERO || *cc == OP_BRAMI Line 3760  if (*cc == OP_BRAZERO || *cc == OP_BRAMI
3760    bra = *cc;    bra = *cc;
3761    cc++;    cc++;
3762    }    }
3763  localptr = PRIV(cc);  localptr = PRIV_DATA(cc);
3764  SLJIT_ASSERT(localptr != 0);  SLJIT_ASSERT(localptr != 0);
3765  framesize = get_framesize(common, cc, FALSE);  framesize = get_framesize(common, cc, FALSE);
3766  fallback->framesize = framesize;  fallback->framesize = framesize;
# Line 4038  if (opcode == OP_CBRA || opcode == OP_SC Line 4241  if (opcode == OP_CBRA || opcode == OP_SC
4241    localptr = OVECTOR_PRIV(offset);    localptr = OVECTOR_PRIV(offset);
4242    offset <<= 1;    offset <<= 1;
4243    FALLBACK_AS(bracket_fallback)->localptr = localptr;    FALLBACK_AS(bracket_fallback)->localptr = localptr;
4244    hotpath += 2;    hotpath += IMM2_SIZE;
4245    }    }
4246  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)
4247    {    {
4248    /* Other brackets simply allocate the next entry. */    /* Other brackets simply allocate the next entry. */
4249    localptr = PRIV(ccbegin);    localptr = PRIV_DATA(ccbegin);
4250    SLJIT_ASSERT(localptr != 0);    SLJIT_ASSERT(localptr != 0);
4251    FALLBACK_AS(bracket_fallback)->localptr = localptr;    FALLBACK_AS(bracket_fallback)->localptr = localptr;
4252    if (opcode == OP_ONCE)    if (opcode == OP_ONCE)
# Line 4202  if (opcode == OP_COND || opcode == OP_SC Line 4405  if (opcode == OP_COND || opcode == OP_SC
4405      SLJIT_ASSERT(has_alternatives);      SLJIT_ASSERT(has_alternatives);
4406      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed),      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed),
4407        CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(hotpath, 1) << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));        CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(hotpath, 1) << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
4408      hotpath += 3;      hotpath += 1 + IMM2_SIZE;
4409      }      }
4410    else if (*hotpath == OP_NCREF)    else if (*hotpath == OP_NCREF)
4411      {      {
# Line 4221  if (opcode == OP_COND || opcode == OP_SC Line 4424  if (opcode == OP_COND || opcode == OP_SC
4424      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));
4425    
4426      JUMPHERE(jump);      JUMPHERE(jump);
4427      hotpath += 3;      hotpath += 1 + IMM2_SIZE;
4428      }      }
4429    else if (*hotpath == OP_RREF || *hotpath == OP_NRREF)    else if (*hotpath == OP_RREF || *hotpath == OP_NRREF)
4430      {      {
# Line 4242  if (opcode == OP_COND || opcode == OP_SC Line 4445  if (opcode == OP_COND || opcode == OP_SC
4445        {        {
4446        SLJIT_ASSERT(!has_alternatives);        SLJIT_ASSERT(!has_alternatives);
4447        if (stacksize != 0)        if (stacksize != 0)
4448          hotpath += 3;          hotpath += 1 + IMM2_SIZE;
4449        else        else
4450          {          {
4451          if (*cc == OP_ALT)          if (*cc == OP_ALT)
# Line 4269  if (opcode == OP_COND || opcode == OP_SC Line 4472  if (opcode == OP_COND || opcode == OP_SC
4472        sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));        sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));
4473        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);
4474        add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));        add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));
4475        hotpath += 3;        hotpath += 1 + IMM2_SIZE;
4476        }        }
4477      }      }
4478    else    else
# Line 4429  if (*cc == OP_BRAPOSZERO) Line 4632  if (*cc == OP_BRAPOSZERO)
4632    }    }
4633    
4634  opcode = *cc;  opcode = *cc;
4635  localptr = PRIV(cc);  localptr = PRIV_DATA(cc);
4636  SLJIT_ASSERT(localptr != 0);  SLJIT_ASSERT(localptr != 0);
4637  FALLBACK_AS(bracketpos_fallback)->localptr = localptr;  FALLBACK_AS(bracketpos_fallback)->localptr = localptr;
4638  switch(opcode)  switch(opcode)
# Line 4444  switch(opcode) Line 4647  switch(opcode)
4647    offset = GET2(cc, 1 + LINK_SIZE);    offset = GET2(cc, 1 + LINK_SIZE);
4648    cbraprivptr = OVECTOR_PRIV(offset);    cbraprivptr = OVECTOR_PRIV(offset);
4649    offset <<= 1;    offset <<= 1;
4650    ccbegin = cc + 1 + LINK_SIZE + 2;    ccbegin = cc + 1 + LINK_SIZE + IMM2_SIZE;
4651    break;    break;
4652    
4653    default:    default:
# Line 4662  else Line 4865  else
4865    SLJIT_ASSERT(*opcode >= OP_CLASS || *opcode <= OP_XCLASS);    SLJIT_ASSERT(*opcode >= OP_CLASS || *opcode <= OP_XCLASS);
4866    *type = *opcode;    *type = *opcode;
4867    cc++;    cc++;
4868    class_len = (*type < OP_XCLASS) ? 33 : GET(cc, 0);    class_len = (*type < OP_XCLASS) ? (1 + (32 / sizeof(pcre_uchar))) : GET(cc, 0);
4869    *opcode = cc[class_len - 1];    *opcode = cc[class_len - 1];
4870    if (*opcode >= OP_CRSTAR && *opcode <= OP_CRMINQUERY)    if (*opcode >= OP_CRSTAR && *opcode <= OP_CRMINQUERY)
4871      {      {
# Line 4673  else Line 4876  else
4876    else    else
4877      {      {
4878      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);
4879      *arg1 = GET2(cc, (class_len + 2));      *arg1 = GET2(cc, (class_len + IMM2_SIZE));
4880      *arg2 = GET2(cc, class_len);      *arg2 = GET2(cc, class_len);
4881    
4882      if (*arg2 == 0)      if (*arg2 == 0)
# Line 4685  else Line 4888  else
4888        *opcode = OP_EXACT;        *opcode = OP_EXACT;
4889    
4890      if (end != NULL)      if (end != NULL)
4891        *end = cc + class_len + 4;        *end = cc + class_len + 2 * IMM2_SIZE;
4892      }      }
4893    return cc;    return cc;
4894    }    }
# Line 4693  else Line 4896  else
4896  if (*opcode == OP_UPTO || *opcode == OP_MINUPTO || *opcode == OP_EXACT || *opcode == OP_POSUPTO)  if (*opcode == OP_UPTO || *opcode == OP_MINUPTO || *opcode == OP_EXACT || *opcode == OP_POSUPTO)
4897    {    {
4898    *arg1 = GET2(cc, 0);    *arg1 = GET2(cc, 0);
4899    cc += 2;    cc += IMM2_SIZE;
4900    }    }
4901    
4902  if (*type == 0)  if (*type == 0)
# Line 4708  if (*type == 0) Line 4911  if (*type == 0)
4911  if (end != NULL)  if (end != NULL)
4912    {    {
4913    *end = cc + 1;    *end = cc + 1;
4914  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
4915    if (common->utf8 && *cc >= 0xc0) *end += _pcre_utf8_table4[*cc & 0x3f];    if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc);
4916  #endif  #endif
4917    }    }
4918  return cc;  return cc;
# Line 4935  int offset = GET2(cc, 1); Line 5138  int offset = GET2(cc, 1);
5138    
5139  /* Data will be discarded anyway... */  /* Data will be discarded anyway... */
5140  if (common->currententry != NULL)  if (common->currententry != NULL)
5141    return cc + 3;    return cc + 1 + IMM2_SIZE;
5142    
5143  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR_PRIV(offset));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR_PRIV(offset));
5144  offset <<= 1;  offset <<= 1;
5145  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
5146  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
5147  return cc + 3;  return cc + 1 + IMM2_SIZE;
5148  }  }
5149    
5150  static void compile_hotpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, fallback_common *parent)  static void compile_hotpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, fallback_common *parent)
# Line 5070  while (cc < ccend) Line 5273  while (cc < ccend)
5273    
5274      case OP_CLASS:      case OP_CLASS:
5275      case OP_NCLASS:      case OP_NCLASS:
5276      if (cc[33] >= OP_CRSTAR && cc[33] <= OP_CRMINRANGE)      if (cc[1 + (32 / sizeof(pcre_uchar))] >= OP_CRSTAR && cc[1 + (32 / sizeof(pcre_uchar))] <= OP_CRMINRANGE)
5277        cc = compile_iterator_hotpath(common, cc, parent);        cc = compile_iterator_hotpath(common, cc, parent);
5278      else      else
5279        cc = compile_char1_hotpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextfallbacks : &parent->topfallbacks);        cc = compile_char1_hotpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextfallbacks : &parent->topfallbacks);
5280      break;      break;
5281    
5282  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || defined COMPILE_PCRE16
5283      case OP_XCLASS:      case OP_XCLASS:
5284      if (*(cc + GET(cc, 1)) >= OP_CRSTAR && *(cc + GET(cc, 1)) <= OP_CRMINRANGE)      if (*(cc + GET(cc, 1)) >= OP_CRSTAR && *(cc + GET(cc, 1)) <= OP_CRMINRANGE)
5285        cc = compile_iterator_hotpath(common, cc, parent);        cc = compile_iterator_hotpath(common, cc, parent);
# Line 5087  while (cc < ccend) Line 5290  while (cc < ccend)
5290    
5291      case OP_REF:      case OP_REF:
5292      case OP_REFI:      case OP_REFI:
5293      if (cc[3] >= OP_CRSTAR && cc[3] <= OP_CRMINRANGE)      if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRMINRANGE)
5294        cc = compile_ref_iterator_hotpath(common, cc, parent);        cc = compile_ref_iterator_hotpath(common, cc, parent);
5295      else      else
5296        cc = compile_ref_hotpath(common, cc, parent->top != NULL ? &parent->top->nextfallbacks : &parent->topfallbacks, TRUE, FALSE);        cc = compile_ref_hotpath(common, cc, parent->top != NULL ? &parent->top->nextfallbacks : &parent->topfallbacks, TRUE, FALSE);
# Line 5325  DEFINE_COMPILER; Line 5528  DEFINE_COMPILER;
5528  pcre_uchar *cc = current->cc;  pcre_uchar *cc = current->cc;
5529  pcre_uchar type;  pcre_uchar type;
5530    
5531  type = cc[3];  type = cc[1 + IMM2_SIZE];
5532  if ((type & 0x1) == 0)  if ((type & 0x1) == 0)
5533    {    {
5534    set_jumps(current->topfallbacks, LABEL());    set_jumps(current->topfallbacks, LABEL());
# Line 5931  while (current) Line 6134  while (current)
6134      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
6135      case OP_CLASS:      case OP_CLASS:
6136      case OP_NCLASS:      case OP_NCLASS:
6137    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
6138      case OP_XCLASS:      case OP_XCLASS:
6139    #endif
6140      compile_iterator_fallbackpath(common, current);      compile_iterator_fallbackpath(common, current);
6141      break;      break;
6142    
# Line 5999  static SLJIT_INLINE void compile_recurse Line 6204  static SLJIT_INLINE void compile_recurse
6204  {  {
6205  DEFINE_COMPILER;  DEFINE_COMPILER;
6206  pcre_uchar *cc = common->start + common->currententry->start;  pcre_uchar *cc = common->start + common->currententry->start;
6207  pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : 2);  pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
6208  pcre_uchar *ccend = bracketend(cc);  pcre_uchar *ccend = bracketend(cc);
6209  int localsize = get_localsize(common, ccbegin, ccend);  int localsize = get_localsize(common, ccbegin, ccend);
6210  int framesize = get_framesize(common, cc, TRUE);  int framesize = get_framesize(common, cc, TRUE);
# Line 6088  sljit_emit_fast_return(compiler, SLJIT_M Line 6293  sljit_emit_fast_return(compiler, SLJIT_M
6293  #undef CURRENT_AS  #undef CURRENT_AS
6294    
6295  void  void
6296  _pcre_jit_compile(const real_pcre *re, pcre_extra *extra)  PRIV(jit_compile)(const real_pcre *re, pcre_extra *extra)
6297  {  {
6298  struct sljit_compiler *compiler;  struct sljit_compiler *compiler;
6299  fallback_common rootfallback;  fallback_common rootfallback;
# Line 6111  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_ Line 6316  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_
6316  study = extra->study_data;  study = extra->study_data;
6317    
6318  if (!tables)  if (!tables)
6319    tables = _pcre_default_tables;    tables = PRIV(default_tables);
6320    
6321  memset(&rootfallback, 0, sizeof(fallback_common));  memset(&rootfallback, 0, sizeof(fallback_common));
6322  rootfallback.cc = (pcre_uchar *)re + re->name_table_offset + re->name_count * re->name_entry_size;  rootfallback.cc = (pcre_uchar *)re + re->name_table_offset + re->name_count * re->name_entry_size;
# Line 6174  common->casefulcmp = NULL; Line 6379  common->casefulcmp = NULL;
6379  common->caselesscmp = NULL;  common->caselesscmp = NULL;
6380  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
6381  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
6382  common->utf8 = (re->options & PCRE_UTF8) != 0;  /* PCRE_UTF16 has the same value as PCRE_UTF8. */
6383    common->utf = (re->options & PCRE_UTF8) != 0;
6384  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6385  common->useucp = (re->options & PCRE_UCP) != 0;  common->useucp = (re->options & PCRE_UCP) != 0;
6386  #endif  #endif
6387  common->utf8readchar = NULL;  common->utfreadchar = NULL;
6388  common->utf8readtype8 = NULL;  #ifdef COMPILE_PCRE8
6389    common->utfreadtype8 = NULL;
6390  #endif  #endif
6391    #endif /* SUPPORT_UTF8 */
6392  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6393  common->getucd = NULL;  common->getucd = NULL;
6394  #endif  #endif
# Line 6212  sljit_emit_enter(compiler, 1, 5, 5, comm Line 6420  sljit_emit_enter(compiler, 1, 5, 5, comm
6420  /* Register init. */  /* Register init. */
6421  reset_ovector(common, (re->top_bracket + 1) * 2);  reset_ovector(common, (re->top_bracket + 1) * 2);
6422  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6423    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), REQ_BYTE_PTR, SLJIT_TEMPORARY_REG1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), REQ_CHAR_PTR, SLJIT_TEMPORARY_REG1, 0);
6424    
6425  OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_GENERAL_REG1, 0);  OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_GENERAL_REG1, 0);
6426  OP1(SLJIT_MOV, TMP1, 0, SLJIT_GENERAL_REG1, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_GENERAL_REG1, 0);
# Line 6230  if ((re->options & PCRE_ANCHORED) == 0) Line 6438  if ((re->options & PCRE_ANCHORED) == 0)
6438    mainloop = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0, (re->options & PCRE_FIRSTLINE) != 0);    mainloop = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0, (re->options & PCRE_FIRSTLINE) != 0);
6439    /* Forward search if possible. */    /* Forward search if possible. */
6440    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
6441      fast_forward_first_byte(common, re->first_byte, (re->options & PCRE_FIRSTLINE) != 0);      fast_forward_first_char(common, re->first_char, (re->flags & PCRE_FCH_CASELESS) != 0, (re->options & PCRE_FIRSTLINE) != 0);
6442    else if ((re->flags & PCRE_STARTLINE) != 0)    else if ((re->flags & PCRE_STARTLINE) != 0)
6443      fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);      fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);
6444    else if ((re->flags & PCRE_STARTLINE) == 0 && study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)    else if ((re->flags & PCRE_STARTLINE) == 0 && study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)
6445      fast_forward_start_bits(common, (sljit_uw)study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);      fast_forward_start_bits(common, (sljit_uw)study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);
6446    }    }
6447  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6448    reqbyte_notfound = search_requested_char(common, re->req_byte, (re->flags & PCRE_FIRSTSET) != 0);    reqbyte_notfound = search_requested_char(common, re->req_char, (re->flags & PCRE_RCH_CASELESS) != 0, (re->flags & PCRE_FIRSTSET) != 0);
6449    
6450  /* Store the current STR_PTR in OVECTOR(0). */  /* Store the current STR_PTR in OVECTOR(0). */
6451  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), STR_PTR, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), STR_PTR, 0);
# Line 6284  if ((re->options & PCRE_ANCHORED) == 0) Line 6492  if ((re->options & PCRE_ANCHORED) == 0)
6492      {      {
6493      if (study != NULL && study->minlength > 1)      if (study != NULL && study->minlength > 1)
6494        {        {
6495        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, study->minlength);        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength));
6496        CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);        CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);
6497        }        }
6498      else      else
# Line 6294  if ((re->options & PCRE_ANCHORED) == 0) Line 6502  if ((re->options & PCRE_ANCHORED) == 0)
6502      {      {
6503      if (study != NULL && study->minlength > 1)      if (study != NULL && study->minlength > 1)
6504        {        {
6505        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, study->minlength);        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength));
6506        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0);
6507        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);
6508        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END);
# Line 6406  if (common->caselesscmp != NULL) Line 6614  if (common->caselesscmp != NULL)
6614    set_jumps(common->caselesscmp, LABEL());    set_jumps(common->caselesscmp, LABEL());
6615    do_caselesscmp(common);    do_caselesscmp(common);
6616    }    }
6617  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
6618  if (common->utf8readchar != NULL)  if (common->utfreadchar != NULL)
6619    {    {
6620    set_jumps(common->utf8readchar, LABEL());    set_jumps(common->utfreadchar, LABEL());
6621    do_utf8readchar(common);    do_utfreadchar(common);
6622    }    }
6623  if (common->utf8readtype8 != NULL)  #ifdef COMPILE_PCRE8
6624    if (common->utfreadtype8 != NULL)
6625    {    {
6626    set_jumps(common->utf8readtype8, LABEL());    set_jumps(common->utfreadtype8, LABEL());
6627    do_utf8readtype8(common);    do_utfreadtype8(common);
6628    }    }
6629  #endif  #endif
6630    #endif /* COMPILE_PCRE8 */
6631  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
6632  if (common->getucd != NULL)  if (common->getucd != NULL)
6633    {    {
# Line 6467  return convert_executable_func.call_exec Line 6677  return convert_executable_func.call_exec
6677  }  }
6678    
6679  int  int
6680  _pcre_jit_exec(const real_pcre *re, void *executable_func,  PRIV(jit_exec)(const real_pcre *re, void *executable_func,
6681    PCRE_SPTR subject, int length, int start_offset, int options,    const pcre_uchar *subject, int length, int start_offset, int options,
6682    int match_limit, int *offsets, int offsetcount)    int match_limit, int *offsets, int offsetcount)
6683  {  {
6684  executable_function *function = (executable_function*)executable_func;  executable_function *function = (executable_function*)executable_func;
# Line 6523  return retval; Line 6733  return retval;
6733  }  }
6734    
6735  void  void
6736  _pcre_jit_free(void *executable_func)  PRIV(jit_free)(void *executable_func)
6737  {  {
6738  executable_function *function = (executable_function*)executable_func;  executable_function *function = (executable_function*)executable_func;
6739  sljit_free_code(function->executable_func);  sljit_free_code(function->executable_func);
6740  SLJIT_FREE(function);  SLJIT_FREE(function);
6741  }  }
6742    
6743    #ifdef COMPILE_PCRE8
6744  PCRE_EXP_DECL pcre_jit_stack *  PCRE_EXP_DECL pcre_jit_stack *
6745  pcre_jit_stack_alloc(int startsize, int maxsize)  pcre_jit_stack_alloc(int startsize, int maxsize)
6746    #else
6747    PCRE_EXP_DECL pcre_jit_stack *
6748    pcre16_jit_stack_alloc(int startsize, int maxsize)
6749    #endif
6750  {  {
6751  if (startsize < 1 || maxsize < 1)  if (startsize < 1 || maxsize < 1)
6752    return NULL;    return NULL;
# Line 6542  maxsize = (maxsize + STACK_GROWTH_RATE - Line 6757  maxsize = (maxsize + STACK_GROWTH_RATE -
6757  return (pcre_jit_stack*)sljit_allocate_stack(startsize, maxsize);  return (pcre_jit_stack*)sljit_allocate_stack(startsize, maxsize);
6758  }  }
6759    
6760    #ifdef COMPILE_PCRE8
6761  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6762  pcre_jit_stack_free(pcre_jit_stack *stack)  pcre_jit_stack_free(pcre_jit_stack *stack)
6763    #else
6764    PCRE_EXP_DECL void
6765    pcre16_jit_stack_free(pcre_jit_stack *stack)
6766    #endif
6767  {  {
6768  sljit_free_stack((struct sljit_stack*)stack);  sljit_free_stack((struct sljit_stack*)stack);
6769  }  }
6770    
6771    #ifdef COMPILE_PCRE8
6772  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6773  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6774    #else
6775    PCRE_EXP_DECL void
6776    pcre16_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6777    #endif
6778  {  {
6779  executable_function *function;  executable_function *function;
6780  if (extra != NULL &&  if (extra != NULL &&
# Line 6567  if (extra != NULL && Line 6792  if (extra != NULL &&
6792  /* These are dummy functions to avoid linking errors when JIT support is not  /* These are dummy functions to avoid linking errors when JIT support is not
6793  being compiled. */  being compiled. */
6794    
6795    #ifdef COMPILE_PCRE8
6796  PCRE_EXP_DECL pcre_jit_stack *  PCRE_EXP_DECL pcre_jit_stack *
6797  pcre_jit_stack_alloc(int startsize, int maxsize)  pcre_jit_stack_alloc(int startsize, int maxsize)
6798    #else
6799    PCRE_EXP_DECL pcre_jit_stack *
6800    pcre16_jit_stack_alloc(int startsize, int maxsize)
6801    #endif
6802  {  {
6803  (void)startsize;  (void)startsize;
6804  (void)maxsize;  (void)maxsize;
6805  return NULL;  return NULL;
6806  }  }
6807    
6808    #ifdef COMPILE_PCRE8
6809  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6810  pcre_jit_stack_free(pcre_jit_stack *stack)  pcre_jit_stack_free(pcre_jit_stack *stack)
6811    #else
6812    PCRE_EXP_DECL void
6813    pcre16_jit_stack_free(pcre_jit_stack *stack)
6814    #endif
6815  {  {
6816  (void)stack;  (void)stack;
6817  }  }
6818    
6819    #ifdef COMPILE_PCRE8
6820  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6821  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6822    #else
6823    PCRE_EXP_DECL void
6824    pcre16_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6825    #endif
6826  {  {
6827  (void)extra;  (void)extra;
6828  (void)callback;  (void)callback;

Legend:
Removed from v.763  
changed lines
  Added in v.782

  ViewVC Help
Powered by ViewVC 1.1.5