/[pcre]/code/trunk/pcre_jit_compile.c
ViewVC logotype

Diff of /code/trunk/pcre_jit_compile.c

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

revision 1308 by zherczeg, Tue Apr 2 06:58:55 2013 UTC revision 1420 by zherczeg, Sun Dec 29 11:43:10 2013 UTC
# Line 168  typedef struct jit_arguments { Line 168  typedef struct jit_arguments {
168    pcre_uchar *mark_ptr;    pcre_uchar *mark_ptr;
169    void *callout_data;    void *callout_data;
170    /* Everything else after. */    /* Everything else after. */
171      pcre_uint32 limit_match;
172    int real_offset_count;    int real_offset_count;
173    int offset_count;    int offset_count;
   int call_limit;  
174    pcre_uint8 notbol;    pcre_uint8 notbol;
175    pcre_uint8 noteol;    pcre_uint8 noteol;
176    pcre_uint8 notempty;    pcre_uint8 notempty;
# Line 182  typedef struct executable_functions { Line 182  typedef struct executable_functions {
182    PUBL(jit_callback) callback;    PUBL(jit_callback) callback;
183    void *userdata;    void *userdata;
184    pcre_uint32 top_bracket;    pcre_uint32 top_bracket;
185      pcre_uint32 limit_match;
186    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
187  } executable_functions;  } executable_functions;
188    
# Line 210  typedef int (SLJIT_CALL *jit_function)(j Line 211  typedef int (SLJIT_CALL *jit_function)(j
211    
212  /* The following structure is the key data type for the recursive  /* The following structure is the key data type for the recursive
213  code generator. It is allocated by compile_matchingpath, and contains  code generator. It is allocated by compile_matchingpath, and contains
214  the aguments for compile_backtrackingpath. Must be the first member  the arguments for compile_backtrackingpath. Must be the first member
215  of its descendants. */  of its descendants. */
216  typedef struct backtrack_common {  typedef struct backtrack_common {
217    /* Concatenation stack. */    /* Concatenation stack. */
# Line 305  typedef struct then_trap_backtrack { Line 306  typedef struct then_trap_backtrack {
306    int framesize;    int framesize;
307  } then_trap_backtrack;  } then_trap_backtrack;
308    
309  #define MAX_RANGE_SIZE 6  #define MAX_RANGE_SIZE 4
310    
311  typedef struct compiler_common {  typedef struct compiler_common {
312    /* The sljit ceneric compiler. */    /* The sljit ceneric compiler. */
# Line 368  typedef struct compiler_common { Line 369  typedef struct compiler_common {
369    int endonly;    int endonly;
370    /* Tables. */    /* Tables. */
371    sljit_sw ctypes;    sljit_sw ctypes;
   int digits[2 + MAX_RANGE_SIZE];  
372    /* Named capturing brackets. */    /* Named capturing brackets. */
373    sljit_uw name_table;    pcre_uchar *name_table;
374    sljit_sw name_count;    sljit_sw name_count;
375    sljit_sw name_entry_size;    sljit_sw name_entry_size;
376    
# Line 407  typedef struct compiler_common { Line 407  typedef struct compiler_common {
407    jump_list *utfreadchar;    jump_list *utfreadchar;
408  #endif  #endif
409  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
410      jump_list *utfreadchar8;
411    jump_list *utfreadtype8;    jump_list *utfreadtype8;
412  #endif  #endif
413  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
# Line 463  typedef struct compare_context { Line 464  typedef struct compare_context {
464  #define STACK_TOP     SLJIT_SCRATCH_REG2  #define STACK_TOP     SLJIT_SCRATCH_REG2
465  #define STACK_LIMIT   SLJIT_SAVED_REG3  #define STACK_LIMIT   SLJIT_SAVED_REG3
466  #define ARGUMENTS     SLJIT_SAVED_EREG1  #define ARGUMENTS     SLJIT_SAVED_EREG1
467  #define CALL_COUNT    SLJIT_SAVED_EREG2  #define COUNT_MATCH   SLJIT_SAVED_EREG2
468  #define RETURN_ADDR   SLJIT_TEMPORARY_EREG1  #define RETURN_ADDR   SLJIT_TEMPORARY_EREG1
469    
470  /* Local space layout. */  /* Local space layout. */
# Line 474  typedef struct compare_context { Line 475  typedef struct compare_context {
475  #define POSSESSIVE0      (2 * sizeof(sljit_sw))  #define POSSESSIVE0      (2 * sizeof(sljit_sw))
476  #define POSSESSIVE1      (3 * sizeof(sljit_sw))  #define POSSESSIVE1      (3 * sizeof(sljit_sw))
477  /* Max limit of recursions. */  /* Max limit of recursions. */
478  #define CALL_LIMIT       (4 * sizeof(sljit_sw))  #define LIMIT_MATCH      (4 * sizeof(sljit_sw))
479  /* The output vector is stored on the stack, and contains pointers  /* The output vector is stored on the stack, and contains pointers
480  to characters. The vector data is divided into two groups: the first  to characters. The vector data is divided into two groups: the first
481  group contains the start / end character pointers, and the second is  group contains the start / end character pointers, and the second is
482  the start pointers when the end of the capturing group has not yet reached. */  the start pointers when the end of the capturing group has not yet reached. */
483  #define OVECTOR_START    (common->ovector_start)  #define OVECTOR_START    (common->ovector_start)
484  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))  #define OVECTOR(i)       (OVECTOR_START + (i) * (sljit_sw)sizeof(sljit_sw))
485  #define OVECTOR_PRIV(i)  (common->cbra_ptr + (i) * sizeof(sljit_sw))  #define OVECTOR_PRIV(i)  (common->cbra_ptr + (i) * (sljit_sw)sizeof(sljit_sw))
486  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
487    
488  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
# Line 532  cc += 1 + LINK_SIZE; Line 533  cc += 1 + LINK_SIZE;
533  return cc;  return cc;
534  }  }
535    
536    static int ones_in_half_byte[16] = {
537      /* 0 */ 0, 1, 1, 2, /* 4 */ 1, 2, 2, 3,
538      /* 8 */ 1, 2, 2, 3, /* 12 */ 2, 3, 3, 4
539    };
540    
541  /* Functions whose might need modification for all new supported opcodes:  /* Functions whose might need modification for all new supported opcodes:
542   next_opcode   next_opcode
543   check_opcode_types   check_opcode_types
# Line 584  switch(*cc) Line 590  switch(*cc)
590    case OP_CRMINQUERY:    case OP_CRMINQUERY:
591    case OP_CRRANGE:    case OP_CRRANGE:
592    case OP_CRMINRANGE:    case OP_CRMINRANGE:
593      case OP_CRPOSSTAR:
594      case OP_CRPOSPLUS:
595      case OP_CRPOSQUERY:
596      case OP_CRPOSRANGE:
597    case OP_CLASS:    case OP_CLASS:
598    case OP_NCLASS:    case OP_NCLASS:
599    case OP_REF:    case OP_REF:
600    case OP_REFI:    case OP_REFI:
601      case OP_DNREF:
602      case OP_DNREFI:
603    case OP_RECURSE:    case OP_RECURSE:
604    case OP_CALLOUT:    case OP_CALLOUT:
605    case OP_ALT:    case OP_ALT:
# Line 613  switch(*cc) Line 625  switch(*cc)
625    case OP_SCBRAPOS:    case OP_SCBRAPOS:
626    case OP_SCOND:    case OP_SCOND:
627    case OP_CREF:    case OP_CREF:
628    case OP_NCREF:    case OP_DNCREF:
629    case OP_RREF:    case OP_RREF:
630    case OP_NRREF:    case OP_DNRREF:
631    case OP_DEF:    case OP_DEF:
632    case OP_BRAZERO:    case OP_BRAZERO:
633    case OP_BRAMINZERO:    case OP_BRAMINZERO:
# Line 735  switch(*cc) Line 747  switch(*cc)
747    
748  static BOOL check_opcode_types(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)  static BOOL check_opcode_types(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)
749  {  {
750  pcre_uchar *name;  int count;
751  pcre_uchar *name2;  pcre_uchar *slot;
 int i, cbra_index;  
752    
753  /* Calculate important variables (like stack size) and checks whether all opcodes are supported. */  /* Calculate important variables (like stack size) and checks whether all opcodes are supported. */
754  while (cc < ccend)  while (cc < ccend)
# Line 771  while (cc < ccend) Line 782  while (cc < ccend)
782      break;      break;
783    
784      case OP_CREF:      case OP_CREF:
785      i = GET2(cc, 1);      common->optimized_cbracket[GET2(cc, 1)] = 0;
     common->optimized_cbracket[i] = 0;  
786      cc += 1 + IMM2_SIZE;      cc += 1 + IMM2_SIZE;
787      break;      break;
788    
789      case OP_NCREF:      case OP_DNREF:
790      cbra_index = GET2(cc, 1);      case OP_DNREFI:
791      name = (pcre_uchar *)common->name_table;      case OP_DNCREF:
792      name2 = name;      count = GET2(cc, 1 + IMM2_SIZE);
793      for (i = 0; i < common->name_count; i++)      slot = common->name_table + GET2(cc, 1) * common->name_entry_size;
794        {      while (count-- > 0)
795        if (GET2(name, 0) == cbra_index) break;        {
796        name += common->name_entry_size;        common->optimized_cbracket[GET2(slot, 0)] = 0;
797        }        slot += common->name_entry_size;
     SLJIT_ASSERT(i != common->name_count);  
   
     for (i = 0; i < common->name_count; i++)  
       {  
       if (STRCMP_UC_UC(name2 + IMM2_SIZE, name + IMM2_SIZE) == 0)  
         common->optimized_cbracket[GET2(name2, 0)] = 0;  
       name2 += common->name_entry_size;  
798        }        }
799      cc += 1 + IMM2_SIZE;      cc += 1 + 2 * IMM2_SIZE;
800      break;      break;
801    
802      case OP_RECURSE:      case OP_RECURSE:
# Line 892  pcre_uchar *next; Line 895  pcre_uchar *next;
895  pcre_uchar *next_end;  pcre_uchar *next_end;
896  pcre_uchar *max_end;  pcre_uchar *max_end;
897  pcre_uchar type;  pcre_uchar type;
898  sljit_uw length = end - begin;  sljit_sw length = end - begin;
899  int min, max, i;  int min, max, i;
900    
901  /* Detect fixed iterations first. */  /* Detect fixed iterations first. */
# Line 2021  while (list_item) Line 2024  while (list_item)
2024  common->stubs = NULL;  common->stubs = NULL;
2025  }  }
2026    
2027  static SLJIT_INLINE void decrease_call_count(compiler_common *common)  static SLJIT_INLINE void count_match(compiler_common *common)
2028  {  {
2029  DEFINE_COMPILER;  DEFINE_COMPILER;
2030    
2031  OP2(SLJIT_SUB | SLJIT_SET_E, CALL_COUNT, 0, CALL_COUNT, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB | SLJIT_SET_E, COUNT_MATCH, 0, COUNT_MATCH, 0, SLJIT_IMM, 1);
2032  add_jump(compiler, &common->calllimit, JUMP(SLJIT_C_ZERO));  add_jump(compiler, &common->calllimit, JUMP(SLJIT_C_ZERO));
2033  }  }
2034    
# Line 2372  return (bit < 256) ? ((0 << 8) | bit) : Line 2375  return (bit < 256) ? ((0 << 8) | bit) :
2375    
2376  static void check_partial(compiler_common *common, BOOL force)  static void check_partial(compiler_common *common, BOOL force)
2377  {  {
2378  /* Checks whether a partial matching is occured. Does not modify registers. */  /* Checks whether a partial matching is occurred. Does not modify registers. */
2379  DEFINE_COMPILER;  DEFINE_COMPILER;
2380  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
2381    
# Line 2509  if (common->utf) Line 2512  if (common->utf)
2512  #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */  #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */
2513  }  }
2514    
2515    static void read_char8(compiler_common *common)
2516    {
2517    /* Reads the precise value of a character into TMP1, if the character is
2518    less than 256. Otherwise it returns with a value greater or equal than 256. */
2519    DEFINE_COMPILER;
2520    #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2521    struct sljit_jump *jump;
2522    #endif
2523    
2524    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2525    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2526    
2527    #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2528    if (common->utf)
2529      {
2530    #if defined COMPILE_PCRE8
2531      jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2532      add_jump(compiler, &common->utfreadchar8, JUMP(SLJIT_FAST_CALL));
2533      JUMPHERE(jump);
2534    #elif defined COMPILE_PCRE16
2535      /* Skip low surrogate if necessary. */
2536      OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);
2537      jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
2538      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2539      JUMPHERE(jump);
2540    #endif /* COMPILE_PCRE[8|16] */
2541      }
2542    #endif
2543    }
2544    
2545  static void read_char8_type(compiler_common *common)  static void read_char8_type(compiler_common *common)
2546  {  {
2547  /* 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. */
# Line 2535  if (common->utf) Line 2568  if (common->utf)
2568    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
2569    JUMPHERE(jump);    JUMPHERE(jump);
2570    /* Skip low surrogate if necessary. */    /* Skip low surrogate if necessary. */
2571    OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xfc00);    OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);
2572    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xd800);    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
2573    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2574    OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);    JUMPHERE(jump);
   OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);  
