/[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 774 by zherczeg, Thu Dec 1 06:08:45 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 316  typedef struct compare_context { Line 316  typedef struct compare_context {
316    int length;    int length;
317    int sourcereg;    int sourcereg;
318  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
319    int byteptr;    int ucharptr;
320    union {    union {
321      int asint;      sljit_i asint;
322      short asshort;      sljit_h asshort;
323    #ifdef COMPILE_PCRE8
324      sljit_ub asbyte;      sljit_ub asbyte;
325      sljit_ub asbytes[4];      sljit_ub asuchars[4];
326    #else
327    #ifdef COMPILE_PCRE16
328        sljit_uh asuchars[2];
329    #endif
330    #endif
331    } c;    } c;
332    union {    union {
333      int asint;      sljit_i asint;
334      short asshort;      sljit_h asshort;
335    #ifdef COMPILE_PCRE8
336      sljit_ub asbyte;      sljit_ub asbyte;
337      sljit_ub asbytes[4];      sljit_ub asuchars[4];
338    #else
339    #ifdef COMPILE_PCRE16
340        sljit_uh asuchars[2];
341    #endif
342    #endif
343    } oc;    } oc;
344  #endif  #endif
345  } compare_context;  } compare_context;
# Line 363  enum { Line 375  enum {
375  /* Max limit of recursions. */  /* Max limit of recursions. */
376  #define CALL_LIMIT       (5 * sizeof(sljit_w))  #define CALL_LIMIT       (5 * sizeof(sljit_w))
377  /* Last known position of the requested byte. */  /* Last known position of the requested byte. */
378  #define REQ_BYTE_PTR     (6 * sizeof(sljit_w))  #define REQ_CHAR_PTR     (6 * sizeof(sljit_w))
379  /* End pointer of the first line. */  /* End pointer of the first line. */
380  #define FIRSTLINE_END    (7 * sizeof(sljit_w))  #define FIRSTLINE_END    (7 * sizeof(sljit_w))
381  /* 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 385  the start pointers when the end of the c
385  #define OVECTOR_START    (8 * sizeof(sljit_w))  #define OVECTOR_START    (8 * sizeof(sljit_w))
386  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))
387  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))
388  #define PRIV(cc)         (common->localptrs[(cc) - common->start])  #define PRIV_DATA(cc)    (common->localptrs[(cc) - common->start])
389    
390    #ifdef COMPILE_PCRE8
391    #define MOV_UCHAR SLJIT_MOV_UB
392    #else
393    #ifdef COMPILE_PCRE16
394    #define MOV_UCHAR SLJIT_MOV_UH
395    #else
396    #error Unsupported compiling mode
397    #endif
398    #endif
399    
400  /* Shortcuts. */  /* Shortcuts. */
401  #define DEFINE_COMPILER \  #define DEFINE_COMPILER \
# Line 522  switch(*cc) Line 544  switch(*cc)
544    case OP_NOTPOSQUERYI:    case OP_NOTPOSQUERYI:
545    cc += 2;    cc += 2;
546  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
547    if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];    if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];
548  #endif  #endif
549    return cc;    return cc;
550    
# Line 542  switch(*cc) Line 564  switch(*cc)
564    case OP_NOTMINUPTOI:    case OP_NOTMINUPTOI:
565    case OP_NOTEXACTI:    case OP_NOTEXACTI:
566    case OP_NOTPOSUPTOI:    case OP_NOTPOSUPTOI:
567    cc += 4;    cc += 2 + IMM2_SIZE;
568  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
569    if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];    if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];
570  #endif  #endif
571    return cc;    return cc;
572    
# Line 561  switch(*cc) Line 583  switch(*cc)
583    case OP_RREF:    case OP_RREF:
584    case OP_NRREF:    case OP_NRREF:
585    case OP_CLOSE:    case OP_CLOSE:
586    cc += 3;    cc += 1 + IMM2_SIZE;
587    return cc;    return cc;
588    
589    case OP_CRRANGE:    case OP_CRRANGE:
590    case OP_CRMINRANGE:    case OP_CRMINRANGE:
591    return cc + 5;    return cc + 1 + 2 * IMM2_SIZE;
592    
593    case OP_CLASS:    case OP_CLASS:
594    case OP_NCLASS:    case OP_NCLASS:
595    return cc + 33;    return cc + 1 + 32 / sizeof(pcre_uchar);
596    
597  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
598    case OP_XCLASS:    case OP_XCLASS:
599    return cc + GET(cc, 1);    return cc + GET(cc, 1);
600  #endif  #endif
# Line 602  switch(*cc) Line 624  switch(*cc)
624    case OP_CBRAPOS:    case OP_CBRAPOS:
625    case OP_SCBRA:    case OP_SCBRA:
626    case OP_SCBRAPOS:    case OP_SCBRAPOS:
627    return cc + 1 + LINK_SIZE + 2;    return cc + 1 + LINK_SIZE + IMM2_SIZE;
628    
629    default:    default:
630    return NULL;    return NULL;
# Line 635  while (cc < ccend) Line 657  while (cc < ccend)
657      case OP_CBRAPOS:      case OP_CBRAPOS:
658      case OP_SCBRAPOS:      case OP_SCBRAPOS:
659      localspace += sizeof(sljit_w);      localspace += sizeof(sljit_w);
660      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
661      break;      break;
662    
663      case OP_COND:      case OP_COND:
# Line 683  while (cc < ccend) Line 705  while (cc < ccend)
705      case OP_SCBRAPOS:      case OP_SCBRAPOS:
706      common->localptrs[cc - common->start] = localptr;      common->localptrs[cc - common->start] = localptr;
707      localptr += sizeof(sljit_w);      localptr += sizeof(sljit_w);
708      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
709      break;      break;
710    
711      case OP_COND:      case OP_COND:
# Line 739  while (cc < ccend) Line 761  while (cc < ccend)
761      case OP_SCBRA:      case OP_SCBRA:
762      case OP_SCBRAPOS:      case OP_SCBRAPOS:
763      length += 3;      length += 3;
764      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
765      break;      break;
766    
767      default:      default:
# Line 802  while (cc < ccend) Line 824  while (cc < ccend)
824      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);
825      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_w);
826    
827      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
828      break;      break;
829    
830      default:      default:
# Line 841  while (cc < ccend) Line 863  while (cc < ccend)
863      case OP_CBRA:      case OP_CBRA:
864      case OP_SCBRA:      case OP_SCBRA:
865      localsize++;      localsize++;
866      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
867      break;      break;
868    
869      case OP_CBRAPOS:      case OP_CBRAPOS:
870      case OP_SCBRAPOS:      case OP_SCBRAPOS:
871      localsize += 2;      localsize += 2;
872      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
873      break;      break;
874    
875      case OP_COND:      case OP_COND:
# Line 938  while (status != end) Line 960  while (status != end)
960        case OP_SBRAPOS:        case OP_SBRAPOS:
961        case OP_SCOND:        case OP_SCOND:
962        count = 1;        count = 1;
963        srcw[0] = PRIV(cc);        srcw[0] = PRIV_DATA(cc);
964        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
965        cc += 1 + LINK_SIZE;        cc += 1 + LINK_SIZE;
966        break;        break;
# Line 947  while (status != end) Line 969  while (status != end)
969        case OP_SCBRA:        case OP_SCBRA:
970        count = 1;        count = 1;
971        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
972        cc += 1 + LINK_SIZE + 2;        cc += 1 + LINK_SIZE + IMM2_SIZE;
973        break;        break;
974    
975        case OP_CBRAPOS:        case OP_CBRAPOS:
976        case OP_SCBRAPOS:        case OP_SCBRAPOS:
977        count = 2;        count = 2;
978        srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
979        srcw[0] = PRIV(cc);        srcw[0] = PRIV_DATA(cc);
980        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
981        cc += 1 + LINK_SIZE + 2;        cc += 1 + LINK_SIZE + IMM2_SIZE;
982        break;        break;
983    
984        case OP_COND:        case OP_COND:
# Line 965  while (status != end) Line 987  while (status != end)
987        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
988          {          {
989          count = 1;          count = 1;
990          srcw[0] = PRIV(cc);          srcw[0] = PRIV_DATA(cc);
991          SLJIT_ASSERT(srcw[0] != 0);          SLJIT_ASSERT(srcw[0] != 0);
992          }          }
993        cc += 1 + LINK_SIZE;        cc += 1 + LINK_SIZE;
# Line 1173  struct sljit_label *loop; Line 1195  struct sljit_label *loop;
1195  int i;  int i;
1196  /* At this point we can freely use all temporary registers. */  /* At this point we can freely use all temporary registers. */
1197  /* TMP1 returns with begin - 1. */  /* TMP1 returns with begin - 1. */
1198  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));
1199  if (length < 8)  if (length < 8)
1200    {    {
1201    for (i = 0; i < length; i++)    for (i = 0; i < length; i++)
# Line 1211  loop = LABEL(); Line 1233  loop = LABEL();
1233  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);
1234  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));
1235  /* Copy the integer value to the output buffer */  /* Copy the integer value to the output buffer */
1236    #ifdef COMPILE_PCRE16
1237    OP2(SLJIT_LSHR, SLJIT_GENERAL_REG2, 0, SLJIT_GENERAL_REG2, 0, SLJIT_IMM, 1);
1238    #endif
1239  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);
1240  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);
1241  JUMPTO(SLJIT_C_NOT_ZERO, loop);  JUMPTO(SLJIT_C_NOT_ZERO, loop);
# Line 1254  if (common->utf8) Line 1279  if (common->utf8)
1279  else  else
1280  #endif  #endif
1281    c = *cc;    c = *cc;
1282  return common->fcc[c] != c;  return MAX_255(c) ? common->fcc[c] != c : FALSE;
1283  }  }
1284    
1285  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)
# Line 1270  if (common->utf8 && c > 127) Line 1295  if (common->utf8 && c > 127)
1295  #endif  #endif
1296    }    }
1297  #endif  #endif
1298  return common->fcc[c];  return TABLE_GET(c, common->fcc, c);
1299  }  }
1300    
1301  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)
# Line 1320  if (!ispowerof2(bit)) Line 1345  if (!ispowerof2(bit))
1345  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1346  if (common->utf8 && c > 127)  if (common->utf8 && c > 127)
1347    {    {
1348    n = _pcre_utf8_table4[*cc & 0x3f];    n = PRIV(utf8_table4)[*cc & 0x3f];
1349    while ((bit & 0x3f) == 0)    while ((bit & 0x3f) == 0)
1350      {      {
1351      n--;      n--;
# Line 1347  DEFINE_COMPILER; Line 1372  DEFINE_COMPILER;
1372  struct sljit_jump *jump;  struct sljit_jump *jump;
1373  #endif  #endif
1374    
1375  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1376  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1377  if (common->utf8)  if (common->utf8)
1378    {    {
# Line 1356  if (common->utf8) Line 1381  if (common->utf8)
1381    JUMPHERE(jump);    JUMPHERE(jump);
1382    }    }
1383  #endif  #endif
1384  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));
1385  }  }
1386    
1387  static void peek_char(compiler_common *common)  static void peek_char(compiler_common *common)
# Line 1402  if (common->utf8) Line 1427  if (common->utf8)
1427    return;    return;
1428    }    }
1429  #endif  #endif
1430  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1431  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));
1432  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);
1433  }  }
1434    
# Line 1424  if (common->utf8) Line 1449  if (common->utf8)
1449    return;    return;
1450    }    }
1451  #endif  #endif
1452  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1453  }  }
1454    
1455  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 1565  sljit_emit_fast_return(compiler, RETURN_ Line 1590  sljit_emit_fast_return(compiler, RETURN_
1590  JUMPHERE(jump);  JUMPHERE(jump);
1591    
1592  /* We only have types for characters less than 256. */  /* We only have types for characters less than 256. */
1593  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);
1594  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1595  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
1596  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
# Line 1589  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si Line 1614  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si
1614    
1615  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);
1616  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
1617  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));
1618  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
1619  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
1620  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
1621  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)_pcre_ucd_stage2);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_stage2));
1622  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);
1623  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));
1624  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);
1625  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
1626  }  }
# Line 1614  struct sljit_jump *singlebyte; Line 1639  struct sljit_jump *singlebyte;
1639  #endif  #endif
1640  jump_list *newline = NULL;  jump_list *newline = NULL;
1641  BOOL newlinecheck = FALSE;  BOOL newlinecheck = FALSE;
1642  BOOL readbyte = FALSE;  BOOL readuchar = FALSE;
1643    
1644  if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||  if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||
1645      common->nltype == NLTYPE_ANYCRLF || common->newline > 255))      common->nltype == NLTYPE_ANYCRLF || common->newline > 255))
# Line 1629  if (firstline) Line 1654  if (firstline)
1654    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
1655      {      {
1656      mainloop = LABEL();      mainloop = LABEL();
1657      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));
1658      end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);      end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1659      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -1);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
1660      OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
1661      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);
1662      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);
1663      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));
1664      }      }
1665    else    else
1666      {      {
# Line 1659  start = JUMP(SLJIT_JUMP); Line 1684  start = JUMP(SLJIT_JUMP);
1684  if (newlinecheck)  if (newlinecheck)
1685    {    {
1686    newlinelabel = LABEL();    newlinelabel = LABEL();
1687    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));
1688    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1689    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1690    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);
1691    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
1692    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 1697  mainloop = LABEL();
1697    
1698  /* 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. */
1699  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1700  if (common->utf8) readbyte = TRUE;  if (common->utf8) readuchar = TRUE;
1701  #endif  #endif
1702  if (newlinecheck) readbyte = TRUE;  if (newlinecheck) readuchar = TRUE;
1703    
1704  if (readbyte)  if (readuchar)
1705    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1706    
1707  if (newlinecheck)  if (newlinecheck)
1708    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);
1709    
1710  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));
1711  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1712  if (common->utf8)  if (common->utf8)
1713    {    {
1714    singlebyte = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    singlebyte = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
1715    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);
1716    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1717    JUMPHERE(singlebyte);    JUMPHERE(singlebyte);
1718    }    }
# Line 1703  if (newlinecheck) Line 1728  if (newlinecheck)
1728  return mainloop;  return mainloop;
1729  }  }
1730    
1731  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)
1732  {  {
1733  DEFINE_COMPILER;  DEFINE_COMPILER;
1734  struct sljit_label *start;  struct sljit_label *start;
1735  struct sljit_jump *leave;  struct sljit_jump *leave;
1736  struct sljit_jump *found;  struct sljit_jump *found;
1737  pcre_uint16 oc, bit;  pcre_uchar oc, bit;
1738    
1739  if (firstline)  if (firstline)
1740    {    {
# Line 1719  if (firstline) Line 1744  if (firstline)
1744    
1745  start = LABEL();  start = LABEL();
1746  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1747  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1748    
1749  if ((firstbyte & REQ_CASELESS) == 0)  oc = firstchar;
1750    found = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, firstbyte & 0xff);  if (caseless)
1751      oc = TABLE_GET(firstchar, common->fcc, firstchar);
1752    if (firstchar == oc)
1753      found = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, firstchar);
1754  else  else
1755    {    {
1756    firstbyte &= 0xff;    bit = firstchar ^ oc;
   oc = common->fcc[firstbyte];  
   bit = firstbyte ^ oc;  
1757    if (ispowerof2(bit))    if (ispowerof2(bit))
1758      {      {
1759      OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);
1760      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, firstbyte | bit);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, firstchar | bit);
1761      }      }
1762    else    else
1763      {      {
1764      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);
1765      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
1766      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);
1767      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 1769  else
1769      }      }
1770    }    }
1771    
1772  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));
1773  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1774  if (common->utf8)  if (common->utf8)
1775    {    {
1776    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
1777    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);
1778    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1779    }    }
1780  #endif  #endif
# Line 1854  if (firstline) Line 1880  if (firstline)
1880    
1881  start = LABEL();  start = LABEL();
1882  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  leave = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1883  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1884  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1885  if (common->utf8)  if (common->utf8)
1886    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
1887  #endif  #endif
1888    #ifndef COMPILE_PCRE8
1889    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xff);
1890    #endif
1891  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
1892  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
1893  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 1895  OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TM
1895  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);
1896  found = JUMP(SLJIT_C_NOT_ZERO);  found = JUMP(SLJIT_C_NOT_ZERO);
1897    
1898  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF
1899  if (common->utf8)  if (common->utf8)
1900    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
1901  #endif  #endif
1902  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));
1903  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1904  if (common->utf8)  if (common->utf8)
1905    {    {
1906    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
1907    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);
1908    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
1909    }    }
1910  #endif  #endif
# Line 1887  if (firstline) Line 1916  if (firstline)
1916    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
1917  }  }
1918    
1919  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)
1920  {  {
1921  DEFINE_COMPILER;  DEFINE_COMPILER;
1922  struct sljit_label *loop;  struct sljit_label *loop;
# Line 1896  struct sljit_jump *alreadyfound; Line 1925  struct sljit_jump *alreadyfound;
1925  struct sljit_jump *found;  struct sljit_jump *found;
1926  struct sljit_jump *foundoc = NULL;  struct sljit_jump *foundoc = NULL;
1927  struct sljit_jump *notfound;  struct sljit_jump *notfound;
1928  pcre_uint16 oc, bit;  pcre_uchar oc, bit;
1929    
1930  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);
1931  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);
1932  toolong = CMP(SLJIT_C_LESS, TMP1, 0, STR_END, 0);  toolong = CMP(SLJIT_C_LESS, TMP1, 0, STR_END, 0);
1933  alreadyfound = CMP(SLJIT_C_LESS, STR_PTR, 0, TMP2, 0);  alreadyfound = CMP(SLJIT_C_LESS, STR_PTR, 0, TMP2, 0);
1934    
1935  if (has_firstbyte)  if (has_firstchar)
1936    OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, 1);    OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, 1);
1937  else  else
1938    OP1(SLJIT_MOV, TMP1, 0, STR_PTR, 0);    OP1(SLJIT_MOV, TMP1, 0, STR_PTR, 0);
# Line 1912  loop = LABEL(); Line 1941  loop = LABEL();
1941  notfound = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, STR_END, 0);  notfound = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, STR_END, 0);
1942    
1943  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), 0);  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), 0);
1944  if ((reqbyte & REQ_CASELESS) == 0)  oc = reqchar;
1945    found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqbyte & 0xff);  if (caseless)
1946      oc = TABLE_GET(reqchar, common->fcc, reqchar);
1947    if (reqchar == oc)
1948      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqchar);
1949  else  else
1950    {    {
1951    reqbyte &= 0xff;    bit = reqchar ^ oc;
   oc = common->fcc[reqbyte];  
   bit = reqbyte ^ oc;  
1952    if (ispowerof2(bit))    if (ispowerof2(bit))
1953      {      {
1954      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);
1955      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqbyte | bit);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqchar | bit);
1956      }      }
1957    else    else
1958      {      {
1959      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqbyte);      found = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, reqchar);
1960      foundoc = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, oc);      foundoc = CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, oc);
1961      }      }
1962    }    }
# Line 1936  JUMPTO(SLJIT_JUMP, loop); Line 1966  JUMPTO(SLJIT_JUMP, loop);
1966  JUMPHERE(found);  JUMPHERE(found);
1967  if (foundoc)  if (foundoc)
1968    JUMPHERE(foundoc);    JUMPHERE(foundoc);
1969  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);
1970  JUMPHERE(alreadyfound);  JUMPHERE(alreadyfound);
1971  JUMPHERE(toolong);  JUMPHERE(toolong);
1972  return notfound;  return notfound;
# Line 2257  static pcre_uchar *byte_sequence_compare Line 2287  static pcre_uchar *byte_sequence_compare
2287  {  {
2288  DEFINE_COMPILER;  DEFINE_COMPILER;
2289  unsigned int othercasebit = 0;  unsigned int othercasebit = 0;
2290  pcre_uint8 *othercasebyte = NULL;  pcre_uchar *othercasechar = NULL;
2291  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2292  int utf8length;  int utf8length;
2293  #endif  #endif
# Line 2267  if (caseless && char_has_othercase(commo Line 2297  if (caseless && char_has_othercase(commo
2297    othercasebit = char_get_othercase_bit(common, cc);    othercasebit = char_get_othercase_bit(common, cc);
2298    SLJIT_ASSERT(othercasebit);    SLJIT_ASSERT(othercasebit);
2299    /* Extracting bit difference info. */    /* Extracting bit difference info. */
2300    othercasebyte = cc + (othercasebit >> 8);  #ifdef COMPILE_PCRE8
2301      othercasechar = cc + (othercasebit >> 8);
2302    othercasebit &= 0xff;    othercasebit &= 0xff;
2303    #else
2304    #ifdef COMPILE_PCRE16
2305      othercasechar = cc + (othercasebit >> 9);
2306      if ((othercasebit & 0x100) != 0)
2307        othercasebit = (othercasebit & 0xff) << 8;
2308      else
2309        othercasebit &= 0xff;
2310    #endif
2311    #endif
2312    }    }
2313    
2314  if (context->sourcereg == -1)  if (context->sourcereg == -1)
2315    {    {
2316    #ifdef COMPILE_PCRE8
2317  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2318    if (context->length >= 4)    if (context->length >= 4)
2319      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 2322  if (context->sourcereg == -1)
2322    else    else
2323  #endif  #endif
2324      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2325    #else
2326    #ifdef COMPILE_PCRE16
2327    #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2328      if (context->length >= 4)
2329        OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2330      else
2331    #endif
2332        OP1(SLJIT_MOV_SH, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2333    #endif
2334    #endif /* COMPILE_PCRE8 */
2335    context->sourcereg = TMP2;    context->sourcereg = TMP2;
2336    }    }
2337    
2338  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2339  utf8length = 1;  utf8length = 1;
2340  if (common->utf8 && *cc >= 0xc0)  if (common->utf8 && *cc >= 0xc0)
2341    utf8length += _pcre_utf8_table4[*cc & 0x3f];    utf8length += PRIV(utf8_table4)[*cc & 0x3f];
2342    
2343  do  do
2344    {    {
2345  #endif  #endif
2346    
2347    context->length--;    context->length -= IN_UCHARS(1);
2348  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2349    
2350    /* Unaligned read is supported. */    /* Unaligned read is supported. */
2351    if (othercasebit != 0 && othercasebyte == cc)    if (othercasebit != 0 && othercasechar == cc)
2352      {      {
2353      context->c.asbytes[context->byteptr] = *cc | othercasebit;      context->c.asuchars[context->ucharptr] = *cc | othercasebit;
2354      context->oc.asbytes[context->byteptr] = othercasebit;      context->oc.asuchars[context->ucharptr] = othercasebit;
2355      }      }
2356    else    else
2357      {      {
2358      context->c.asbytes[context->byteptr] = *cc;      context->c.asuchars[context->ucharptr] = *cc;
2359      context->oc.asbytes[context->byteptr] = 0;      context->oc.asuchars[context->ucharptr] = 0;
2360      }      }
2361    context->byteptr++;    context->ucharptr++;
2362    
2363    if (context->byteptr >= 4 || context->length == 0 || (context->byteptr == 2 && context->length == 1))  #ifdef COMPILE_PCRE8
2364      if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
2365    #else
2366      if (context->ucharptr >= 2 || context->length == 0)
2367    #endif
2368      {      {
2369      if (context->length >= 4)      if (context->length >= 4)
2370        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);
2371    #ifdef COMPILE_PCRE8
2372      else if (context->length >= 2)      else if (context->length >= 2)
2373        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);
2374      else if (context->length >= 1)      else if (context->length >= 1)
2375        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);
2376    #else
2377        else if (context->length >= 2)
2378          OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2379    #endif
2380      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
2381    
2382      switch(context->byteptr)      switch(context->ucharptr)
2383        {        {
2384        case 4:        case 4 / sizeof(pcre_uchar):
2385        if (context->oc.asint != 0)        if (context->oc.asint != 0)
2386          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);
2387        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));
2388        break;        break;
2389    
2390        case 2:        case 2 / sizeof(pcre_uchar):
2391        if (context->oc.asshort != 0)        if (context->oc.asshort != 0)
2392          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);
2393        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));
2394        break;        break;
2395    
2396    #ifdef COMPILE_PCRE8
2397        case 1:        case 1:
2398        if (context->oc.asbyte != 0)        if (context->oc.asbyte != 0)
2399          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);
2400        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));
2401        break;        break;
2402    #endif
2403    
2404        default:        default:
2405        SLJIT_ASSERT_STOP();        SLJIT_ASSERT_STOP();
2406        break;        break;
2407        }        }
2408      context->byteptr = 0;      context->ucharptr = 0;
2409      }      }
2410    
2411  #else  #else
2412    
2413    /* Unaligned read is unsupported. */    /* Unaligned read is unsupported. */
2414    #ifdef COMPILE_PCRE8
2415    if (context->length > 0)    if (context->length > 0)
2416      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);
2417    #else
2418      if (context->length > 0)
2419        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2420    #endif
2421    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
2422    
2423    if (othercasebit != 0 && othercasebyte == cc)    if (othercasebit != 0 && othercasechar == cc)
2424      {      {
2425      OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);      OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);
2426      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 2373  while (utf8length > 0); Line 2440  while (utf8length > 0);
2440  return cc;  return cc;
2441  }  }
2442    
2443  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
2444    
2445  #define SET_TYPE_OFFSET(value) \  #define SET_TYPE_OFFSET(value) \
2446    if ((value) != typeoffset) \    if ((value) != typeoffset) \
# Line 2420  read_char(common); Line 2487  read_char(common);
2487  if ((*cc++ & XCL_MAP) != 0)  if ((*cc++ & XCL_MAP) != 0)
2488    {    {
2489    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
2490    #ifndef COMPILE_PCRE8
2491      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
2492    #elif defined SUPPORT_UTF8
2493    if (common->utf8)    if (common->utf8)
2494      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
2495    #endif
2496    
2497    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
2498    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 2501  if ((*cc++ & XCL_MAP) != 0)
2501    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);
2502    add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));    add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));
2503    
2504    #ifndef COMPILE_PCRE8
2505      JUMPHERE(jump);
2506    #elif defined SUPPORT_UTF8
2507    if (common->utf8)    if (common->utf8)
2508      JUMPHERE(jump);      JUMPHERE(jump);
2509    #endif
2510    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
2511  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2512    charsaved = TRUE;    charsaved = TRUE;
2513  #endif  #endif
2514    cc += 32;    cc += 32 / sizeof(pcre_uchar);
2515    }    }
2516    
2517  /* Scanning the necessary info. */  /* Scanning the necessary info. */
# Line 2449  while (*cc != XCL_END) Line 2524  while (*cc != XCL_END)
2524      {      {
2525      cc += 2;      cc += 2;
2526  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2527      if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];
2528  #endif  #endif
2529  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2530      needschar = TRUE;      needschar = TRUE;
# Line 2459  while (*cc != XCL_END) Line 2534  while (*cc != XCL_END)
2534      {      {
2535      cc += 2;      cc += 2;
2536  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2537      if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];
2538  #endif  #endif
2539      cc++;      cc++;
2540  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2541      if (common->utf8 && cc[-1] >= 0xc0) cc += _pcre_utf8_table4[cc[-1] & 0x3f];      if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];
2542  #endif  #endif
2543  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
2544      needschar = TRUE;      needschar = TRUE;
# Line 2533  if (needstype || needsscript) Line 2608  if (needstype || needsscript)
2608      {      {
2609      if (scriptreg == TMP1)      if (scriptreg == TMP1)
2610        {        {
2611        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));
2612        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);
2613        }        }
2614      else      else
2615        {        {
2616        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
2617        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));
2618        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);
2619        }        }
2620      }      }
# Line 2660  while (*cc != XCL_END) Line 2735  while (*cc != XCL_END)
2735        break;        break;
2736    
2737        case PT_GC:        case PT_GC:
2738        c = _pcre_ucp_typerange[(int)cc[1] * 2];        c = PRIV(ucp_typerange)[(int)cc[1] * 2];
2739        SET_TYPE_OFFSET(c);        SET_TYPE_OFFSET(c);
2740        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);
2741        break;        break;
2742    
2743        case PT_PC:        case PT_PC:
# Line 2806  switch(type) Line 2881  switch(type)
2881      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2882      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
2883      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2884      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);
2885      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2886      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
2887      return cc;      return cc;
# Line 3021  switch(type) Line 3096  switch(type)
3096    case OP_CHARI:    case OP_CHARI:
3097    length = 1;    length = 1;
3098  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3099    if (common->utf8 && *cc >= 0xc0) length += _pcre_utf8_table4[*cc & 0x3f];    if (common->utf8 && *cc >= 0xc0) length += PRIV(utf8_table4)[*cc & 0x3f];
3100  #endif  #endif
3101    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)
3102      {      {
3103      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));
3104      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));
3105    
3106      context.length = length;      context.length = IN_UCHARS(length);
3107      context.sourcereg = -1;      context.sourcereg = -1;
3108  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
3109      context.byteptr = 0;      context.ucharptr = 0;
3110  #endif  #endif
3111      return byte_sequence_compare(common, type == OP_CHARI, cc, &context, fallbacks);      return byte_sequence_compare(common, type == OP_CHARI, cc, &context, fallbacks);
3112      }      }
3113    add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));    check_input_end(common, fallbacks);
3114    read_char(common);    read_char(common);
3115  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3116    if (common->utf8)    if (common->utf8)
# Line 3054  switch(type) Line 3129  switch(type)
3129    
3130    case OP_NOT:    case OP_NOT:
3131    case OP_NOTI:    case OP_NOTI:
   length = 1;  
