/[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 1084 by chpe, Tue Oct 16 15:55:28 2012 UTC revision 1249 by zherczeg, Mon Feb 18 09:55:43 2013 UTC
# Line 65  system files. */ Line 65  system files. */
65  #error Unsupported architecture  #error Unsupported architecture
66  #endif  #endif
67    
68    /* Defines for debugging purposes. */
69    
70    /* 1 - Use unoptimized capturing brackets.
71       2 - Enable capture_last_ptr (includes option 1). */
72    /* #define DEBUG_FORCE_UNOPTIMIZED_CBRAS 2 */
73    
74  /* Allocate memory for the regex stack on the real machine stack.  /* Allocate memory for the regex stack on the real machine stack.
75  Fast, but limited size. */  Fast, but limited size. */
76  #define MACHINE_STACK_SIZE 32768  #define MACHINE_STACK_SIZE 32768
# Line 157  typedef struct jit_arguments { Line 163  typedef struct jit_arguments {
163    int *offsets;    int *offsets;
164    pcre_uchar *uchar_ptr;    pcre_uchar *uchar_ptr;
165    pcre_uchar *mark_ptr;    pcre_uchar *mark_ptr;
166      void *callout_data;
167    /* Everything else after. */    /* Everything else after. */
168    int offsetcount;    int offset_count;
169    int calllimit;    int call_limit;
170    pcre_uint8 notbol;    pcre_uint8 notbol;
171    pcre_uint8 noteol;    pcre_uint8 noteol;
172    pcre_uint8 notempty;    pcre_uint8 notempty;
# Line 170  typedef struct executable_functions { Line 177  typedef struct executable_functions {
177    void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];    void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];
178    PUBL(jit_callback) callback;    PUBL(jit_callback) callback;
179    void *userdata;    void *userdata;
180      pcre_uint32 top_bracket;
181    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
182  } executable_functions;  } executable_functions;
183    
# Line 178  typedef struct jump_list { Line 186  typedef struct jump_list {
186    struct jump_list *next;    struct jump_list *next;
187  } jump_list;  } jump_list;
188    
 enum stub_types { stack_alloc };  
   
189  typedef struct stub_list {  typedef struct stub_list {
   enum stub_types type;  
   int data;  
190    struct sljit_jump *start;    struct sljit_jump *start;
191    struct sljit_label *quit;    struct sljit_label *quit;
192    struct stub_list *next;    struct stub_list *next;
193  } stub_list;  } stub_list;
194    
195    enum frame_types { no_frame = -1, no_stack = -2 };
196    
197  typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);  typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);
198    
199  /* The following structure is the key data type for the recursive  /* The following structure is the key data type for the recursive
# Line 269  typedef struct recurse_entry { Line 275  typedef struct recurse_entry {
275    
276  typedef struct recurse_backtrack {  typedef struct recurse_backtrack {
277    backtrack_common common;    backtrack_common common;
278      BOOL inlined_pattern;
279  } recurse_backtrack;  } recurse_backtrack;
280    
281  #define MAX_RANGE_SIZE 6  #define MAX_RANGE_SIZE 6
# Line 288  typedef struct compiler_common { Line 295  typedef struct compiler_common {
295    /* Last known position of the requested byte. */    /* Last known position of the requested byte. */
296    int req_char_ptr;    int req_char_ptr;
297    /* Head of the last recursion. */    /* Head of the last recursion. */
298    int recursive_head;    int recursive_head_ptr;
299    /* First inspected character for partial matching. */    /* First inspected character for partial matching. */
300    int start_used_ptr;    int start_used_ptr;
301    /* Starting pointer for partial soft matches. */    /* Starting pointer for partial soft matches. */
# Line 297  typedef struct compiler_common { Line 304  typedef struct compiler_common {
304    int first_line_end;    int first_line_end;
305    /* Points to the marked string. */    /* Points to the marked string. */
306    int mark_ptr;    int mark_ptr;
307      /* Points to the last matched capture block index. */
308      int capture_last_ptr;
309    
310    /* Flipped and lower case tables. */    /* Flipped and lower case tables. */
311    const pcre_uint8 *fcc;    const pcre_uint8 *fcc;
312    sljit_w lcc;    sljit_sw lcc;
313    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */
314    int mode;    int mode;
315    /* Newline control. */    /* Newline control. */
# Line 311  typedef struct compiler_common { Line 320  typedef struct compiler_common {
320    int endonly;    int endonly;
321    BOOL has_set_som;    BOOL has_set_som;
322    /* Tables. */    /* Tables. */
323    sljit_w ctypes;    sljit_sw ctypes;
324    int digits[2 + MAX_RANGE_SIZE];    int digits[2 + MAX_RANGE_SIZE];
325    /* Named capturing brackets. */    /* Named capturing brackets. */
326    sljit_uw name_table;    sljit_uw name_table;
327    sljit_w name_count;    sljit_sw name_count;
328    sljit_w name_entry_size;    sljit_sw name_entry_size;
329    
330    /* Labels and jump lists. */    /* Labels and jump lists. */
331    struct sljit_label *partialmatchlabel;    struct sljit_label *partialmatchlabel;
332    struct sljit_label *quitlabel;    struct sljit_label *quit_label;
333    struct sljit_label *acceptlabel;    struct sljit_label *forced_quit_label;
334      struct sljit_label *accept_label;
335    stub_list *stubs;    stub_list *stubs;
336    recurse_entry *entries;    recurse_entry *entries;
337    recurse_entry *currententry;    recurse_entry *currententry;
338    jump_list *partialmatch;    jump_list *partialmatch;
339    jump_list *quit;    jump_list *quit;
340      jump_list *forced_quit;
341    jump_list *accept;    jump_list *accept;
342    jump_list *calllimit;    jump_list *calllimit;
343    jump_list *stackalloc;    jump_list *stackalloc;
# Line 363  typedef struct compare_context { Line 374  typedef struct compare_context {
374  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
375    int ucharptr;    int ucharptr;
376    union {    union {
377      sljit_i asint;      sljit_si asint;
378      sljit_uh asushort;      sljit_uh asushort;
379  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
380      sljit_ub asbyte;      sljit_ub asbyte;
# Line 375  typedef struct compare_context { Line 386  typedef struct compare_context {
386  #endif  #endif
387    } c;    } c;
388    union {    union {
389      sljit_i asint;      sljit_si asint;
390      sljit_uh asushort;      sljit_uh asushort;
391  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
392      sljit_ub asbyte;      sljit_ub asbyte;
# Line 389  typedef struct compare_context { Line 400  typedef struct compare_context {
400  #endif  #endif
401  } compare_context;  } compare_context;
402    
 enum {  
   frame_end = 0,  
   frame_setstrbegin = -1,  
   frame_setmark = -2  
 };  
   
403  /* Undefine sljit macros. */  /* Undefine sljit macros. */
404  #undef CMP  #undef CMP
405    
406  /* Used for accessing the elements of the stack. */  /* Used for accessing the elements of the stack. */
407  #define STACK(i)      ((-(i) - 1) * (int)sizeof(sljit_w))  #define STACK(i)      ((-(i) - 1) * (int)sizeof(sljit_sw))
408    
409  #define TMP1          SLJIT_TEMPORARY_REG1  #define TMP1          SLJIT_SCRATCH_REG1
410  #define TMP2          SLJIT_TEMPORARY_REG3  #define TMP2          SLJIT_SCRATCH_REG3
411  #define TMP3          SLJIT_TEMPORARY_EREG2  #define TMP3          SLJIT_TEMPORARY_EREG2
412  #define STR_PTR       SLJIT_SAVED_REG1  #define STR_PTR       SLJIT_SAVED_REG1
413  #define STR_END       SLJIT_SAVED_REG2  #define STR_END       SLJIT_SAVED_REG2
414  #define STACK_TOP     SLJIT_TEMPORARY_REG2  #define STACK_TOP     SLJIT_SCRATCH_REG2
415  #define STACK_LIMIT   SLJIT_SAVED_REG3  #define STACK_LIMIT   SLJIT_SAVED_REG3
416  #define ARGUMENTS     SLJIT_SAVED_EREG1  #define ARGUMENTS     SLJIT_SAVED_EREG1
417  #define CALL_COUNT    SLJIT_SAVED_EREG2  #define CALL_COUNT    SLJIT_SAVED_EREG2
# Line 414  enum { Line 419  enum {
419    
420  /* Local space layout. */  /* Local space layout. */
421  /* These two locals can be used by the current opcode. */  /* These two locals can be used by the current opcode. */
422  #define LOCALS0          (0 * sizeof(sljit_w))  #define LOCALS0          (0 * sizeof(sljit_sw))
423  #define LOCALS1          (1 * sizeof(sljit_w))  #define LOCALS1          (1 * sizeof(sljit_sw))
424  /* Two local variables for possessive quantifiers (char1 cannot use them). */  /* Two local variables for possessive quantifiers (char1 cannot use them). */
425  #define POSSESSIVE0      (2 * sizeof(sljit_w))  #define POSSESSIVE0      (2 * sizeof(sljit_sw))
426  #define POSSESSIVE1      (3 * sizeof(sljit_w))  #define POSSESSIVE1      (3 * sizeof(sljit_sw))
427  /* Max limit of recursions. */  /* Max limit of recursions. */
428  #define CALL_LIMIT       (4 * sizeof(sljit_w))  #define CALL_LIMIT       (4 * sizeof(sljit_sw))
429  /* The output vector is stored on the stack, and contains pointers  /* The output vector is stored on the stack, and contains pointers
430  to characters. The vector data is divided into two groups: the first  to characters. The vector data is divided into two groups: the first
431  group contains the start / end character pointers, and the second is  group contains the start / end character pointers, and the second is
432  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. */
433  #define OVECTOR_START    (common->ovector_start)  #define OVECTOR_START    (common->ovector_start)
434  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))
435  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_sw))
436  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
437    
438  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
# Line 458  the start pointers when the end of the c Line 463  the start pointers when the end of the c
463    sljit_set_label(sljit_emit_jump(compiler, (type)), (label))    sljit_set_label(sljit_emit_jump(compiler, (type)), (label))
464  #define JUMPHERE(jump) \  #define JUMPHERE(jump) \
465    sljit_set_label((jump), sljit_emit_label(compiler))    sljit_set_label((jump), sljit_emit_label(compiler))
466    #define SET_LABEL(jump, label) \
467      sljit_set_label((jump), (label))
468  #define CMP(type, src1, src1w, src2, src2w) \  #define CMP(type, src1, src1w, src2, src2w) \
469    sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w))    sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w))
470  #define CMPTO(type, src1, src1w, src2, src2w, label) \  #define CMPTO(type, src1, src1w, src2, src2w, label) \
471    sljit_set_label(sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w)), (label))    sljit_set_label(sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w)), (label))
472  #define COND_VALUE(op, dst, dstw, type) \  #define OP_FLAGS(op, dst, dstw, src, srcw, type) \
473    sljit_emit_cond_value(compiler, (op), (dst), (dstw), (type))    sljit_emit_op_flags(compiler, (op), (dst), (dstw), (src), (srcw), (type))
474  #define GET_LOCAL_BASE(dst, dstw, offset) \  #define GET_LOCAL_BASE(dst, dstw, offset) \
475    sljit_get_local_base(compiler, (dst), (dstw), (offset))    sljit_get_local_base(compiler, (dst), (dstw), (offset))
476    
# Line 506  switch(*cc) Line 513  switch(*cc)
513    case OP_WORDCHAR:    case OP_WORDCHAR:
514    case OP_ANY:    case OP_ANY:
515    case OP_ALLANY:    case OP_ALLANY:
516      case OP_NOTPROP:
517      case OP_PROP:
518    case OP_ANYNL:    case OP_ANYNL:
519    case OP_NOT_HSPACE:    case OP_NOT_HSPACE:
520    case OP_HSPACE:    case OP_HSPACE:
# Line 518  switch(*cc) Line 527  switch(*cc)
527    case OP_CIRCM:    case OP_CIRCM:
528    case OP_DOLL:    case OP_DOLL:
529    case OP_DOLLM:    case OP_DOLLM:
   case OP_TYPESTAR:  
   case OP_TYPEMINSTAR:  
   case OP_TYPEPLUS:  
   case OP_TYPEMINPLUS:  
   case OP_TYPEQUERY:  
   case OP_TYPEMINQUERY:  
   case OP_TYPEPOSSTAR:  
   case OP_TYPEPOSPLUS:  
   case OP_TYPEPOSQUERY:  
530    case OP_CRSTAR:    case OP_CRSTAR:
531    case OP_CRMINSTAR:    case OP_CRMINSTAR:
532    case OP_CRPLUS:    case OP_CRPLUS:
533    case OP_CRMINPLUS:    case OP_CRMINPLUS:
534    case OP_CRQUERY:    case OP_CRQUERY:
535    case OP_CRMINQUERY:    case OP_CRMINQUERY:
536      case OP_CRRANGE:
537      case OP_CRMINRANGE:
538      case OP_CLASS:
539      case OP_NCLASS:
540      case OP_REF:
541      case OP_REFI:
542      case OP_RECURSE:
543      case OP_CALLOUT:
544      case OP_ALT:
545      case OP_KET:
546      case OP_KETRMAX:
547      case OP_KETRMIN:
548      case OP_KETRPOS:
549      case OP_REVERSE:
550      case OP_ASSERT:
551      case OP_ASSERT_NOT:
552      case OP_ASSERTBACK:
553      case OP_ASSERTBACK_NOT:
554      case OP_ONCE:
555      case OP_ONCE_NC:
556      case OP_BRA:
557      case OP_BRAPOS:
558      case OP_CBRA:
559      case OP_CBRAPOS:
560      case OP_COND:
561      case OP_SBRA:
562      case OP_SBRAPOS:
563      case OP_SCBRA:
564      case OP_SCBRAPOS:
565      case OP_SCOND:
566      case OP_CREF:
567      case OP_NCREF:
568      case OP_RREF:
569      case OP_NRREF:
570    case OP_DEF:    case OP_DEF:
571    case OP_BRAZERO:    case OP_BRAZERO:
572    case OP_BRAMINZERO:    case OP_BRAMINZERO:
# Line 541  switch(*cc) Line 575  switch(*cc)
575    case OP_FAIL:    case OP_FAIL:
576    case OP_ACCEPT:    case OP_ACCEPT:
577    case OP_ASSERT_ACCEPT:    case OP_ASSERT_ACCEPT:
578      case OP_CLOSE:
579    case OP_SKIPZERO:    case OP_SKIPZERO:
580    return cc + 1;    return cc + PRIV(OP_lengths)[*cc];
   
   case OP_ANYBYTE:  
 #ifdef SUPPORT_UTF  
   if (common->utf) return NULL;  
 #endif  
   return cc + 1;  
581    
582    case OP_CHAR:    case OP_CHAR:
583    case OP_CHARI:    case OP_CHARI:
# Line 560  switch(*cc) Line 589  switch(*cc)
589    case OP_MINPLUS:    case OP_MINPLUS:
590    case OP_QUERY:    case OP_QUERY:
591    case OP_MINQUERY:    case OP_MINQUERY:
592      case OP_UPTO:
593      case OP_MINUPTO:
594      case OP_EXACT:
595    case OP_POSSTAR:    case OP_POSSTAR:
596    case OP_POSPLUS:    case OP_POSPLUS:
597    case OP_POSQUERY:    case OP_POSQUERY:
598      case OP_POSUPTO:
599    case OP_STARI:    case OP_STARI:
600    case OP_MINSTARI:    case OP_MINSTARI:
601    case OP_PLUSI:    case OP_PLUSI:
602    case OP_MINPLUSI:    case OP_MINPLUSI:
603    case OP_QUERYI:    case OP_QUERYI:
604    case OP_MINQUERYI:    case OP_MINQUERYI:
605      case OP_UPTOI:
606      case OP_MINUPTOI:
607      case OP_EXACTI:
608    case OP_POSSTARI:    case OP_POSSTARI:
609    case OP_POSPLUSI:    case OP_POSPLUSI:
610    case OP_POSQUERYI:    case OP_POSQUERYI:
611      case OP_POSUPTOI:
612    case OP_NOTSTAR:    case OP_NOTSTAR:
613    case OP_NOTMINSTAR:    case OP_NOTMINSTAR:
614    case OP_NOTPLUS:    case OP_NOTPLUS:
615    case OP_NOTMINPLUS:    case OP_NOTMINPLUS:
616    case OP_NOTQUERY:    case OP_NOTQUERY:
617    case OP_NOTMINQUERY:    case OP_NOTMINQUERY:
618      case OP_NOTUPTO:
619      case OP_NOTMINUPTO:
620      case OP_NOTEXACT:
621    case OP_NOTPOSSTAR:    case OP_NOTPOSSTAR:
622    case OP_NOTPOSPLUS:    case OP_NOTPOSPLUS:
623    case OP_NOTPOSQUERY:    case OP_NOTPOSQUERY:
624      case OP_NOTPOSUPTO:
625    case OP_NOTSTARI:    case OP_NOTSTARI:
626    case OP_NOTMINSTARI:    case OP_NOTMINSTARI:
627    case OP_NOTPLUSI:    case OP_NOTPLUSI:
628    case OP_NOTMINPLUSI:    case OP_NOTMINPLUSI:
629    case OP_NOTQUERYI:    case OP_NOTQUERYI:
630    case OP_NOTMINQUERYI:    case OP_NOTMINQUERYI:
   case OP_NOTPOSSTARI:  
   case OP_NOTPOSPLUSI:  
   case OP_NOTPOSQUERYI:  
   cc += 2;  
 #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  
   if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);  
 #endif  
   return cc;  
   
   case OP_UPTO:  
   case OP_MINUPTO:  
   case OP_EXACT:  
   case OP_POSUPTO:  
   case OP_UPTOI:  
   case OP_MINUPTOI:  
   case OP_EXACTI:  
   case OP_POSUPTOI:  
   case OP_NOTUPTO:  
   case OP_NOTMINUPTO:  
   case OP_NOTEXACT:  
   case OP_NOTPOSUPTO:  
631    case OP_NOTUPTOI:    case OP_NOTUPTOI:
632    case OP_NOTMINUPTOI:    case OP_NOTMINUPTOI:
633    case OP_NOTEXACTI:    case OP_NOTEXACTI:
634      case OP_NOTPOSSTARI:
635      case OP_NOTPOSPLUSI:
636      case OP_NOTPOSQUERYI:
637    case OP_NOTPOSUPTOI:    case OP_NOTPOSUPTOI:
638    cc += 2 + IMM2_SIZE;    cc += PRIV(OP_lengths)[*cc];
639  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
640    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);    if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
641  #endif  #endif
642    return cc;    return cc;
643    
644    case OP_NOTPROP:    /* Special cases. */
645    case OP_PROP:    case OP_TYPESTAR:
646    return cc + 1 + 2;    case OP_TYPEMINSTAR:
647      case OP_TYPEPLUS:
648      case OP_TYPEMINPLUS:
649      case OP_TYPEQUERY:
650      case OP_TYPEMINQUERY:
651    case OP_TYPEUPTO:    case OP_TYPEUPTO:
652    case OP_TYPEMINUPTO:    case OP_TYPEMINUPTO:
653    case OP_TYPEEXACT:    case OP_TYPEEXACT:
654      case OP_TYPEPOSSTAR:
655      case OP_TYPEPOSPLUS:
656      case OP_TYPEPOSQUERY:
657    case OP_TYPEPOSUPTO:    case OP_TYPEPOSUPTO:
658    case OP_REF:    return cc + PRIV(OP_lengths)[*cc] - 1;
   case OP_REFI:  
   case OP_CREF:  
   case OP_NCREF:  
   case OP_RREF:  
   case OP_NRREF:  
   case OP_CLOSE:  
   cc += 1 + IMM2_SIZE;  
   return cc;  