2575  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
2576    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2577    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);
# Line 2683  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UC Line 2715  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UC
2715  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2716  }  }
2717    
2718    static void do_utfreadchar8(compiler_common *common)
2719    {
2720    /* Fast decoding a UTF-8 character. TMP1 contains the first byte
2721    of the character (>= 0xc0). Return value in TMP1. */
2722    DEFINE_COMPILER;
2723    struct sljit_jump *jump;
2724    
2725    sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
2726    
2727    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);
2728    jump = JUMP(SLJIT_C_NOT_ZERO);
2729    /* Two byte sequence. */
2730    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2731    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2732    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1f);
2733    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
2734    OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2735    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2736    sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2737    
2738    JUMPHERE(jump);
2739    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2740    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0x800);
2741    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
2742    sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2743    }
2744    
2745  static void do_utfreadtype8(compiler_common *common)  static void do_utfreadtype8(compiler_common *common)
2746  {  {
2747  /* Fast decoding a UTF-8 character type. TMP2 contains the first byte  /* Fast decoding a UTF-8 character type. TMP2 contains the first byte
# Line 2699  jump = JUMP(SLJIT_C_NOT_ZERO); Line 2758  jump = JUMP(SLJIT_C_NOT_ZERO);
2758  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2759  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2760  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x1f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x1f);
2761    /* The upper 5 bits are known at this point. */
2762    compare = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0x3);
2763  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
2764  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
2765  OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0);  OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0);
 compare = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);  
2766  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
2767  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2768    
2769  JUMPHERE(compare);  JUMPHERE(compare);
2770  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2771  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
 JUMPHERE(jump);  
2772    
2773  /* We only have types for characters less than 256. */  /* We only have types for characters less than 256. */
2774  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);  JUMPHERE(jump);
2775  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2776  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2777    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
2778  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2779  }  }
2780    
# Line 2896  if (newlinecheck) Line 2956  if (newlinecheck)
2956  return mainloop;  return mainloop;
2957  }  }
2958    
2959  #define MAX_N_CHARS 3  static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, int max_chars)
   
 static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common, BOOL firstline)  
2960  {  {
2961  DEFINE_COMPILER;  /* Recursive function, which scans prefix literals. */
2962  struct sljit_label *start;  int len, repeat, len_save, consumed = 0;
2963  struct sljit_jump *quit;  pcre_int32 caseless, chr, mask;
2964  pcre_uint32 chars[MAX_N_CHARS * 2];  pcre_uchar *alternative, *cc_save;
2965  pcre_uchar *cc = common->start + 1 + LINK_SIZE;  BOOL last, any;
 int location = 0;  
 pcre_int32 len, c, bit, caseless;  
 int must_stop;  
   
 /* We do not support alternatives now. */  
 if (*(common->start + GET(common->start, 1)) == OP_ALT)  
   return FALSE;  
2966    
2967    repeat = 1;
2968  while (TRUE)  while (TRUE)
2969    {    {
2970      last = TRUE;
2971      any = FALSE;
2972    caseless = 0;    caseless = 0;
2973    must_stop = 1;    switch (*cc)
   switch(*cc)  
2974      {      {
     case OP_CHAR:  
     must_stop = 0;  
     cc++;  
     break;  
   
2975      case OP_CHARI:      case OP_CHARI:
2976      caseless = 1;      caseless = 1;
2977      must_stop = 0;      case OP_CHAR:
2978        last = FALSE;
2979      cc++;      cc++;
2980      break;      break;
2981    
# Line 2951  while (TRUE) Line 3000  while (TRUE)
3000      cc++;      cc++;
3001      break;      break;
3002    
3003        case OP_EXACTI:
3004        caseless = 1;
3005      case OP_EXACT:      case OP_EXACT:
3006        repeat = GET2(cc, 1);
3007        last = FALSE;
3008      cc += 1 + IMM2_SIZE;      cc += 1 + IMM2_SIZE;
3009      break;      break;
3010    
# Line 2962  while (TRUE) Line 3015  while (TRUE)
3015      cc++;      cc++;
3016      break;      break;
3017    
3018      case OP_EXACTI:      case OP_KET:
3019      caseless = 1;      cc += 1 + LINK_SIZE;
3020      cc += 1 + IMM2_SIZE;      continue;
3021    
3022        case OP_ALT:
3023        cc += GET(cc, 1);
3024        continue;
3025    
3026        case OP_ONCE:
3027        case OP_ONCE_NC:
3028        case OP_BRA:
3029        case OP_BRAPOS:
3030        case OP_CBRA:
3031        case OP_CBRAPOS:
3032        alternative = cc + GET(cc, 1);
3033        while (*alternative == OP_ALT)
3034          {
3035          max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, max_chars);
3036          if (max_chars == 0)
3037            return consumed;
3038          alternative += GET(alternative, 1);
3039          }
3040    
3041        if (*cc == OP_CBRA || *cc == OP_CBRAPOS)
3042          cc += IMM2_SIZE;
3043        cc += 1 + LINK_SIZE;
3044        continue;
3045    
3046        case OP_CLASS:
3047        case OP_NCLASS:
3048        any = TRUE;
3049        cc += 1 + 32 / sizeof(pcre_uchar);
3050      break;      break;
3051    
3052      default:  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
3053      must_stop = 2;      case OP_XCLASS:
3054        any = TRUE;
3055        cc += GET(cc, 1);
3056        break;
3057    #endif
3058    
3059        case OP_NOT_DIGIT:
3060        case OP_DIGIT:
3061        case OP_NOT_WHITESPACE:
3062        case OP_WHITESPACE:
3063        case OP_NOT_WORDCHAR:
3064        case OP_WORDCHAR:
3065        case OP_ANY:
3066        case OP_ALLANY:
3067        any = TRUE;
3068        cc++;
3069        break;
3070    
3071    #ifdef SUPPORT_UCP
3072        case OP_NOTPROP:
3073        case OP_PROP:
3074        any = TRUE;
3075        cc += 1 + 2;
3076      break;      break;
3077    #endif
3078    
3079        case OP_TYPEEXACT:
3080        repeat = GET2(cc, 1);
3081        cc += 1 + IMM2_SIZE;
3082        continue;
3083    
3084        default:
3085        return consumed;
3086      }      }
3087    
3088    if (must_stop == 2)    if (any)
3089        break;      {
3090    #ifdef SUPPORT_UTF
3091        if (common->utf) return consumed;
3092    #endif
3093    #if defined COMPILE_PCRE8
3094        mask = 0xff;
3095    #elif defined COMPILE_PCRE16
3096        mask = 0xffff;
3097    #elif defined COMPILE_PCRE32
3098        mask = 0xffffffff;
3099    #else
3100        SLJIT_ASSERT_STOP();
3101    #endif
3102    
3103        do
3104          {
3105          chars[0] = mask;
3106          chars[1] = mask;
3107    
3108          if (--max_chars == 0)
3109            return consumed;
3110          consumed++;
3111          chars += 2;
3112          }
3113        while (--repeat > 0);
3114    
3115        repeat = 1;
3116        continue;
3117        }
3118    
3119    len = 1;    len = 1;
3120  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3121    if (common->utf && HAS_EXTRALEN(cc[0])) len += GET_EXTRALEN(cc[0]);    if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc);
3122  #endif  #endif
3123    
3124    if (caseless && char_has_othercase(common, cc))    if (caseless != 0 && char_has_othercase(common, cc))
3125      {      {
3126      caseless = char_get_othercase_bit(common, cc);      caseless = char_get_othercase_bit(common, cc);
3127      if (caseless == 0)      if (caseless == 0)
3128        return FALSE;        return consumed;
3129  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3130      caseless = ((caseless & 0xff) << 8) | (len - (caseless >> 8));      caseless = ((caseless & 0xff) << 8) | (len - (caseless >> 8));
3131  #else  #else
# Line 2997  while (TRUE) Line 3138  while (TRUE)
3138    else    else
3139      caseless = 0;      caseless = 0;
3140    
3141    while (len > 0 && location < MAX_N_CHARS * 2)    len_save = len;
3142      {    cc_save = cc;
3143      c = *cc;    while (TRUE)
3144      bit = 0;      {
3145      if (len == (caseless & 0xff))      do
3146        {        {
3147        bit = caseless >> 8;        chr = *cc;
3148        c |= bit;  #ifdef COMPILE_PCRE32
3149          if (SLJIT_UNLIKELY(chr == NOTACHAR))
3150            return consumed;
3151    #endif
3152          mask = 0;
3153          if (len == (caseless & 0xff))
3154            {
3155            mask = caseless >> 8;
3156            chr |= mask;
3157            }
3158    
3159          if (chars[0] == NOTACHAR)
3160            {
3161            chars[0] = chr;
3162            chars[1] = mask;
3163            }
3164          else
3165            {
3166            mask |= chars[0] ^ chr;
3167            chr |= mask;
3168            chars[0] = chr;
3169            chars[1] |= mask;
3170            }
3171    
3172          len--;
3173          if (--max_chars == 0)
3174            return consumed;
3175          consumed++;
3176          chars += 2;
3177          cc++;
3178        }        }
3179        while (len > 0);
3180    
3181      chars[location] = c;      if (--repeat == 0)
3182      chars[location + 1] = bit;        break;
3183    
3184      len--;      len = len_save;
3185      location += 2;      cc = cc_save;
3186      cc++;      }
3187    
3188      repeat = 1;
3189      if (last)
3190        return consumed;
3191      }
3192    }
3193    
3194    #define MAX_N_CHARS 16
3195    
3196    static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common, BOOL firstline)
3197    {
3198    DEFINE_COMPILER;
3199    struct sljit_label *start;
3200    struct sljit_jump *quit;
3201    pcre_uint32 chars[MAX_N_CHARS * 2];
3202    pcre_uint8 ones[MAX_N_CHARS];
3203    pcre_uint32 mask;
3204    int i, max;
3205    int offsets[3];
3206    
3207    for (i = 0; i < MAX_N_CHARS; i++)
3208      {
3209      chars[i << 1] = NOTACHAR;
3210      chars[(i << 1) + 1] = 0;
3211      }
3212    
3213    max = scan_prefix(common, common->start, chars, MAX_N_CHARS);
3214    
3215    if (max <= 1)
3216      return FALSE;
3217    
3218    for (i = 0; i < max; i++)
3219      {
3220      mask = chars[(i << 1) + 1];
3221      ones[i] = ones_in_half_byte[mask & 0xf];
3222      mask >>= 4;
3223      while (mask != 0)
3224        {
3225        ones[i] += ones_in_half_byte[mask & 0xf];
3226        mask >>= 4;
3227      }      }
3228      }
3229    
3230    if (location >= MAX_N_CHARS * 2 || must_stop != 0)  offsets[0] = -1;
3231    /* Scan forward. */
3232    for (i = 0; i < max; i++)
3233      if (ones[i] <= 2) {
3234        offsets[0] = i;
3235      break;      break;
3236    }    }
3237    
3238  /* At least two characters are required. */  if (offsets[0] == -1)
3239  if (location < 2 * 2)    return FALSE;
     return FALSE;  
3240    
3241    /* Scan backward. */
3242    offsets[1] = -1;
3243    for (i = max - 1; i > offsets[0]; i--)
3244      if (ones[i] <= 2) {
3245        offsets[1] = i;
3246        break;
3247      }
3248    
3249    offsets[2] = -1;
3250    if (offsets[1] >= 0)
3251      {
3252      /* Scan from middle. */
3253      for (i = (offsets[0] + offsets[1]) / 2 + 1; i < offsets[1]; i++)
3254        if (ones[i] <= 2)
3255          {
3256          offsets[2] = i;
3257          break;
3258          }
3259    
3260      if (offsets[2] == -1)
3261        {
3262        for (i = (offsets[0] + offsets[1]) / 2; i > offsets[0]; i--)
3263          if (ones[i] <= 2)
3264            {
3265            offsets[2] = i;
3266            break;
3267            }
3268        }
3269      }
3270    
3271    SLJIT_ASSERT(offsets[1] == -1 || (offsets[0] < offsets[1]));
3272    SLJIT_ASSERT(offsets[2] == -1 || (offsets[0] < offsets[2] && offsets[1] > offsets[2]));
3273    
3274    chars[0] = chars[offsets[0] << 1];
3275    chars[1] = chars[(offsets[0] << 1) + 1];
3276    if (offsets[2] >= 0)
3277      {
3278      chars[2] = chars[offsets[2] << 1];
3279      chars[3] = chars[(offsets[2] << 1) + 1];
3280      }
3281    if (offsets[1] >= 0)
3282      {
3283      chars[4] = chars[offsets[1] << 1];
3284      chars[5] = chars[(offsets[1] << 1) + 1];
3285      }
3286    
3287    max -= 1;
3288  if (firstline)  if (firstline)
3289    {    {
3290    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
3291    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
3292    OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));    OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, IN_UCHARS(max));
3293    }    }
3294  else  else
3295    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));
3296    
3297  start = LABEL();  start = LABEL();
3298  quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
3299    
3300  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[0]));
3301  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));  if (offsets[1] >= 0)
3302      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[1]));
3303  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3304    
3305  if (chars[1] != 0)  if (chars[1] != 0)
3306    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[1]);    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[1]);
3307  CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[0], start);  CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[0], start);
3308  if (location > 2 * 2)  if (offsets[2] >= 0)
3309    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[2] - 1));
3310  if (chars[3] != 0)  
3311    OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, chars[3]);  if (offsets[1] >= 0)
 CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, chars[2], start);  
 if (location > 2 * 2)  