3132  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3133    if (common->utf8)    if (common->utf8)
3134      {      {
3135      if (*cc >= 0xc0) length += _pcre_utf8_table4[*cc & 0x3f];      length = 1;
3136        if (*cc >= 0xc0) length += PRIV(utf8_table4)[*cc & 0x3f];
3137    
3138      check_input_end(common, fallbacks);      check_input_end(common, fallbacks);
3139      GETCHAR(c, cc);      GETCHAR(c, cc);
# Line 3077  switch(type) Line 3152  switch(type)
3152        /* Skip the variable-length character. */        /* Skip the variable-length character. */
3153        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
3154        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
3155        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);
3156        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
3157        JUMPHERE(jump[0]);        JUMPHERE(jump[0]);
3158        return cc + length;        return cc + length;
# Line 3088  switch(type) Line 3163  switch(type)
3163    else    else
3164  #endif  #endif
3165      {      {
3166      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));
3167      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));
3168      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -1);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
3169      c = *cc;      c = *cc;
3170      }      }
3171    
# Line 3111  switch(type) Line 3186  switch(type)
3186        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));
3187        }        }
3188      }      }
3189    return cc + length;    return cc + 1;
3190    
3191    case OP_CLASS:    case OP_CLASS:
3192    case OP_NCLASS:    case OP_NCLASS:
3193    check_input_end(common, fallbacks);    check_input_end(common, fallbacks);
3194    read_char(common);    read_char(common);
3195  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3196    jump[0] = NULL;    jump[0] = NULL;
3197    #ifdef SUPPORT_UTF8
3198      /* This check can only be skipped in pure 8 bit mode. */
3199    if (common->utf8)    if (common->utf8)
3200    #endif
3201      {      {
3202      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
3203      if (type == OP_CLASS)      if (type == OP_CLASS)
# Line 3135  switch(type) Line 3213  switch(type)
3213    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
3214    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);
3215    add_jump(compiler, fallbacks, JUMP(SLJIT_C_ZERO));    add_jump(compiler, fallbacks, JUMP(SLJIT_C_ZERO));
3216  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3217    if (jump[0] != NULL)    if (jump[0] != NULL)
3218      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
3219  #endif  #endif
3220    return cc + 32;    return cc + 32 / sizeof(pcre_uchar);
3221    
3222  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || defined COMPILE_PCRE16
3223    case OP_XCLASS:    case OP_XCLASS:
3224    compile_xclass_hotpath(common, cc + LINK_SIZE, fallbacks);    compile_xclass_hotpath(common, cc + LINK_SIZE, fallbacks);
3225    return cc + GET(cc, 0) - 1;    return cc + GET(cc, 0) - 1;
# Line 3192  do Line 3270  do
3270      size = 1;      size = 1;
3271  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3272      if (common->utf8 && cc[1] >= 0xc0)      if (common->utf8 && cc[1] >= 0xc0)
3273        size += _pcre_utf8_table4[cc[1] & 0x3f];        size += PRIV(utf8_table4)[cc[1] & 0x3f];
3274  #endif  #endif
3275      }      }
3276    else if (*cc == OP_CHARI)    else if (*cc == OP_CHARI)
# Line 3204  do Line 3282  do
3282        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)
3283          size = 0;          size = 0;
3284        else if (cc[1] >= 0xc0)        else if (cc[1] >= 0xc0)
3285          size += _pcre_utf8_table4[cc[1] & 0x3f];          size += PRIV(utf8_table4)[cc[1] & 0x3f];
3286        }        }
3287      else      else
3288  #endif  #endif
# Line 3215  do Line 3293  do
3293      size = 0;      size = 0;
3294    
3295    cc += 1 + size;    cc += 1 + size;
3296    context.length += size;    context.length += IN_UCHARS(size);
3297    }    }
3298  while (size > 0 && context.length <= 128);  while (size > 0 && context.length <= 128);
3299    
# Line 3228  if (context.length > 0) Line 3306  if (context.length > 0)
3306    
3307    context.sourcereg = -1;    context.sourcereg = -1;
3308  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
3309    context.byteptr = 0;    context.ucharptr = 0;
3310  #endif  #endif
3311    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);
3312    return cc;    return cc;
# Line 3340  if (jump != NULL) Line 3418  if (jump != NULL)
3418    else    else
3419      JUMPHERE(jump);      JUMPHERE(jump);
3420    }    }
3421  return cc + 3;  return cc + 1 + IMM2_SIZE;
3422  }  }
3423    
3424  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 3435  BOOL minimize;
3435    
3436  PUSH_FALLBACK(sizeof(iterator_fallback), cc, NULL);  PUSH_FALLBACK(sizeof(iterator_fallback), cc, NULL);
3437    
3438  type = cc[3];  type = cc[1 + IMM2_SIZE];
3439  minimize = (type & 0x1) != 0;  minimize = (type & 0x1) != 0;
3440  switch(type)  switch(type)
3441    {    {
# Line 3365  switch(type) Line 3443  switch(type)
3443    case OP_CRMINSTAR:    case OP_CRMINSTAR:
3444    min = 0;    min = 0;
3445    max = 0;    max = 0;
3446    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3447    break;    break;
3448    case OP_CRPLUS:    case OP_CRPLUS:
3449    case OP_CRMINPLUS:    case OP_CRMINPLUS:
3450    min = 1;    min = 1;
3451    max = 0;    max = 0;
3452    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3453    break;    break;
3454    case OP_CRQUERY:    case OP_CRQUERY:
3455    case OP_CRMINQUERY:    case OP_CRMINQUERY:
3456    min = 0;    min = 0;
3457    max = 1;    max = 1;
3458    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3459    break;    break;
3460    case OP_CRRANGE:    case OP_CRRANGE:
3461    case OP_CRMINRANGE:    case OP_CRMINRANGE:
3462    min = GET2(cc, 3 + 1);    min = GET2(cc, 1 + IMM2_SIZE + 1);
3463    max = GET2(cc, 3 + 3);    max = GET2(cc, 1 + IMM2_SIZE + 1 + IMM2_SIZE);
3464    cc += 8;    cc += 1 + IMM2_SIZE + 1 + 2 * IMM2_SIZE;
3465    break;    break;
3466    default:    default:
3467    SLJIT_ASSERT_STOP();    SLJIT_ASSERT_STOP();
# Line 3557  if (*cc == OP_BRAZERO || *cc == OP_BRAMI Line 3635  if (*cc == OP_BRAZERO || *cc == OP_BRAMI
3635    bra = *cc;    bra = *cc;
3636    cc++;    cc++;
3637    }    }
3638  localptr = PRIV(cc);  localptr = PRIV_DATA(cc);
3639  SLJIT_ASSERT(localptr != 0);  SLJIT_ASSERT(localptr != 0);
3640  framesize = get_framesize(common, cc, FALSE);  framesize = get_framesize(common, cc, FALSE);
3641  fallback->framesize = framesize;  fallback->framesize = framesize;
# Line 4038  if (opcode == OP_CBRA || opcode == OP_SC Line 4116  if (opcode == OP_CBRA || opcode == OP_SC
4116    localptr = OVECTOR_PRIV(offset);    localptr = OVECTOR_PRIV(offset);
4117    offset <<= 1;    offset <<= 1;
4118    FALLBACK_AS(bracket_fallback)->localptr = localptr;    FALLBACK_AS(bracket_fallback)->localptr = localptr;
4119    hotpath += 2;    hotpath += IMM2_SIZE;
4120    }    }
4121  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)
4122    {    {
4123    /* Other brackets simply allocate the next entry. */    /* Other brackets simply allocate the next entry. */
4124    localptr = PRIV(ccbegin);    localptr = PRIV_DATA(ccbegin);
4125    SLJIT_ASSERT(localptr != 0);    SLJIT_ASSERT(localptr != 0);
4126    FALLBACK_AS(bracket_fallback)->localptr = localptr;    FALLBACK_AS(bracket_fallback)->localptr = localptr;
4127    if (opcode == OP_ONCE)    if (opcode == OP_ONCE)
# Line 4202  if (opcode == OP_COND || opcode == OP_SC Line 4280  if (opcode == OP_COND || opcode == OP_SC
4280      SLJIT_ASSERT(has_alternatives);      SLJIT_ASSERT(has_alternatives);
4281      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed),      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed),
4282        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)));
4283      hotpath += 3;      hotpath += 1 + IMM2_SIZE;
4284      }      }
4285    else if (*hotpath == OP_NCREF)    else if (*hotpath == OP_NCREF)
4286      {      {
# Line 4221  if (opcode == OP_COND || opcode == OP_SC Line 4299  if (opcode == OP_COND || opcode == OP_SC
4299      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));
4300    
4301      JUMPHERE(jump);      JUMPHERE(jump);
4302      hotpath += 3;      hotpath += 1 + IMM2_SIZE;
4303      }      }
4304    else if (*hotpath == OP_RREF || *hotpath == OP_NRREF)    else if (*hotpath == OP_RREF || *hotpath == OP_NRREF)
4305      {      {
# Line 4242  if (opcode == OP_COND || opcode == OP_SC Line 4320  if (opcode == OP_COND || opcode == OP_SC
4320        {        {
4321        SLJIT_ASSERT(!has_alternatives);        SLJIT_ASSERT(!has_alternatives);
4322        if (stacksize != 0)        if (stacksize != 0)
4323          hotpath += 3;          hotpath += 1 + IMM2_SIZE;
4324        else        else
4325          {          {
4326          if (*cc == OP_ALT)          if (*cc == OP_ALT)
# Line 4269  if (opcode == OP_COND || opcode == OP_SC Line 4347  if (opcode == OP_COND || opcode == OP_SC
4347        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));
4348        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);
4349        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));
4350        hotpath += 3;        hotpath += 1 + IMM2_SIZE;
4351        }        }
4352      }      }
4353    else    else
# Line 4429  if (*cc == OP_BRAPOSZERO) Line 4507  if (*cc == OP_BRAPOSZERO)
4507    }    }
4508    
4509  opcode = *cc;  opcode = *cc;
4510  localptr = PRIV(cc);  localptr = PRIV_DATA(cc);
4511  SLJIT_ASSERT(localptr != 0);  SLJIT_ASSERT(localptr != 0);
4512  FALLBACK_AS(bracketpos_fallback)->localptr = localptr;  FALLBACK_AS(bracketpos_fallback)->localptr = localptr;
4513  switch(opcode)  switch(opcode)
# Line 4444  switch(opcode) Line 4522  switch(opcode)
4522    offset = GET2(cc, 1 + LINK_SIZE);    offset = GET2(cc, 1 + LINK_SIZE);
4523    cbraprivptr = OVECTOR_PRIV(offset);    cbraprivptr = OVECTOR_PRIV(offset);
4524    offset <<= 1;    offset <<= 1;
4525    ccbegin = cc + 1 + LINK_SIZE + 2;    ccbegin = cc + 1 + LINK_SIZE + IMM2_SIZE;
4526    break;    break;
4527    
4528    default:    default:
# Line 4662  else Line 4740  else
4740    SLJIT_ASSERT(*opcode >= OP_CLASS || *opcode <= OP_XCLASS);    SLJIT_ASSERT(*opcode >= OP_CLASS || *opcode <= OP_XCLASS);
4741    *type = *opcode;    *type = *opcode;
4742    cc++;    cc++;
4743    class_len = (*type < OP_XCLASS) ? 33 : GET(cc, 0);    class_len = (*type < OP_XCLASS) ? (1 + (32 / sizeof(pcre_uchar))) : GET(cc, 0);
4744    *opcode = cc[class_len - 1];    *opcode = cc[class_len - 1];
4745    if (*opcode >= OP_CRSTAR && *opcode <= OP_CRMINQUERY)    if (*opcode >= OP_CRSTAR && *opcode <= OP_CRMINQUERY)
4746      {      {
# Line 4673  else Line 4751  else
4751    else    else
4752      {      {
4753      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);
4754      *arg1 = GET2(cc, (class_len + 2));      *arg1 = GET2(cc, (class_len + IMM2_SIZE));
4755      *arg2 = GET2(cc, class_len);      *arg2 = GET2(cc, class_len);
4756    
4757      if (*arg2 == 0)      if (*arg2 == 0)
# Line 4685  else Line 4763  else
4763        *opcode = OP_EXACT;        *opcode = OP_EXACT;
4764    
4765      if (end != NULL)      if (end != NULL)
4766        *end = cc + class_len + 4;        *end = cc + class_len + 2 * IMM2_SIZE;
4767      }      }
4768    return cc;    return cc;
4769    }    }
# Line 4693  else Line 4771  else
4771  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)
4772    {    {
4773    *arg1 = GET2(cc, 0);    *arg1 = GET2(cc, 0);
4774    cc += 2;    cc += IMM2_SIZE;
4775    }    }
4776    
4777  if (*type == 0)  if (*type == 0)
# Line 4709  if (end != NULL) Line 4787  if (end != NULL)
4787    {    {
4788    *end = cc + 1;    *end = cc + 1;
4789  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
4790    if (common->utf8 && *cc >= 0xc0) *end += _pcre_utf8_table4[*cc & 0x3f];    if (common->utf8 && *cc >= 0xc0) *end += PRIV(utf8_table4)[*cc & 0x3f];
4791  #endif  #endif
4792    }    }
4793  return cc;  return cc;
# Line 4935  int offset = GET2(cc, 1); Line 5013  int offset = GET2(cc, 1);
5013    
5014  /* Data will be discarded anyway... */  /* Data will be discarded anyway... */
5015  if (common->currententry != NULL)  if (common->currententry != NULL)
5016    return cc + 3;    return cc + 1 + IMM2_SIZE;
5017    
5018  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));
5019  offset <<= 1;  offset <<= 1;
5020  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);
5021  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
5022  return cc + 3;  return cc + 1 + IMM2_SIZE;
5023  }  }
5024    
5025  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 5148  while (cc < ccend)
5148    
5149      case OP_CLASS:      case OP_CLASS:
5150      case OP_NCLASS:      case OP_NCLASS:
5151      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)
5152        cc = compile_iterator_hotpath(common, cc, parent);        cc = compile_iterator_hotpath(common, cc, parent);
5153      else      else
5154        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);
5155      break;      break;
5156    
5157  #ifdef SUPPORT_UTF8  #if defined SUPPORT_UTF || defined COMPILE_PCRE16
5158      case OP_XCLASS:      case OP_XCLASS:
5159      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)
5160        cc = compile_iterator_hotpath(common, cc, parent);        cc = compile_iterator_hotpath(common, cc, parent);
# Line 5087  while (cc < ccend) Line 5165  while (cc < ccend)
5165    
5166      case OP_REF:      case OP_REF:
5167      case OP_REFI:      case OP_REFI:
5168      if (cc[3] >= OP_CRSTAR && cc[3] <= OP_CRMINRANGE)      if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRMINRANGE)
5169        cc = compile_ref_iterator_hotpath(common, cc, parent);        cc = compile_ref_iterator_hotpath(common, cc, parent);
5170      else      else
5171        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 5403  DEFINE_COMPILER;
5403  pcre_uchar *cc = current->cc;  pcre_uchar *cc = current->cc;
5404  pcre_uchar type;  pcre_uchar type;
5405    
5406  type = cc[3];  type = cc[1 + IMM2_SIZE];
5407  if ((type & 0x1) == 0)  if ((type & 0x1) == 0)
5408    {    {
5409    set_jumps(current->topfallbacks, LABEL());    set_jumps(current->topfallbacks, LABEL());
# Line 5931  while (current) Line 6009  while (current)
6009      case OP_TYPEPOSUPTO:      case OP_TYPEPOSUPTO:
6010      case OP_CLASS:      case OP_CLASS:
6011      case OP_NCLASS:      case OP_NCLASS:
6012    #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
6013      case OP_XCLASS:      case OP_XCLASS:
6014    #endif
6015      compile_iterator_fallbackpath(common, current);      compile_iterator_fallbackpath(common, current);
6016      break;      break;
6017    
# Line 5999  static SLJIT_INLINE void compile_recurse Line 6079  static SLJIT_INLINE void compile_recurse
6079  {  {
6080  DEFINE_COMPILER;  DEFINE_COMPILER;
6081  pcre_uchar *cc = common->start + common->currententry->start;  pcre_uchar *cc = common->start + common->currententry->start;
6082  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);
6083  pcre_uchar *ccend = bracketend(cc);  pcre_uchar *ccend = bracketend(cc);
6084  int localsize = get_localsize(common, ccbegin, ccend);  int localsize = get_localsize(common, ccbegin, ccend);
6085  int framesize = get_framesize(common, cc, TRUE);  int framesize = get_framesize(common, cc, TRUE);
# Line 6088  sljit_emit_fast_return(compiler, SLJIT_M Line 6168  sljit_emit_fast_return(compiler, SLJIT_M
6168  #undef CURRENT_AS  #undef CURRENT_AS
6169    
6170  void  void
6171  _pcre_jit_compile(const real_pcre *re, pcre_extra *extra)  PRIV(jit_compile)(const real_pcre *re, pcre_extra *extra)
6172  {  {
6173  struct sljit_compiler *compiler;  struct sljit_compiler *compiler;
6174  fallback_common rootfallback;  fallback_common rootfallback;
# Line 6111  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_ Line 6191  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_
6191  study = extra->study_data;  study = extra->study_data;
6192    
6193  if (!tables)  if (!tables)
6194    tables = _pcre_default_tables;    tables = PRIV(default_tables);
6195    
6196  memset(&rootfallback, 0, sizeof(fallback_common));  memset(&rootfallback, 0, sizeof(fallback_common));
6197  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 6212  sljit_emit_enter(compiler, 1, 5, 5, comm Line 6292  sljit_emit_enter(compiler, 1, 5, 5, comm
6292  /* Register init. */  /* Register init. */
6293  reset_ovector(common, (re->top_bracket + 1) * 2);  reset_ovector(common, (re->top_bracket + 1) * 2);
6294  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6295    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);
6296    
6297  OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_GENERAL_REG1, 0);  OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_GENERAL_REG1, 0);
6298  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 6310  if ((re->options & PCRE_ANCHORED) == 0)
6310    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);
6311    /* Forward search if possible. */    /* Forward search if possible. */
6312    if ((re->flags & PCRE_FIRSTSET) != 0)    if ((re->flags & PCRE_FIRSTSET) != 0)
6313      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);
6314    else if ((re->flags & PCRE_STARTLINE) != 0)    else if ((re->flags & PCRE_STARTLINE) != 0)
6315      fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);      fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);
6316    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)
6317      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);
6318    }    }
6319  if ((re->flags & PCRE_REQCHSET) != 0)  if ((re->flags & PCRE_REQCHSET) != 0)
6320    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);
6321    
6322  /* Store the current STR_PTR in OVECTOR(0). */  /* Store the current STR_PTR in OVECTOR(0). */
6323  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 6364  if ((re->options & PCRE_ANCHORED) == 0)
6364      {      {
6365      if (study != NULL && study->minlength > 1)      if (study != NULL && study->minlength > 1)
6366        {        {
6367        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));
6368        CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);        CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);
6369        }        }
6370      else      else
# Line 6294  if ((re->options & PCRE_ANCHORED) == 0) Line 6374  if ((re->options & PCRE_ANCHORED) == 0)
6374      {      {
6375      if (study != NULL && study->minlength > 1)      if (study != NULL && study->minlength > 1)
6376        {        {
6377        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));
6378        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);
6379        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);
6380        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 6467  return convert_executable_func.call_exec Line 6547  return convert_executable_func.call_exec
6547  }  }
6548    
6549  int  int
6550  _pcre_jit_exec(const real_pcre *re, void *executable_func,  PRIV(jit_exec)(const real_pcre *re, void *executable_func,
6551    PCRE_SPTR subject, int length, int start_offset, int options,    const pcre_uchar *subject, int length, int start_offset, int options,
6552    int match_limit, int *offsets, int offsetcount)    int match_limit, int *offsets, int offsetcount)
6553  {  {
6554  executable_function *function = (executable_function*)executable_func;  executable_function *function = (executable_function*)executable_func;
# Line 6523  return retval; Line 6603  return retval;
6603  }  }
6604    
6605  void  void
6606  _pcre_jit_free(void *executable_func)  PRIV(jit_free)(void *executable_func)
6607  {  {
6608  executable_function *function = (executable_function*)executable_func;  executable_function *function = (executable_function*)executable_func;
6609  sljit_free_code(function->executable_func);  sljit_free_code(function->executable_func);
6610  SLJIT_FREE(function);  SLJIT_FREE(function);
6611  }  }
6612    
6613    #ifdef COMPILE_PCRE8
6614  PCRE_EXP_DECL pcre_jit_stack *  PCRE_EXP_DECL pcre_jit_stack *
6615  pcre_jit_stack_alloc(int startsize, int maxsize)  pcre_jit_stack_alloc(int startsize, int maxsize)
6616    #else
6617    PCRE_EXP_DECL pcre_jit_stack *
6618    pcre16_jit_stack_alloc(int startsize, int maxsize)
6619    #endif
6620  {  {
6621  if (startsize < 1 || maxsize < 1)  if (startsize < 1 || maxsize < 1)
6622    return NULL;    return NULL;
# Line 6542  maxsize = (maxsize + STACK_GROWTH_RATE - Line 6627  maxsize = (maxsize + STACK_GROWTH_RATE -
6627  return (pcre_jit_stack*)sljit_allocate_stack(startsize, maxsize);  return (pcre_jit_stack*)sljit_allocate_stack(startsize, maxsize);
6628  }  }
6629    
6630    #ifdef COMPILE_PCRE8
6631  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6632  pcre_jit_stack_free(pcre_jit_stack *stack)  pcre_jit_stack_free(pcre_jit_stack *stack)
6633    #else
6634    PCRE_EXP_DECL void
6635    pcre16_jit_stack_free(pcre_jit_stack *stack)
6636    #endif
6637  {  {
6638  sljit_free_stack((struct sljit_stack*)stack);  sljit_free_stack((struct sljit_stack*)stack);
6639  }  }
6640    
6641    #ifdef COMPILE_PCRE8
6642  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6643  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)
6644    #else
6645    PCRE_EXP_DECL void
6646    pcre16_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6647    #endif
6648  {  {
6649  executable_function *function;  executable_function *function;
6650  if (extra != NULL &&  if (extra != NULL &&
# Line 6567  if (extra != NULL && Line 6662  if (extra != NULL &&
6662  /* 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
6663  being compiled. */  being compiled. */
6664    
6665    #ifdef COMPILE_PCRE8
6666  PCRE_EXP_DECL pcre_jit_stack *  PCRE_EXP_DECL pcre_jit_stack *
6667  pcre_jit_stack_alloc(int startsize, int maxsize)  pcre_jit_stack_alloc(int startsize, int maxsize)
6668    #else
6669    PCRE_EXP_DECL pcre_jit_stack *
6670    pcre16_jit_stack_alloc(int startsize, int maxsize)
6671    #endif
6672  {  {
6673  (void)startsize;  (void)startsize;
6674  (void)maxsize;  (void)maxsize;
6675  return NULL;  return NULL;
6676  }  }
6677    
6678    #ifdef COMPILE_PCRE8
6679  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6680  pcre_jit_stack_free(pcre_jit_stack *stack)  pcre_jit_stack_free(pcre_jit_stack *stack)
6681    #else
6682    PCRE_EXP_DECL void
6683    pcre16_jit_stack_free(pcre_jit_stack *stack)
6684    #endif
6685  {  {
6686  (void)stack;  (void)stack;
6687  }  }
6688    
6689    #ifdef COMPILE_PCRE8
6690  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6691  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)
6692    #else
6693    PCRE_EXP_DECL void
6694    pcre16_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6695    #endif
6696  {  {
6697  (void)extra;  (void)extra;
6698  (void)callback;  (void)callback;

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

  ViewVC Help
Powered by ViewVC 1.1.5