659    
660    case OP_CRRANGE:    case OP_ANYBYTE:
661    case OP_CRMINRANGE:  #ifdef SUPPORT_UTF
662    return cc + 1 + 2 * IMM2_SIZE;    if (common->utf) return NULL;
663    #endif
664    case OP_CLASS:    return cc + 1;
   case OP_NCLASS:  
   return cc + 1 + 32 / sizeof(pcre_uchar);  
665    
666  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
667    case OP_XCLASS:    case OP_XCLASS:
668    return cc + GET(cc, 1);    return cc + GET(cc, 1);
669  #endif  #endif
670    
   case OP_RECURSE:  
   case OP_ASSERT:  
   case OP_ASSERT_NOT:  
   case OP_ASSERTBACK:  
   case OP_ASSERTBACK_NOT:  
   case OP_REVERSE:  
   case OP_ONCE:  
   case OP_ONCE_NC:  
   case OP_BRA:  
   case OP_BRAPOS:  
   case OP_COND:  
   case OP_SBRA:  
   case OP_SBRAPOS:  
   case OP_SCOND:  
   case OP_ALT:  
   case OP_KET:  
   case OP_KETRMAX:  
   case OP_KETRMIN:  
   case OP_KETRPOS:  
   return cc + 1 + LINK_SIZE;  
   
   case OP_CBRA:  
   case OP_CBRAPOS:  
   case OP_SCBRA:  
   case OP_SCBRAPOS:  
   return cc + 1 + LINK_SIZE + IMM2_SIZE;  
   
671    case OP_MARK:    case OP_MARK:
672    return cc + 1 + 2 + cc[1];    return cc + 1 + 2 + cc[1];
673    
# Line 767  int private_data_length = 0; Line 759  int private_data_length = 0;
759  pcre_uchar *alternative;  pcre_uchar *alternative;
760  pcre_uchar *name;  pcre_uchar *name;
761  pcre_uchar *end = NULL;  pcre_uchar *end = NULL;
762  int space, size, bracketlen, i;  int space, size, i;
763    pcre_uint32 bracketlen;
764    
765  /* 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. */
766  while (cc < ccend)  while (cc < ccend)
# Line 797  while (cc < ccend) Line 790  while (cc < ccend)
790      case OP_BRAPOS:      case OP_BRAPOS:
791      case OP_SBRA:      case OP_SBRA:
792      case OP_SBRAPOS:      case OP_SBRAPOS:
793      private_data_length += sizeof(sljit_w);      private_data_length += sizeof(sljit_sw);
794      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
795      break;      break;
796    
797      case OP_CBRAPOS:      case OP_CBRAPOS:
798      case OP_SCBRAPOS:      case OP_SCBRAPOS:
799      private_data_length += sizeof(sljit_w);      private_data_length += sizeof(sljit_sw);
800      common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;      common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;
801      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
802      break;      break;
803    
804      case OP_COND:      case OP_COND:
805      case OP_SCOND:      case OP_SCOND:
806      bracketlen = cc[1 + LINK_SIZE];      /* Only AUTO_CALLOUT can insert this opcode. We do
807      if (bracketlen == OP_CREF)         not intend to support this case. */
808        {      if (cc[1 + LINK_SIZE] == OP_CALLOUT)
809        bracketlen = GET2(cc, 1 + LINK_SIZE + 1);        return -1;
       common->optimized_cbracket[bracketlen] = 0;  
       }  
     else if (bracketlen == OP_NCREF)  
       {  
       bracketlen = GET2(cc, 1 + LINK_SIZE + 1);  
       name = (pcre_uchar *)common->name_table;  
       alternative = name;  
       for (i = 0; i < common->name_count; i++)  
         {  
         if (GET2(name, 0) == bracketlen) break;  
         name += common->name_entry_size;  
         }  
       SLJIT_ASSERT(i != common->name_count);  
   
       for (i = 0; i < common->name_count; i++)  
         {  
         if (STRCMP_UC_UC(alternative + IMM2_SIZE, name + IMM2_SIZE) == 0)  
           common->optimized_cbracket[GET2(alternative, 0)] = 0;  
         alternative += common->name_entry_size;  
         }  
       }  