3312    {    {
3313    if (chars[5] != 0)    if (chars[5] != 0)
3314      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[5]);      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, chars[5]);
3315    CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[4], start);    CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, chars[4], start);
3316      }
3317    
3318    if (offsets[2] >= 0)
3319      {
3320      if (chars[3] != 0)
3321        OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[3]);
3322      CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[2], start);
3323    }    }
3324  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3325    
# Line 3059  JUMPHERE(quit); Line 3328  JUMPHERE(quit);
3328  if (firstline)  if (firstline)
3329    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
3330  else  else
3331    OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));    OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));
3332  return TRUE;  return TRUE;
3333  }  }
3334    
# Line 3208  if (firstline) Line 3477  if (firstline)
3477    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
3478  }  }
3479    
3480  static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, jump_list **backtracks);  static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks);
3481    
3482  static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, sljit_uw start_bits, BOOL firstline)  static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, pcre_uint8 *start_bits, BOOL firstline)
3483  {  {
3484  DEFINE_COMPILER;  DEFINE_COMPILER;
3485  struct sljit_label *start;  struct sljit_label *start;
3486  struct sljit_jump *quit;  struct sljit_jump *quit;
3487  struct sljit_jump *found = NULL;  struct sljit_jump *found = NULL;
3488  jump_list *matches = NULL;  jump_list *matches = NULL;
 pcre_uint8 inverted_start_bits[32];  
 int i;  
3489  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
3490  struct sljit_jump *jump;  struct sljit_jump *jump;
3491  #endif  #endif
3492    
 for (i = 0; i < 32; ++i)  
   inverted_start_bits[i] = ~(((pcre_uint8*)start_bits)[i]);  
   
3493  if (firstline)  if (firstline)
3494    {    {
3495    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
# Line 3241  if (common->utf) Line 3505  if (common->utf)
3505    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
3506  #endif  #endif
3507    
3508  if (!check_class_ranges(common, inverted_start_bits, (inverted_start_bits[31] & 0x80) != 0, &matches))  if (!check_class_ranges(common, start_bits, (start_bits[31] & 0x80) != 0, TRUE, &matches))
3509    {    {
3510  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
3511    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255);
# Line 3250  if (!check_class_ranges(common, inverted Line 3514  if (!check_class_ranges(common, inverted
3514  #endif  #endif
3515    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
3516    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
3517    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits);
3518    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
3519    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);
3520    found = JUMP(SLJIT_C_NOT_ZERO);    found = JUMP(SLJIT_C_NOT_ZERO);
# Line 3510  sljit_emit_fast_return(compiler, SLJIT_M Line 3774  sljit_emit_fast_return(compiler, SLJIT_M
3774  static BOOL check_ranges(compiler_common *common, int *ranges, jump_list **backtracks, BOOL readch)  static BOOL check_ranges(compiler_common *common, int *ranges, jump_list **backtracks, BOOL readch)
3775  {  {
3776  DEFINE_COMPILER;  DEFINE_COMPILER;
3777  struct sljit_jump *jump;  int offset;
3778    
3779  if (ranges[0] < 0)  if (ranges[0] < 0 || ranges[0] > 4)
3780    return FALSE;    return FALSE;
3781    
3782    /* No character is accepted. */
3783    if (ranges[0] == 0 && ranges[1] == 0)
3784      add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
3785    
3786    if (readch)
3787      read_char8(common);
3788    
3789  switch(ranges[0])  switch(ranges[0])
3790    {    {
3791      case 0:
3792      /* When ranges[1] != 0, all characters are accepted. */
3793      return TRUE;
3794    
3795    case 1:    case 1:
   if (readch)  
     read_char(common);  
3796    add_jump(compiler, backtracks, CMP(ranges[1] == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));    add_jump(compiler, backtracks, CMP(ranges[1] == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3797    return TRUE;    return TRUE;
3798    
3799    case 2:    case 2:
3800    if (readch)    if (ranges[2] + 1 != ranges[3])
3801      read_char(common);      {
3802    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3803    add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));      add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3804        }
3805      else
3806        add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3807    return TRUE;    return TRUE;
3808    
3809    case 4:    case 3:
3810    if (ranges[2] + 1 == ranges[3] && ranges[4] + 1 == ranges[5])    if (ranges[1] != 0)
3811      {      {
3812      if (readch)      add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));
3813        read_char(common);      if (ranges[2] + 1 != ranges[3])
     if (ranges[1] != 0)  
3814        {        {
3815        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3816        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3817        }        }
3818      else      else
3819        {        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
       jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]);  
       add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));  
       JUMPHERE(jump);  
       }  
3820      return TRUE;      return TRUE;
3821      }      }
3822    if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4]) && is_powerof2(ranges[4] - ranges[2]))  
3823      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2]));
3824      if (ranges[3] + 1 != ranges[4])
3825        {
3826        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3]);
3827        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));
3828        }
3829      else
3830        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3]));
3831      return TRUE;
3832    
3833      case 4:
3834      if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4])
3835          && (ranges[2] | (ranges[4] - ranges[2])) == ranges[4]
3836          && is_powerof2(ranges[4] - ranges[2]))
3837      {      {
     if (readch)  
       read_char(common);  
3838      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[2]);      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[2]);
3839      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]);      if (ranges[4] + 1 != ranges[5])
3840      add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));        {
3841          OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]);
3842          add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));
3843          }
3844        else
3845          add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));
3846      return TRUE;      return TRUE;
3847      }      }
   return FALSE;  
3848    
3849    default:    if (ranges[1] != 0)
3850    return FALSE;      {
3851    }      offset = 0;
3852  }      if (ranges[2] + 1 != ranges[3])
3853          {
3854  static void get_ctype_ranges(compiler_common *common, int flag, int *ranges)        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3855  {        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3856  int i, bit, length;        offset = ranges[2];
3857  const pcre_uint8 *ctypes = (const pcre_uint8*)common->ctypes;        }
3858        else
3859          add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3860    
3861  bit = ctypes[0] & flag;      if (ranges[4] + 1 != ranges[5])
3862  ranges[0] = -1;        {
3863  ranges[1] = bit != 0 ? 1 : 0;        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - offset);
3864  length = 0;        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));
3865          }
3866        else
3867          add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4] - offset));
3868        return TRUE;
3869        }
3870    
3871  for (i = 1; i < 256; i++)    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3872    if ((ctypes[i] & flag) != bit)    add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[2]));
3873      if (ranges[3] + 1 != ranges[4])
3874      {      {
3875      if (length >= MAX_RANGE_SIZE)      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]);
3876        return;      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));
     ranges[2 + length] = i;  
     length++;  
     bit ^= flag;  
3877      }      }
3878      else
3879        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3880      return TRUE;
3881    
3882  if (bit != 0)    default:
3883    {    SLJIT_ASSERT_STOP();
3884    if (length >= MAX_RANGE_SIZE)    return FALSE;
     return;  
   ranges[2 + length] = 256;  
   length++;  
3885    }    }
 ranges[0] = length;  
3886  }  }
3887    
3888  static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, jump_list **backtracks)  static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks)
3889  {  {
3890  int ranges[2 + MAX_RANGE_SIZE];  int ranges[2 + MAX_RANGE_SIZE];
3891  pcre_uint8 bit, cbit, all;  pcre_uint8 bit, cbit, all;
3892  int i, byte, length = 0;  int i, byte, length = 0;
3893    
3894  bit = bits[0] & 0x1;  bit = bits[0] & 0x1;
3895  ranges[1] = bit;  ranges[1] = !invert ? bit : (bit ^ 0x1);
3896  /* Can be 0 or 255. */  /* All bits will be zero or one (since bit is zero or one). */
3897  all = -bit;  all = -bit;
3898    
3899  for (i = 0; i < 256; )  for (i = 0; i < 256; )
# Line 4023  static void compile_xclass_matchingpath( Line 4314  static void compile_xclass_matchingpath(
4314  {  {
4315  DEFINE_COMPILER;  DEFINE_COMPILER;
4316  jump_list *found = NULL;  jump_list *found = NULL;
4317  jump_list **list = (*cc & XCL_NOT) == 0 ? &found : backtracks;  jump_list **list = (cc[0] & XCL_NOT) == 0 ? &found : backtracks;
4318  pcre_int32 c, charoffset;  pcre_int32 c, charoffset;
 const pcre_uint32 *other_cases;  
4319  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
4320  pcre_uchar *ccbegin;  pcre_uchar *ccbegin;
4321  int compares, invertcmp, numberofcmps;  int compares, invertcmp, numberofcmps;
4322    
4323  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4324  BOOL needstype = FALSE, needsscript = FALSE, needschar = FALSE;  BOOL needstype = FALSE, needsscript = FALSE, needschar = FALSE;
4325  BOOL charsaved = FALSE;  BOOL charsaved = FALSE;
4326  int typereg = TMP1, scriptreg = TMP1;  int typereg = TMP1, scriptreg = TMP1;
4327    const pcre_uint32 *other_cases;
4328  pcre_int32 typeoffset;  pcre_int32 typeoffset;
4329  #endif  #endif
4330    
# Line 4041  pcre_int32 typeoffset; Line 4333  pcre_int32 typeoffset;
4333  detect_partial_match(common, backtracks);  detect_partial_match(common, backtracks);
4334  read_char(common);  read_char(common);
4335    
4336  if ((*cc++ & XCL_MAP) != 0)  cc++;
4337    if ((cc[-1] & XCL_HASPROP) == 0)
4338    {    {
4339    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    if ((cc[-1] & XCL_MAP) != 0)
4340  #ifndef COMPILE_PCRE8      {
4341    jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
4342  #elif defined SUPPORT_UTF  #ifdef SUPPORT_UCP
4343    if (common->utf)      charsaved = TRUE;
4344      jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);  #endif
4345        if (!check_class_ranges(common, (const pcre_uint8 *)cc, TRUE, FALSE, backtracks))
4346          {
4347          jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
4348    
4349          OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
4350          OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
4351          OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
4352          OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
4353          OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
4354          add_jump(compiler, &found, JUMP(SLJIT_C_NOT_ZERO));
4355          add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
4356    
4357          JUMPHERE(jump);
4358          }
4359        else
4360          add_jump(compiler, &found, CMP(SLJIT_C_LESS_EQUAL, TMP3, 0, SLJIT_IMM, 0xff));
4361    
4362        OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
4363        cc += 32 / sizeof(pcre_uchar);
4364        }
4365      else
4366        add_jump(compiler, (cc[-1] & XCL_NOT) == 0 ? backtracks : &found, CMP(SLJIT_C_LESS_EQUAL, TMP1, 0, SLJIT_IMM, 0xff));
4367      }
4368    else if ((cc[-1] & XCL_MAP) != 0)
4369      {
4370      OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
4371    #ifdef SUPPORT_UCP
4372      charsaved = TRUE;
4373  #endif  #endif
4374      if (!check_class_ranges(common, (const pcre_uint8 *)cc, FALSE, TRUE, list))
   if (!check_class_ranges(common, (const pcre_uint8 *)cc, TRUE, list))  
4375      {      {
4376    #ifdef COMPILE_PCRE8
4377        SLJIT_ASSERT(common->utf);
4378    #endif
4379        jump = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
4380    
4381      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
4382      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
4383      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
4384      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
4385      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);
4386      add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));      add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));
     }  
4387    
 #ifndef COMPILE_PCRE8  
   JUMPHERE(jump);  
 #elif defined SUPPORT_UTF  
   if (common->utf)  
4388      JUMPHERE(jump);      JUMPHERE(jump);
4389  #endif      }
4390    
4391    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);    OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
 #ifdef SUPPORT_UCP  
   charsaved = TRUE;  
 #endif  
4392    cc += 32 / sizeof(pcre_uchar);    cc += 32 / sizeof(pcre_uchar);
4393    }    }
4394    
# Line 4128  while (*cc != XCL_END) Line 4446  while (*cc != XCL_END)
4446        case PT_SPACE:        case PT_SPACE:
4447        case PT_PXSPACE:        case PT_PXSPACE:
4448        case PT_WORD:        case PT_WORD:
4449          case PT_PXGRAPH:
4450          case PT_PXPRINT:
4451          case PT_PXPUNCT:
4452        needstype = TRUE;        needstype = TRUE;
4453        needschar = TRUE;        needschar = TRUE;
4454        break;        break;
# Line 4315  while (*cc != XCL_END) Line 4636  while (*cc != XCL_END)
4636    
4637        case PT_SPACE:        case PT_SPACE:
4638        case PT_PXSPACE:        case PT_PXSPACE:
       if (*cc == PT_SPACE)  
         {  
         OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);  
         jump = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, 11 - charoffset);  
         }  
4639        SET_CHAR_OFFSET(9);        SET_CHAR_OFFSET(9);
4640        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 13 - 9);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd - 0x9);
4641        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
4642        if (*cc == PT_SPACE)  
4643          JUMPHERE(jump);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x9);
4644          OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4645    
4646          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e - 0x9);
4647          OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4648    
4649        SET_TYPE_OFFSET(ucp_Zl);        SET_TYPE_OFFSET(ucp_Zl);
4650        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Zl);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Zl);
# Line 4416  while (*cc != XCL_END) Line 4736  while (*cc != XCL_END)
4736        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_GREATER_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_GREATER_EQUAL);
4737        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4738        break;        break;
4739    
4740          case PT_PXGRAPH:
4741          /* C and Z groups are the farthest two groups. */
4742          SET_TYPE_OFFSET(ucp_Ll);
4743          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);
4744          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_GREATER);
4745    
4746          jump = CMP(SLJIT_C_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);
4747    
4748          /* In case of ucp_Cf, we overwrite the result. */
4749          SET_CHAR_OFFSET(0x2066);
4750          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);
4751          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
4752    
4753          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);
4754          OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4755    
4756          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066);
4757          OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4758    
4759          JUMPHERE(jump);
4760          jump = CMP(SLJIT_C_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);
4761          break;
4762    
4763          case PT_PXPRINT:
4764          /* C and Z groups are the farthest two groups. */
4765          SET_TYPE_OFFSET(ucp_Ll);
4766          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);
4767          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_GREATER);
4768    
4769          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Ll);
4770          OP_FLAGS(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_C_NOT_EQUAL);
4771    
4772          jump = CMP(SLJIT_C_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);
4773    
4774          /* In case of ucp_Cf, we overwrite the result. */
4775          SET_CHAR_OFFSET(0x2066);
4776          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);
4777          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
4778    
4779          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);
4780          OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4781    
4782          JUMPHERE(jump);
4783          jump = CMP(SLJIT_C_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);
4784          break;
4785    
4786          case PT_PXPUNCT:
4787          SET_TYPE_OFFSET(ucp_Sc);
4788          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_So - ucp_Sc);
4789          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
4790    
4791          SET_CHAR_OFFSET(0);
4792          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xff);
4793          OP_FLAGS(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
4794    
4795          SET_TYPE_OFFSET(ucp_Pc);
4796          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Ps - ucp_Pc);
4797          OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
4798          jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4799          break;
4800        }        }
4801      cc += 2;      cc += 2;
4802      }      }
# Line 4472  switch(type) Line 4853  switch(type)
4853    case OP_NOT_DIGIT:    case OP_NOT_DIGIT:
4854    case OP_DIGIT:    case OP_DIGIT:
4855    /* Digits are usually 0-9, so it is worth to optimize them. */    /* Digits are usually 0-9, so it is worth to optimize them. */
   if (common->digits[0] == -2)  
     get_ctype_ranges(common, ctype_digit, common->digits);  
4856    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
4857    /* Flip the starting bit in the negative case. */    /* Flip the starting bit in the negative case. */
4858    if (type == OP_NOT_DIGIT)    read_char8_type(common);
4859      common->digits[1] ^= 1;    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit);
4860    if (!check_ranges(common, common->digits, backtracks, TRUE))    add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));
     {  
     read_char8_type(common);  
     OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit);  
     add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));  
     }  
   if (type == OP_NOT_DIGIT)  
     common->digits[1] ^= 1;  
4861    return cc;    return cc;
4862    
4863    case OP_NOT_WHITESPACE:    case OP_NOT_WHITESPACE:
# Line 4562  switch(type) Line 4934  switch(type)
4934  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4935    case OP_NOTPROP:    case OP_NOTPROP:
4936    case OP_PROP:    case OP_PROP:
4937    propdata[0] = 0;    propdata[0] = XCL_HASPROP;
4938    propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP;    propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP;
4939    propdata[2] = cc[0];    propdata[2] = cc[0];
4940    propdata[3] = cc[1];    propdata[3] = cc[1];
# Line 4920  switch(type) Line 5292  switch(type)
5292    case OP_CLASS:    case OP_CLASS:
5293    case OP_NCLASS:    case OP_NCLASS:
5294    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
5295    read_char(common);    read_char8(common);
5296    if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, backtracks))    if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, FALSE, backtracks))
5297      return cc + 32 / sizeof(pcre_uchar);      return cc + 32 / sizeof(pcre_uchar);
5298    
5299  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
# Line 5054  if (context.length > 0) Line 5426  if (context.length > 0)
5426  return compile_char1_matchingpath(common, *cc, cc + 1, backtracks);  return compile_char1_matchingpath(common, *cc, cc + 1, backtracks);
5427  }  }
5428    
 static struct sljit_jump *compile_ref_checks(compiler_common *common, pcre_uchar *cc, jump_list **backtracks)  
 {  
 DEFINE_COMPILER;  
 int offset = GET2(cc, 1) << 1;  
   
 OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));  
 if (!common->jscript_compat)  
   {  
   if (backtracks == NULL)  
     {  
     /* OVECTOR(1) contains the "string begin - 1" constant. */  
     OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));  
     OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);  
     OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));  
     OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);  
     return JUMP(SLJIT_C_NOT_ZERO);  
     }  
   add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));  
   }  
 return CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));  
 }  
   