810    
811      if (*cc == OP_COND)      if (*cc == OP_COND)
812        {        {
813        /* Might be a hidden SCOND. */        /* Might be a hidden SCOND. */
814        alternative = cc + GET(cc, 1);        alternative = cc + GET(cc, 1);
815        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
816          private_data_length += sizeof(sljit_w);          private_data_length += sizeof(sljit_sw);
817        }        }
818      else      else
819        private_data_length += sizeof(sljit_w);        private_data_length += sizeof(sljit_sw);
820      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
821      break;      break;
822    
823        case OP_CREF:
824        i = GET2(cc, 1);
825        common->optimized_cbracket[i] = 0;
826        cc += 1 + IMM2_SIZE;
827        break;
828    
829        case OP_NCREF:
830        bracketlen = GET2(cc, 1);
831        name = (pcre_uchar *)common->name_table;
832        alternative = name;
833        for (i = 0; i < common->name_count; i++)
834          {
835          if (GET2(name, 0) == bracketlen) break;
836          name += common->name_entry_size;
837          }
838        SLJIT_ASSERT(i != common->name_count);
839    
840        for (i = 0; i < common->name_count; i++)
841          {
842          if (STRCMP_UC_UC(alternative + IMM2_SIZE, name + IMM2_SIZE) == 0)
843            common->optimized_cbracket[GET2(alternative, 0)] = 0;
844          alternative += common->name_entry_size;
845          }
846        bracketlen = 0;
847        cc += 1 + IMM2_SIZE;
848        break;
849    
850      case OP_BRA:      case OP_BRA:
851      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
852      break;      break;
# Line 904  while (cc < ccend) Line 903  while (cc < ccend)
903    
904      case OP_RECURSE:      case OP_RECURSE:
905      /* Set its value only once. */      /* Set its value only once. */
906      if (common->recursive_head == 0)      if (common->recursive_head_ptr == 0)
907        {        {
908        common->recursive_head = common->ovector_start;        common->recursive_head_ptr = common->ovector_start;
909        common->ovector_start += sizeof(sljit_w);        common->ovector_start += sizeof(sljit_sw);
910        }        }
911      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
912      break;      break;
913    
914        case OP_CALLOUT:
915        if (common->capture_last_ptr == 0)
916          {
917          common->capture_last_ptr = common->ovector_start;
918          common->ovector_start += sizeof(sljit_sw);
919          }
920        cc += 2 + 2 * LINK_SIZE;
921        break;
922    
923      case OP_MARK:      case OP_MARK:
924      if (common->mark_ptr == 0)      if (common->mark_ptr == 0)
925        {        {
926        common->mark_ptr = common->ovector_start;        common->mark_ptr = common->ovector_start;
927        common->ovector_start += sizeof(sljit_w);        common->ovector_start += sizeof(sljit_sw);
928        }        }
929      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
930      break;      break;
# Line 929  while (cc < ccend) Line 937  while (cc < ccend)
937      }      }
938    
939    if (space > 0 && cc >= end)    if (space > 0 && cc >= end)
940      private_data_length += sizeof(sljit_w) * space;      private_data_length += sizeof(sljit_sw) * space;
941    
942    if (size != 0)    if (size != 0)
943      {      {
944      if (size < 0)      if (size < 0)
945        {        {
946        cc += -size;        cc += -size;
947  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
948        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
949  #endif  #endif
950        }        }
# Line 944  while (cc < ccend) Line 952  while (cc < ccend)
952        cc += size;        cc += size;
953      }      }
954    
955    if (bracketlen > 0)    if (bracketlen != 0)
956      {      {
957      if (cc >= end)      if (cc >= end)
958        {        {
# Line 983  while (cc < ccend) Line 991  while (cc < ccend)
991      case OP_SBRAPOS:      case OP_SBRAPOS:
992      case OP_SCOND:      case OP_SCOND:
993      common->private_data_ptrs[cc - common->start] = private_data_ptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
994      private_data_ptr += sizeof(sljit_w);      private_data_ptr += sizeof(sljit_sw);
995      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
996      break;      break;
997    
998      case OP_CBRAPOS:      case OP_CBRAPOS:
999      case OP_SCBRAPOS:      case OP_SCBRAPOS:
1000      common->private_data_ptrs[cc - common->start] = private_data_ptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
1001      private_data_ptr += sizeof(sljit_w);      private_data_ptr += sizeof(sljit_sw);
1002      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
1003      break;      break;
1004    
# Line 1000  while (cc < ccend) Line 1008  while (cc < ccend)
1008      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
1009        {        {
1010        common->private_data_ptrs[cc - common->start] = private_data_ptr;        common->private_data_ptrs[cc - common->start] = private_data_ptr;
1011        private_data_ptr += sizeof(sljit_w);        private_data_ptr += sizeof(sljit_sw);
1012        }        }
1013      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
1014      break;      break;
# Line 1068  while (cc < ccend) Line 1076  while (cc < ccend)
1076    if (space > 0 && cc >= end)    if (space > 0 && cc >= end)
1077      {      {
1078      common->private_data_ptrs[cc - common->start] = private_data_ptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
1079      private_data_ptr += sizeof(sljit_w) * space;      private_data_ptr += sizeof(sljit_sw) * space;
1080      }      }
1081    
1082    if (size != 0)    if (size != 0)
# Line 1076  while (cc < ccend) Line 1084  while (cc < ccend)
1084      if (size < 0)      if (size < 0)
1085        {        {
1086        cc += -size;        cc += -size;
1087  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1088        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1089  #endif  #endif
1090        }        }
# Line 1097  while (cc < ccend) Line 1105  while (cc < ccend)
1105    }    }
1106  }  }
1107    
1108  /* Returns with -1 if no need for frame. */  /* Returns with a frame_types (always < 0) if no need for frame. */
1109  static int get_framesize(compiler_common *common, pcre_uchar *cc, BOOL recursive)  static int get_framesize(compiler_common *common, pcre_uchar *cc, BOOL recursive)
1110  {  {
1111  pcre_uchar *ccend = bracketend(cc);  pcre_uchar *ccend = bracketend(cc) - (1 + LINK_SIZE);
1112  int length = 0;  int length = 0;
1113  BOOL possessive = FALSE;  int possessive = 0;
1114    BOOL stack_restore = FALSE;
1115  BOOL setsom_found = recursive;  BOOL setsom_found = recursive;
1116  BOOL setmark_found = recursive;  BOOL setmark_found = recursive;
1117    /* The last capture is a local variable even for recursions. */
1118    BOOL capture_last_found = FALSE;
1119    
1120  if (!recursive && (*cc == OP_CBRAPOS || *cc == OP_SCBRAPOS))  if (!recursive && (*cc == OP_CBRAPOS || *cc == OP_SCBRAPOS))
1121    {    {
1122    length = 3;    possessive = length = (common->capture_last_ptr != 0) ? 5 : 3;
1123    possessive = TRUE;    /* This is correct regardless of common->capture_last_ptr. */
1124      capture_last_found = TRUE;
1125    }    }
1126    
1127  cc = next_opcode(common, cc);  cc = next_opcode(common, cc);
# Line 1119  while (cc < ccend) Line 1131  while (cc < ccend)
1131      {      {
1132      case OP_SET_SOM:      case OP_SET_SOM:
1133      SLJIT_ASSERT(common->has_set_som);      SLJIT_ASSERT(common->has_set_som);
1134        stack_restore = TRUE;
1135      if (!setsom_found)      if (!setsom_found)
1136        {        {
1137        length += 2;        length += 2;
# Line 1129  while (cc < ccend) Line 1142  while (cc < ccend)
1142    
1143      case OP_MARK:      case OP_MARK:
1144      SLJIT_ASSERT(common->mark_ptr != 0);      SLJIT_ASSERT(common->mark_ptr != 0);
1145        stack_restore = TRUE;
1146      if (!setmark_found)      if (!setmark_found)
1147        {        {
1148        length += 2;        length += 2;
# Line 1138  while (cc < ccend) Line 1152  while (cc < ccend)
1152      break;      break;
1153    
1154      case OP_RECURSE:      case OP_RECURSE:
1155        stack_restore = TRUE;
1156      if (common->has_set_som && !setsom_found)      if (common->has_set_som && !setsom_found)
1157        {        {
1158        length += 2;        length += 2;
# Line 1148  while (cc < ccend) Line 1163  while (cc < ccend)
1163        length += 2;        length += 2;
1164        setmark_found = TRUE;        setmark_found = TRUE;
1165        }        }
1166        if (common->capture_last_ptr != 0 && !capture_last_found)
1167          {
1168          length += 2;
1169          capture_last_found = TRUE;
1170          }
1171      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
1172      break;      break;
1173    
# Line 1155  while (cc < ccend) Line 1175  while (cc < ccend)
1175      case OP_CBRAPOS:      case OP_CBRAPOS:
1176      case OP_SCBRA:      case OP_SCBRA:
1177      case OP_SCBRAPOS:      case OP_SCBRAPOS:
1178        stack_restore = TRUE;
1179        if (common->capture_last_ptr != 0 && !capture_last_found)
1180          {
1181          length += 2;
1182          capture_last_found = TRUE;
1183          }
1184      length += 3;      length += 3;
1185      cc += 1 + LINK_SIZE + IMM2_SIZE;      cc += 1 + LINK_SIZE + IMM2_SIZE;
1186      break;      break;
1187    
1188      default:      default:
1189        stack_restore = TRUE;
1190        /* Fall through. */
1191    
1192        case OP_NOT_WORD_BOUNDARY:
1193        case OP_WORD_BOUNDARY:
1194        case OP_NOT_DIGIT:
1195        case OP_DIGIT:
1196        case OP_NOT_WHITESPACE:
1197        case OP_WHITESPACE:
1198        case OP_NOT_WORDCHAR:
1199        case OP_WORDCHAR:
1200        case OP_ANY:
1201        case OP_ALLANY:
1202        case OP_ANYBYTE:
1203        case OP_NOTPROP:
1204        case OP_PROP:
1205        case OP_ANYNL:
1206        case OP_NOT_HSPACE:
1207        case OP_HSPACE:
1208        case OP_NOT_VSPACE:
1209        case OP_VSPACE:
1210        case OP_EXTUNI:
1211        case OP_EODN:
1212        case OP_EOD:
1213        case OP_CIRC:
1214        case OP_CIRCM:
1215        case OP_DOLL:
1216        case OP_DOLLM:
1217        case OP_CHAR:
1218        case OP_CHARI:
1219        case OP_NOT:
1220        case OP_NOTI:
1221    
1222        case OP_EXACT:
1223        case OP_POSSTAR:
1224        case OP_POSPLUS:
1225        case OP_POSQUERY:
1226        case OP_POSUPTO:
1227    
1228        case OP_EXACTI:
1229        case OP_POSSTARI:
1230        case OP_POSPLUSI:
1231        case OP_POSQUERYI:
1232        case OP_POSUPTOI:
1233    
1234        case OP_NOTEXACT:
1235        case OP_NOTPOSSTAR:
1236        case OP_NOTPOSPLUS:
1237        case OP_NOTPOSQUERY:
1238        case OP_NOTPOSUPTO:
1239    
1240        case OP_NOTEXACTI:
1241        case OP_NOTPOSSTARI:
1242        case OP_NOTPOSPLUSI:
1243        case OP_NOTPOSQUERYI:
1244        case OP_NOTPOSUPTOI:
1245    
1246        case OP_TYPEEXACT:
1247        case OP_TYPEPOSSTAR:
1248        case OP_TYPEPOSPLUS:
1249        case OP_TYPEPOSQUERY:
1250        case OP_TYPEPOSUPTO:
1251    
1252        case OP_CLASS:
1253        case OP_NCLASS:
1254        case OP_XCLASS:
1255    
1256      cc = next_opcode(common, cc);      cc = next_opcode(common, cc);
1257      SLJIT_ASSERT(cc != NULL);      SLJIT_ASSERT(cc != NULL);
1258      break;      break;
1259      }      }
1260    
1261  /* Possessive quantifiers can use a special case. */  /* Possessive quantifiers can use a special case. */
1262  if (SLJIT_UNLIKELY(possessive) && length == 3)  if (SLJIT_UNLIKELY(possessive == length))
1263    return -1;    return stack_restore ? no_frame : no_stack;
1264    
1265  if (length > 0)  if (length > 0)
1266    return length + 1;    return length + 1;
1267  return -1;  return stack_restore ? no_frame : no_stack;
1268  }  }
1269    
1270  static void init_frame(compiler_common *common, pcre_uchar *cc, int stackpos, int stacktop, BOOL recursive)  static void init_frame(compiler_common *common, pcre_uchar *cc, int stackpos, int stacktop, BOOL recursive)
1271  {  {
1272  DEFINE_COMPILER;  DEFINE_COMPILER;
1273  pcre_uchar *ccend = bracketend(cc);  pcre_uchar *ccend = bracketend(cc) - (1 + LINK_SIZE);
1274  BOOL setsom_found = recursive;  BOOL setsom_found = recursive;
1275  BOOL setmark_found = recursive;  BOOL setmark_found = recursive;
1276    /* The last capture is a local variable even for recursions. */
1277    BOOL capture_last_found = FALSE;
1278  int offset;  int offset;
1279    
1280  /* >= 1 + shortest item size (2) */  /* >= 1 + shortest item size (2) */
# Line 1198  while (cc < ccend) Line 1293  while (cc < ccend)
1293      if (!setsom_found)      if (!setsom_found)
1294        {        {
1295        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
1296        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setstrbegin);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -OVECTOR(0));
1297        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1298        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1299        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1300        setsom_found = TRUE;        setsom_found = TRUE;
1301        }        }
1302      cc += 1;      cc += 1;
# Line 1212  while (cc < ccend) Line 1307  while (cc < ccend)
1307      if (!setmark_found)      if (!setmark_found)
1308        {        {
1309        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);
1310        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setmark);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->mark_ptr);
1311        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1312        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1313        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1314        setmark_found = TRUE;        setmark_found = TRUE;
1315        }        }
1316      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
# Line 1225  while (cc < ccend) Line 1320  while (cc < ccend)
1320      if (common->has_set_som && !setsom_found)      if (common->has_set_som && !setsom_found)
1321        {        {
1322        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
1323        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setstrbegin);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -OVECTOR(0));
1324        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1325        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1326        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1327        setsom_found = TRUE;        setsom_found = TRUE;
1328        }        }
1329      if (common->mark_ptr != 0 && !setmark_found)      if (common->mark_ptr != 0 && !setmark_found)
1330        {        {
1331        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);
1332        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setmark);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->mark_ptr);
1333        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1334        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1335        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1336        setmark_found = TRUE;        setmark_found = TRUE;
1337        }        }
1338        if (common->capture_last_ptr != 0 && !capture_last_found)
1339          {
1340          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
1341          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->capture_last_ptr);
1342          stackpos += (int)sizeof(sljit_sw);
1343          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1344          stackpos += (int)sizeof(sljit_sw);
1345          capture_last_found = TRUE;
1346          }
1347      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
1348      break;      break;
1349    
# Line 1247  while (cc < ccend) Line 1351  while (cc < ccend)
1351      case OP_CBRAPOS:      case OP_CBRAPOS:
1352      case OP_SCBRA:      case OP_SCBRA:
1353      case OP_SCBRAPOS:      case OP_SCBRAPOS:
1354        if (common->capture_last_ptr != 0 && !capture_last_found)
1355          {
1356          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
1357          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->capture_last_ptr);
1358          stackpos += (int)sizeof(sljit_sw);
1359          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1360          stackpos += (int)sizeof(sljit_sw);
1361          capture_last_found = TRUE;
1362          }
1363      offset = (GET2(cc, 1 + LINK_SIZE)) << 1;      offset = (GET2(cc, 1 + LINK_SIZE)) << 1;
1364      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, OVECTOR(offset));      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, OVECTOR(offset));
1365      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_sw);
1366      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
1367      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
1368      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1369      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_sw);
1370      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);
1371      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_sw);
1372    
1373      cc += 1 + LINK_SIZE + IMM2_SIZE;      cc += 1 + LINK_SIZE + IMM2_SIZE;
1374      break;      break;
# Line 1266  while (cc < ccend) Line 1379  while (cc < ccend)
1379      break;      break;
1380      }      }
1381    
1382  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_end);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, 0);
1383  SLJIT_ASSERT(stackpos == STACK(stacktop));  SLJIT_ASSERT(stackpos == STACK(stacktop));
1384  }  }
1385    
# Line 1320  while (cc < ccend) Line 1433  while (cc < ccend)
1433      if (PRIVATE_DATA(cc))      if (PRIVATE_DATA(cc))
1434        private_data_length++;        private_data_length++;
1435      cc += 2;      cc += 2;
1436  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1437      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1438  #endif  #endif
1439      break;      break;
# Line 1329  while (cc < ccend) Line 1442  while (cc < ccend)
1442      if (PRIVATE_DATA(cc))      if (PRIVATE_DATA(cc))
1443        private_data_length += 2;        private_data_length += 2;
1444      cc += 2;      cc += 2;
1445  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1446      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1447  #endif  #endif
1448      break;      break;
# Line 1338  while (cc < ccend) Line 1451  while (cc < ccend)
1451      if (PRIVATE_DATA(cc))      if (PRIVATE_DATA(cc))
1452        private_data_length += 2;        private_data_length += 2;
1453      cc += 2 + IMM2_SIZE;      cc += 2 + IMM2_SIZE;
1454  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1455      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1456  #endif  #endif
1457      break;      break;
# Line 1406  stacktop = STACK(stacktop - 1); Line 1519  stacktop = STACK(stacktop - 1);
1519    
1520  if (!save)  if (!save)
1521    {    {
1522    stackptr += sizeof(sljit_w);    stackptr += sizeof(sljit_sw);
1523    if (stackptr < stacktop)    if (stackptr < stacktop)
1524      {      {
1525      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1526      stackptr += sizeof(sljit_w);      stackptr += sizeof(sljit_sw);
1527      tmp1empty = FALSE;      tmp1empty = FALSE;
1528      }      }
1529    if (stackptr < stacktop)    if (stackptr < stacktop)
1530      {      {
1531      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1532      stackptr += sizeof(sljit_w);      stackptr += sizeof(sljit_sw);
1533      tmp2empty = FALSE;      tmp2empty = FALSE;
1534      }      }
1535    /* The tmp1next must be TRUE in either way. */    /* The tmp1next must be TRUE in either way. */
# Line 1428  while (status != end) Line 1541  while (status != end)
1541    switch(status)    switch(status)
1542      {      {
1543      case start:      case start:
1544      SLJIT_ASSERT(save && common->recursive_head != 0);      SLJIT_ASSERT(save && common->recursive_head_ptr != 0);
1545      count = 1;      count = 1;
1546      srcw[0] = common->recursive_head;      srcw[0] = common->recursive_head_ptr;
1547      status = loop;      status = loop;
1548      break;      break;
1549    
# Line 1497  while (status != end) Line 1610  while (status != end)
1610          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1611          }          }
1612        cc += 2;        cc += 2;
1613  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1614        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1615  #endif  #endif
1616        break;        break;
# Line 1507  while (status != end) Line 1620  while (status != end)
1620          {          {
1621          count = 2;          count = 2;
1622          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1623          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_sw);
1624          }          }
1625        cc += 2;        cc += 2;
1626  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1627        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1628  #endif  #endif
1629        break;        break;
# Line 1520  while (status != end) Line 1633  while (status != end)
1633          {          {
1634          count = 2;          count = 2;
1635          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1636          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_sw);
1637          }          }
1638        cc += 2 + IMM2_SIZE;        cc += 2 + IMM2_SIZE;
1639  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
1640        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);        if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1641  #endif  #endif
1642        break;        break;
# Line 1542  while (status != end) Line 1655  while (status != end)
1655          {          {
1656          count = 2;          count = 2;
1657          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1658          srcw[1] = srcw[0] + sizeof(sljit_w);          srcw[1] = srcw[0] + sizeof(sljit_sw);
1659          }          }
1660        cc += 1;        cc += 1;
1661        break;        break;
# Line 1552  while (status != end) Line 1665  while (status != end)
1665          {          {
1666          count = 2;          count = 2;
1667          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1668          srcw[1] = srcw[0] + sizeof(sljit_w);          srcw[1] = srcw[0] + sizeof(sljit_sw);
1669          }          }
1670        cc += 1 + IMM2_SIZE;        cc += 1 + IMM2_SIZE;
1671        break;        break;
# Line 1576  while (status != end) Line 1689  while (status != end)
1689            case 2:            case 2:
1690            count = 2;            count = 2;
1691            srcw[0] = PRIVATE_DATA(cc);            srcw[0] = PRIVATE_DATA(cc);
1692            srcw[1] = srcw[0] + sizeof(sljit_w);            srcw[1] = srcw[0] + sizeof(sljit_sw);
1693            break;            break;
1694    
1695            default:            default:
# Line 1608  while (status != end) Line 1721  while (status != end)
1721          if (!tmp1empty)          if (!tmp1empty)
1722            {            {
1723            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
1724            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1725            }            }
1726          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);
1727          tmp1empty = FALSE;          tmp1empty = FALSE;
# Line 1619  while (status != end) Line 1732  while (status != end)
1732          if (!tmp2empty)          if (!tmp2empty)
1733            {            {
1734            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
1735            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1736            }            }
1737          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);
1738          tmp2empty = FALSE;          tmp2empty = FALSE;
# Line 1636  while (status != end) Line 1749  while (status != end)
1749          if (!tmp1empty)          if (!tmp1empty)
1750            {            {
1751            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1752            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1753            }            }
1754          tmp1next = FALSE;          tmp1next = FALSE;
1755          }          }
# Line 1648  while (status != end) Line 1761  while (status != end)
1761          if (!tmp2empty)          if (!tmp2empty)
1762            {            {
1763            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1764            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1765            }            }
1766          tmp1next = TRUE;          tmp1next = TRUE;
1767          }          }
# Line 1663  if (save) Line 1776  if (save)
1776      if (!tmp1empty)      if (!tmp1empty)
1777        {        {
1778        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
1779        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1780        }        }
1781      if (!tmp2empty)      if (!tmp2empty)
1782        {        {
1783        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
1784        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1785        }        }
1786      }      }
1787    else    else
# Line 1676  if (save) Line 1789  if (save)
1789      if (!tmp2empty)      if (!tmp2empty)
1790        {        {
1791        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
1792        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1793        }        }
1794      if (!tmp1empty)      if (!tmp1empty)
1795        {        {
1796        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
1797        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1798        }        }
1799      }      }
1800    }    }
# Line 1706  while (list) Line 1819  while (list)
1819    {    {
1820    /* sljit_set_label is clever enough to do nothing    /* sljit_set_label is clever enough to do nothing
1821    if either the jump or the label is NULL. */    if either the jump or the label is NULL. */
1822    sljit_set_label(list->jump, label);    SET_LABEL(list->jump, label);
1823    list = list->next;    list = list->next;
1824    }    }
1825  }  }
# Line 1722  if (list_item) Line 1835  if (list_item)
1835    }    }
1836  }  }
1837    
1838  static void add_stub(compiler_common *common, enum stub_types type, int data, struct sljit_jump *start)  static void add_stub(compiler_common *common, struct sljit_jump *start)
1839  {  {
1840  DEFINE_COMPILER;  DEFINE_COMPILER;
1841  stub_list* list_item = sljit_alloc_memory(compiler, sizeof(stub_list));  stub_list* list_item = sljit_alloc_memory(compiler, sizeof(stub_list));
1842    
1843  if (list_item)  if (list_item)
1844    {    {
   list_item->type = type;  
   list_item->data = data;  
1845    list_item->start = start;    list_item->start = start;
1846    list_item->quit = LABEL();    list_item->quit = LABEL();
1847    list_item->next = common->stubs;    list_item->next = common->stubs;
# Line 1746  stub_list* list_item = common->stubs; Line 1857  stub_list* list_item = common->stubs;
1857  while (list_item)  while (list_item)
1858    {    {
1859    JUMPHERE(list_item->start);    JUMPHERE(list_item->start);
1860    switch(list_item->type)    add_jump(compiler, &common->stackalloc, JUMP(SLJIT_FAST_CALL));
     {  
     case stack_alloc:  
     add_jump(compiler, &common->stackalloc, JUMP(SLJIT_FAST_CALL));  
     break;  
     }  
1861    JUMPTO(SLJIT_JUMP, list_item->quit);    JUMPTO(SLJIT_JUMP, list_item->quit);
1862    list_item = list_item->next;    list_item = list_item->next;
1863    }    }
# Line 1771  static SLJIT_INLINE void allocate_stack( Line 1877  static SLJIT_INLINE void allocate_stack(
1877  /* May destroy all locals and registers except TMP2. */  /* May destroy all locals and registers except TMP2. */
1878  DEFINE_COMPILER;  DEFINE_COMPILER;
1879    
1880  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_w));  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
1881  #ifdef DESTROY_REGISTERS  #ifdef DESTROY_REGISTERS
1882  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);
1883  OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);  OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
# Line 1779  OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0); Line 1885  OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
1885  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, TMP1, 0);
1886  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, TMP1, 0);
1887  #endif  #endif
1888  add_stub(common, stack_alloc, 0, CMP(SLJIT_C_GREATER, STACK_TOP, 0, STACK_LIMIT, 0));  add_stub(common, CMP(SLJIT_C_GREATER, STACK_TOP, 0, STACK_LIMIT, 0));
1889  }  }
1890    
1891  static SLJIT_INLINE void free_stack(compiler_common *common, int size)  static SLJIT_INLINE void free_stack(compiler_common *common, int size)
1892  {  {
1893  DEFINE_COMPILER;  DEFINE_COMPILER;
1894  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_w));  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
1895  }  }
1896    
1897  static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)  static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)
# Line 1795  struct sljit_label *loop; Line 1901  struct sljit_label *loop;
1901  int i;  int i;
1902  /* At this point we can freely use all temporary registers. */  /* At this point we can freely use all temporary registers. */
1903  /* TMP1 returns with begin - 1. */  /* TMP1 returns with begin - 1. */
1904  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, IN_UCHARS(1));  OP2(SLJIT_SUB, SLJIT_SCRATCH_REG1, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, IN_UCHARS(1));
1905  if (length < 8)  if (length < 8)
1906    {    {
1907    for (i = 0; i < length; i++)    for (i = 0; i < length; i++)
1908      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(i), SLJIT_TEMPORARY_REG1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(i), SLJIT_SCRATCH_REG1, 0);
1909    }    }
1910  else  else
1911    {    {
1912    GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, OVECTOR_START - sizeof(sljit_w));    GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, OVECTOR_START - sizeof(sljit_sw));
1913    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, length);    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, length);
1914    loop = LABEL();    loop = LABEL();
1915    OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);    OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_SCRATCH_REG2), sizeof(sljit_sw), SLJIT_SCRATCH_REG1, 0);
1916    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, 1);
1917    JUMPTO(SLJIT_C_NOT_ZERO, loop);    JUMPTO(SLJIT_C_NOT_ZERO, loop);
1918    }    }
1919  }  }
# Line 1816  static SLJIT_INLINE void copy_ovector(co Line 1922  static SLJIT_INLINE void copy_ovector(co
1922  {  {
1923  DEFINE_COMPILER;  DEFINE_COMPILER;
1924  struct sljit_label *loop;  struct sljit_label *loop;
1925  struct sljit_jump *earlyexit;  struct sljit_jump *early_quit;
1926    
1927  /* At this point we can freely use all registers. */  /* At this point we can freely use all registers. */
1928  OP1(SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));  OP1(SLJIT_MOV, SLJIT_SAVED_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));
1929  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1), STR_PTR, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1), STR_PTR, 0);
1930    
1931  OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, ARGUMENTS, 0);
1932  if (common->mark_ptr != 0)  if (common->mark_ptr != 0)
1933    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);
1934  OP1(SLJIT_MOV_SI, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), SLJIT_OFFSETOF(jit_arguments, offsetcount));  OP1(SLJIT_MOV_SI, SLJIT_SCRATCH_REG2, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG1), SLJIT_OFFSETOF(jit_arguments, offset_count));
1935  if (common->mark_ptr != 0)  if (common->mark_ptr != 0)
1936    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_TEMPORARY_REG3, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SCRATCH_REG1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_SCRATCH_REG3, 0);
1937  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), SLJIT_OFFSETOF(jit_arguments, offsets), SLJIT_IMM, sizeof(int));  OP2(SLJIT_SUB, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG1), SLJIT_OFFSETOF(jit_arguments, offsets), SLJIT_IMM, sizeof(int));
1938  OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), SLJIT_OFFSETOF(jit_arguments, begin));  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG1), SLJIT_OFFSETOF(jit_arguments, begin));
1939  GET_LOCAL_BASE(SLJIT_SAVED_REG1, 0, OVECTOR_START);  GET_LOCAL_BASE(SLJIT_SAVED_REG1, 0, OVECTOR_START);
1940  /* Unlikely, but possible */  /* Unlikely, but possible */
1941  earlyexit = CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);  early_quit = CMP(SLJIT_C_EQUAL, SLJIT_SCRATCH_REG2, 0, SLJIT_IMM, 0);
1942  loop = LABEL();  loop = LABEL();
1943  OP2(SLJIT_SUB, SLJIT_SAVED_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);  OP2(SLJIT_SUB, SLJIT_SAVED_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_SCRATCH_REG1, 0);
1944  OP2(SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_w));  OP2(SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_sw));
1945  /* Copy the integer value to the output buffer */  /* Copy the integer value to the output buffer */
1946  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1947  OP2(SLJIT_ASHR, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, UCHAR_SHIFT);  OP2(SLJIT_ASHR, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, UCHAR_SHIFT);
1948  #endif  #endif
1949  OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), sizeof(int), SLJIT_SAVED_REG2, 0);  OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_SCRATCH_REG3), sizeof(int), SLJIT_SAVED_REG2, 0);
1950  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_SCRATCH_REG2, 0, SLJIT_SCRATCH_REG2, 0, SLJIT_IMM, 1);
1951  JUMPTO(SLJIT_C_NOT_ZERO, loop);  JUMPTO(SLJIT_C_NOT_ZERO, loop);
1952  JUMPHERE(earlyexit);  JUMPHERE(early_quit);
1953    
1954  /* Calculate the return value, which is the maximum ovector value. */  /* Calculate the return value, which is the maximum ovector value. */
1955  if (topbracket > 1)  if (topbracket > 1)
1956    {    {
1957    GET_LOCAL_BASE(SLJIT_TEMPORARY_REG1, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_w));    GET_LOCAL_BASE(SLJIT_SCRATCH_REG1, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_sw));
1958    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, topbracket + 1);    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, SLJIT_IMM, topbracket + 1);
1959    
1960    /* OVECTOR(0) is never equal to SLJIT_SAVED_REG3. */    /* OVECTOR(0) is never equal to SLJIT_SAVED_REG3. */
1961    loop = LABEL();    loop = LABEL();
1962    OP1(SLJIT_MOVU, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), -(2 * (sljit_w)sizeof(sljit_w)));    OP1(SLJIT_MOVU, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG1), -(2 * (sljit_sw)sizeof(sljit_sw)));
1963    OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);    OP2(SLJIT_SUB, SLJIT_SCRATCH_REG2, 0, SLJIT_SCRATCH_REG2, 0, SLJIT_IMM, 1);
1964    CMPTO(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, loop);    CMPTO(SLJIT_C_EQUAL, SLJIT_SCRATCH_REG3, 0, SLJIT_SAVED_REG3, 0, loop);
1965    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_TEMPORARY_REG2, 0);    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_SCRATCH_REG2, 0);
1966    }    }
1967  else  else
1968    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
# Line 1869  DEFINE_COMPILER; Line 1975  DEFINE_COMPILER;
1975  SLJIT_COMPILE_ASSERT(STR_END == SLJIT_SAVED_REG2, str_end_must_be_saved_reg2);  SLJIT_COMPILE_ASSERT(STR_END == SLJIT_SAVED_REG2, str_end_must_be_saved_reg2);
1976  SLJIT_ASSERT(common->start_used_ptr != 0 && (common->mode == JIT_PARTIAL_SOFT_COMPILE ? common->hit_start != 0 : common->hit_start == 0));  SLJIT_ASSERT(common->start_used_ptr != 0 && (common->mode == JIT_PARTIAL_SOFT_COMPILE ? common->hit_start != 0 : common->hit_start == 0));
1977    
1978  OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, ARGUMENTS, 0);
1979  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_PARTIAL);  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_PARTIAL);
1980  OP1(SLJIT_MOV_SI, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), SLJIT_OFFSETOF(jit_arguments, offsetcount));  OP1(SLJIT_MOV_SI, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG2), SLJIT_OFFSETOF(jit_arguments, offset_count));
1981  CMPTO(SLJIT_C_LESS, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 2, quit);  CMPTO(SLJIT_C_LESS, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, 2, quit);
1982    
1983  /* Store match begin and end. */  /* Store match begin and end. */
1984  OP1(SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), SLJIT_OFFSETOF(jit_arguments, begin));  OP1(SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG2), SLJIT_OFFSETOF(jit_arguments, begin));
1985  OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), SLJIT_OFFSETOF(jit_arguments, offsets));  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG2), SLJIT_OFFSETOF(jit_arguments, offsets));
1986  OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_used_ptr : common->hit_start);  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_used_ptr : common->hit_start);
1987  OP2(SLJIT_SUB, SLJIT_SAVED_REG2, 0, STR_END, 0, SLJIT_SAVED_REG1, 0);  OP2(SLJIT_SUB, SLJIT_SAVED_REG2, 0, STR_END, 0, SLJIT_SAVED_REG1, 0);
1988  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1989  OP2(SLJIT_ASHR, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, UCHAR_SHIFT);  OP2(SLJIT_ASHR, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, UCHAR_SHIFT);
1990  #endif  #endif
1991  OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(int), SLJIT_SAVED_REG2, 0);  OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_SCRATCH_REG2), sizeof(int), SLJIT_SAVED_REG2, 0);
1992    
1993  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG1, 0);  OP2(SLJIT_SUB, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_SAVED_REG1, 0);
1994  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1995  OP2(SLJIT_ASHR, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, UCHAR_SHIFT);  OP2(SLJIT_ASHR, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, UCHAR_SHIFT);
1996  #endif  #endif
1997  OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), 0, SLJIT_TEMPORARY_REG3, 0);  OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_SCRATCH_REG2), 0, SLJIT_SCRATCH_REG3, 0);
1998    
1999  JUMPTO(SLJIT_JUMP, quit);  JUMPTO(SLJIT_JUMP, quit);
2000  }  }
# Line 2204  if (common->utf) Line 2310  if (common->utf)
2310    /* Skip low surrogate if necessary. */    /* Skip low surrogate if necessary. */
2311    OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xfc00);    OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xfc00);
2312    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xd800);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0xd800);
2313    COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2314    OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);    OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);
2315    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
2316  #elif defined COMPILE_PCRE32  #elif defined COMPILE_PCRE32
# Line 2254  if (common->utf) Line 2360  if (common->utf)
2360    /* Skip low surrogate if necessary. */    /* Skip low surrogate if necessary. */
2361    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
2362    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xdc00);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xdc00);
2363    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2364    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
2365    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2366    return;    return;
# Line 2277  if (nltype == NLTYPE_ANY) Line 2383  if (nltype == NLTYPE_ANY)
2383  else if (nltype == NLTYPE_ANYCRLF)  else if (nltype == NLTYPE_ANYCRLF)
2384    {    {
2385    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_CR);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_CR);
2386    COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2387    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);
2388    COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
2389    add_jump(compiler, backtracks, JUMP(jumpiftrue ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO));    add_jump(compiler, backtracks, JUMP(jumpiftrue ? SLJIT_C_NOT_ZERO : SLJIT_C_ZERO));
2390    }    }
2391  else  else
# Line 2379  sljit_emit_fast_return(compiler, RETURN_ Line 2485  sljit_emit_fast_return(compiler, RETURN_
2485  JUMPHERE(jump);  JUMPHERE(jump);
2486    
2487  /* We only have types for characters less than 256. */  /* We only have types for characters less than 256. */
2488  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_w)PRIV(utf8_table4) - 0xc0);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2489  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2490  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2491  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
# Line 2432  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si Line 2538  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si
2538    
2539  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
2540  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
2541  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_w)PRIV(ucd_stage1));  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));
2542  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
2543  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
2544  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
2545  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_stage2));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));
2546  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);
2547  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
2548  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);
2549  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2550  }  }
# Line 2452  struct sljit_label *newlinelabel = NULL; Line 2558  struct sljit_label *newlinelabel = NULL;
2558  struct sljit_jump *start;  struct sljit_jump *start;
2559  struct sljit_jump *end = NULL;  struct sljit_jump *end = NULL;
2560  struct sljit_jump *nl = NULL;  struct sljit_jump *nl = NULL;
2561  #ifdef SUPPORT_UTF  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2562  struct sljit_jump *singlechar;  struct sljit_jump *singlechar;
2563  #endif  #endif
2564  jump_list *newline = NULL;  jump_list *newline = NULL;
# Line 2507  if (newlinecheck) Line 2613  if (newlinecheck)
2613    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
2614    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2615    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);
2616    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2617  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
2618    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);
2619  #endif  #endif
# Line 2535  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S Line 2641  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S
2641  if (common->utf)  if (common->utf)
2642    {    {
2643    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2644    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2645    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2646    JUMPHERE(singlechar);    JUMPHERE(singlechar);
2647    }    }
# Line 2545  if (common->utf) Line 2651  if (common->utf)
2651    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
2652    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
2653    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
2654    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2655    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
2656    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2657    JUMPHERE(singlechar);    JUMPHERE(singlechar);
# Line 2571  DEFINE_COMPILER; Line 2677  DEFINE_COMPILER;
2677  struct sljit_label *start;  struct sljit_label *start;
2678  struct sljit_jump *quit;  struct sljit_jump *quit;
2679  pcre_uint32 chars[MAX_N_CHARS * 2];  pcre_uint32 chars[MAX_N_CHARS * 2];
2680  pcre_uchar *cc = common->start + 1 + IMM2_SIZE;  pcre_uchar *cc = common->start + 1 + LINK_SIZE;
2681  int location = 0;  int location = 0;
2682  pcre_int32 len, c, bit, caseless;  pcre_int32 len, c, bit, caseless;
2683  int must_stop;  int must_stop;
# Line 2643  while (TRUE) Line 2749  while (TRUE)
2749        break;        break;
2750    
2751    len = 1;    len = 1;
2752  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
2753    if (common->utf && HAS_EXTRALEN(cc[0])) len += GET_EXTRALEN(cc[0]);    if (common->utf && HAS_EXTRALEN(cc[0])) len += GET_EXTRALEN(cc[0]);
2754  #endif  #endif
2755    
# Line 2694  if (firstline) Line 2800  if (firstline)
2800    {    {
2801    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
2802    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
2803    OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, (location >> 1) - 1);    OP2(SLJIT_SUB, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
2804    }    }
2805  else  else
2806    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, (location >> 1) - 1);    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
2807    
2808  start = LABEL();  start = LABEL();
2809  quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);  quit = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
# Line 2726  JUMPHERE(quit); Line 2832  JUMPHERE(quit);
2832  if (firstline)  if (firstline)
2833    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
2834  else  else
2835    OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, (location >> 1) - 1);    OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS((location >> 1) - 1));
2836  return TRUE;  return TRUE;
2837  }  }
2838    
# Line 2773  else Line 2879  else
2879    else    else
2880      {      {
2881      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, first_char);      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, first_char);
2882      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2883      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);
2884      COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);      OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
2885      found = JUMP(SLJIT_C_NOT_ZERO);      found = JUMP(SLJIT_C_NOT_ZERO);
2886      }      }
2887    }    }
# Line 2817  if (common->nltype == NLTYPE_FIXED && co Line 2923  if (common->nltype == NLTYPE_FIXED && co
2923    
2924    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(2));    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(2));
2925    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, TMP1, 0);
2926    COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_GREATER_EQUAL);
2927  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
2928    OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCHAR_SHIFT);    OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCHAR_SHIFT);
2929  #endif  #endif
# Line 2860  if (common->nltype == NLTYPE_ANY || comm Line 2966  if (common->nltype == NLTYPE_ANY || comm
2966    notfoundnl = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    notfoundnl = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
2967    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2968    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);
2969    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
2970  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
2971    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);
2972  #endif  #endif
# Line 2875  if (firstline) Line 2981  if (firstline)
2981    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
2982  }  }
2983    
2984    static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, jump_list **backtracks);
2985    
2986  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, sljit_uw start_bits, BOOL firstline)
2987  {  {
2988  DEFINE_COMPILER;  DEFINE_COMPILER;
2989  struct sljit_label *start;  struct sljit_label *start;
2990  struct sljit_jump *quit;  struct sljit_jump *quit;
2991  struct sljit_jump *found;  struct sljit_jump *found = NULL;
2992    jump_list *matches = NULL;
2993    pcre_uint8 inverted_start_bits[32];
2994    int i;
2995  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
2996  struct sljit_jump *jump;  struct sljit_jump *jump;
2997  #endif  #endif
2998    
2999    for (i = 0; i < 32; ++i)
3000      inverted_start_bits[i] = ~(((pcre_uint8*)start_bits)[i]);
3001    
3002  if (firstline)  if (firstline)
3003    {    {
3004    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
# Line 2899  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_P Line 3013  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_P
3013  if (common->utf)  if (common->utf)
3014    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);    OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
3015  #endif  #endif
3016    
3017    if (!check_class_ranges(common, inverted_start_bits, (inverted_start_bits[31] & 0x80) != 0, &matches))
3018      {
3019  #ifndef COMPILE_PCRE8  #ifndef COMPILE_PCRE8
3020  jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 255);
3021  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 255);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 255);
3022  JUMPHERE(jump);    JUMPHERE(jump);
3023  #endif  #endif
3024  OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
3025  OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
3026  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), start_bits);
3027  OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
3028  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);
3029  found = JUMP(SLJIT_C_NOT_ZERO);    found = JUMP(SLJIT_C_NOT_ZERO);
3030      }
3031    
3032  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3033  if (common->utf)  if (common->utf)
# Line 2921  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S Line 3039  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S
3039  if (common->utf)  if (common->utf)
3040    {    {
3041    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
3042    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
3043    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
3044    }    }
3045  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
# Line 2930  if (common->utf) Line 3048  if (common->utf)
3048    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800, start);
3049    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);    OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
3050    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
3051    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
3052    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);    OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
3053    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
3054    }    }
3055  #endif /* COMPILE_PCRE[8|16] */  #endif /* COMPILE_PCRE[8|16] */
3056  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
3057  JUMPTO(SLJIT_JUMP, start);  JUMPTO(SLJIT_JUMP, start);
3058  JUMPHERE(found);  if (found != NULL)
3059      JUMPHERE(found);
3060    if (matches != NULL)
3061      set_jumps(matches, LABEL());
3062  JUMPHERE(quit);  JUMPHERE(quit);
3063    
3064  if (firstline)  if (firstline)
# Line 3020  GET_LOCAL_BASE(TMP3, 0, 0); Line 3141  GET_LOCAL_BASE(TMP3, 0, 0);
3141  /* Drop frames until we reach STACK_TOP. */  /* Drop frames until we reach STACK_TOP. */
3142  mainloop = LABEL();  mainloop = LABEL();
3143  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), 0);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), 0);
3144  jump = CMP(SLJIT_C_SIG_LESS_EQUAL, TMP2, 0, SLJIT_IMM, frame_end);  OP2(SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0);
3145    jump = JUMP(SLJIT_C_SIG_LESS_EQUAL);
3146    
3147  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);
3148  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
3149  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), sizeof(sljit_w), SLJIT_MEM1(TMP1), 2 * sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), sizeof(sljit_sw), SLJIT_MEM1(TMP1), 2 * sizeof(sljit_sw));
3150  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_w));  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_sw));
3151  JUMPTO(SLJIT_JUMP, mainloop);  JUMPTO(SLJIT_JUMP, mainloop);
3152    
3153  JUMPHERE(jump);  JUMPHERE(jump);
3154  jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_end);  jump = JUMP(SLJIT_C_SIG_LESS);
3155  /* End of dropping frames. */  /* End of dropping frames. */
3156  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
3157    
3158  JUMPHERE(jump);  JUMPHERE(jump);
3159  jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_setstrbegin);  OP1(SLJIT_NEG, TMP2, 0, TMP2, 0);
3160  /* Set string begin. */  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);
3161  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
3162  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_w));  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_sw));
 OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), TMP2, 0);  
 JUMPTO(SLJIT_JUMP, mainloop);  
   
 JUMPHERE(jump);  
 if (common->mark_ptr != 0)  
   {  
   jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_setmark);  
   OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), sizeof(sljit_w));  
   OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_w));  
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);  
   JUMPTO(SLJIT_JUMP, mainloop);  
   
   JUMPHERE(jump);  
   }  
   
 /* Unknown command. */  
 OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_w));  