5429  /* Forward definitions. */  /* Forward definitions. */
5430  static void compile_matchingpath(compiler_common *, pcre_uchar *, pcre_uchar *, backtrack_common *);  static void compile_matchingpath(compiler_common *, pcre_uchar *, pcre_uchar *, backtrack_common *);
5431  static void compile_backtrackingpath(compiler_common *, struct backtrack_common *);  static void compile_backtrackingpath(compiler_common *, struct backtrack_common *);
# Line 5108  static void compile_backtrackingpath(com Line 5458  static void compile_backtrackingpath(com
5458    
5459  #define BACKTRACK_AS(type) ((type *)backtrack)  #define BACKTRACK_AS(type) ((type *)backtrack)
5460    
5461  static pcre_uchar *compile_ref_matchingpath(compiler_common *common, pcre_uchar *cc, jump_list **backtracks, BOOL withchecks, BOOL emptyfail)  static void compile_dnref_search(compiler_common *common, pcre_uchar *cc, jump_list **backtracks)
5462    {
5463    /* The OVECTOR offset goes to TMP2. */
5464    DEFINE_COMPILER;
5465    int count = GET2(cc, 1 + IMM2_SIZE);
5466    pcre_uchar *slot = common->name_table + GET2(cc, 1) * common->name_entry_size;
5467    unsigned int offset;
5468    jump_list *found = NULL;
5469    
5470    SLJIT_ASSERT(*cc == OP_DNREF || *cc == OP_DNREFI);
5471    
5472    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));
5473    
5474    count--;
5475    while (count-- > 0)
5476      {
5477      offset = GET2(slot, 0) << 1;
5478      GET_LOCAL_BASE(TMP2, 0, OVECTOR(offset));
5479      add_jump(compiler, &found, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0));
5480      slot += common->name_entry_size;
5481      }
5482    
5483    offset = GET2(slot, 0) << 1;
5484    GET_LOCAL_BASE(TMP2, 0, OVECTOR(offset));
5485    if (backtracks != NULL && !common->jscript_compat)
5486      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0));
5487    
5488    set_jumps(found, LABEL());
5489    }
5490    
5491    static void compile_ref_matchingpath(compiler_common *common, pcre_uchar *cc, jump_list **backtracks, BOOL withchecks, BOOL emptyfail)
5492  {  {
5493  DEFINE_COMPILER;  DEFINE_COMPILER;
5494  int offset = GET2(cc, 1) << 1;  BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
5495    int offset = 0;
5496  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
5497  struct sljit_jump *partial;  struct sljit_jump *partial;
5498  struct sljit_jump *nopartial;  struct sljit_jump *nopartial;
5499    
5500  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));  if (ref)
5501  /* OVECTOR(1) contains the "string begin - 1" constant. */    {
5502  if (withchecks && !common->jscript_compat)    offset = GET2(cc, 1) << 1;
5503    add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
5504      /* OVECTOR(1) contains the "string begin - 1" constant. */
5505      if (withchecks && !common->jscript_compat)
5506        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
5507      }
5508    else
5509      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
5510    
5511  #if defined SUPPORT_UTF && defined SUPPORT_UCP  #if defined SUPPORT_UTF && defined SUPPORT_UCP
5512  if (common->utf && *cc == OP_REFI)  if (common->utf && *cc == OP_REFI)
5513    {    {
5514    SLJIT_ASSERT(TMP1 == SLJIT_SCRATCH_REG1 && STACK_TOP == SLJIT_SCRATCH_REG2 && TMP2 == SLJIT_SCRATCH_REG3);    SLJIT_ASSERT(TMP1 == SLJIT_SCRATCH_REG1 && STACK_TOP == SLJIT_SCRATCH_REG2 && TMP2 == SLJIT_SCRATCH_REG3);
5515    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));    if (ref)
5516        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
5517      else
5518        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
5519    
5520    if (withchecks)    if (withchecks)
5521      jump = CMP(SLJIT_C_EQUAL, TMP1, 0, TMP2, 0);      jump = CMP(SLJIT_C_EQUAL, TMP1, 0, TMP2, 0);
5522    
# Line 5150  if (common->utf && *cc == OP_REFI) Line 5541  if (common->utf && *cc == OP_REFI)
5541  else  else
5542  #endif /* SUPPORT_UTF && SUPPORT_UCP */  #endif /* SUPPORT_UTF && SUPPORT_UCP */
5543    {    {
5544    OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP1, 0);    if (ref)
5545        OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP1, 0);
5546      else
5547        OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);
5548    
5549    if (withchecks)    if (withchecks)
5550      jump = JUMP(SLJIT_C_ZERO);      jump = JUMP(SLJIT_C_ZERO);
5551    
# Line 5187  if (jump != NULL) Line 5582  if (jump != NULL)
5582    else    else
5583      JUMPHERE(jump);      JUMPHERE(jump);
5584    }    }
 return cc + 1 + IMM2_SIZE;  
5585  }  }
5586    
5587  static SLJIT_INLINE pcre_uchar *compile_ref_iterator_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)  static SLJIT_INLINE pcre_uchar *compile_ref_iterator_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
5588  {  {
5589  DEFINE_COMPILER;  DEFINE_COMPILER;
5590    BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
5591  backtrack_common *backtrack;  backtrack_common *backtrack;
5592  pcre_uchar type;  pcre_uchar type;
5593    int offset = 0;
5594  struct sljit_label *label;  struct sljit_label *label;
5595  struct sljit_jump *zerolength;  struct sljit_jump *zerolength;
5596  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
# Line 5204  BOOL minimize; Line 5600  BOOL minimize;
5600    
5601  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
5602    
5603    if (ref)
5604      offset = GET2(cc, 1) << 1;
5605    else
5606      cc += IMM2_SIZE;
5607  type = cc[1 + IMM2_SIZE];  type = cc[1 + IMM2_SIZE];
5608    
5609    SLJIT_COMPILE_ASSERT((OP_CRSTAR & 0x1) == 0, crstar_opcode_must_be_even);
5610  minimize = (type & 0x1) != 0;  minimize = (type & 0x1) != 0;
5611  switch(type)  switch(type)
5612    {    {
# Line 5242  if (!minimize) Line 5644  if (!minimize)
5644    if (min == 0)    if (min == 0)
5645      {      {
5646      allocate_stack(common, 2);      allocate_stack(common, 2);
5647        if (ref)
5648          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
5649      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5650      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
5651      /* Temporary release of STR_PTR. */      /* Temporary release of STR_PTR. */
5652      OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));      OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5653      zerolength = compile_ref_checks(common, ccbegin, NULL);      /* Handles both invalid and empty cases. Since the minimum repeat,
5654        is zero the invalid case is basically the same as an empty case. */
5655        if (ref)
5656          zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
5657        else
5658          {
5659          compile_dnref_search(common, ccbegin, NULL);
5660          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
5661          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, TMP2, 0);
5662          zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
5663          }
5664      /* Restore if not zero length. */      /* Restore if not zero length. */
5665      OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));      OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5666      }      }
5667    else    else
5668      {      {
5669      allocate_stack(common, 1);      allocate_stack(common, 1);
5670        if (ref)
5671          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
5672      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5673      zerolength = compile_ref_checks(common, ccbegin, &backtrack->topbacktracks);      if (ref)
5674          {
5675          add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
5676          zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
5677          }
5678        else
5679          {
5680          compile_dnref_search(common, ccbegin, &backtrack->topbacktracks);
5681          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
5682          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, TMP2, 0);
5683          zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
5684          }
5685      }      }
5686    
5687    if (min > 1 || max > 1)    if (min > 1 || max > 1)
5688      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 0);
5689    
5690    label = LABEL();    label = LABEL();
5691      if (!ref)
5692        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);
5693    compile_ref_matchingpath(common, ccbegin, &backtrack->topbacktracks, FALSE, FALSE);    compile_ref_matchingpath(common, ccbegin, &backtrack->topbacktracks, FALSE, FALSE);
5694    
5695    if (min > 1 || max > 1)    if (min > 1 || max > 1)
# Line 5291  if (!minimize) Line 5720  if (!minimize)
5720    JUMPHERE(zerolength);    JUMPHERE(zerolength);
5721    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
5722    
5723    decrease_call_count(common);    count_match(common);
5724    return cc;    return cc;
5725    }    }
5726    
5727  allocate_stack(common, 2);  allocate_stack(common, ref ? 2 : 3);
5728    if (ref)
5729      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
5730  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5731  if (type != OP_CRMINSTAR)  if (type != OP_CRMINSTAR)
5732    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
5733    
5734  if (min == 0)  if (min == 0)
5735    {    {
5736    zerolength = compile_ref_checks(common, ccbegin, NULL);    /* Handles both invalid and empty cases. Since the minimum repeat,
5737      is zero the invalid case is basically the same as an empty case. */
5738      if (ref)
5739        zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
5740      else
5741        {
5742        compile_dnref_search(common, ccbegin, NULL);
5743        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
5744        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP2, 0);
5745        zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
5746        }
5747      /* Length is non-zero, we can match real repeats. */
5748    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5749    jump = JUMP(SLJIT_JUMP);    jump = JUMP(SLJIT_JUMP);
5750    }    }
5751  else  else
5752    zerolength = compile_ref_checks(common, ccbegin, &backtrack->topbacktracks);    {
5753      if (ref)
5754        {
5755        add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
5756        zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
5757        }
5758      else
5759        {
5760        compile_dnref_search(common, ccbegin, &backtrack->topbacktracks);
5761        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
5762        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP2, 0);
5763        zerolength = CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
5764        }
5765      }
5766    
5767  BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();  BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
5768  if (max > 0)  if (max > 0)
5769    add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, max));    add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, max));
5770    
5771    if (!ref)
5772      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(2));
5773  compile_ref_matchingpath(common, ccbegin, &backtrack->topbacktracks, TRUE, TRUE);  compile_ref_matchingpath(common, ccbegin, &backtrack->topbacktracks, TRUE, TRUE);
5774  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5775    
# Line 5330  if (jump != NULL) Line 5787  if (jump != NULL)
5787    JUMPHERE(jump);    JUMPHERE(jump);
5788  JUMPHERE(zerolength);  JUMPHERE(zerolength);
5789    
5790  decrease_call_count(common);  count_match(common);
5791  return cc;  return cc;
5792  }  }
5793    
# Line 5900  common->accept = save_accept; Line 6357  common->accept = save_accept;
6357  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
6358  }  }
6359    
 static sljit_sw SLJIT_CALL do_searchovector(sljit_uw refno, sljit_sw* locals, pcre_uchar *name_table)  
 {  
 int condition = FALSE;  
 pcre_uchar *slotA = name_table;  
 pcre_uchar *slotB;  
 sljit_sw name_count = locals[LOCALS0 / sizeof(sljit_sw)];  
 sljit_sw name_entry_size = locals[LOCALS1 / sizeof(sljit_sw)];  
 sljit_sw no_capture;  
 int i;  
   
 locals += refno & 0xff;  
 refno >>= 8;  
 no_capture = locals[1];  
   
 for (i = 0; i < name_count; i++)  
   {  
   if (GET2(slotA, 0) == refno) break;  
   slotA += name_entry_size;  
   }  
   
 if (i < name_count)  
   {  
   /* Found a name for the number - there can be only one; duplicate names  
   for different numbers are allowed, but not vice versa. First scan down  
   for duplicates. */  
   
   slotB = slotA;  
   while (slotB > name_table)  
     {  
     slotB -= name_entry_size;  
     if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)  
       {  
       condition = locals[GET2(slotB, 0) << 1] != no_capture;  
       if (condition) break;  
       }  
     else break;  
     }  
   
   /* Scan up for duplicates */  
   if (!condition)  
     {  
     slotB = slotA;  
     for (i++; i < name_count; i++)  
       {  
       slotB += name_entry_size;  
       if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)  
         {  
         condition = locals[GET2(slotB, 0) << 1] != no_capture;  
         if (condition) break;  
         }  
       else break;  
       }  
     }  
   }  
 return condition;  
 }  
   
 static sljit_sw SLJIT_CALL do_searchgroups(sljit_uw recno, sljit_uw* locals, pcre_uchar *name_table)  
 {  
 int condition = FALSE;  
 pcre_uchar *slotA = name_table;  
 pcre_uchar *slotB;  
 sljit_uw name_count = locals[LOCALS0 / sizeof(sljit_sw)];  
 sljit_uw name_entry_size = locals[LOCALS1 / sizeof(sljit_sw)];  
 sljit_uw group_num = locals[POSSESSIVE0 / sizeof(sljit_sw)];  
 sljit_uw i;  
   
 for (i = 0; i < name_count; i++)  
   {  
   if (GET2(slotA, 0) == recno) break;  
   slotA += name_entry_size;  
   }  
   
 if (i < name_count)  
   {  
   /* Found a name for the number - there can be only one; duplicate  
   names for different numbers are allowed, but not vice versa. First  
   scan down for duplicates. */  
   
   slotB = slotA;  
   while (slotB > name_table)  
     {  
     slotB -= name_entry_size;  
     if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)  
       {  
       condition = GET2(slotB, 0) == group_num;  
       if (condition) break;  
       }  
     else break;  
     }  
   
   /* Scan up for duplicates */  
   if (!condition)  
     {  
     slotB = slotA;  
     for (i++; i < name_count; i++)  
       {  
       slotB += name_entry_size;  
       if (STRCMP_UC_UC(slotA + IMM2_SIZE, slotB + IMM2_SIZE) == 0)  
         {  
         condition = GET2(slotB, 0) == group_num;  
         if (condition) break;  
         }  
       else break;  
       }  
     }  
   }  
 return condition;  
 }  
   