3163  JUMPTO(SLJIT_JUMP, mainloop);  JUMPTO(SLJIT_JUMP, mainloop);
3164  }  }
3165    
# Line 3086  if (common->use_ucp) Line 3192  if (common->use_ucp)
3192    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
3193    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Ll);    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Ll);
3194    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);
3195    COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
3196    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Nd - ucp_Ll);    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Nd - ucp_Ll);
3197    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_No - ucp_Nd);    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_No - ucp_Nd);
3198    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_LESS_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
3199    JUMPHERE(jump);    JUMPHERE(jump);
3200    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, TMP2, 0);
3201    }    }
# Line 3130  if (common->use_ucp) Line 3236  if (common->use_ucp)
3236    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
3237    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Ll);    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Ll);
3238    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);
3239    COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
3240    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Nd - ucp_Ll);    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Nd - ucp_Ll);
3241    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_No - ucp_Nd);    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_No - ucp_Nd);
3242    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_LESS_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
3243    JUMPHERE(jump);    JUMPHERE(jump);
3244    }    }
3245  else  else
# Line 3313  sljit_emit_fast_enter(compiler, RETURN_A Line 3419  sljit_emit_fast_enter(compiler, RETURN_A
3419    
3420  OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0a);  OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0a);
3421  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x0d - 0x0a);  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x0d - 0x0a);
3422  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);  OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
3423  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);
3424  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
3425  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3426  if (common->utf)  if (common->utf)
3427    {    {
3428  #endif  #endif
3429    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3430    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);
3431    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2029 - 0x0a);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2029 - 0x0a);
3432  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3433    }    }
3434  #endif  #endif
3435  #endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */  #endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */
3436  COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);  OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3437  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
3438  }  }
3439    
# Line 3339  DEFINE_COMPILER; Line 3445  DEFINE_COMPILER;
3445  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
3446    
3447  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x09);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x09);
3448  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);  OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
3449  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);
3450  COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);  OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3451  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xa0);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xa0);
3452  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
3453  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3454  if (common->utf)  if (common->utf)
3455    {    {
3456  #endif  #endif
3457    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3458    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x1680);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x1680);
3459    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3460    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e);
3461    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3462    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x2000);    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x2000);
3463    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x200A - 0x2000);    OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x200A - 0x2000);
3464    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_LESS_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
3465    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x202f - 0x2000);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x202f - 0x2000);
3466    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3467    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x205f - 0x2000);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x205f - 0x2000);
3468    COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3469    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x3000 - 0x2000);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x3000 - 0x2000);
3470  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3471    }    }
3472  #endif  #endif
3473  #endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */  #endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */
3474  COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);  OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3475    
3476  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
3477  }  }
# Line 3379  sljit_emit_fast_enter(compiler, RETURN_A Line 3485  sljit_emit_fast_enter(compiler, RETURN_A
3485    
3486  OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0a);  OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0a);
3487  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x0d - 0x0a);  OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x0d - 0x0a);
3488  COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);  OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
3489  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);
3490  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
3491  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3492  if (common->utf)  if (common->utf)
3493    {    {
3494  #endif  #endif
3495    COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3496    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);    OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);
3497    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2029 - 0x0a);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2029 - 0x0a);
3498  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
3499    }    }
3500  #endif  #endif
3501  #endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */  #endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */
3502  COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);  OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3503    
3504  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
3505  }  }
# Line 3479  sljit_emit_fast_return(compiler, RETURN_ Line 3585  sljit_emit_fast_return(compiler, RETURN_
3585    
3586  #if defined SUPPORT_UTF && defined SUPPORT_UCP  #if defined SUPPORT_UTF && defined SUPPORT_UCP
3587    
3588  static const pcre_uchar *SLJIT_CALL do_utf_caselesscmp(pcre_uchar *src1, jit_arguments *args, pcre_uchar *end1)  static const pcre_uchar * SLJIT_CALL do_utf_caselesscmp(pcre_uchar *src1, jit_arguments *args, pcre_uchar *end1)
3589  {  {
3590  /* This function would be ineffective to do in JIT level. */  /* This function would be ineffective to do in JIT level. */
3591  pcre_uint32 c1, c2;  pcre_uint32 c1, c2;
# Line 3529  if (caseless && char_has_othercase(commo Line 3635  if (caseless && char_has_othercase(commo
3635    othercasechar = cc + (othercasebit >> 8);    othercasechar = cc + (othercasebit >> 8);
3636    othercasebit &= 0xff;    othercasebit &= 0xff;
3637  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
3638      /* Note that this code only handles characters in the BMP. If there
3639      ever are characters outside the BMP whose othercase differs in only one
3640      bit from itself (there currently are none), this code will need to be
3641      revised for COMPILE_PCRE32. */
3642    othercasechar = cc + (othercasebit >> 9);    othercasechar = cc + (othercasebit >> 9);
3643    if ((othercasebit & 0x100) != 0)    if ((othercasebit & 0x100) != 0)
3644      othercasebit = (othercasebit & 0xff) << 8;      othercasebit = (othercasebit & 0xff) << 8;
# Line 3563  if (context->sourcereg == -1) Line 3673  if (context->sourcereg == -1)
3673    
3674  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
3675  utflength = 1;  utflength = 1;
 #ifndef COMPILE_PCRE32  
3676  if (common->utf && HAS_EXTRALEN(*cc))  if (common->utf && HAS_EXTRALEN(*cc))
3677    utflength += GET_EXTRALEN(*cc);    utflength += GET_EXTRALEN(*cc);
 #endif  
3678    
3679  do  do
3680    {    {
3681  #endif  #endif
3682    
3683    context->length -= IN_UCHARS(1);    context->length -= IN_UCHARS(1);
3684  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED) && (defined COMPILE_PCRE8 || defined COMPILE_PCRE16)
3685    
3686    /* Unaligned read is supported. */    /* Unaligned read is supported. */
3687    if (othercasebit != 0 && othercasechar == cc)    if (othercasebit != 0 && othercasechar == cc)
# Line 3590  do Line 3698  do
3698    
3699  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
3700    if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))    if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
3701  #elif defined COMPILE_PCRE16  #else
3702    if (context->ucharptr >= 2 || context->length == 0)    if (context->ucharptr >= 2 || context->length == 0)
 #elif defined COMPILE_PCRE32  
   if (1 /* context->ucharptr >= 1 || context->length == 0 */)  
3703  #endif  #endif
3704      {      {
 #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16  
3705      if (context->length >= 4)      if (context->length >= 4)
3706        OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
 #if defined COMPILE_PCRE8  
3707      else if (context->length >= 2)      else if (context->length >= 2)
3708        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
3709    #if defined COMPILE_PCRE8
3710      else if (context->length >= 1)      else if (context->length >= 1)
3711        OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
3712  #elif defined COMPILE_PCRE16  #endif /* COMPILE_PCRE8 */
     else if (context->length >= 2)  
       OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);  
 #endif /* COMPILE_PCRE[8|16] */  
 #elif defined COMPILE_PCRE32  
     OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);  
 #endif /* COMPILE_PCRE[8|16|32] */  
3713      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
3714    
3715      switch(context->ucharptr)      switch(context->ucharptr)
# Line 3621  do Line 3720  do
3720        add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));        add_jump(compiler, backtracks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));
3721        break;        break;
3722    
 #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16  
3723        case 2 / sizeof(pcre_uchar):        case 2 / sizeof(pcre_uchar):
3724        if (context->oc.asushort != 0)        if (context->oc.asushort != 0)
3725          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asushort);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asushort);
# Line 3636  do Line 3734  do
3734        break;        break;
3735  #endif  #endif
3736    
 #endif /* COMPILE_PCRE[8|16] */  
   