6360  static SLJIT_INLINE void match_once_common(compiler_common *common, pcre_uchar ket, int framesize, int private_data_ptr, BOOL has_alternatives, BOOL needs_control_head)  static SLJIT_INLINE void match_once_common(compiler_common *common, pcre_uchar ket, int framesize, int private_data_ptr, BOOL has_alternatives, BOOL needs_control_head)
6361  {  {
6362  DEFINE_COMPILER;  DEFINE_COMPILER;
# Line 6142  backtrack_common *backtrack; Line 6489  backtrack_common *backtrack;
6489  pcre_uchar opcode;  pcre_uchar opcode;
6490  int private_data_ptr = 0;  int private_data_ptr = 0;
6491  int offset = 0;  int offset = 0;
6492  int stacksize;  int i, stacksize;
6493  int repeat_ptr = 0, repeat_length = 0;  int repeat_ptr = 0, repeat_length = 0;
6494  int repeat_type = 0, repeat_count = 0;  int repeat_type = 0, repeat_count = 0;
6495  pcre_uchar *ccbegin;  pcre_uchar *ccbegin;
6496  pcre_uchar *matchingpath;  pcre_uchar *matchingpath;
6497    pcre_uchar *slot;
6498  pcre_uchar bra = OP_BRA;  pcre_uchar bra = OP_BRA;
6499  pcre_uchar ket;  pcre_uchar ket;
6500  assert_backtrack *assert;  assert_backtrack *assert;
# Line 6196  SLJIT_ASSERT(!((bra == OP_BRAZERO && ket Line 6544  SLJIT_ASSERT(!((bra == OP_BRAZERO && ket
6544  cc += GET(cc, 1);  cc += GET(cc, 1);
6545    
6546  has_alternatives = *cc == OP_ALT;  has_alternatives = *cc == OP_ALT;
6547  if (SLJIT_UNLIKELY(opcode == OP_COND) || SLJIT_UNLIKELY(opcode == OP_SCOND))  if (SLJIT_UNLIKELY(opcode == OP_COND || opcode == OP_SCOND))
6548    {    has_alternatives = (*matchingpath == OP_RREF || *matchingpath == OP_DNRREF) ? FALSE : TRUE;
   has_alternatives = (*matchingpath == OP_RREF) ? FALSE : TRUE;  
   if (*matchingpath == OP_NRREF)  
     {  
     stacksize = GET2(matchingpath, 1);  
     if (common->currententry == NULL || stacksize == RREF_ANY)  
       has_alternatives = FALSE;  
     else if (common->currententry->start == 0)  
       has_alternatives = stacksize != 0;  
     else  
       has_alternatives = stacksize != (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);  
     }  
   }  
6549    
6550  if (SLJIT_UNLIKELY(opcode == OP_COND) && (*cc == OP_KETRMAX || *cc == OP_KETRMIN))  if (SLJIT_UNLIKELY(opcode == OP_COND) && (*cc == OP_KETRMAX || *cc == OP_KETRMIN))
6551    opcode = OP_SCOND;    opcode = OP_SCOND;
# Line 6446  if (opcode == OP_COND || opcode == OP_SC Line 6782  if (opcode == OP_COND || opcode == OP_SC
6782        CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(matchingpath, 1) << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));        CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(matchingpath, 1) << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
6783      matchingpath += 1 + IMM2_SIZE;      matchingpath += 1 + IMM2_SIZE;
6784      }      }
6785    else if (*matchingpath == OP_NCREF)    else if (*matchingpath == OP_DNCREF)
6786      {      {
6787      SLJIT_ASSERT(has_alternatives);      SLJIT_ASSERT(has_alternatives);
     stacksize = GET2(matchingpath, 1);  
     jump = CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(stacksize << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));  
   
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STACK_TOP, 0);  
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);  
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);  
     OP1(SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, (stacksize << 8) | (common->ovector_start / sizeof(sljit_sw)));  
     GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, 0);  
     OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, common->name_table);  
     sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchovector));  
     OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);  
     add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, 0));  
6788    
6789      JUMPHERE(jump);      i = GET2(matchingpath, 1 + IMM2_SIZE);
6790      matchingpath += 1 + IMM2_SIZE;      slot = common->name_table + GET2(matchingpath, 1) * common->name_entry_size;
6791        OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
6792        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));
6793        OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(slot, 0) << 1), TMP1, 0);
6794        slot += common->name_entry_size;
6795        i--;
6796        while (i-- > 0)
6797          {
6798          OP2(SLJIT_SUB, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(slot, 0) << 1), TMP1, 0);
6799          OP2(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, STR_PTR, 0);
6800          slot += common->name_entry_size;
6801          }
6802        OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
6803        add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), JUMP(SLJIT_C_ZERO));
6804        matchingpath += 1 + 2 * IMM2_SIZE;
6805      }      }
6806    else if (*matchingpath == OP_RREF || *matchingpath == OP_NRREF)    else if (*matchingpath == OP_RREF || *matchingpath == OP_DNRREF)
6807      {      {
6808      /* Never has other case. */      /* Never has other case. */
6809      BACKTRACK_AS(bracket_backtrack)->u.condfailed = NULL;      BACKTRACK_AS(bracket_backtrack)->u.condfailed = NULL;
6810        SLJIT_ASSERT(!has_alternatives);
6811    
6812      stacksize = GET2(matchingpath, 1);      if (*matchingpath == OP_RREF)
     if (common->currententry == NULL)  
       stacksize = 0;  
     else if (stacksize == RREF_ANY)  
       stacksize = 1;  
     else if (common->currententry->start == 0)  
       stacksize = stacksize == 0;  
     else  
       stacksize = stacksize == (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);  
   
     if (*matchingpath == OP_RREF || stacksize || common->currententry == NULL)  
6813        {        {
6814        SLJIT_ASSERT(!has_alternatives);        stacksize = GET2(matchingpath, 1);
6815          if (common->currententry == NULL)
6816            stacksize = 0;
6817          else if (stacksize == RREF_ANY)
6818            stacksize = 1;
6819          else if (common->currententry->start == 0)
6820            stacksize = stacksize == 0;
6821          else
6822            stacksize = stacksize == (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
6823    
6824        if (stacksize != 0)        if (stacksize != 0)
6825          matchingpath += 1 + IMM2_SIZE;          matchingpath += 1 + IMM2_SIZE;
6826          }
6827        else
6828          {
6829          if (common->currententry == NULL || common->currententry->start == 0)
6830            stacksize = 0;
6831        else        else
6832          {          {
6833            stacksize = GET2(matchingpath, 1 + IMM2_SIZE);
6834            slot = common->name_table + GET2(matchingpath, 1) * common->name_entry_size;
6835            i = (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
6836            while (stacksize > 0)
6837              {
6838              if ((int)GET2(slot, 0) == i)
6839                break;
6840              slot += common->name_entry_size;
6841              stacksize--;
6842              }
6843            }
6844    
6845          if (stacksize != 0)
6846            matchingpath += 1 + 2 * IMM2_SIZE;
6847          }
6848    
6849          /* The stacksize == 0 is a common "else" case. */
6850          if (stacksize == 0)
6851            {
6852          if (*cc == OP_ALT)          if (*cc == OP_ALT)
6853            {            {
6854            matchingpath = cc + 1 + LINK_SIZE;            matchingpath = cc + 1 + LINK_SIZE;
# Line 6495  if (opcode == OP_COND || opcode == OP_SC Line 6857  if (opcode == OP_COND || opcode == OP_SC
6857          else          else
6858            matchingpath = cc;            matchingpath = cc;
6859          }          }
       }  
     else  
       {  
       SLJIT_ASSERT(has_alternatives);  
   
       stacksize = GET2(matchingpath, 1);  
       OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STACK_TOP, 0);  
       OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);  
       OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);  
       OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, GET2(common->start, common->currententry->start + 1 + LINK_SIZE));  
       OP1(SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, stacksize);  
       GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, 0);  
       OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, common->name_table);  
       sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));  
       OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);  
       add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, 0));  
       matchingpath += 1 + IMM2_SIZE;  
       }  