3737        default:        default:
3738        SLJIT_ASSERT_STOP();        SLJIT_ASSERT_STOP();
3739        break;        break;
# Line 3647  do Line 3743  do
3743    
3744  #else  #else
3745    
3746    /* Unaligned read is unsupported. */    /* Unaligned read is unsupported or in 32 bit mode. */
3747    if (context->length > 0)    if (context->length >= 1)
3748      OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
3749    
3750    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
# Line 3731  if ((*cc++ & XCL_MAP) != 0) Line 3827  if ((*cc++ & XCL_MAP) != 0)
3827      {      {
3828      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
3829      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
3830      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)cc);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
3831      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
3832      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);
3833      add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));      add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));
# Line 3759  while (*cc != XCL_END) Line 3855  while (*cc != XCL_END)
3855    if (*cc == XCL_SINGLE)    if (*cc == XCL_SINGLE)
3856      {      {
3857      cc += 2;      cc += 2;
3858  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
3859      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
3860  #endif  #endif
3861  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 3769  while (*cc != XCL_END) Line 3865  while (*cc != XCL_END)
3865    else if (*cc == XCL_RANGE)    else if (*cc == XCL_RANGE)
3866      {      {
3867      cc += 2;      cc += 2;
3868  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
3869      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
3870  #endif  #endif
3871      cc++;      cc++;
3872  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
3873      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
3874  #endif  #endif
3875  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 3848  if (needstype || needsscript) Line 3944  if (needstype || needsscript)
3944      {      {
3945      if (scriptreg == TMP1)      if (scriptreg == TMP1)
3946        {        {
3947        OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));        OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
3948        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);
3949        }        }
3950      else      else
3951        {        {
3952        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
3953        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
3954        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);
3955        }        }
3956      }      }
# Line 3890  while (*cc != XCL_END) Line 3986  while (*cc != XCL_END)
3986      if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))      if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))
3987        {        {
3988        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);
3989        COND_VALUE(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);        OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, numberofcmps == 0 ? SLJIT_UNUSED : TMP2, 0, SLJIT_C_EQUAL);
3990        numberofcmps++;        numberofcmps++;
3991        }        }
3992      else if (numberofcmps > 0)      else if (numberofcmps > 0)
3993        {        {
3994        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);
3995        COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
3996        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
3997        numberofcmps = 0;        numberofcmps = 0;
3998        }        }
# Line 3929  while (*cc != XCL_END) Line 4025  while (*cc != XCL_END)
4025      if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))      if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))
4026        {        {
4027        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);
4028        COND_VALUE(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, numberofcmps == 0 ? SLJIT_UNUSED : TMP2, 0, SLJIT_C_LESS_EQUAL);
4029        numberofcmps++;        numberofcmps++;
4030        }        }
4031      else if (numberofcmps > 0)      else if (numberofcmps > 0)
4032        {        {
4033        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c - charoffset);
4034        COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
4035        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4036        numberofcmps = 0;        numberofcmps = 0;
4037        }        }
# Line 3966  while (*cc != XCL_END) Line 4062  while (*cc != XCL_END)
4062    
4063        case PT_LAMP:        case PT_LAMP:
4064        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lu - typeoffset);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lu - typeoffset);
4065        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4066        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Ll - typeoffset);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Ll - typeoffset);
4067        COND_VALUE(SLJIT_OR, TMP2, 0, SLJIT_C_EQUAL);        OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4068        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lt - typeoffset);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lt - typeoffset);
4069        COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4070        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4071        break;        break;
4072    
# Line 3997  while (*cc != XCL_END) Line 4093  while (*cc != XCL_END)
4093          }          }
4094        SET_CHAR_OFFSET(9);        SET_CHAR_OFFSET(9);
4095        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, 13 - 9);
4096        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS_EQUAL);
4097        if (*cc == PT_SPACE)        if (*cc == PT_SPACE)
4098          JUMPHERE(jump);          JUMPHERE(jump);
4099    
4100        SET_TYPE_OFFSET(ucp_Zl);        SET_TYPE_OFFSET(ucp_Zl);
4101        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);
4102        COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
4103        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4104        break;        break;
4105    
4106        case PT_WORD:        case PT_WORD:
4107        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_UNDERSCORE - charoffset);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_UNDERSCORE - charoffset);
4108        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4109        /* ... fall through */        /* Fall through. */
4110    
4111        case PT_ALNUM:        case PT_ALNUM:
4112        SET_TYPE_OFFSET(ucp_Ll);        SET_TYPE_OFFSET(ucp_Ll);
4113        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);
4114        COND_VALUE((*cc == PT_ALNUM) ? SLJIT_MOV : SLJIT_OR, TMP2, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS((*cc == PT_ALNUM) ? SLJIT_MOV : SLJIT_OR, TMP2, 0, (*cc == PT_ALNUM) ? SLJIT_UNUSED : TMP2, 0, SLJIT_C_LESS_EQUAL);
4115        SET_TYPE_OFFSET(ucp_Nd);        SET_TYPE_OFFSET(ucp_Nd);
4116        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_No - ucp_Nd);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_No - ucp_Nd);
4117        COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_LESS_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
4118        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4119        break;        break;
4120    
# Line 4037  while (*cc != XCL_END) Line 4133  while (*cc != XCL_END)
4133            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4134          else          else
4135            {            {
4136            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_w)charoffset);            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);
4137            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4138            }            }
4139          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[1]);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[1]);
4140          COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4141          other_cases += 2;          other_cases += 2;
4142          }          }
4143        else if (is_powerof2(other_cases[2] ^ other_cases[1]))        else if (is_powerof2(other_cases[2] ^ other_cases[1]))
# Line 4050  while (*cc != XCL_END) Line 4146  while (*cc != XCL_END)
4146            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);
4147          else          else
4148            {            {
4149            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_w)charoffset);            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);
4150            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4151            }            }
4152          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]);
4153          COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4154    
4155          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, other_cases[0] - charoffset);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, other_cases[0] - charoffset);
4156          COND_VALUE(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, SLJIT_C_EQUAL);          OP_FLAGS(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4157    
4158          other_cases += 3;          other_cases += 3;
4159          }          }
4160        else        else
4161          {          {
4162          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);
4163          COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4164          }          }
4165    
4166        while (*other_cases != NOTACHAR)        while (*other_cases != NOTACHAR)
4167          {          {
4168          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, *other_cases++ - charoffset);
4169          COND_VALUE(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, SLJIT_C_EQUAL);          OP_FLAGS(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4170          }          }
4171        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4172        break;        break;
# Line 4192  switch(type) Line 4288  switch(type)
4288  #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16  #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
4289  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
4290      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
4291      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
4292      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4293  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
4294      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
4295      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
4296      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
4297      COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);      OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4298      OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);      OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
4299      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4300  #endif  #endif
# Line 4270  switch(type) Line 4366  switch(type)
4366    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
4367    read_char(common);    read_char(common);
4368    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
4369    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));
4370    /* Optimize register allocation: use a real register. */    /* Optimize register allocation: use a real register. */
4371    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
4372    OP1(SLJIT_MOV_UB, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3);    OP1(SLJIT_MOV_UB, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3);
# Line 4280  switch(type) Line 4376  switch(type)
4376    OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
4377    read_char(common);    read_char(common);
4378    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
4379    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));
4380    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3);    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3);
4381    
4382    OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2);    OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2);
4383    OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_w)PRIV(ucp_gbtable));    OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_sw)PRIV(ucp_gbtable));
4384    OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);    OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);
4385    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
4386    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);
# Line 4317  switch(type) Line 4413  switch(type)
4413        {        {
4414        jump[1] = CMP(SLJIT_C_EQUAL, TMP2, 0, STR_END, 0);        jump[1] = CMP(SLJIT_C_EQUAL, TMP2, 0, STR_END, 0);
4415        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP2, 0, STR_END, 0);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP2, 0, STR_END, 0);
4416        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS);        OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_LESS);
4417        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);        OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);
4418        COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_NOT_EQUAL);        OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_NOT_EQUAL);
4419        add_jump(compiler, backtracks, JUMP(SLJIT_C_NOT_EQUAL));        add_jump(compiler, backtracks, JUMP(SLJIT_C_NOT_EQUAL));
4420        check_partial(common, TRUE);        check_partial(common, TRUE);
4421        add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));        add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
# Line 4467  switch(type) Line 4563  switch(type)
4563    case OP_CHAR:    case OP_CHAR:
4564    case OP_CHARI:    case OP_CHARI:
4565    length = 1;    length = 1;
4566  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
4567    if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);    if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);
4568  #endif  #endif
4569    if (common->mode == JIT_COMPILE && (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0))    if (common->mode == JIT_COMPILE && (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0))
# Line 4506  switch(type) Line 4602  switch(type)
4602      return cc + length;      return cc + length;
4603      }      }
4604    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c);
4605    COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4606    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);
4607    COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);    OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4608    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));
4609    return cc + length;    return cc + length;
4610    
# Line 4535  switch(type) Line 4631  switch(type)
4631        /* Skip the variable-length character. */        /* Skip the variable-length character. */
4632        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));
4633        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
4634        OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);        OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
4635        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4636        JUMPHERE(jump[0]);        JUMPHERE(jump[0]);
4637        return cc + 1;        return cc + 1;
# Line 4598  switch(type) Line 4694  switch(type)
4694  #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */  #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */
4695    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
4696    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
4697    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)cc);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
4698    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
4699    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);
4700    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));
# Line 4662  do Line 4758  do
4758    if (*cc == OP_CHAR)    if (*cc == OP_CHAR)
4759      {      {
4760      size = 1;      size = 1;
4761  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
4762      if (common->utf && HAS_EXTRALEN(cc[1]))      if (common->utf && HAS_EXTRALEN(cc[1]))
4763        size += GET_EXTRALEN(cc[1]);        size += GET_EXTRALEN(cc[1]);
4764  #endif  #endif
# Line 4675  do Line 4771  do
4771        {        {
4772        if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)        if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
4773          size = 0;          size = 0;
 #ifndef COMPILE_PCRE32  
4774        else if (HAS_EXTRALEN(cc[1]))        else if (HAS_EXTRALEN(cc[1]))
4775          size += GET_EXTRALEN(cc[1]);          size += GET_EXTRALEN(cc[1]);
 #endif  
4776        }        }
4777      else      else
4778  #endif  #endif
# Line 4724  if (!common->jscript_compat) Line 4818  if (!common->jscript_compat)
4818      {      {
4819      /* OVECTOR(1) contains the "string begin - 1" constant. */      /* OVECTOR(1) contains the "string begin - 1" constant. */
4820      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));
4821      COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);      OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4822      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
4823      COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);      OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4824      return JUMP(SLJIT_C_NOT_ZERO);      return JUMP(SLJIT_C_NOT_ZERO);
4825      }      }
4826    add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));    add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
# Line 4782  if (withchecks && !common->jscript_compa Line 4876  if (withchecks && !common->jscript_compa
4876  #if defined SUPPORT_UTF && defined SUPPORT_UCP  #if defined SUPPORT_UTF && defined SUPPORT_UCP
4877  if (common->utf && *cc == OP_REFI)  if (common->utf && *cc == OP_REFI)
4878    {    {
4879    SLJIT_ASSERT(TMP1 == SLJIT_TEMPORARY_REG1 && STACK_TOP == SLJIT_TEMPORARY_REG2 && TMP2 == SLJIT_TEMPORARY_REG3);    SLJIT_ASSERT(TMP1 == SLJIT_SCRATCH_REG1 && STACK_TOP == SLJIT_SCRATCH_REG2 && TMP2 == SLJIT_SCRATCH_REG3);
4880    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
4881    if (withchecks)    if (withchecks)
4882      jump = CMP(SLJIT_C_EQUAL, TMP1, 0, TMP2, 0);      jump = CMP(SLJIT_C_EQUAL, TMP1, 0, TMP2, 0);
4883    
4884    /* Needed to save important temporary registers. */    /* Needed to save important temporary registers. */
4885    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
4886    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, ARGUMENTS, 0);    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, ARGUMENTS, 0);
4887    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), SLJIT_OFFSETOF(jit_arguments, uchar_ptr), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SCRATCH_REG2), SLJIT_OFFSETOF(jit_arguments, uchar_ptr), STR_PTR, 0);
4888    sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp));    sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp));
4889    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
4890    if (common->mode == JIT_COMPILE)    if (common->mode == JIT_COMPILE)
# Line 4903  if (!minimize) Line 4997  if (!minimize)
4997      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
4998      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
4999      /* Temporary release of STR_PTR. */      /* Temporary release of STR_PTR. */
5000      OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));      OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5001      zerolength = compile_ref_checks(common, ccbegin, NULL);      zerolength = compile_ref_checks(common, ccbegin, NULL);
5002      /* Restore if not zero length. */      /* Restore if not zero length. */
5003      OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));      OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5004      }      }
5005    else    else
5006      {      {
# Line 4999  backtrack_common *backtrack; Line 5093  backtrack_common *backtrack;
5093  recurse_entry *entry = common->entries;  recurse_entry *entry = common->entries;
5094  recurse_entry *prev = NULL;  recurse_entry *prev = NULL;
5095  int start = GET(cc, 1);  int start = GET(cc, 1);
5096    pcre_uchar *start_cc;
5097    
5098  PUSH_BACKTRACK(sizeof(recurse_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(recurse_backtrack), cc, NULL);
5099    
5100    /* Inlining simple patterns. */
5101    if (get_framesize(common, common->start + start, TRUE) == no_stack)
5102      {
5103      start_cc = common->start + start;
5104      compile_matchingpath(common, next_opcode(common, start_cc), bracketend(start_cc) - (1 + LINK_SIZE), backtrack);
5105      BACKTRACK_AS(recurse_backtrack)->inlined_pattern = TRUE;
5106      return cc + 1 + LINK_SIZE;
5107      }
5108    
5109  while (entry != NULL)  while (entry != NULL)
5110    {    {
5111    if (entry->start == start)    if (entry->start == start)
# Line 5049  add_jump(compiler, &backtrack->topbacktr Line 5154  add_jump(compiler, &backtrack->topbacktr
5154  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
5155  }  }
5156    
5157    static int SLJIT_CALL do_callout(struct jit_arguments* arguments, PUBL(callout_block) *callout_block, pcre_uchar **jit_ovector)
5158    {
5159    const pcre_uchar *begin = arguments->begin;
5160    int *offset_vector = arguments->offsets;
5161    int offset_count = arguments->offset_count;
5162    int i;
5163    
5164    if (PUBL(callout) == NULL)
5165      return 0;
5166    
5167    callout_block->version = 2;
5168    callout_block->callout_data = arguments->callout_data;
5169    
5170    /* Offsets in subject. */
5171    callout_block->subject_length = arguments->end - arguments->begin;
5172    callout_block->start_match = (pcre_uchar*)callout_block->subject - arguments->begin;
5173    callout_block->current_position = (pcre_uchar*)callout_block->offset_vector - arguments->begin;
5174    #if defined COMPILE_PCRE8
5175    callout_block->subject = (PCRE_SPTR)begin;
5176    #elif defined COMPILE_PCRE16
5177    callout_block->subject = (PCRE_SPTR16)begin;
5178    #elif defined COMPILE_PCRE32
5179    callout_block->subject = (PCRE_SPTR32)begin;
5180    #endif
5181    
5182    /* Convert and copy the JIT offset vector to the offset_vector array. */
5183    callout_block->capture_top = 0;
5184    callout_block->offset_vector = offset_vector;
5185    for (i = 2; i < offset_count; i += 2)
5186      {
5187      offset_vector[i] = jit_ovector[i] - begin;
5188      offset_vector[i + 1] = jit_ovector[i + 1] - begin;
5189      if (jit_ovector[i] >= begin)
5190        callout_block->capture_top = i;
5191      }
5192    
5193    callout_block->capture_top = (callout_block->capture_top >> 1) + 1;
5194    if (offset_count > 0)
5195      offset_vector[0] = -1;
5196    if (offset_count > 1)
5197      offset_vector[1] = -1;
5198    return (*PUBL(callout))(callout_block);
5199    }
5200    
5201    /* Aligning to 8 byte. */
5202    #define CALLOUT_ARG_SIZE \
5203        (((int)sizeof(PUBL(callout_block)) + 7) & ~7)
5204    
5205    #define CALLOUT_ARG_OFFSET(arg) \
5206        (-CALLOUT_ARG_SIZE + SLJIT_OFFSETOF(PUBL(callout_block), arg))
5207    
5208    static SLJIT_INLINE pcre_uchar *compile_callout_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
5209    {
5210    DEFINE_COMPILER;
5211    backtrack_common *backtrack;
5212    
5213    PUSH_BACKTRACK(sizeof(backtrack_common), cc, NULL);
5214    
5215    allocate_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw));
5216    
5217    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
5218    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
5219    SLJIT_ASSERT(common->capture_last_ptr != 0);
5220    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_number), SLJIT_IMM, cc[1]);
5221    OP1(SLJIT_MOV_UI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(capture_last), TMP2, 0);
5222    
5223    /* These pointer sized fields temporarly stores internal variables. */
5224    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
5225    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(offset_vector), STR_PTR, 0);
5226    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(subject), TMP2, 0);
5227    
5228    if (common->mark_ptr != 0)
5229      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr));
5230    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position), SLJIT_IMM, GET(cc, 2));
5231    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(next_item_length), SLJIT_IMM, GET(cc, 2 + LINK_SIZE));
5232    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(mark), (common->mark_ptr != 0) ? TMP2 : SLJIT_IMM, 0);
5233    
5234    /* Needed to save important temporary registers. */
5235    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
5236    OP2(SLJIT_SUB, SLJIT_SCRATCH_REG2, 0, STACK_TOP, 0, SLJIT_IMM, CALLOUT_ARG_SIZE);
5237    GET_LOCAL_BASE(SLJIT_SCRATCH_REG3, 0, OVECTOR_START);
5238    sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_callout));
5239    OP1(SLJIT_MOV_SI, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0);
5240    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
5241    free_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw));
5242    
5243    /* Check return value. */
5244    OP2(SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
5245    add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_C_SIG_GREATER));
5246    if (common->forced_quit_label == NULL)
5247      add_jump(compiler, &common->forced_quit, JUMP(SLJIT_C_SIG_LESS));
5248    else
5249      JUMPTO(SLJIT_C_SIG_LESS, common->forced_quit_label);
5250    return cc + 2 + 2 * LINK_SIZE;
5251    }
5252    
5253    #undef CALLOUT_ARG_SIZE
5254    #undef CALLOUT_ARG_OFFSET
5255    
5256  static pcre_uchar *compile_assert_matchingpath(compiler_common *common, pcre_uchar *cc, assert_backtrack *backtrack, BOOL conditional)  static pcre_uchar *compile_assert_matchingpath(compiler_common *common, pcre_uchar *cc, assert_backtrack *backtrack, BOOL conditional)
5257  {  {
5258  DEFINE_COMPILER;  DEFINE_COMPILER;
# Line 5062  jump_list *tmp = NULL; Line 5266  jump_list *tmp = NULL;
5266  jump_list **target = (conditional) ? &backtrack->condfailed : &backtrack->common.topbacktracks;  jump_list **target = (conditional) ? &backtrack->condfailed : &backtrack->common.topbacktracks;
5267  jump_list **found;  jump_list **found;
5268  /* Saving previous accept variables. */  /* Saving previous accept variables. */
5269  struct sljit_label *save_quitlabel = common->quitlabel;  struct sljit_label *save_quit_label = common->quit_label;
5270  struct sljit_label *save_acceptlabel = common->acceptlabel;  struct sljit_label *save_accept_label = common->accept_label;
5271  jump_list *save_quit = common->quit;  jump_list *save_quit = common->quit;
5272  jump_list *save_accept = common->accept;  jump_list *save_accept = common->accept;
5273  struct sljit_jump *jump;  struct sljit_jump *jump;
# Line 5112  else Line 5316  else
5316    }    }
5317    
5318  memset(&altbacktrack, 0, sizeof(backtrack_common));  memset(&altbacktrack, 0, sizeof(backtrack_common));
5319  common->quitlabel = NULL;  common->quit_label = NULL;
5320  common->quit = NULL;  common->quit = NULL;
5321  while (1)  while (1)
5322    {    {
5323    common->acceptlabel = NULL;    common->accept_label = NULL;
5324    common->accept = NULL;    common->accept = NULL;
5325    altbacktrack.top = NULL;    altbacktrack.top = NULL;
5326    altbacktrack.topbacktracks = NULL;    altbacktrack.topbacktracks = NULL;
# Line 5128  while (1) Line 5332  while (1)
5332    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);
5333    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5334      {      {
5335      common->quitlabel = save_quitlabel;      common->quit_label = save_quit_label;
5336      common->acceptlabel = save_acceptlabel;      common->accept_label = save_accept_label;
5337      common->quit = save_quit;      common->quit = save_quit;
5338      common->accept = save_accept;      common->accept = save_accept;
5339      return NULL;      return NULL;
5340      }      }
5341    common->acceptlabel = LABEL();    common->accept_label = LABEL();
5342    if (common->accept != NULL)    if (common->accept != NULL)
5343      set_jumps(common->accept, common->acceptlabel);      set_jumps(common->accept, common->accept_label);
5344    
5345    /* Reset stack. */    /* Reset stack. */
5346    if (framesize < 0)    if (framesize < 0)
# Line 5145  while (1) Line 5349  while (1)
5349      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)
5350        {        {
5351        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5352        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
5353        }        }
5354      else      else
5355        {        {
# Line 5165  while (1) Line 5369  while (1)
5369          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5370        else        else
5371          {          {
5372          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_w));          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5373          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_w));          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_sw));
5374          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
5375          }          }
5376        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5377        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5378        }        }
5379      else if (framesize >= 0)      else if (framesize >= 0)
5380        {        {
5381        /* For OP_BRA and OP_BRAMINZERO. */        /* For OP_BRA and OP_BRAMINZERO. */
5382        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5383        }        }
5384      }      }
5385    add_jump(compiler, found, JUMP(SLJIT_JUMP));    add_jump(compiler, found, JUMP(SLJIT_JUMP));
# Line 5183  while (1) Line 5387  while (1)
5387    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
5388    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5389      {      {
5390      common->quitlabel = save_quitlabel;      common->quit_label = save_quit_label;
5391      common->acceptlabel = save_acceptlabel;      common->accept_label = save_accept_label;
5392      common->quit = save_quit;      common->quit = save_quit;
5393      common->accept = save_accept;      common->accept = save_accept;
5394      return NULL;      return NULL;
# Line 5240  if (opcode == OP_ASSERT || opcode == OP_ Line 5444  if (opcode == OP_ASSERT || opcode == OP_
5444      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5445      /* Keep the STR_PTR on the top of the stack. */      /* Keep the STR_PTR on the top of the stack. */
5446      if (bra == OP_BRAZERO)      if (bra == OP_BRAZERO)
5447        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5448      else if (bra == OP_BRAMINZERO)      else if (bra == OP_BRAMINZERO)
5449        {        {
5450        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5451        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5452        }        }
5453      }      }
# Line 5252  if (opcode == OP_ASSERT || opcode == OP_ Line 5456  if (opcode == OP_ASSERT || opcode == OP_
5456      if (bra == OP_BRA)      if (bra == OP_BRA)
5457        {        {
5458        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5459        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
5460        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5461        }        }
5462      else      else
5463        {        {
5464        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5465        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_sw));
5466        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
5467        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);
5468        }        }
# Line 5267  if (opcode == OP_ASSERT || opcode == OP_ Line 5471  if (opcode == OP_ASSERT || opcode == OP_
5471    if (bra == OP_BRAZERO)    if (bra == OP_BRAZERO)
5472      {      {
5473      backtrack->matchingpath = LABEL();      backtrack->matchingpath = LABEL();
5474      sljit_set_label(jump, backtrack->matchingpath);      SET_LABEL(jump, backtrack->matchingpath);
5475      }      }
5476    else if (bra == OP_BRAMINZERO)    else if (bra == OP_BRAMINZERO)
5477      {      {
# Line 5277  if (opcode == OP_ASSERT || opcode == OP_ Line 5481  if (opcode == OP_ASSERT || opcode == OP_
5481        {        {
5482        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5483        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5484        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5485        }        }
5486      set_jumps(backtrack->common.topbacktracks, LABEL());      set_jumps(backtrack->common.topbacktracks, LABEL());
5487      }      }
# Line 5324  else Line 5528  else
5528      }      }
5529    }    }
5530    
5531  common->quitlabel = save_quitlabel;  common->quit_label = save_quit_label;
5532  common->acceptlabel = save_acceptlabel;  common->accept_label = save_accept_label;
5533  common->quit = save_quit;  common->quit = save_quit;
5534  common->accept = save_accept;  common->accept = save_accept;
5535  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
5536  }  }
5537    
5538  static sljit_w SLJIT_CALL do_searchovector(sljit_w refno, sljit_w* locals, pcre_uchar *name_table)  static sljit_sw SLJIT_CALL do_searchovector(sljit_uw refno, sljit_sw* locals, pcre_uchar *name_table)
5539  {  {
5540  int condition = FALSE;  int condition = FALSE;
5541  pcre_uchar *slotA = name_table;  pcre_uchar *slotA = name_table;
5542  pcre_uchar *slotB;  pcre_uchar *slotB;
5543  sljit_w name_count = locals[LOCALS0 / sizeof(sljit_w)];  sljit_sw name_count = locals[LOCALS0 / sizeof(sljit_sw)];
5544  sljit_w name_entry_size = locals[LOCALS1 / sizeof(sljit_w)];  sljit_sw name_entry_size = locals[LOCALS1 / sizeof(sljit_sw)];
5545  sljit_w no_capture;  sljit_sw no_capture;
5546  int i;  int i;
5547    
5548  locals += refno & 0xff;  locals += refno & 0xff;
# Line 5388  if (i < name_count) Line 5592  if (i < name_count)
5592  return condition;  return condition;
5593  }  }
5594    
5595  static sljit_w SLJIT_CALL do_searchgroups(sljit_w recno, sljit_w* locals, pcre_uchar *name_table)  static sljit_sw SLJIT_CALL do_searchgroups(sljit_uw recno, sljit_uw* locals, pcre_uchar *name_table)
5596  {  {
5597  int condition = FALSE;  int condition = FALSE;
5598  pcre_uchar *slotA = name_table;  pcre_uchar *slotA = name_table;
5599  pcre_uchar *slotB;  pcre_uchar *slotB;
5600  sljit_w name_count = locals[LOCALS0 / sizeof(sljit_w)];  sljit_uw name_count = locals[LOCALS0 / sizeof(sljit_sw)];
5601  sljit_w name_entry_size = locals[LOCALS1 / sizeof(sljit_w)];  sljit_uw name_entry_size = locals[LOCALS1 / sizeof(sljit_sw)];
5602  sljit_w group_num = locals[POSSESSIVE0 / sizeof(sljit_w)];  sljit_uw group_num = locals[POSSESSIVE0 / sizeof(sljit_sw)];
5603  int i;  sljit_uw i;
5604    
5605  for (i = 0; i < name_count; i++)  for (i = 0; i < name_count; i++)
5606    {    {
# Line 5551  if (SLJIT_UNLIKELY(opcode == OP_COND) || Line 5755  if (SLJIT_UNLIKELY(opcode == OP_COND) ||
5755      else if (common->currententry->start == 0)      else if (common->currententry->start == 0)
5756        has_alternatives = stacksize != 0;        has_alternatives = stacksize != 0;
5757      else      else
5758        has_alternatives = stacksize != GET2(common->start, common->currententry->start + 1 + LINK_SIZE);        has_alternatives = stacksize != (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
5759      }      }
5760    }    }
5761    
# Line 5635  if (bra == OP_BRAMINZERO) Line 5839  if (bra == OP_BRAMINZERO)
5839          {          {
5840          /* Except when the whole stack frame must be saved. */          /* Except when the whole stack frame must be saved. */
5841          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5842          braminzerojump = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (BACKTRACK_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_w));          braminzerojump = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (BACKTRACK_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_sw));
5843          }          }
5844        JUMPHERE(skip);        JUMPHERE(skip);
5845        }        }
# Line 5670  if (opcode == OP_ONCE) Line 5874  if (opcode == OP_ONCE)
5874        allocate_stack(common, 2);        allocate_stack(common, 2);
5875        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5876        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
5877        OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5878        }        }
5879      else if (ket == OP_KETRMAX || has_alternatives)      else if (ket == OP_KETRMAX || has_alternatives)
5880        {        {
# Line 5707  if (opcode == OP_ONCE) Line 5911  if (opcode == OP_ONCE)
5911  else if (opcode == OP_CBRA || opcode == OP_SCBRA)  else if (opcode == OP_CBRA || opcode == OP_SCBRA)
5912    {    {
5913    /* Saving the previous values. */    /* Saving the previous values. */
5914    if (common->optimized_cbracket[offset >> 1] == 0)    if (common->optimized_cbracket[offset >> 1] != 0)
     {  
     allocate_stack(common, 3);  
     OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));  
     OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));  
     OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);  
     OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);  
     OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);  
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);  
     OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);  
     }  
   else  