6860      }      }
6861    else    else
6862      {      {
# Line 6663  if (bra == OP_BRAMINZERO) Line 7007  if (bra == OP_BRAMINZERO)
7007    }    }
7008    
7009  if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO)  if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO)
7010    decrease_call_count(common);    count_match(common);
7011    
7012  /* Skip the other alternatives. */  /* Skip the other alternatives. */
7013  while (*cc == OP_ALT)  while (*cc == OP_ALT)
# Line 6950  if (!zero) Line 7294  if (!zero)
7294    
7295  /* None of them matched. */  /* None of them matched. */
7296  set_jumps(emptymatch, LABEL());  set_jumps(emptymatch, LABEL());
7297  decrease_call_count(common);  count_match(common);
7298  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
7299  }  }
7300    
7301  static SLJIT_INLINE pcre_uchar *get_iterator_parameters(compiler_common *common, pcre_uchar *cc, pcre_uchar *opcode, pcre_uchar *type, int *arg1, int *arg2, pcre_uchar **end)  static SLJIT_INLINE pcre_uchar *get_iterator_parameters(compiler_common *common, pcre_uchar *cc, pcre_uchar *opcode, pcre_uchar *type, int *max, int *min, pcre_uchar **end)
7302  {  {
7303  int class_len;  int class_len;
7304    
# Line 6990  else if (*opcode >= OP_TYPESTAR && *opco Line 7334  else if (*opcode >= OP_TYPESTAR && *opco
7334    }    }
7335  else  else
7336    {    {
7337    SLJIT_ASSERT(*opcode >= OP_CLASS || *opcode <= OP_XCLASS);    SLJIT_ASSERT(*opcode == OP_CLASS || *opcode == OP_NCLASS || *opcode == OP_XCLASS);
7338    *type = *opcode;    *type = *opcode;
7339    cc++;    cc++;
7340    class_len = (*type < OP_XCLASS) ? (int)(1 + (32 / sizeof(pcre_uchar))) : GET(cc, 0);    class_len = (*type < OP_XCLASS) ? (int)(1 + (32 / sizeof(pcre_uchar))) : GET(cc, 0);
# Line 7001  else Line 7345  else
7345      if (end != NULL)      if (end != NULL)
7346        *end = cc + class_len;        *end = cc + class_len;
7347      }      }
7348      else if (*opcode >= OP_CRPOSSTAR && *opcode <= OP_CRPOSQUERY)
7349        {
7350        *opcode -= OP_CRPOSSTAR - OP_POSSTAR;
7351        if (end != NULL)
7352          *end = cc + class_len;
7353        }
7354    else    else
7355      {      {
7356      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE || *opcode == OP_CRPOSRANGE);
7357      *arg1 = GET2(cc, (class_len + IMM2_SIZE));      *max = GET2(cc, (class_len + IMM2_SIZE));
7358      *arg2 = GET2(cc, class_len);      *min = GET2(cc, class_len);
7359    
7360      if (*arg2 == 0)      if (*min == 0)
7361        {        {
7362        SLJIT_ASSERT(*arg1 != 0);        SLJIT_ASSERT(*max != 0);
7363        *opcode = (*opcode == OP_CRRANGE) ? OP_UPTO : OP_MINUPTO;        *opcode = (*opcode == OP_CRRANGE) ? OP_UPTO : (*opcode == OP_CRMINRANGE ? OP_MINUPTO : OP_POSUPTO);
7364        }        }
7365      if (*arg1 == *arg2)      if (*max == *min)
7366        *opcode = OP_EXACT;        *opcode = OP_EXACT;
7367    
7368      if (end != NULL)      if (end != NULL)
# Line 7023  else Line 7373  else
7373    
7374  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)
7375    {    {
7376    *arg1 = GET2(cc, 0);    *max = GET2(cc, 0);
7377    cc += IMM2_SIZE;    cc += IMM2_SIZE;
7378    }    }
7379    
# Line 7052  DEFINE_COMPILER; Line 7402  DEFINE_COMPILER;
7402  backtrack_common *backtrack;  backtrack_common *backtrack;
7403  pcre_uchar opcode;  pcre_uchar opcode;
7404  pcre_uchar type;  pcre_uchar type;
7405  int arg1 = -1, arg2 = -1;  int max = -1, min = -1;
7406  pcre_uchar* end;  pcre_uchar* end;
7407  jump_list *nomatch = NULL;  jump_list *nomatch = NULL;
7408  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
# Line 7065  int tmp_base, tmp_offset; Line 7415  int tmp_base, tmp_offset;
7415    
7416  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
7417    
7418  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, &end);  cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &min, &end);
7419    
7420  switch(type)  switch(type)
7421    {    {
# Line 7136  switch(opcode) Line 7486  switch(opcode)
7486        {        {
7487        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);
7488        OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);        OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
7489        if (opcode == OP_CRRANGE && arg2 > 0)        if (opcode == OP_CRRANGE && min > 0)
7490          CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg2, label);          CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, min, label);
7491        if (opcode == OP_UPTO || (opcode == OP_CRRANGE && arg1 > 0))        if (opcode == OP_UPTO || (opcode == OP_CRRANGE && max > 0))
7492          jump = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, arg1);          jump = CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, max);
7493        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, TMP1, 0);
7494        }        }
7495    
# Line 7166  switch(opcode) Line 7516  switch(opcode)
7516      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
7517      if (opcode <= OP_PLUS)      if (opcode <= OP_PLUS)
7518        JUMPTO(SLJIT_JUMP, label);        JUMPTO(SLJIT_JUMP, label);
7519      else if (opcode == OP_CRRANGE && arg1 == 0)      else if (opcode == OP_CRRANGE && max == 0)
7520        {        {
7521        OP2(SLJIT_ADD, base, offset1, base, offset1, SLJIT_IMM, 1);        OP2(SLJIT_ADD, base, offset1, base, offset1, SLJIT_IMM, 1);
7522        JUMPTO(SLJIT_JUMP, label);        JUMPTO(SLJIT_JUMP, label);
# Line 7176  switch(opcode) Line 7526  switch(opcode)
7526        OP1(SLJIT_MOV, TMP1, 0, base, offset1);        OP1(SLJIT_MOV, TMP1, 0, base, offset1);
7527        OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);        OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
7528        OP1(SLJIT_MOV, base, offset1, TMP1, 0);        OP1(SLJIT_MOV, base, offset1, TMP1, 0);
7529        CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg1 + 1, label);        CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, max + 1, label);
7530        }        }
7531      set_jumps(nomatch, LABEL());      set_jumps(nomatch, LABEL());
7532      if (opcode == OP_CRRANGE)      if (opcode == OP_CRRANGE)
7533        add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_LESS, base, offset1, SLJIT_IMM, arg2 + 1));        add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_LESS, base, offset1, SLJIT_IMM, min + 1));
7534      OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);      OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
7535      }      }
7536    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
# Line 7218  switch(opcode) Line 7568  switch(opcode)
7568    break;    break;
7569    
7570    case OP_EXACT:    case OP_EXACT:
7571    OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, arg1);    OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max);
7572    label = LABEL();    label = LABEL();
7573    compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);    compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
7574    OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);    OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);
# Line 7231  switch(opcode) Line 7581  switch(opcode)
7581    if (opcode == OP_POSPLUS)    if (opcode == OP_POSPLUS)
7582      compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);      compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
7583    if (opcode == OP_POSUPTO)    if (opcode == OP_POSUPTO)
7584      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_IMM, arg1);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_IMM, max);
7585    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
7586    label = LABEL();    label = LABEL();
7587    compile_char1_matchingpath(common, type, cc, &nomatch);    compile_char1_matchingpath(common, type, cc, &nomatch);
# Line 7255  switch(opcode) Line 7605  switch(opcode)
7605    OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);    OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
7606    break;    break;
7607    
7608      case OP_CRPOSRANGE:
7609      /* Combination of OP_EXACT and OP_POSSTAR or OP_POSUPTO */
7610      OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, min);
7611      label = LABEL();
7612      compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
7613      OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);
7614      JUMPTO(SLJIT_C_NOT_ZERO, label);
7615    
7616      if (max != 0)
7617        {
7618        SLJIT_ASSERT(max - min > 0);
7619        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_IMM, max - min);
7620        }
7621      OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
7622      label = LABEL();
7623      compile_char1_matchingpath(common, type, cc, &nomatch);
7624      OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
7625      if (max == 0)
7626        JUMPTO(SLJIT_JUMP, label);
7627      else
7628        {
7629        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_IMM, 1);
7630        JUMPTO(SLJIT_C_NOT_ZERO, label);
7631        }
7632      set_jumps(nomatch, LABEL());
7633      OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
7634      break;
7635    
7636    default:    default:
7637    SLJIT_ASSERT_STOP();    SLJIT_ASSERT_STOP();
7638    break;    break;
7639    }    }
7640    
7641  decrease_call_count(common);  count_match(common);
7642  return end;  return end;
7643  }  }
7644    
# Line 7532  while (cc < ccend) Line 7910  while (cc < ccend)
7910    
7911      case OP_CLASS:      case OP_CLASS:
7912      case OP_NCLASS:      case OP_NCLASS:
7913      if (cc[1 + (32 / sizeof(pcre_uchar))] >= OP_CRSTAR && cc[1 + (32 / sizeof(pcre_uchar))] <= OP_CRMINRANGE)      if (cc[1 + (32 / sizeof(pcre_uchar))] >= OP_CRSTAR && cc[1 + (32 / sizeof(pcre_uchar))] <= OP_CRPOSRANGE)
7914        cc = compile_iterator_matchingpath(common, cc, parent);        cc = compile_iterator_matchingpath(common, cc, parent);
7915      else      else
7916        cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);        cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
# Line 7540  while (cc < ccend) Line 7918  while (cc < ccend)
7918    
7919  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
7920      case OP_XCLASS:      case OP_XCLASS:
7921      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_CRPOSRANGE)
7922        cc = compile_iterator_matchingpath(common, cc, parent);        cc = compile_iterator_matchingpath(common, cc, parent);
7923      else      else
7924        cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);        cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
# Line 7549  while (cc < ccend) Line 7927  while (cc < ccend)
7927    
7928      case OP_REF:      case OP_REF:
7929      case OP_REFI:      case OP_REFI:
7930      if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRMINRANGE)      if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRPOSRANGE)
7931          cc = compile_ref_iterator_matchingpath(common, cc, parent);
7932        else
7933          {
7934          compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);
7935          cc += 1 + IMM2_SIZE;
7936          }
7937        break;
7938    
7939        case OP_DNREF:
7940        case OP_DNREFI:
7941        if (cc[1 + 2 * IMM2_SIZE] >= OP_CRSTAR && cc[1 + 2 * IMM2_SIZE] <= OP_CRPOSRANGE)
7942        cc = compile_ref_iterator_matchingpath(common, cc, parent);        cc = compile_ref_iterator_matchingpath(common, cc, parent);
7943      else      else
7944        cc = compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);        {
7945          compile_dnref_search(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
7946          compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);
7947          cc += 1 + 2 * IMM2_SIZE;
7948          }
7949      break;      break;
7950    
7951      case OP_RECURSE:      case OP_RECURSE:
# Line 7587  while (cc < ccend) Line 7980  while (cc < ccend)
7980        }        }
7981      BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();      BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();
7982      if (cc[1] > OP_ASSERTBACK_NOT)      if (cc[1] > OP_ASSERTBACK_NOT)
7983        decrease_call_count(common);        count_match(common);
7984      break;      break;
7985    
7986      case OP_ONCE:      case OP_ONCE:
# Line 7705  DEFINE_COMPILER; Line 8098  DEFINE_COMPILER;
8098  pcre_uchar *cc = current->cc;  pcre_uchar *cc = current->cc;
8099  pcre_uchar opcode;  pcre_uchar opcode;
8100  pcre_uchar type;  pcre_uchar type;
8101  int arg1 = -1, arg2 = -1;  int max = -1, min = -1;
8102  struct sljit_label *label = NULL;  struct sljit_label *label = NULL;
8103  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
8104  jump_list *jumplist = NULL;  jump_list *jumplist = NULL;
# Line 7714  int base = (private_data_ptr == 0) ? SLJ Line 8107  int base = (private_data_ptr == 0) ? SLJ
8107  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
8108  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
8109    
8110  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);  cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &min, NULL);
8111    
8112  switch(opcode)  switch(opcode)
8113    {    {
# Line 7733  switch(opcode) Line 8126  switch(opcode)
8126    else    else
8127      {      {
8128      if (opcode == OP_UPTO)      if (opcode == OP_UPTO)
8129        arg2 = 0;        min = 0;
8130      if (opcode <= OP_PLUS)      if (opcode <= OP_PLUS)
8131        {        {
8132        OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);        OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
# Line 7743  switch(opcode) Line 8136  switch(opcode)
8136        {        {
8137        OP1(SLJIT_MOV, TMP1, 0, base, offset1);        OP1(SLJIT_MOV, TMP1, 0, base, offset1);
8138        OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);        OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
8139        jump = CMP(SLJIT_C_LESS_EQUAL, TMP1, 0, SLJIT_IMM, arg2 + 1);        jump = CMP(SLJIT_C_LESS_EQUAL, TMP1, 0, SLJIT_IMM, min + 1);
8140        OP2(SLJIT_SUB, base, offset1, TMP1, 0, SLJIT_IMM, 1);        OP2(SLJIT_SUB, base, offset1, TMP1, 0, SLJIT_IMM, 1);
8141        }        }
8142      skip_char_back(common);      skip_char_back(common);
# Line 7788  switch(opcode) Line 8181  switch(opcode)
8181    OP1(SLJIT_MOV, base, offset1, TMP1, 0);    OP1(SLJIT_MOV, base, offset1, TMP1, 0);
8182    
8183    if (opcode == OP_CRMINRANGE)    if (opcode == OP_CRMINRANGE)
8184      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg2 + 1, label);      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, min + 1, label);
8185    
8186    if (opcode == OP_CRMINRANGE && arg1 == 0)    if (opcode == OP_CRMINRANGE && max == 0)
8187      JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);      JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
8188    else    else
8189      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg1 + 2, CURRENT_AS(iterator_backtrack)->matchingpath);      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, max + 2, CURRENT_AS(iterator_backtrack)->matchingpath);
8190    
8191    set_jumps(jumplist, LABEL());    set_jumps(jumplist, LABEL());
8192    if (private_data_ptr == 0)    if (private_data_ptr == 0)
# Line 7828  switch(opcode) Line 8221  switch(opcode)
8221    
8222    case OP_EXACT:    case OP_EXACT:
8223    case OP_POSPLUS:    case OP_POSPLUS:
8224      case OP_CRPOSRANGE:
8225    set_jumps(current->topbacktracks, LABEL());    set_jumps(current->topbacktracks, LABEL());
8226    break;    break;
8227    
# Line 7846  static SLJIT_INLINE void compile_ref_ite Line 8240  static SLJIT_INLINE void compile_ref_ite
8240  {  {
8241  DEFINE_COMPILER;  DEFINE_COMPILER;
8242  pcre_uchar *cc = current->cc;  pcre_uchar *cc = current->cc;
8243    BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
8244  pcre_uchar type;  pcre_uchar type;
8245    
8246  type = cc[1 + IMM2_SIZE];  type = cc[ref ? 1 + IMM2_SIZE : 1 + 2 * IMM2_SIZE];
8247    
8248  if ((type & 0x1) == 0)  if ((type & 0x1) == 0)
8249    {    {
8250      /* Maximize case. */
8251    set_jumps(current->topbacktracks, LABEL());    set_jumps(current->topbacktracks, LABEL());
8252    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
8253    free_stack(common, 1);    free_stack(common, 1);
# Line 7861  if ((type & 0x1) == 0) Line 8258  if ((type & 0x1) == 0)
8258  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
8259  CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath);  CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath);
8260  set_jumps(current->topbacktracks, LABEL());  set_jumps(current->topbacktracks, LABEL());
8261  free_stack(common, 2);  free_stack(common, ref ? 2 : 3);
8262  }  }
8263    
8264  static SLJIT_INLINE void compile_recurse_backtrackingpath(compiler_common *common, struct backtrack_common *current)  static SLJIT_INLINE void compile_recurse_backtrackingpath(compiler_common *common, struct backtrack_common *current)
# Line 8225  if (has_alternatives) Line 8622  if (has_alternatives)
8622          return;          return;
8623        }        }
8624    
8625      /* Instructions after the current alternative is succesfully matched. */      /* Instructions after the current alternative is successfully matched. */
8626      /* There is a similar code in compile_bracket_matchingpath. */      /* There is a similar code in compile_bracket_matchingpath. */
8627      if (opcode == OP_ONCE)      if (opcode == OP_ONCE)
8628        match_once_common(common, ket, CURRENT_AS(bracket_backtrack)->u.framesize, private_data_ptr, has_alternatives, needs_control_head);        match_once_common(common, ket, CURRENT_AS(bracket_backtrack)->u.framesize, private_data_ptr, has_alternatives, needs_control_head);
# Line 8662  while (current) Line 9059  while (current)
9059    
9060      case OP_REF:      case OP_REF:
9061      case OP_REFI:      case OP_REFI:
9062        case OP_DNREF:
9063        case OP_DNREFI:
9064      compile_ref_iterator_backtrackingpath(common, current);      compile_ref_iterator_backtrackingpath(common, current);
9065      break;      break;
9066    
# Line 8955  else Line 9354  else
9354    }    }
9355  common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
9356  common->ctypes = (sljit_sw)(tables + ctypes_offset);  common->ctypes = (sljit_sw)(tables + ctypes_offset);
9357  common->digits[0] = -2;  common->name_table = ((pcre_uchar *)re) + re->name_table_offset;
 common->name_table = (sljit_sw)((pcre_uchar *)re + re->name_table_offset);  