5915      {      {
5916      SLJIT_ASSERT(private_data_ptr == OVECTOR(offset));      SLJIT_ASSERT(private_data_ptr == OVECTOR(offset));
5917      allocate_stack(common, 2);      allocate_stack(common, 2);
5918      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5919      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr + sizeof(sljit_w));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr + sizeof(sljit_sw));
5920      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);
5921      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
5922      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
5923      }      }
5924      else
5925        {
5926        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5927        allocate_stack(common, 1);
5928        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);
5929        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
5930        }
5931    }    }
5932  else if (opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_SBRA || opcode == OP_SCOND)
5933    {    {
# Line 5763  if (opcode == OP_COND || opcode == OP_SC Line 5963  if (opcode == OP_COND || opcode == OP_SC
5963      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STACK_TOP, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STACK_TOP, 0);
5964      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);
5965      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);
5966      OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (stacksize << 8) | (common->ovector_start / sizeof(sljit_w)));      OP1(SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, (stacksize << 8) | (common->ovector_start / sizeof(sljit_sw)));
5967      GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, 0);      GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, 0);
5968      OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, common->name_table);      OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, common->name_table);
5969      sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchovector));      sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchovector));
5970      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);
5971      add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));      add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, 0));
5972    
5973      JUMPHERE(jump);      JUMPHERE(jump);
5974      matchingpath += 1 + IMM2_SIZE;      matchingpath += 1 + IMM2_SIZE;
# Line 5786  if (opcode == OP_COND || opcode == OP_SC Line 5986  if (opcode == OP_COND || opcode == OP_SC
5986      else if (common->currententry->start == 0)      else if (common->currententry->start == 0)
5987        stacksize = stacksize == 0;        stacksize = stacksize == 0;
5988      else      else
5989        stacksize = stacksize == GET2(common->start, common->currententry->start + 1 + LINK_SIZE);        stacksize = stacksize == (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
5990    
5991      if (*matchingpath == OP_RREF || stacksize || common->currententry == NULL)      if (*matchingpath == OP_RREF || stacksize || common->currententry == NULL)
5992        {        {
# Line 5813  if (opcode == OP_COND || opcode == OP_SC Line 6013  if (opcode == OP_COND || opcode == OP_SC
6013        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);
6014        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);
6015        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, GET2(common->start, common->currententry->start + 1 + LINK_SIZE));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, GET2(common->start, common->currententry->start + 1 + LINK_SIZE));
6016        OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, stacksize);        OP1(SLJIT_MOV, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, stacksize);
6017        GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, 0);        GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, 0);
6018        OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, common->name_table);        OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, common->name_table);
6019        sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));        sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));
6020        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);
6021        add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));        add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_SCRATCH_REG1, 0, SLJIT_IMM, 0));
6022        matchingpath += 1 + IMM2_SIZE;        matchingpath += 1 + IMM2_SIZE;
6023        }        }
6024      }      }
# Line 5857  if (opcode == OP_ONCE) Line 6057  if (opcode == OP_ONCE)
6057    else    else
6058      {      {
6059      stacksize = (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives) ? 2 : 1;      stacksize = (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives) ? 2 : 1;
6060      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (BACKTRACK_AS(bracket_backtrack)->u.framesize + stacksize) * sizeof(sljit_w));      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (BACKTRACK_AS(bracket_backtrack)->u.framesize + stacksize) * sizeof(sljit_sw));
6061      if (ket == OP_KETRMAX)      if (ket == OP_KETRMAX)
6062        {        {
6063        /* TMP2 which is set here used by OP_KETRMAX below. */        /* TMP2 which is set here used by OP_KETRMAX below. */
# Line 5869  if (opcode == OP_ONCE) Line 6069  if (opcode == OP_ONCE)
6069  stacksize = 0;  stacksize = 0;
6070  if (ket != OP_KET || bra != OP_BRA)  if (ket != OP_KET || bra != OP_BRA)
6071    stacksize++;    stacksize++;
6072    if (offset != 0)
6073      {
6074      if (common->capture_last_ptr != 0)
6075        stacksize++;
6076      if (common->optimized_cbracket[offset >> 1] == 0)
6077        stacksize += 2;
6078      }
6079  if (has_alternatives && opcode != OP_ONCE)  if (has_alternatives && opcode != OP_ONCE)
6080    stacksize++;    stacksize++;
6081    
# Line 5876  if (stacksize > 0) Line 6083  if (stacksize > 0)
6083    allocate_stack(common, stacksize);    allocate_stack(common, stacksize);
6084    
6085  stacksize = 0;  stacksize = 0;
6086  if (ket != OP_KET)  if (ket != OP_KET || bra != OP_BRA)
6087    {    {
6088    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);    if (ket != OP_KET)
6089        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
6090      else
6091        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0);
6092    stacksize++;    stacksize++;
6093    }    }
6094  else if (bra != OP_BRA)  
6095    if (offset != 0)
6096    {    {
6097    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0);    if (common->capture_last_ptr != 0)
6098    stacksize++;      {
6099        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
6100        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
6101        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP2, 0);
6102        stacksize++;
6103        }
6104      if (common->optimized_cbracket[offset >> 1] == 0)
6105        {
6106        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
6107        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
6108        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
6109        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6110        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize + 1), TMP2, 0);
6111        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
6112        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
6113        stacksize += 2;
6114        }
6115    }    }
6116    
6117  if (has_alternatives)  if (has_alternatives)
# Line 5896  if (has_alternatives) Line 6123  if (has_alternatives)
6123    }    }
6124    
6125  /* Must be after the matchingpath label. */  /* Must be after the matchingpath label. */
6126  if (offset != 0)  if (offset != 0 && common->optimized_cbracket[offset >> 1] != 0)
6127    {    {
6128    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);    SLJIT_ASSERT(private_data_ptr == OVECTOR(offset + 0));
6129    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 0), TMP1, 0);  
6130    }    }
6131    
6132  if (ket == OP_KETRMAX)  if (ket == OP_KETRMAX)
# Line 6014  framesize = get_framesize(common, cc, FA Line 6240  framesize = get_framesize(common, cc, FA
6240  BACKTRACK_AS(bracketpos_backtrack)->framesize = framesize;  BACKTRACK_AS(bracketpos_backtrack)->framesize = framesize;
6241  if (framesize < 0)  if (framesize < 0)
6242    {    {
6243    stacksize = (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS) ? 2 : 1;    if (offset != 0)
6244        {
6245        stacksize = 2;
6246        if (common->capture_last_ptr != 0)
6247          stacksize++;
6248        }
6249      else
6250        stacksize = 1;
6251    
6252    if (!zero)    if (!zero)
6253      stacksize++;      stacksize++;
6254    
6255    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
6256    allocate_stack(common, stacksize);    allocate_stack(common, stacksize);
6257    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);    if (framesize == no_frame)
6258        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);
6259    
6260    if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)    if (offset != 0)
6261      {      {
6262      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
6263      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
6264      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
6265        if (common->capture_last_ptr != 0)
6266          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
6267      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
6268        if (common->capture_last_ptr != 0)
6269          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);
6270      }      }
6271    else    else
6272      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
# Line 6042  else Line 6282  else
6282    if (opcode == OP_BRAPOS || opcode == OP_SBRAPOS)    if (opcode == OP_BRAPOS || opcode == OP_SBRAPOS)
6283      stacksize++;      stacksize++;
6284    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
   allocate_stack(common, stacksize);  