9358  common->name_count = re->name_count;  common->name_count = re->name_count;
9359  common->name_entry_size = re->name_entry_size;  common->name_entry_size = re->name_entry_size;
9360  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
# Line 8970  common->use_ucp = (re->options & PCRE_UC Line 9368  common->use_ucp = (re->options & PCRE_UC
9368  ccend = bracketend(rootbacktrack.cc);  ccend = bracketend(rootbacktrack.cc);
9369    
9370  /* Calculate the local space size on the stack. */  /* Calculate the local space size on the stack. */
9371  common->ovector_start = CALL_LIMIT + sizeof(sljit_sw);  common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw);
9372  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);
9373  if (!common->optimized_cbracket)  if (!common->optimized_cbracket)
9374    return;    return;
# Line 9102  OP1(SLJIT_MOV, TMP1, 0, SLJIT_SAVED_REG1 Line 9500  OP1(SLJIT_MOV, TMP1, 0, SLJIT_SAVED_REG1
9500  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
9501  OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end));  OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end));
9502  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));
9503  OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, call_limit));  OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match));
9504  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));
9505  OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));  OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));
9506  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LIMIT_MATCH, TMP1, 0);
9507    
9508  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
9509    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);
# Line 9129  if ((re->options & PCRE_ANCHORED) == 0) Line 9527  if ((re->options & PCRE_ANCHORED) == 0)
9527      else if ((re->flags & PCRE_STARTLINE) != 0)      else if ((re->flags & PCRE_STARTLINE) != 0)
9528        fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);        fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);
9529      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)
9530        fast_forward_start_bits(common, (sljit_uw)study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);        fast_forward_start_bits(common, study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);
9531      }      }
9532    }    }
9533  else  else
# Line 9147  if (common->req_char_ptr != 0) Line 9545  if (common->req_char_ptr != 0)
9545  /* Store the current STR_PTR in OVECTOR(0). */  /* Store the current STR_PTR in OVECTOR(0). */
9546  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);
9547  /* Copy the limit of allowed recursions. */  /* Copy the limit of allowed recursions. */
9548  OP1(SLJIT_MOV, CALL_COUNT, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT);  OP1(SLJIT_MOV, COUNT_MATCH, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LIMIT_MATCH);
9549  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
9550    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, -1);
9551    
# Line 9375  if (common->utfreadchar != NULL) Line 9773  if (common->utfreadchar != NULL)
9773    }    }
9774  #endif /* !COMPILE_PCRE32 */  #endif /* !COMPILE_PCRE32 */
9775  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
9776    if (common->utfreadchar8 != NULL)
9777      {
9778      set_jumps(common->utfreadchar8, LABEL());
9779      do_utfreadchar8(common);
9780      }
9781  if (common->utfreadtype8 != NULL)  if (common->utfreadtype8 != NULL)
9782    {    {
9783    set_jumps(common->utfreadtype8, LABEL());    set_jumps(common->utfreadtype8, LABEL());
# Line 9425  else Line 9828  else
9828      }      }
9829    memset(functions, 0, sizeof(executable_functions));    memset(functions, 0, sizeof(executable_functions));
9830    functions->top_bracket = (re->top_bracket + 1) * 2;    functions->top_bracket = (re->top_bracket + 1) * 2;
9831      functions->limit_match = (re->flags & PCRE_MLSET) != 0 ? re->limit_match : 0;
9832    extra->executable_jit = functions;    extra->executable_jit = functions;
9833    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;
9834    }    }
# Line 9479  arguments.begin = subject; Line 9883  arguments.begin = subject;
9883  arguments.end = subject + length;  arguments.end = subject + length;
9884  arguments.mark_ptr = NULL;  arguments.mark_ptr = NULL;
9885  /* JIT decreases this value less frequently than the interpreter. */  /* JIT decreases this value less frequently than the interpreter. */
9886  arguments.call_limit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;  arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit);
9887    if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match)
9888      arguments.limit_match = functions->limit_match;
9889  arguments.notbol = (options & PCRE_NOTBOL) != 0;  arguments.notbol = (options & PCRE_NOTBOL) != 0;
9890  arguments.noteol = (options & PCRE_NOTEOL) != 0;  arguments.noteol = (options & PCRE_NOTEOL) != 0;
9891  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
# Line 9570  arguments.begin = subject_ptr; Line 9976  arguments.begin = subject_ptr;
9976  arguments.end = subject_ptr + length;  arguments.end = subject_ptr + length;
9977  arguments.mark_ptr = NULL;  arguments.mark_ptr = NULL;
9978  /* JIT decreases this value less frequently than the interpreter. */  /* JIT decreases this value less frequently than the interpreter. */
9979  arguments.call_limit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;  arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit);
9980    if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match)
9981      arguments.limit_match = functions->limit_match;
9982  arguments.notbol = (options & PCRE_NOTBOL) != 0;  arguments.notbol = (options & PCRE_NOTBOL) != 0;
9983  arguments.noteol = (options & PCRE_NOTEOL) != 0;  arguments.noteol = (options & PCRE_NOTEOL) != 0;
9984  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
# Line 9689  if (extra != NULL && Line 10097  if (extra != NULL &&
10097    }    }
10098  }  }
10099    
10100    #if defined COMPILE_PCRE8
10101    PCRE_EXP_DECL void
10102    pcre_jit_free_unused_memory(void)
10103    #elif defined COMPILE_PCRE16
10104    PCRE_EXP_DECL void
10105    pcre16_jit_free_unused_memory(void)
10106    #elif defined COMPILE_PCRE32
10107    PCRE_EXP_DECL void
10108    pcre32_jit_free_unused_memory(void)
10109    #endif
10110    {
10111    sljit_free_unused_memory_exec();
10112    }
10113    
10114  #else  /* SUPPORT_JIT */  #else  /* SUPPORT_JIT */
10115    
10116  /* 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
# Line 9740  pcre32_assign_jit_stack(pcre32_extra *ex Line 10162  pcre32_assign_jit_stack(pcre32_extra *ex
10162  (void)userdata;  (void)userdata;
10163  }  }
10164    
10165    #if defined COMPILE_PCRE8
10166    PCRE_EXP_DECL void
10167    pcre_jit_free_unused_memory(void)
10168    #elif defined COMPILE_PCRE16
10169    PCRE_EXP_DECL void
10170    pcre16_jit_free_unused_memory(void)
10171    #elif defined COMPILE_PCRE32
10172    PCRE_EXP_DECL void
10173    pcre32_jit_free_unused_memory(void)
10174    #endif
10175    {
10176    }
10177    
10178  #endif  #endif
10179    
10180  /* End of pcre_jit_compile.c */  /* End of pcre_jit_compile.c */

Legend:
Removed from v.1308  
changed lines
  Added in v.1420

  ViewVC Help
Powered by ViewVC 1.1.5