6285    
6286      allocate_stack(common, stacksize);
6287    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6288    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(stacksize - 1));    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(stacksize - 1));
6289    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP2, 0);
6290    
6291    stack = 0;    stack = 0;
6292    if (!zero)    if (!zero)
6293      {      {
# Line 6062  else Line 6303  else
6303    init_frame(common, cc, stacksize - 1, stacksize - framesize, FALSE);    init_frame(common, cc, stacksize - 1, stacksize - framesize, FALSE);
6304    }    }
6305    
6306  if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)  if (offset != 0)
6307    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);
6308    
6309  loop = LABEL();  loop = LABEL();
# Line 6078  while (*cc != OP_KETRPOS) Line 6319  while (*cc != OP_KETRPOS)
6319    
6320    if (framesize < 0)    if (framesize < 0)
6321      {      {
6322      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);      if (framesize == no_frame)
6323          OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6324    
6325      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (offset != 0)
6326        {        {
6327        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);
6328        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
6329        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);
6330          if (common->capture_last_ptr != 0)
6331            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
6332        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
6333        }        }
6334      else      else
# Line 6102  while (*cc != OP_KETRPOS) Line 6346  while (*cc != OP_KETRPOS)
6346      }      }
6347    else    else
6348      {      {
6349      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (offset != 0)
6350        {        {
6351        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, stacksize * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, stacksize * sizeof(sljit_sw));
6352        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);
6353        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
6354        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);
6355          if (common->capture_last_ptr != 0)
6356            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
6357        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
6358        }        }
6359      else      else
6360        {        {
6361        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6362        OP2(SLJIT_ADD, STACK_TOP, 0, TMP2, 0, SLJIT_IMM, stacksize * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, TMP2, 0, SLJIT_IMM, stacksize * sizeof(sljit_sw));
6363        if (opcode == OP_SBRAPOS)        if (opcode == OP_SBRAPOS)
6364          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_w));          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw));
6365        OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_w), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw), STR_PTR, 0);
6366        }        }
6367    
6368      if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)      if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
# Line 6140  while (*cc != OP_KETRPOS) Line 6386  while (*cc != OP_KETRPOS)
6386    
6387    if (framesize < 0)    if (framesize < 0)
6388      {      {
6389      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (offset != 0)
6390        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);
6391      else      else
6392        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
6393      }      }
6394    else    else
6395      {      {
6396      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (offset != 0)
6397        {        {
6398        /* Last alternative. */        /* Last alternative. */
6399        if (*cc == OP_KETRPOS)        if (*cc == OP_KETRPOS)
# Line 6157  while (*cc != OP_KETRPOS) Line 6403  while (*cc != OP_KETRPOS)
6403      else      else
6404        {        {
6405        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6406        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_w));        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw));
6407        }        }
6408      }      }
6409    
# Line 6172  if (!zero) Line 6418  if (!zero)
6418    if (framesize < 0)    if (framesize < 0)
6419      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0));      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0));
6420    else /* TMP2 is set to [private_data_ptr] above. */    else /* TMP2 is set to [private_data_ptr] above. */
6421      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(TMP2), (stacksize - 1) * sizeof(sljit_w), SLJIT_IMM, 0));      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(TMP2), (stacksize - 1) * sizeof(sljit_sw), SLJIT_IMM, 0));
6422    }    }
6423    
6424  /* None of them matched. */  /* None of them matched. */
# Line 6266  if (*type == 0) Line 6512  if (*type == 0)
6512  if (end != NULL)  if (end != NULL)
6513    {    {
6514    *end = cc + 1;    *end = cc + 1;
6515  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #ifdef SUPPORT_UTF
6516    if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc);    if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc);
6517  #endif  #endif
6518    }    }
# Line 6287  struct sljit_label *label; Line 6533  struct sljit_label *label;
6533  int private_data_ptr = PRIVATE_DATA(cc);  int private_data_ptr = PRIVATE_DATA(cc);
6534  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);
6535  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
6536  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_w);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
6537  int tmp_base, tmp_offset;  int tmp_base, tmp_offset;
6538    
6539  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
6540    
6541  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, &end);  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, &end);
6542    
6543  switch (type)  switch(type)
6544    {    {
6545    case OP_NOT_DIGIT:    case OP_NOT_DIGIT:
6546    case OP_DIGIT:    case OP_DIGIT:
# Line 6496  static SLJIT_INLINE pcre_uchar *compile_ Line 6742  static SLJIT_INLINE pcre_uchar *compile_
6742  DEFINE_COMPILER;  DEFINE_COMPILER;
6743  backtrack_common *backtrack;  backtrack_common *backtrack;
6744    
6745  PUSH_BACKTRACK(sizeof(bracket_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(backtrack_common), cc, NULL);
6746    
6747  if (*cc == OP_FAIL)  if (*cc == OP_FAIL)
6748    {    {
# Line 6507  if (*cc == OP_FAIL) Line 6753  if (*cc == OP_FAIL)
6753  if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL)  if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL)
6754    {    {
6755    /* No need to check notempty conditions. */    /* No need to check notempty conditions. */
6756    if (common->acceptlabel == NULL)    if (common->accept_label == NULL)
6757      add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));      add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));
6758    else    else
6759      JUMPTO(SLJIT_JUMP, common->acceptlabel);      JUMPTO(SLJIT_JUMP, common->accept_label);
6760    return cc + 1;    return cc + 1;
6761    }    }
6762    
6763  if (common->acceptlabel == NULL)  if (common->accept_label == NULL)
6764    add_jump(compiler, &common->accept, CMP(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0)));    add_jump(compiler, &common->accept, CMP(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0)));
6765  else  else
6766    CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), common->acceptlabel);    CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), common->accept_label);
6767  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
6768  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty));  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty));
6769  add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));  add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
6770  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart));  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart));
6771  if (common->acceptlabel == NULL)  if (common->accept_label == NULL)
6772    add_jump(compiler, &common->accept, CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0));    add_jump(compiler, &common->accept, CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0));
6773  else  else
6774    CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, common->acceptlabel);    CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, common->accept_label);
6775  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
6776  if (common->acceptlabel == NULL)  if (common->accept_label == NULL)
6777    add_jump(compiler, &common->accept, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0));    add_jump(compiler, &common->accept, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0));
6778  else  else
6779    CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, common->acceptlabel);    CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, common->accept_label);
6780  add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_JUMP));  add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_JUMP));
6781  return cc + 1;  return cc + 1;
6782  }  }
# Line 6710  while (cc < ccend) Line 6956  while (cc < ccend)
6956      cc = compile_recurse_matchingpath(common, cc, parent);      cc = compile_recurse_matchingpath(common, cc, parent);
6957      break;      break;
6958    
6959        case OP_CALLOUT:
6960        cc = compile_callout_matchingpath(common, cc, parent);
6961        break;
6962    
6963      case OP_ASSERT:      case OP_ASSERT:
6964      case OP_ASSERT_NOT:      case OP_ASSERT_NOT:
6965      case OP_ASSERTBACK:      case OP_ASSERTBACK:
# Line 6773  while (cc < ccend) Line 7023  while (cc < ccend)
7023      allocate_stack(common, 1);      allocate_stack(common, 1);
7024      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
7025      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
7026      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)(cc + 2));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
7027      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);
7028      OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
7029      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
# Line 6836  jump_list *jumplist = NULL; Line 7086  jump_list *jumplist = NULL;
7086  int private_data_ptr = PRIVATE_DATA(cc);  int private_data_ptr = PRIVATE_DATA(cc);
7087  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);
7088  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
7089  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_w);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
7090    
7091  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);
7092    
# Line 6992  static void compile_recurse_backtracking Line 7242  static void compile_recurse_backtracking
7242  {  {
7243  DEFINE_COMPILER;  DEFINE_COMPILER;
7244    
7245    if (CURRENT_AS(recurse_backtrack)->inlined_pattern)
7246      compile_backtrackingpath(common, current->top);
7247  set_jumps(current->topbacktracks, LABEL());  set_jumps(current->topbacktracks, LABEL());
7248    if (CURRENT_AS(recurse_backtrack)->inlined_pattern)
7249      return;
7250    
7251  if (common->has_set_som && common->mark_ptr != 0)  if (common->has_set_som && common->mark_ptr != 0)
7252    {    {
# Line 7060  if (*cc == OP_ASSERT || *cc == OP_ASSERT Line 7314  if (*cc == OP_ASSERT || *cc == OP_ASSERT
7314    {    {
7315    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr);    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr);
7316    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7317    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(assert_backtrack)->framesize * sizeof(sljit_w));    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(assert_backtrack)->framesize * sizeof(sljit_sw));
7318    
7319    set_jumps(current->topbacktracks, LABEL());    set_jumps(current->topbacktracks, LABEL());
7320    }    }
# Line 7070  else Line 7324  else
7324  if (bra == OP_BRAZERO)  if (bra == OP_BRAZERO)
7325    {    {
7326    /* We know there is enough place on the stack. */    /* We know there is enough place on the stack. */
7327    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
7328    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
7329    JUMPTO(SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);    JUMPTO(SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);
7330    JUMPHERE(brajump);    JUMPHERE(brajump);
# Line 7141  else if (ket == OP_KETRMIN) Line 7395  else if (ket == OP_KETRMIN)
7395        else        else
7396          {          {
7397          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7398          CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (CURRENT_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_w), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);          CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (CURRENT_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_sw), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
7399          }          }
7400        if (opcode != OP_ONCE)        if (opcode != OP_ONCE)
7401          free_stack(common, 1);          free_stack(common, 1);
# Line 7158  else if (bra == OP_BRAZERO) Line 7412  else if (bra == OP_BRAZERO)
7412    brazero = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0);    brazero = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0);
7413    }    }
7414    
7415    if (offset != 0)
7416      {
7417      if (common->capture_last_ptr != 0)
7418        {
7419        SLJIT_ASSERT(common->optimized_cbracket[offset >> 1] == 0);
7420        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
7421        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
7422        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, TMP1, 0);
7423        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(2));
7424        free_stack(common, 3);
7425        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP2, 0);
7426        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP1, 0);
7427        }
7428      else if (common->optimized_cbracket[offset >> 1] == 0)
7429        {
7430        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
7431        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
7432        free_stack(common, 2);
7433        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
7434        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);
7435        }
7436      }
7437    
7438  if (SLJIT_UNLIKELY(opcode == OP_ONCE))  if (SLJIT_UNLIKELY(opcode == OP_ONCE))
7439    {    {
7440    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
# Line 7230  if (SLJIT_UNLIKELY(opcode == OP_COND) || Line 7507  if (SLJIT_UNLIKELY(opcode == OP_COND) ||
7507        {        {
7508        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);
7509        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7510        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_sw));
7511        }        }
7512      cond = JUMP(SLJIT_JUMP);      cond = JUMP(SLJIT_JUMP);
7513      set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());      set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());
# Line 7287  if (has_alternatives) Line 7564  if (has_alternatives)
7564          }          }
7565        else        else
7566          {          {
7567          OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (CURRENT_AS(bracket_backtrack)->u.framesize + 2) * sizeof(sljit_w));          OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (CURRENT_AS(bracket_backtrack)->u.framesize + 2) * sizeof(sljit_sw));
7568          if (ket == OP_KETRMAX)          if (ket == OP_KETRMAX)
7569            {            {
7570            /* TMP2 which is set here used by OP_KETRMAX below. */            /* TMP2 which is set here used by OP_KETRMAX below. */
# Line 7297  if (has_alternatives) Line 7574  if (has_alternatives)
7574        }        }
7575    
7576      stacksize = 0;      stacksize = 0;
     if (opcode != OP_ONCE)  
       stacksize++;  
7577      if (ket != OP_KET || bra != OP_BRA)      if (ket != OP_KET || bra != OP_BRA)
7578        stacksize++;        stacksize++;
7579        if (offset != 0)
7580          {
7581          if (common->capture_last_ptr != 0)
7582            stacksize++;
7583          if (common->optimized_cbracket[offset >> 1] == 0)
7584            stacksize += 2;
7585          }
7586        if (opcode != OP_ONCE)
7587          stacksize++;
7588    
7589      if (stacksize > 0) {      if (stacksize > 0) {
7590        if (opcode != OP_ONCE || CURRENT_AS(bracket_backtrack)->u.framesize >= 0)        if (opcode != OP_ONCE || CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
# Line 7309  if (has_alternatives) Line 7593  if (has_alternatives)
7593          {          {
7594          /* We know we have place at least for one item on the top of the stack. */          /* We know we have place at least for one item on the top of the stack. */
7595          SLJIT_ASSERT(stacksize == 1);          SLJIT_ASSERT(stacksize == 1);
7596          OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));          OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
7597          }          }
7598      }      }
7599    
# Line 7323  if (has_alternatives) Line 7607  if (has_alternatives)
7607        stacksize++;        stacksize++;
7608        }        }
7609    
7610        if (offset != 0)
7611          {
7612          if (common->capture_last_ptr != 0)
7613            {
7614            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
7615            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
7616            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
7617            stacksize++;
7618            }
7619          if (common->optimized_cbracket[offset >> 1] == 0)
7620            {
7621            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
7622            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
7623            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
7624            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7625            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize + 1), TMP2, 0);
7626            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
7627            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
7628            stacksize += 2;
7629            }
7630          }
7631    
7632      if (opcode != OP_ONCE)      if (opcode != OP_ONCE)
7633        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, count++);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, count++);
7634    
7635      if (offset != 0)      if (offset != 0 && ket == OP_KETRMAX && common->optimized_cbracket[offset >> 1] != 0)
7636        {        {
7637        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        /* If ket is not OP_KETRMAX, this code path is executed after the jump to alternative_matchingpath. */
7638          SLJIT_ASSERT(private_data_ptr == OVECTOR(offset + 0));
7639        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
       OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 0), TMP1, 0);  
7640        }        }
7641    
7642      JUMPTO(SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->alternative_matchingpath);      JUMPTO(SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->alternative_matchingpath);
# Line 7359  if (has_alternatives) Line 7665  if (has_alternatives)
7665        {        {
7666        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);
7667        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7668        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_sw));
7669        }        }
7670      JUMPHERE(cond);      JUMPHERE(cond);
7671      }      }
# Line 7372  if (has_alternatives) Line 7678  if (has_alternatives)
7678  if (offset != 0)  if (offset != 0)
7679    {    {
7680    /* Using both tmp register is better for instruction scheduling. */    /* Using both tmp register is better for instruction scheduling. */
7681    if (common->optimized_cbracket[offset >> 1] == 0)    if (common->optimized_cbracket[offset >> 1] != 0)
7682      {      {
7683      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
7684      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
7685        free_stack(common, 2);
7686      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
     OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(2));  
     free_stack(common, 3);  
7687      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);  
7688      }      }
7689    else    else
7690      {      {
7691      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
7692      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      free_stack(common, 1);
7693      free_stack(common, 2);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);  
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);  
7694      }      }
7695    }    }
7696  else if (opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_SBRA || opcode == OP_SCOND)
# Line 7414  else if (opcode == OP_ONCE) Line 7716  else if (opcode == OP_ONCE)
7716    JUMPHERE(once);    JUMPHERE(once);
7717    /* Restore previous private_data_ptr */    /* Restore previous private_data_ptr */
7718    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
7719      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracket_backtrack)->u.framesize * sizeof(sljit_w));      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracket_backtrack)->u.framesize * sizeof(sljit_sw));
7720    else if (ket == OP_KETRMIN)    else if (ket == OP_KETRMIN)
7721      {      {
7722      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
# Line 7475  if (CURRENT_AS(bracketpos_backtrack)->fr Line 7777  if (CURRENT_AS(bracketpos_backtrack)->fr
7777      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
7778      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
7779      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
7780        if (common->capture_last_ptr != 0)
7781          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(2));
7782      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);
7783        if (common->capture_last_ptr != 0)
7784          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, TMP1, 0);
7785      }      }
7786    set_jumps(current->topbacktracks, LABEL());    set_jumps(current->topbacktracks, LABEL());
7787    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
# Line 7493  if (current->topbacktracks) Line 7799  if (current->topbacktracks)
7799    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
7800    JUMPHERE(jump);    JUMPHERE(jump);
7801    }    }
7802  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracketpos_backtrack)->framesize * sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracketpos_backtrack)->framesize * sizeof(sljit_sw));
7803  }  }
7804    
7805  static void compile_braminzero_backtrackingpath(compiler_common *common, struct backtrack_common *current)  static void compile_braminzero_backtrackingpath(compiler_common *common, struct backtrack_common *current)
# Line 7663  while (current) Line 7969  while (current)
7969    
7970      case OP_COMMIT:      case OP_COMMIT:
7971      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
7972      if (common->quitlabel == NULL)      if (common->quit_label == NULL)
7973        add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));        add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
7974      else      else
7975        JUMPTO(SLJIT_JUMP, common->quitlabel);        JUMPTO(SLJIT_JUMP, common->quit_label);
7976      break;      break;
7977    
7978        case OP_CALLOUT:
7979      case OP_FAIL:      case OP_FAIL:
7980      case OP_ACCEPT:      case OP_ACCEPT:
7981      case OP_ASSERT_ACCEPT:      case OP_ASSERT_ACCEPT:
# Line 7694  int framesize = get_framesize(common, cc Line 8001  int framesize = get_framesize(common, cc
8001  int alternativesize;  int alternativesize;
8002  BOOL needsframe;  BOOL needsframe;
8003  backtrack_common altbacktrack;  backtrack_common altbacktrack;
8004  struct sljit_label *save_quitlabel = common->quitlabel;  struct sljit_label *save_quit_label = common->quit_label;
8005  jump_list *save_quit = common->quit;  jump_list *save_quit = common->quit;
8006  struct sljit_jump *jump;  struct sljit_jump *jump;
8007    
# Line 7704  if (!needsframe) Line 8011  if (!needsframe)
8011    framesize = 0;    framesize = 0;
8012  alternativesize = *(cc + GET(cc, 1)) == OP_ALT ? 1 : 0;  alternativesize = *(cc + GET(cc, 1)) == OP_ALT ? 1 : 0;
8013    
8014  SLJIT_ASSERT(common->currententry->entry == NULL && common->recursive_head != 0);  SLJIT_ASSERT(common->currententry->entry == NULL && common->recursive_head_ptr != 0);
8015  common->currententry->entry = LABEL();  common->currententry->entry = LABEL();
8016  set_jumps(common->currententry->calls, common->currententry->entry);  set_jumps(common->currententry->calls, common->currententry->entry);
8017    
# Line 7712  sljit_emit_fast_enter(compiler, TMP2, 0) Line 8019  sljit_emit_fast_enter(compiler, TMP2, 0)
8019  allocate_stack(common, private_data_size + framesize + alternativesize);  allocate_stack(common, private_data_size + framesize + alternativesize);
8020  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0);
8021  copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize);  copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize);
8022  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head, STACK_TOP, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, STACK_TOP, 0);
8023  if (needsframe)  if (needsframe)
8024    init_frame(common, cc, framesize + alternativesize - 1, alternativesize, TRUE);    init_frame(common, cc, framesize + alternativesize - 1, alternativesize, TRUE);
8025    
# Line 7720  if (alternativesize > 0) Line 8027  if (alternativesize > 0)
8027    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
8028    
8029  memset(&altbacktrack, 0, sizeof(backtrack_common));  memset(&altbacktrack, 0, sizeof(backtrack_common));
8030  common->quitlabel = NULL;  common->quit_label = NULL;
8031  common->acceptlabel = NULL;  common->accept_label = NULL;
8032  common->quit = NULL;  common->quit = NULL;
8033  common->accept = NULL;  common->accept = NULL;
8034  altbacktrack.cc = ccbegin;  altbacktrack.cc = ccbegin;
# Line 7737  while (1) Line 8044  while (1)
8044    compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);    compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);
8045    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
8046      {      {
8047      common->quitlabel = save_quitlabel;      common->quit_label = save_quit_label;
8048      common->quit = save_quit;      common->quit = save_quit;
8049      return;      return;
8050      }      }
# Line 7747  while (1) Line 8054  while (1)
8054    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
8055    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
8056      {      {
8057      common->quitlabel = save_quitlabel;      common->quit_label = save_quit_label;
8058      common->quit = save_quit;      common->quit = save_quit;
8059      return;      return;
8060      }      }
# Line 7767  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0); Line 8074  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0);
8074  jump = JUMP(SLJIT_JUMP);  jump = JUMP(SLJIT_JUMP);
8075    
8076  set_jumps(common->accept, LABEL());  set_jumps(common->accept, LABEL());
8077  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head);  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr);
8078  if (needsframe)  if (needsframe)
8079    {    {
8080    OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_w));    OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
8081    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
8082    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_w));    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
8083    }    }
8084  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);
8085    
8086  JUMPHERE(jump);  JUMPHERE(jump);
8087  copy_private_data(common, ccbegin, ccend, FALSE, private_data_size + framesize + alternativesize, framesize + alternativesize);  copy_private_data(common, ccbegin, ccend, FALSE, private_data_size + framesize + alternativesize, framesize + alternativesize);
8088  free_stack(common, private_data_size + framesize + alternativesize);  free_stack(common, private_data_size + framesize + alternativesize);
8089  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_w));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));
8090  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
8091  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head, TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, TMP2, 0);
8092  sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);  sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);
8093    
8094  common->quitlabel = save_quitlabel;  common->quit_label = save_quit_label;
8095  common->quit = save_quit;  common->quit = save_quit;
8096  }  }
8097    
# Line 7809  struct sljit_label *mainloop = NULL; Line 8116  struct sljit_label *mainloop = NULL;
8116  struct sljit_label *empty_match_found;  struct sljit_label *empty_match_found;
8117  struct sljit_label *empty_match_backtrack;  struct sljit_label *empty_match_backtrack;
8118  struct sljit_jump *jump;  struct sljit_jump *jump;
8119    struct sljit_jump *minlength_check_failed = NULL;
8120  struct sljit_jump *reqbyte_notfound = NULL;  struct sljit_jump *reqbyte_notfound = NULL;
8121  struct sljit_jump *empty_match;  struct sljit_jump *empty_match;
8122    
# Line 7824  rootbacktrack.cc = (pcre_uchar *)re + re Line 8132  rootbacktrack.cc = (pcre_uchar *)re + re
8132    
8133  common->start = rootbacktrack.cc;  common->start = rootbacktrack.cc;
8134  common->fcc = tables + fcc_offset;  common->fcc = tables + fcc_offset;
8135  common->lcc = (sljit_w)(tables + lcc_offset);  common->lcc = (sljit_sw)(tables + lcc_offset);
8136  common->mode = mode;  common->mode = mode;
8137  common->nltype = NLTYPE_FIXED;  common->nltype = NLTYPE_FIXED;
8138  switch(re->options & PCRE_NEWLINE_BITS)  switch(re->options & PCRE_NEWLINE_BITS)
# Line 7859  else Line 8167  else
8167  #endif  #endif
8168    }    }
8169  common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
8170  common->ctypes = (sljit_w)(tables + ctypes_offset);  common->ctypes = (sljit_sw)(tables + ctypes_offset);
8171  common->digits[0] = -2;  common->digits[0] = -2;
8172  common->name_table = (sljit_w)((pcre_uchar *)re + re->name_table_offset);  common->name_table = (sljit_sw)((pcre_uchar *)re + re->name_table_offset);
8173  common->name_count = re->name_count;  common->name_count = re->name_count;
8174  common->name_entry_size = re->name_entry_size;  common->name_entry_size = re->name_entry_size;
8175  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
# Line 7875  common->use_ucp = (re->options & PCRE_UC Line 8183  common->use_ucp = (re->options & PCRE_UC
8183  ccend = bracketend(rootbacktrack.cc);  ccend = bracketend(rootbacktrack.cc);
8184    
8185  /* Calculate the local space size on the stack. */  /* Calculate the local space size on the stack. */
8186  common->ovector_start = CALL_LIMIT + sizeof(sljit_w);  common->ovector_start = CALL_LIMIT + sizeof(sljit_sw);
8187  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);
8188  if (!common->optimized_cbracket)  if (!common->optimized_cbracket)
8189    return;    return;
8190    #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1
8191    memset(common->optimized_cbracket, 0, re->top_bracket + 1);
8192    #else
8193  memset(common->optimized_cbracket, 1, re->top_bracket + 1);  memset(common->optimized_cbracket, 1, re->top_bracket + 1);
8194    #endif
8195    
8196  SLJIT_ASSERT(*rootbacktrack.cc == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET);  SLJIT_ASSERT(*rootbacktrack.cc == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET);
8197    #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 2
8198    common->capture_last_ptr = common->ovector_start;
8199    common->ovector_start += sizeof(sljit_sw);
8200    #endif
8201  private_data_size = get_private_data_length(common, rootbacktrack.cc, ccend);  private_data_size = get_private_data_length(common, rootbacktrack.cc, ccend);
8202  if (private_data_size < 0)  if (private_data_size < 0)
8203    {    {
# Line 7893  if (private_data_size < 0) Line 8209  if (private_data_size < 0)
8209  if (mode == JIT_COMPILE && (re->flags & PCRE_REQCHSET) != 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)  if (mode == JIT_COMPILE && (re->flags & PCRE_REQCHSET) != 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
8210    {    {
8211    common->req_char_ptr = common->ovector_start;    common->req_char_ptr = common->ovector_start;
8212    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
8213    }    }
8214  if (mode != JIT_COMPILE)  if (mode != JIT_COMPILE)
8215    {    {
8216    common->start_used_ptr = common->ovector_start;    common->start_used_ptr = common->ovector_start;
8217    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
8218    if (mode == JIT_PARTIAL_SOFT_COMPILE)    if (mode == JIT_PARTIAL_SOFT_COMPILE)
8219      {      {
8220      common->hit_start = common->ovector_start;      common->hit_start = common->ovector_start;
8221      common->ovector_start += sizeof(sljit_w);      common->ovector_start += sizeof(sljit_sw);
8222      }      }
8223    }    }
8224  if ((re->options & PCRE_FIRSTLINE) != 0)  if ((re->options & PCRE_FIRSTLINE) != 0)
8225    {    {
8226    common->first_line_end = common->ovector_start;    common->first_line_end = common->ovector_start;
8227    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
8228    }    }
8229    
8230  /* Aligning ovector to even number of sljit words. */  /* Aligning ovector to even number of sljit words. */
8231  if ((common->ovector_start & sizeof(sljit_w)) != 0)  if ((common->ovector_start & sizeof(sljit_sw)) != 0)
8232    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
8233    
8234    /* Capturing brackets cannot be optimized if callouts are allowed. */
8235    if (common->capture_last_ptr != 0)
8236      memset(common->optimized_cbracket, 0, re->top_bracket + 1);
8237    
8238  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
8239  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_w);  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);
8240  private_data_size += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w);  private_data_size += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_sw);
8241  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
8242    {    {
8243    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket);
# Line 7930  if (!common->private_data_ptrs) Line 8250  if (!common->private_data_ptrs)
8250    return;    return;
8251    }    }
8252  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));
8253  set_private_data_ptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w), ccend);  set_private_data_ptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_sw), ccend);
8254    
8255  compiler = sljit_create_compiler();  compiler = sljit_create_compiler();
8256  if (!compiler)  if (!compiler)
# Line 7947  sljit_emit_enter(compiler, 1, 5, 5, priv Line 8267  sljit_emit_enter(compiler, 1, 5, 5, priv
8267  /* Register init. */  /* Register init. */
8268  reset_ovector(common, (re->top_bracket + 1) * 2);  reset_ovector(common, (re->top_bracket + 1) * 2);
8269  if (common->req_char_ptr != 0)  if (common->req_char_ptr != 0)
8270    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->req_char_ptr, SLJIT_TEMPORARY_REG1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->req_char_ptr, SLJIT_SCRATCH_REG1, 0);
8271    
8272  OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_SAVED_REG1, 0);  OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_SAVED_REG1, 0);
8273  OP1(SLJIT_MOV, TMP1, 0, SLJIT_SAVED_REG1, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_SAVED_REG1, 0);
8274  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));
8275  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));
8276  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));
8277  OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, calllimit));  OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, call_limit));
8278  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));
8279  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));
8280  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT, TMP1, 0);
# Line 7979  if ((re->options & PCRE_ANCHORED) == 0) Line 8299  if ((re->options & PCRE_ANCHORED) == 0)
8299        fast_forward_start_bits(common, (sljit_uw)study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);        fast_forward_start_bits(common, (sljit_uw)study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);
8300      }      }
8301    }    }
8302    if (mode == JIT_COMPILE && study->minlength > 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
8303      {
8304      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8305      OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength));
8306      minlength_check_failed = CMP(SLJIT_C_GREATER, TMP2, 0, STR_END, 0);
8307      }
8308  if (common->req_char_ptr != 0)  if (common->req_char_ptr != 0)
8309    reqbyte_notfound = search_requested_char(common, (pcre_uchar)re->req_char, (re->flags & PCRE_RCH_CASELESS) != 0, (re->flags & PCRE_FIRSTSET) != 0);    reqbyte_notfound = search_requested_char(common, (pcre_uchar)re->req_char, (re->flags & PCRE_RCH_CASELESS) != 0, (re->flags & PCRE_FIRSTSET) != 0);
8310    
# Line 7988  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_R Line 8314  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_R
8314  OP1(SLJIT_MOV, CALL_COUNT, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT);  OP1(SLJIT_MOV, CALL_COUNT, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT);
8315  if (common->mark_ptr != 0)  if (common->mark_ptr != 0)
8316    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, SLJIT_IMM, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, SLJIT_IMM, 0);
8317    if (common->capture_last_ptr != 0)
8318      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, -1);
8319  /* Copy the beginning of the string. */  /* Copy the beginning of the string. */
8320  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8321    {    {
# Line 8010  if (SLJIT_UNLIKELY(sljit_get_compiler_er Line 8338  if (SLJIT_UNLIKELY(sljit_get_compiler_er
8338  empty_match = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));  empty_match = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
8339  empty_match_found = LABEL();  empty_match_found = LABEL();
8340    
8341  common->acceptlabel = LABEL();  common->accept_label = LABEL();
8342  if (common->accept != NULL)  if (common->accept != NULL)
8343    set_jumps(common->accept, common->acceptlabel);    set_jumps(common->accept, common->accept_label);
8344    
8345  /* This means we have a match. Update the ovector. */  /* This means we have a match. Update the ovector. */
8346  copy_ovector(common, re->top_bracket + 1);  copy_ovector(common, re->top_bracket + 1);
8347  common->quitlabel = LABEL();  common->quit_label = common->forced_quit_label = LABEL();
8348  if (common->quit != NULL)  if (common->quit != NULL)
8349    set_jumps(common->quit, common->quitlabel);    set_jumps(common->quit, common->quit_label);
8350    if (common->forced_quit != NULL)
8351      set_jumps(common->forced_quit, common->forced_quit_label);
8352    if (minlength_check_failed != NULL)
8353      SET_LABEL(minlength_check_failed, common->forced_quit_label);
8354  sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);  sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
8355    
8356  if (mode != JIT_COMPILE)  if (mode != JIT_COMPILE)
8357    {    {
8358    common->partialmatchlabel = LABEL();    common->partialmatchlabel = LABEL();
8359    set_jumps(common->partialmatch, common->partialmatchlabel);    set_jumps(common->partialmatch, common->partialmatchlabel);
8360    return_with_partial_match(common, common->quitlabel);    return_with_partial_match(common, common->quit_label);
8361    }    }
8362    
8363  empty_match_backtrack = LABEL();  empty_match_backtrack = LABEL();
# Line 8051  if (mode == JIT_PARTIAL_SOFT_COMPILE) Line 8383  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8383    }    }
8384    
8385  /* Check we have remaining characters. */  /* Check we have remaining characters. */
8386    if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_FIRSTLINE) != 0)
8387      {
8388      SLJIT_ASSERT(common->first_line_end != 0);
8389      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);
8390      }
8391  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
8392    
8393  if ((re->options & PCRE_ANCHORED) == 0)  if ((re->options & PCRE_ANCHORED) == 0)
8394    {    {
8395    if ((re->options & PCRE_FIRSTLINE) == 0)    if ((re->options & PCRE_FIRSTLINE) == 0)
8396      {      CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop);
     if (mode == JIT_COMPILE && study != NULL && study->minlength > 1 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)  
       {  
       OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength + 1));  
       CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);  
       }  
     else  
       CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop);  
     }  
8397    else    else
8398      {      CMPTO(SLJIT_C_LESS, STR_PTR, 0, TMP1, 0, mainloop);
     SLJIT_ASSERT(common->first_line_end != 0);  
     if (mode == JIT_COMPILE && study != NULL && study->minlength > 1 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)  
       {  
       OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength + 1));  
       OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0);  
       COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);  
       OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);  
       COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_GREATER_EQUAL);  
       JUMPTO(SLJIT_C_ZERO, mainloop);  
       }  
     else  
       CMPTO(SLJIT_C_LESS, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, mainloop);  
     }  
8399    }    }
8400    
8401  /* No more remaining characters. */  /* No more remaining characters. */
# Line 8090  if (mode == JIT_PARTIAL_SOFT_COMPILE) Line 8406  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8406    CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0, common->partialmatchlabel);    CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0, common->partialmatchlabel);
8407    
8408  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8409  JUMPTO(SLJIT_JUMP, common->quitlabel);  JUMPTO(SLJIT_JUMP, common->quit_label);
8410    
8411  flush_stubs(common);  flush_stubs(common);
8412    
# Line 8144  sljit_emit_fast_return(compiler, SLJIT_M Line 8460  sljit_emit_fast_return(compiler, SLJIT_M
8460  JUMPHERE(jump);  JUMPHERE(jump);
8461  /* We break the return address cache here, but this is a really rare case. */  /* We break the return address cache here, but this is a really rare case. */
8462  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_JIT_STACKLIMIT);  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_JIT_STACKLIMIT);
8463  JUMPTO(SLJIT_JUMP, common->quitlabel);  JUMPTO(SLJIT_JUMP, common->quit_label);
8464    
8465  /* Call limit reached. */  /* Call limit reached. */
8466  set_jumps(common->calllimit, LABEL());  set_jumps(common->calllimit, LABEL());
8467  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_MATCHLIMIT);  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_MATCHLIMIT);
8468  JUMPTO(SLJIT_JUMP, common->quitlabel);  JUMPTO(SLJIT_JUMP, common->quit_label);
8469    
8470  if (common->revertframes != NULL)  if (common->revertframes != NULL)
8471    {    {
# Line 8241  else Line 8557  else
8557      return;      return;
8558      }      }
8559    memset(functions, 0, sizeof(executable_functions));    memset(functions, 0, sizeof(executable_functions));
8560      functions->top_bracket = (re->top_bracket + 1) * 2;
8561    extra->executable_jit = functions;    extra->executable_jit = functions;
8562    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;
8563    }    }
# Line 8258  union { Line 8575  union {
8575  pcre_uint8 local_space[MACHINE_STACK_SIZE];  pcre_uint8 local_space[MACHINE_STACK_SIZE];
8576  struct sljit_stack local_stack;  struct sljit_stack local_stack;
8577    
8578  local_stack.top = (sljit_w)&local_space;  local_stack.top = (sljit_sw)&local_space;
8579  local_stack.base = local_stack.top;  local_stack.base = local_stack.top;
8580  local_stack.limit = local_stack.base + MACHINE_STACK_SIZE;  local_stack.limit = local_stack.base + MACHINE_STACK_SIZE;
8581  local_stack.max_limit = local_stack.limit;  local_stack.max_limit = local_stack.limit;
# Line 8268  return convert_executable_func.call_exec Line 8585  return convert_executable_func.call_exec
8585  }  }
8586    
8587  int  int
8588  PRIV(jit_exec)(const REAL_PCRE *re, const PUBL(extra) *extra_data, const pcre_uchar *subject,  PRIV(jit_exec)(const PUBL(extra) *extra_data, const pcre_uchar *subject,
8589    int length, int start_offset, int options, int *offsets, int offsetcount)    int length, int start_offset, int options, int *offsets, int offset_count)
8590  {  {
8591  executable_functions *functions = (executable_functions *)extra_data->executable_jit;  executable_functions *functions = (executable_functions *)extra_data->executable_jit;
8592  union {  union {
# Line 8277  union { Line 8594  union {
8594     jit_function call_executable_func;     jit_function call_executable_func;
8595  } convert_executable_func;  } convert_executable_func;
8596  jit_arguments arguments;  jit_arguments arguments;
8597  int maxoffsetcount;  int max_offset_count;
8598  int retval;  int retval;
8599  int mode = JIT_COMPILE;  int mode = JIT_COMPILE;
8600    
# Line 8287  else if ((options & PCRE_PARTIAL_SOFT) ! Line 8604  else if ((options & PCRE_PARTIAL_SOFT) !
8604    mode = JIT_PARTIAL_SOFT_COMPILE;    mode = JIT_PARTIAL_SOFT_COMPILE;
8605    
8606  if (functions->executable_funcs[mode] == NULL)  if (functions->executable_funcs[mode] == NULL)
8607    return PCRE_ERROR_NULL;    return PCRE_ERROR_JIT_BADOPTION;
8608    
8609  /* Sanity checks should be handled by pcre_exec. */  /* Sanity checks should be handled by pcre_exec. */
 arguments.stack = NULL;  
8610  arguments.str = subject + start_offset;  arguments.str = subject + start_offset;
8611  arguments.begin = subject;  arguments.begin = subject;
8612  arguments.end = subject + length;  arguments.end = subject + length;
8613  arguments.mark_ptr = NULL;  arguments.mark_ptr = NULL;
8614  /* JIT decreases this value less frequently than the interpreter. */  /* JIT decreases this value less frequently than the interpreter. */
8615  arguments.calllimit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;  arguments.call_limit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;
8616  arguments.notbol = (options & PCRE_NOTBOL) != 0;  arguments.notbol = (options & PCRE_NOTBOL) != 0;
8617  arguments.noteol = (options & PCRE_NOTEOL) != 0;  arguments.noteol = (options & PCRE_NOTEOL) != 0;
8618  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
8619  arguments.notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;  arguments.notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
8620  arguments.offsets = offsets;  arguments.offsets = offsets;
8621    arguments.callout_data = (extra_data->flags & PCRE_EXTRA_CALLOUT_DATA) != 0 ? extra_data->callout_data : NULL;
8622    
8623  /* pcre_exec() rounds offsetcount to a multiple of 3, and then uses only 2/3 of  /* pcre_exec() rounds offset_count to a multiple of 3, and then uses only 2/3 of
8624  the output vector for storing captured strings, with the remainder used as  the output vector for storing captured strings, with the remainder used as
8625  workspace. We don't need the workspace here. For compatibility, we limit the  workspace. We don't need the workspace here. For compatibility, we limit the
8626  number of captured strings in the same way as pcre_exec(), so that the user  number of captured strings in the same way as pcre_exec(), so that the user
8627  gets the same result with and without JIT. */  gets the same result with and without JIT. */
8628    
8629  if (offsetcount != 2)  if (offset_count != 2)
8630    offsetcount = ((offsetcount - (offsetcount % 3)) * 2) / 3;    offset_count = ((offset_count - (offset_count % 3)) * 2) / 3;
8631  maxoffsetcount = (re->top_bracket + 1) * 2;  max_offset_count = functions->top_bracket;
8632  if (offsetcount > maxoffsetcount)  if (offset_count > max_offset_count)
8633    offsetcount = maxoffsetcount;    offset_count = max_offset_count;
8634  arguments.offsetcount = offsetcount;  arguments.offset_count = offset_count;
8635    
8636  if (functions->callback)  if (functions->callback)
8637    arguments.stack = (struct sljit_stack *)functions->callback(functions->userdata);    arguments.stack = (struct sljit_stack *)functions->callback(functions->userdata);
# Line 8329  else Line 8646  else
8646    retval = convert_executable_func.call_executable_func(&arguments);    retval = convert_executable_func.call_executable_func(&arguments);
8647    }    }
8648    
8649  if (retval * 2 > offsetcount)  if (retval * 2 > offset_count)
8650      retval = 0;
8651    if ((extra_data->flags & PCRE_EXTRA_MARK) != 0)
8652      *(extra_data->mark) = arguments.mark_ptr;
8653    
8654    return retval;
8655    }
8656    
8657    #if defined COMPILE_PCRE8
8658    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
8659    pcre_jit_exec(const pcre *argument_re, const pcre_extra *extra_data,
8660      PCRE_SPTR subject, int length, int start_offset, int options,
8661      int *offsets, int offset_count, pcre_jit_stack *stack)
8662    #elif defined COMPILE_PCRE16
8663    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
8664    pcre16_jit_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
8665      PCRE_SPTR16 subject, int length, int start_offset, int options,
8666      int *offsets, int offset_count, pcre16_jit_stack *stack)
8667    #elif defined COMPILE_PCRE32
8668    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
8669    pcre32_jit_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
8670      PCRE_SPTR32 subject, int length, int start_offset, int options,
8671      int *offsets, int offset_count, pcre32_jit_stack *stack)
8672    #endif
8673    {
8674    pcre_uchar *subject_ptr = (pcre_uchar *)subject;
8675    executable_functions *functions = (executable_functions *)extra_data->executable_jit;
8676    union {
8677       void* executable_func;
8678       jit_function call_executable_func;
8679    } convert_executable_func;
8680    jit_arguments arguments;
8681    int max_offset_count;
8682    int retval;
8683    int mode = JIT_COMPILE;
8684    
8685    SLJIT_UNUSED_ARG(argument_re);
8686    
8687    /* Plausibility checks */
8688    if ((options & ~PUBLIC_JIT_EXEC_OPTIONS) != 0) return PCRE_ERROR_JIT_BADOPTION;
8689    
8690    if ((options & PCRE_PARTIAL_HARD) != 0)
8691      mode = JIT_PARTIAL_HARD_COMPILE;
8692    else if ((options & PCRE_PARTIAL_SOFT) != 0)
8693      mode = JIT_PARTIAL_SOFT_COMPILE;
8694    
8695    if (functions->executable_funcs[mode] == NULL)
8696      return PCRE_ERROR_JIT_BADOPTION;
8697    
8698    /* Sanity checks should be handled by pcre_exec. */
8699    arguments.stack = (struct sljit_stack *)stack;
8700    arguments.str = subject_ptr + start_offset;
8701    arguments.begin = subject_ptr;
8702    arguments.end = subject_ptr + length;
8703    arguments.mark_ptr = NULL;