/[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 1252 by zherczeg, Fri Feb 22 11:13:38 2013 UTC revision 1275 by zherczeg, Sun Mar 10 05:32:10 2013 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2012 University of Cambridge             Copyright (c) 1997-2013 University of Cambridge
10    
11    The machine code generator part (this module) was written by Zoltan Herczeg    The machine code generator part (this module) was written by Zoltan Herczeg
12                        Copyright (c) 2010-2012                        Copyright (c) 2010-2013
13    
14  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
15  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 71  system files. */ Line 71  system files. */
71     2 - Enable capture_last_ptr (includes option 1). */     2 - Enable capture_last_ptr (includes option 1). */
72  /* #define DEBUG_FORCE_UNOPTIMIZED_CBRAS 2 */  /* #define DEBUG_FORCE_UNOPTIMIZED_CBRAS 2 */
73    
74    /* 1 - Always have a control head. */
75    /* #define DEBUG_FORCE_CONTROL_HEAD 1 */
76    
77  /* Allocate memory for the regex stack on the real machine stack.  /* Allocate memory for the regex stack on the real machine stack.
78  Fast, but limited size. */  Fast, but limited size. */
79  #define MACHINE_STACK_SIZE 32768  #define MACHINE_STACK_SIZE 32768
# Line 193  typedef struct stub_list { Line 196  typedef struct stub_list {
196    struct stub_list *next;    struct stub_list *next;
197  } stub_list;  } stub_list;
198    
199  enum frame_types { no_frame = -1, no_stack = -2 };  enum frame_types {
200      no_frame = -1,
201      no_stack = -2
202    };
203    
204    enum control_types {
205      type_commit = 0,
206      type_prune = 1,
207      type_skip = 2
208    };
209    
210  typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);  typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);
211    
# Line 282  typedef struct recurse_backtrack { Line 294  typedef struct recurse_backtrack {
294  #define MAX_RANGE_SIZE 6  #define MAX_RANGE_SIZE 6
295    
296  typedef struct compiler_common {  typedef struct compiler_common {
297      /* The sljit ceneric compiler. */
298    struct sljit_compiler *compiler;    struct sljit_compiler *compiler;
299      /* First byte code. */
300    pcre_uchar *start;    pcre_uchar *start;
   
301    /* Maps private data offset to each opcode. */    /* Maps private data offset to each opcode. */
302    int *private_data_ptrs;    int *private_data_ptrs;
303    /* Tells whether the capturing bracket is optimized. */    /* Tells whether the capturing bracket is optimized. */
304    pcre_uint8 *optimized_cbracket;    pcre_uint8 *optimized_cbracket;
305    /* Starting offset of private data for capturing brackets. */    /* Starting offset of private data for capturing brackets. */
306    int cbraptr;    int cbra_ptr;
307    /* OVector starting point. Must be divisible by 2. */    /* Output vector starting point. Must be divisible by 2. */
308    int ovector_start;    int ovector_start;
309    /* Last known position of the requested byte. */    /* Last known position of the requested byte. */
310    int req_char_ptr;    int req_char_ptr;
# Line 305  typedef struct compiler_common { Line 318  typedef struct compiler_common {
318    int first_line_end;    int first_line_end;
319    /* Points to the marked string. */    /* Points to the marked string. */
320    int mark_ptr;    int mark_ptr;
321      /* Recursive control verb management chain. */
322      int control_head_ptr;
323    /* Points to the last matched capture block index. */    /* Points to the last matched capture block index. */
324    int capture_last_ptr;    int capture_last_ptr;
325      /* Points to the starting position of the current match. */
326      int start_ptr;
327    
328    /* Flipped and lower case tables. */    /* Flipped and lower case tables. */
329    const pcre_uint8 *fcc;    const pcre_uint8 *fcc;
330    sljit_sw lcc;    sljit_sw lcc;
331    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */
332    int mode;    int mode;
333      /* \K is in the pattern. */
334      BOOL has_set_som;
335      /* Needs to know the start position anytime. */
336      BOOL needs_start_ptr;
337      /* Currently in recurse or assert. */
338      BOOL local_exit;
339    /* Newline control. */    /* Newline control. */
340    int nltype;    int nltype;
341    int newline;    int newline;
342    int bsr_nltype;    int bsr_nltype;
343    /* Dollar endonly. */    /* Dollar endonly. */
344    int endonly;    int endonly;
   BOOL has_set_som;  
345    /* Tables. */    /* Tables. */
346    sljit_sw ctypes;    sljit_sw ctypes;
347    int digits[2 + MAX_RANGE_SIZE];    int digits[2 + MAX_RANGE_SIZE];
# Line 349  typedef struct compiler_common { Line 371  typedef struct compiler_common {
371    jump_list *vspace;    jump_list *vspace;
372    jump_list *casefulcmp;    jump_list *casefulcmp;
373    jump_list *caselesscmp;    jump_list *caselesscmp;
374      jump_list *reset_match;
375    BOOL jscript_compat;    BOOL jscript_compat;
376  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
377    BOOL utf;    BOOL utf;
# Line 433  group contains the start / end character Line 456  group contains the start / end character
456  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. */
457  #define OVECTOR_START    (common->ovector_start)  #define OVECTOR_START    (common->ovector_start)
458  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))
459  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_sw))  #define OVECTOR_PRIV(i)  (common->cbra_ptr + (i) * sizeof(sljit_sw))
460  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
461    
462  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
# Line 572  switch(*cc) Line 595  switch(*cc)
595    case OP_BRAZERO:    case OP_BRAZERO:
596    case OP_BRAMINZERO:    case OP_BRAMINZERO:
597    case OP_BRAPOSZERO:    case OP_BRAPOSZERO:
598      case OP_PRUNE:
599      case OP_SKIP:
600    case OP_COMMIT:    case OP_COMMIT:
601    case OP_FAIL:    case OP_FAIL:
602    case OP_ACCEPT:    case OP_ACCEPT:
# Line 670  switch(*cc) Line 695  switch(*cc)
695  #endif  #endif
696    
697    case OP_MARK:    case OP_MARK:
698      case OP_PRUNE_ARG:
699    return cc + 1 + 2 + cc[1];    return cc + 1 + 2 + cc[1];
700    
701    default:    default:
# Line 921  while (cc < ccend) Line 947  while (cc < ccend)
947      cc += 2 + 2 * LINK_SIZE;      cc += 2 + 2 * LINK_SIZE;
948      break;      break;
949    
950        case OP_PRUNE_ARG:
951        common->needs_start_ptr = TRUE;
952        common->control_head_ptr = 1;
953        /* Fall through. */
954    
955      case OP_MARK:      case OP_MARK:
956      if (common->mark_ptr == 0)      if (common->mark_ptr == 0)
957        {        {
# Line 930  while (cc < ccend) Line 961  while (cc < ccend)
961      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
962      break;      break;
963    
964        case OP_PRUNE:
965        case OP_SKIP:
966        common->needs_start_ptr = TRUE;
967        /* Fall through. */
968    
969        case OP_COMMIT:
970        common->control_head_ptr = 1;
971        cc += 1;
972        break;
973    
974      default:      default:
975      cc = next_opcode(common, cc);      cc = next_opcode(common, cc);
976      if (cc == NULL)      if (cc == NULL)
# Line 1142  while (cc < ccend) Line 1183  while (cc < ccend)
1183      break;      break;
1184    
1185      case OP_MARK:      case OP_MARK:
1186        case OP_PRUNE_ARG:
1187      SLJIT_ASSERT(common->mark_ptr != 0);      SLJIT_ASSERT(common->mark_ptr != 0);
1188      stack_restore = TRUE;      stack_restore = TRUE;
1189      if (!setmark_found)      if (!setmark_found)
# Line 1304  while (cc < ccend) Line 1346  while (cc < ccend)
1346      break;      break;
1347    
1348      case OP_MARK:      case OP_MARK:
1349        case OP_PRUNE_ARG:
1350      SLJIT_ASSERT(common->mark_ptr != 0);      SLJIT_ASSERT(common->mark_ptr != 0);
1351      if (!setmark_found)      if (!setmark_found)
1352        {        {
# Line 1386  SLJIT_ASSERT(stackpos == STACK(stacktop) Line 1429  SLJIT_ASSERT(stackpos == STACK(stacktop)
1429    
1430  static SLJIT_INLINE int get_private_data_length_for_copy(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)  static SLJIT_INLINE int get_private_data_length_for_copy(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)
1431  {  {
1432  int private_data_length = 2;  int private_data_length = common->control_head_ptr ? 3 : 2;
1433  int size;  int size;
1434  pcre_uchar *alternative;  pcre_uchar *alternative;
1435  /* Calculate the sum of the private machine words. */  /* Calculate the sum of the private machine words. */
# Line 1520  stacktop = STACK(stacktop - 1); Line 1563  stacktop = STACK(stacktop - 1);
1563    
1564  if (!save)  if (!save)
1565    {    {
1566    stackptr += sizeof(sljit_sw);    stackptr += (common->control_head_ptr ? 2 : 1) * sizeof(sljit_sw);
1567    if (stackptr < stacktop)    if (stackptr < stacktop)
1568      {      {
1569      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
# Line 1536  if (!save) Line 1579  if (!save)
1579    /* The tmp1next must be TRUE in either way. */    /* The tmp1next must be TRUE in either way. */
1580    }    }
1581    
1582  while (status != end)  do
1583    {    {
1584    count = 0;    count = 0;
1585    switch(status)    switch(status)
# Line 1545  while (status != end) Line 1588  while (status != end)
1588      SLJIT_ASSERT(save && common->recursive_head_ptr != 0);      SLJIT_ASSERT(save && common->recursive_head_ptr != 0);
1589      count = 1;      count = 1;
1590      srcw[0] = common->recursive_head_ptr;      srcw[0] = common->recursive_head_ptr;
1591        if (common->control_head_ptr != 0)
1592          {
1593          count = 2;
1594          srcw[1] = common->control_head_ptr;
1595          }
1596      status = loop;      status = loop;
1597      break;      break;
1598    
# Line 1769  while (status != end) Line 1817  while (status != end)
1817        }        }
1818      }      }
1819    }    }
1820    while (status != end);
1821    
1822  if (save)  if (save)
1823    {    {
# Line 1900  static SLJIT_INLINE void reset_ovector(c Line 1949  static SLJIT_INLINE void reset_ovector(c
1949  DEFINE_COMPILER;  DEFINE_COMPILER;
1950  struct sljit_label *loop;  struct sljit_label *loop;
1951  int i;  int i;
1952    
1953  /* At this point we can freely use all temporary registers. */  /* At this point we can freely use all temporary registers. */
1954    SLJIT_ASSERT(length > 1);
1955  /* TMP1 returns with begin - 1. */  /* TMP1 returns with begin - 1. */
1956  OP2(SLJIT_SUB, SLJIT_SCRATCH_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));
1957  if (length < 8)  if (length < 8)
1958    {    {
1959    for (i = 0; i < length; i++)    for (i = 1; i < length; i++)
1960      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(i), SLJIT_SCRATCH_REG1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(i), SLJIT_SCRATCH_REG1, 0);
1961    }    }
1962  else  else
1963    {    {
1964    GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, OVECTOR_START - sizeof(sljit_sw));    GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, OVECTOR_START);
1965    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, length);    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, length - 1);
1966    loop = LABEL();    loop = LABEL();
1967    OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_SCRATCH_REG2), sizeof(sljit_sw), SLJIT_SCRATCH_REG1, 0);    OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_SCRATCH_REG2), sizeof(sljit_sw), SLJIT_SCRATCH_REG1, 0);
1968    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, 1);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, 1);
# Line 1919  else Line 1970  else
1970    }    }
1971  }  }
1972    
1973    static SLJIT_INLINE void do_reset_match(compiler_common *common, int length)
1974    {
1975    DEFINE_COMPILER;
1976    struct sljit_label *loop;
1977    int i;
1978    
1979    SLJIT_ASSERT(length > 1);
1980    /* OVECTOR(1) contains the "string begin - 1" constant. */
1981    if (length > 2)
1982      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));
1983    if (length < 8)
1984      {
1985      for (i = 2; i < length; i++)
1986        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(i), TMP1, 0);
1987      }
1988    else
1989      {
1990      GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + sizeof(sljit_sw));
1991      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, length - 2);
1992      loop = LABEL();
1993      OP1(SLJIT_MOVU, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);
1994      OP2(SLJIT_SUB | SLJIT_SET_E, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 1);
1995      JUMPTO(SLJIT_C_NOT_ZERO, loop);
1996      }
1997    
1998    OP1(SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0);
1999    if (common->mark_ptr != 0)
2000      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, SLJIT_IMM, 0);
2001    SLJIT_ASSERT(common->control_head_ptr != 0);
2002    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_IMM, 0);
2003    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack));
2004    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_ptr);
2005    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(struct sljit_stack, base));
2006    }
2007    
2008    static sljit_sw do_check_control_chain(sljit_sw *current)
2009    {
2010    sljit_sw return_value = 0;
2011    
2012    SLJIT_ASSERT(current != NULL);
2013    do
2014      {
2015      switch (current[-2])
2016        {
2017        case type_commit:
2018        /* Commit overwrites all. */
2019        return -1;
2020    
2021        case type_prune:
2022        break;
2023    
2024        case type_skip:
2025        /* Overwrites prune, but not other skips. */
2026        if (return_value == 0)
2027          return_value = current[-3];
2028        break;
2029    
2030        default:
2031        SLJIT_ASSERT_STOP();
2032        break;
2033        }
2034      current = (sljit_sw*)current[-1];
2035      }
2036    while (current != NULL);
2037    return return_value;
2038    }
2039    
2040  static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)  static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)
2041  {  {
2042  DEFINE_COMPILER;  DEFINE_COMPILER;
# Line 1975  DEFINE_COMPILER; Line 2093  DEFINE_COMPILER;
2093  struct sljit_jump *jump;  struct sljit_jump *jump;
2094    
2095  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);
2096  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->start_ptr != 0
2097      && (common->mode == JIT_PARTIAL_SOFT_COMPILE ? common->hit_start != 0 : common->hit_start == 0));
2098    
2099  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, ARGUMENTS, 0);
2100  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_PARTIAL);  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_PARTIAL);
# Line 1987  OP1(SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJI Line 2106  OP1(SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJI
2106  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG2), SLJIT_OFFSETOF(jit_arguments, offsets));  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, SLJIT_MEM1(SLJIT_SCRATCH_REG2), SLJIT_OFFSETOF(jit_arguments, offsets));
2107    
2108  jump = CMP(SLJIT_C_SIG_LESS, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, 3);  jump = CMP(SLJIT_C_SIG_LESS, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, 3);
2109  OP2(SLJIT_SUB, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), (common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_used_ptr : common->hit_start) + sizeof(sljit_sw), SLJIT_SAVED_REG1, 0);  OP2(SLJIT_SUB, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_ptr : (common->hit_start + sizeof(sljit_sw)), SLJIT_SAVED_REG1, 0);
2110  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
2111  OP2(SLJIT_ASHR, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, UCHAR_SHIFT);  OP2(SLJIT_ASHR, SLJIT_SCRATCH_REG3, 0, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, UCHAR_SHIFT);
2112  #endif  #endif
# Line 2170  else if (common->mode == JIT_PARTIAL_SOF Line 2289  else if (common->mode == JIT_PARTIAL_SOF
2289    jump = CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, SLJIT_IMM, -1);    jump = CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, SLJIT_IMM, -1);
2290    
2291  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
2292    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0);
2293  else  else
2294    {    {
2295    if (common->partialmatchlabel != NULL)    if (common->partialmatchlabel != NULL)
# Line 2183  if (jump != NULL) Line 2302  if (jump != NULL)
2302    JUMPHERE(jump);    JUMPHERE(jump);
2303  }  }
2304    
2305  static struct sljit_jump *check_str_end(compiler_common *common)  static void check_str_end(compiler_common *common, jump_list **end_reached)
2306  {  {
2307  /* Does not affect registers. Usually used in a tight spot. */  /* Does not affect registers. Usually used in a tight spot. */
2308  DEFINE_COMPILER;  DEFINE_COMPILER;
2309  struct sljit_jump *jump;  struct sljit_jump *jump;
 struct sljit_jump *nohit;  
 struct sljit_jump *return_value;  
2310    
2311  if (common->mode == JIT_COMPILE)  if (common->mode == JIT_COMPILE)
2312    return CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    {
2313      add_jump(compiler, end_reached, CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
2314      return;
2315      }
2316    
2317  jump = CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0);  jump = CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0);
2318  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
2319    {    {
2320    nohit = CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0);    add_jump(compiler, end_reached, CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0));
2321    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0);
2322    JUMPHERE(nohit);    add_jump(compiler, end_reached, JUMP(SLJIT_JUMP));
   return_value = JUMP(SLJIT_JUMP);  
2323    }    }
2324  else  else
2325    {    {
2326    return_value = CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0);    add_jump(compiler, end_reached, CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0));
2327    if (common->partialmatchlabel != NULL)    if (common->partialmatchlabel != NULL)
2328      JUMPTO(SLJIT_JUMP, common->partialmatchlabel);      JUMPTO(SLJIT_JUMP, common->partialmatchlabel);
2329    else    else
2330      add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));      add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));
2331    }    }
2332  JUMPHERE(jump);  JUMPHERE(jump);
 return return_value;  
2333  }  }
2334    
2335  static void detect_partial_match(compiler_common *common, jump_list **backtracks)  static void detect_partial_match(compiler_common *common, jump_list **backtracks)
# Line 2230  jump = CMP(SLJIT_C_LESS, STR_PTR, 0, STR Line 2348  jump = CMP(SLJIT_C_LESS, STR_PTR, 0, STR
2348  add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0));  add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0));
2349  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
2350    {    {
2351    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0);
2352    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
2353    }    }
2354  else  else
# Line 3178  static void check_wordboundary(compiler_ Line 3296  static void check_wordboundary(compiler_
3296  {  {
3297  DEFINE_COMPILER;  DEFINE_COMPILER;
3298  struct sljit_jump *skipread;  struct sljit_jump *skipread;
3299    jump_list *skipread_list = NULL;
3300  #if !(defined COMPILE_PCRE8) || defined SUPPORT_UTF  #if !(defined COMPILE_PCRE8) || defined SUPPORT_UTF
3301  struct sljit_jump *jump;  struct sljit_jump *jump;
3302  #endif  #endif
# Line 3235  else Line 3354  else
3354  JUMPHERE(skipread);  JUMPHERE(skipread);
3355    
3356  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);
3357  skipread = check_str_end(common);  check_str_end(common, &skipread_list);
3358  peek_char(common);  peek_char(common);
3359    
3360  /* Testing char type. This is a code duplication. */  /* Testing char type. This is a code duplication. */
# Line 3276  else Line 3395  else
3395      JUMPHERE(jump);      JUMPHERE(jump);
3396  #endif /* COMPILE_PCRE8 */  #endif /* COMPILE_PCRE8 */
3397    }    }
3398  JUMPHERE(skipread);  set_jumps(skipread_list, LABEL());
3399    
3400  OP2(SLJIT_XOR | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1);  OP2(SLJIT_XOR | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1);
3401  sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);  sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
# Line 3916  while (*cc != XCL_END) Line 4035  while (*cc != XCL_END)
4035        break;        break;
4036    
4037        case PT_CLIST:        case PT_CLIST:
4038          case PT_UCNC:
4039        needschar = TRUE;        needschar = TRUE;
4040        break;        break;
4041    
# Line 4181  while (*cc != XCL_END) Line 4301  while (*cc != XCL_END)
4301          }          }
4302        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);        jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4303        break;        break;
4304    
4305          case PT_UCNC:
4306          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_DOLLAR_SIGN - charoffset);
4307          OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_C_EQUAL);
4308          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_COMMERCIAL_AT - charoffset);
4309          OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4310          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_GRAVE_ACCENT - charoffset);
4311          OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_EQUAL);
4312    
4313          SET_CHAR_OFFSET(0xa0);
4314          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd7ff - charoffset);
4315          OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_C_LESS_EQUAL);
4316          SET_CHAR_OFFSET(0);
4317          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xe000 - 0);
4318          OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_C_GREATER_EQUAL);
4319          jump = JUMP(SLJIT_C_NOT_ZERO ^ invertcmp);
4320          break;
4321        }        }
4322      cc += 2;      cc += 2;
4323      }      }
# Line 4206  int length; Line 4343  int length;
4343  unsigned int c, oc, bit;  unsigned int c, oc, bit;
4344  compare_context context;  compare_context context;
4345  struct sljit_jump *jump[4];  struct sljit_jump *jump[4];
4346    jump_list *end_list;
4347  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
4348  struct sljit_label *label;  struct sljit_label *label;
4349  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
# Line 4274  switch(type) Line 4412  switch(type)
4412    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
4413      {      {
4414      jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);      jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);
4415        end_list = NULL;
4416      if (common->mode != JIT_PARTIAL_HARD_COMPILE)      if (common->mode != JIT_PARTIAL_HARD_COMPILE)
4417        jump[1] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);        add_jump(compiler, &end_list, CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
4418      else      else
4419        jump[1] = check_str_end(common);        check_str_end(common, &end_list);
4420    
4421      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
4422      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff));      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff));
4423      if (jump[1] != NULL)      set_jumps(end_list, LABEL());
       JUMPHERE(jump[1]);  
4424      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
4425      }      }
4426    else    else
# Line 4341  switch(type) Line 4479  switch(type)
4479    read_char(common);    read_char(common);
4480    jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);    jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
4481    /* We don't need to handle soft partial matching case. */    /* We don't need to handle soft partial matching case. */
4482      end_list = NULL;
4483    if (common->mode != JIT_PARTIAL_HARD_COMPILE)    if (common->mode != JIT_PARTIAL_HARD_COMPILE)
4484      jump[1] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);      add_jump(compiler, &end_list, CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
4485    else    else
4486      jump[1] = check_str_end(common);      check_str_end(common, &end_list);
4487    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
4488    jump[2] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);    jump[1] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);
4489    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));
4490    jump[3] = JUMP(SLJIT_JUMP);    jump[2] = JUMP(SLJIT_JUMP);
4491    JUMPHERE(jump[0]);    JUMPHERE(jump[0]);
4492    check_newlinechar(common, common->bsr_nltype, backtracks, FALSE);    check_newlinechar(common, common->bsr_nltype, backtracks, FALSE);
4493      set_jumps(end_list, LABEL());
4494    JUMPHERE(jump[1]);    JUMPHERE(jump[1]);
4495    JUMPHERE(jump[2]);    JUMPHERE(jump[2]);
   JUMPHERE(jump[3]);  
4496    return cc;    return cc;
4497    
4498    case OP_NOT_HSPACE:    case OP_NOT_HSPACE:
# Line 5228  allocate_stack(common, CALLOUT_ARG_SIZE Line 5367  allocate_stack(common, CALLOUT_ARG_SIZE
5367  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr);
5368  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
5369  SLJIT_ASSERT(common->capture_last_ptr != 0);  SLJIT_ASSERT(common->capture_last_ptr != 0);
5370  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_number), SLJIT_IMM, cc[1]);  OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_number), SLJIT_IMM, cc[1]);
5371  OP1(SLJIT_MOV_UI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(capture_last), TMP2, 0);  OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(capture_last), TMP2, 0);
5372    
5373  /* These pointer sized fields temporarly stores internal variables. */  /* These pointer sized fields temporarly stores internal variables. */
5374  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
# Line 5238  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CA Line 5377  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CA
5377    
5378  if (common->mark_ptr != 0)  if (common->mark_ptr != 0)
5379    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr));    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr));
5380  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position), SLJIT_IMM, GET(cc, 2));  OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position), SLJIT_IMM, GET(cc, 2));
5381  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(next_item_length), SLJIT_IMM, GET(cc, 2 + LINK_SIZE));  OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(next_item_length), SLJIT_IMM, GET(cc, 2 + LINK_SIZE));
5382  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(mark), (common->mark_ptr != 0) ? TMP2 : SLJIT_IMM, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(mark), (common->mark_ptr != 0) ? TMP2 : SLJIT_IMM, 0);
5383    
5384  /* Needed to save important temporary registers. */  /* Needed to save important temporary registers. */
# Line 5268  static pcre_uchar *compile_assert_matchi Line 5407  static pcre_uchar *compile_assert_matchi
5407  {  {
5408  DEFINE_COMPILER;  DEFINE_COMPILER;
5409  int framesize;  int framesize;
5410    int extrasize;
5411    BOOL needs_control_head = common->control_head_ptr != 0;
5412  int private_data_ptr;  int private_data_ptr;
5413  backtrack_common altbacktrack;  backtrack_common altbacktrack;
5414  pcre_uchar *ccbegin;  pcre_uchar *ccbegin;
# Line 5281  struct sljit_label *save_quit_label = co Line 5422  struct sljit_label *save_quit_label = co
5422  struct sljit_label *save_accept_label = common->accept_label;  struct sljit_label *save_accept_label = common->accept_label;
5423  jump_list *save_quit = common->quit;  jump_list *save_quit = common->quit;
5424  jump_list *save_accept = common->accept;  jump_list *save_accept = common->accept;
5425    BOOL save_local_exit = common->local_exit;
5426  struct sljit_jump *jump;  struct sljit_jump *jump;
5427  struct sljit_jump *brajump = NULL;  struct sljit_jump *brajump = NULL;
5428    
# Line 5311  if (bra == OP_BRAMINZERO) Line 5453  if (bra == OP_BRAMINZERO)
5453    
5454  if (framesize < 0)  if (framesize < 0)
5455    {    {
5456    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);    extrasize = needs_control_head ? 2 : 1;
5457    allocate_stack(common, 1);    if (framesize != no_stack)
5458        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);
5459      allocate_stack(common, extrasize);
5460      if (needs_control_head)
5461        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
5462    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5463      if (needs_control_head)
5464        {
5465        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_IMM, 0);
5466        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
5467        }
5468    }    }
5469  else  else
5470    {    {
5471    allocate_stack(common, framesize + 2);    extrasize = needs_control_head ? 3 : 2;
5472      allocate_stack(common, framesize + extrasize);
5473    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);
5474    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(framesize + 1));    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw));
5475    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);
5476      if (needs_control_head)
5477        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
5478    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5479    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);    if (needs_control_head)
5480    init_frame(common, ccbegin, framesize + 1, 2, FALSE);      {
5481        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);
5482        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
5483        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_IMM, 0);
5484        }
5485      else
5486        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
5487      init_frame(common, ccbegin, framesize + extrasize - 1, extrasize, FALSE);
5488    }    }
5489    
5490  memset(&altbacktrack, 0, sizeof(backtrack_common));  memset(&altbacktrack, 0, sizeof(backtrack_common));
5491    common->local_exit = TRUE;
5492  common->quit_label = NULL;  common->quit_label = NULL;
5493  common->quit = NULL;  common->quit = NULL;
5494  while (1)  while (1)
# Line 5343  while (1) Line 5505  while (1)
5505    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);
5506    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5507      {      {
5508        common->local_exit = save_local_exit;
5509      common->quit_label = save_quit_label;      common->quit_label = save_quit_label;
5510      common->accept_label = save_accept_label;      common->accept_label = save_accept_label;
5511      common->quit = save_quit;      common->quit = save_quit;
# Line 5355  while (1) Line 5518  while (1)
5518    
5519    /* Reset stack. */    /* Reset stack. */
5520    if (framesize < 0)    if (framesize < 0)
5521      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);      {
5522    else {      if (framesize != no_stack)
5523          OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5524        else
5525          free_stack(common, extrasize);
5526        if (needs_control_head)
5527          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0);
5528        }
5529      else
5530        {
5531      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)
5532        {        {
5533        /* 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. */
5534        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
5535          if (needs_control_head)
5536            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0);
5537        }        }
5538      else      else
5539        {        {
5540        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);
5541          if (needs_control_head)
5542            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_sw));
5543        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5544        }        }
5545    }      }
5546    
5547    if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)    if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
5548      {      {
5549      /* We know that STR_PTR was stored on the top of the stack. */      /* We know that STR_PTR was stored on the top of the stack. */
5550      if (conditional)      if (conditional)
5551        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? sizeof(sljit_sw) : 0);
5552      else if (bra == OP_BRAZERO)      else if (bra == OP_BRAZERO)
5553        {        {
5554        if (framesize < 0)        if (framesize < 0)
5555          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw));
5556        else        else
5557          {          {
5558          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5559          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_sw));          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + extrasize - 1) * sizeof(sljit_sw));
5560          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);
5561          }          }
5562        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
# Line 5398  while (1) Line 5573  while (1)
5573    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
5574    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5575      {      {
5576        common->local_exit = save_local_exit;
5577      common->quit_label = save_quit_label;      common->quit_label = save_quit_label;
5578      common->accept_label = save_accept_label;      common->accept_label = save_accept_label;
5579      common->quit = save_quit;      common->quit = save_quit;
# Line 5412  while (1) Line 5588  while (1)
5588    ccbegin = cc;    ccbegin = cc;
5589    cc += GET(cc, 1);    cc += GET(cc, 1);
5590    }    }
5591    
5592  /* None of them matched. */  /* None of them matched. */
5593  if (common->quit != NULL)  if (common->quit != NULL)
5594      {
5595      jump = JUMP(SLJIT_JUMP);
5596    set_jumps(common->quit, LABEL());    set_jumps(common->quit, LABEL());
5597      SLJIT_ASSERT(framesize != no_stack);
5598      if (framesize < 0)
5599        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, extrasize * sizeof(sljit_sw));
5600      else
5601        {
5602        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5603        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5604        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw));
5605        }
5606      JUMPHERE(jump);
5607      }
5608    
5609    if (needs_control_head)
5610      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(1));
5611    
5612  if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK)  if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK)
5613    {    {
# Line 5426  if (opcode == OP_ASSERT || opcode == OP_ Line 5619  if (opcode == OP_ASSERT || opcode == OP_
5619      {      {
5620      /* The topmost item should be 0. */      /* The topmost item should be 0. */
5621      if (bra == OP_BRAZERO)      if (bra == OP_BRAZERO)
5622          {
5623          if (extrasize == 2)
5624            free_stack(common, 1);
5625        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5626          }
5627      else      else
5628        free_stack(common, 1);        free_stack(common, extrasize);
5629      }      }
5630    else    else
5631      {      {
5632      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(extrasize - 1));
5633      /* The topmost item should be 0. */      /* The topmost item should be 0. */
5634      if (bra == OP_BRAZERO)      if (bra == OP_BRAZERO)
5635        {        {
5636        free_stack(common, framesize + 1);        free_stack(common, framesize + extrasize - 1);
5637        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5638        }        }
5639      else      else
5640        free_stack(common, framesize + 2);        free_stack(common, framesize + extrasize);
5641      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);
5642      }      }
5643    jump = JUMP(SLJIT_JUMP);    jump = JUMP(SLJIT_JUMP);
# Line 5452  if (opcode == OP_ASSERT || opcode == OP_ Line 5649  if (opcode == OP_ASSERT || opcode == OP_
5649    if (framesize < 0)    if (framesize < 0)
5650      {      {
5651      /* We know that STR_PTR was stored on the top of the stack. */      /* We know that STR_PTR was stored on the top of the stack. */
5652      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw));
5653      /* Keep the STR_PTR on the top of the stack. */      /* Keep the STR_PTR on the top of the stack. */
5654      if (bra == OP_BRAZERO)      if (bra == OP_BRAZERO)
5655          {
5656        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5657          if (extrasize == 2)
5658            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5659          }
5660      else if (bra == OP_BRAMINZERO)      else if (bra == OP_BRAMINZERO)
5661        {        {
5662        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
# Line 5468  if (opcode == OP_ASSERT || opcode == OP_ Line 5669  if (opcode == OP_ASSERT || opcode == OP_
5669        {        {
5670        /* 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. */
5671        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
5672        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 2) * sizeof(sljit_sw));
5673        }        }
5674      else      else
5675        {        {
5676        /* 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. */
5677        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_sw));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_sw));
5678        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));        if (extrasize == 2)
5679        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);          {
5680            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
5681            if (bra == OP_BRAMINZERO)
5682              OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5683            }
5684          else
5685            {
5686            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5687            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);
5688            }
5689        }        }
5690      }      }
5691    
# Line 5504  else Line 5714  else
5714      {      {
5715      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
5716      if (bra != OP_BRA)      if (bra != OP_BRA)
5717          {
5718          if (extrasize == 2)
5719            free_stack(common, 1);
5720        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5721          }
5722      else      else
5723        free_stack(common, 1);        free_stack(common, extrasize);
5724      }      }
5725    else    else
5726      {      {
5727      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
5728      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(extrasize - 1));
5729      /* The topmost item should be 0. */      /* The topmost item should be 0. */
5730      if (bra != OP_BRA)      if (bra != OP_BRA)
5731        {        {
5732        free_stack(common, framesize + 1);        free_stack(common, framesize + extrasize - 1);
5733        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5734        }        }
5735      else      else
5736        free_stack(common, framesize + 2);        free_stack(common, framesize + extrasize);
5737      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);
5738      }      }
5739    
# Line 5539  else Line 5753  else
5753      }      }
5754    }    }
5755    
5756    common->local_exit = save_local_exit;
5757  common->quit_label = save_quit_label;  common->quit_label = save_quit_label;
5758  common->accept_label = save_accept_label;  common->accept_label = save_accept_label;
5759  common->quit = save_quit;  common->quit = save_quit;
# Line 7040  while (cc < ccend) Line 7255  while (cc < ccend)
7255      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
7256      break;      break;
7257    
7258        case OP_PRUNE_ARG:
7259        OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
7260        OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
7261        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);
7262        OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
7263        /* Fall through. */
7264    
7265        case OP_PRUNE:
7266      case OP_COMMIT:      case OP_COMMIT:
7267      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
7268        SLJIT_ASSERT(common->control_head_ptr != 0);
7269        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
7270        allocate_stack(common, 2);
7271        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0);
7272        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, *cc == OP_COMMIT ? type_commit : type_prune);
7273        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
7274        cc += (*cc == OP_PRUNE_ARG) ? (1 + 2 + cc[1]) : 1;
7275        break;
7276    
7277        case OP_SKIP:
7278        PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
7279        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
7280        allocate_stack(common, 3);
7281        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0);
7282        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, type_skip);
7283        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), STR_PTR, 0);
7284        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
7285      cc += 1;      cc += 1;
7286      break;      break;
7287    
# Line 7672  if (has_alternatives) Line 7912  if (has_alternatives)
7912      SLJIT_ASSERT(opcode == OP_COND || opcode == OP_SCOND);      SLJIT_ASSERT(opcode == OP_COND || opcode == OP_SCOND);
7913      assert = CURRENT_AS(bracket_backtrack)->u.assert;      assert = CURRENT_AS(bracket_backtrack)->u.assert;
7914      if ((ccbegin[1 + LINK_SIZE] == OP_ASSERT_NOT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK_NOT) && assert->framesize >= 0)      if ((ccbegin[1 + LINK_SIZE] == OP_ASSERT_NOT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK_NOT) && assert->framesize >= 0)
   
7915        {        {
7916        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);
7917        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
# Line 7978  while (current) Line 8217  while (current)
8217      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP1, 0);
8218      break;      break;
8219    
8220        case OP_PRUNE:
8221        case OP_PRUNE_ARG:
8222        case OP_SKIP:
8223        if (!common->local_exit)
8224          {
8225          SLJIT_ASSERT(common->control_head_ptr != 0);
8226          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
8227          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
8228          sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_check_control_chain));
8229          OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
8230    
8231          OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0);
8232          add_jump(compiler, &common->reset_match, CMP(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, -1));
8233    
8234          OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8235          }
8236    
8237        /* Commit or in recurse or accept. */
8238        if (common->quit_label == NULL)
8239          add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
8240        else
8241          JUMPTO(SLJIT_JUMP, common->quit_label);
8242        break;
8243    
8244      case OP_COMMIT:      case OP_COMMIT:
8245      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);      if (!common->local_exit)
8246          OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8247      if (common->quit_label == NULL)      if (common->quit_label == NULL)
8248        add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));        add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
8249      else      else
# Line 8010  pcre_uchar *ccend = bracketend(cc); Line 8274  pcre_uchar *ccend = bracketend(cc);
8274  int private_data_size = get_private_data_length_for_copy(common, ccbegin, ccend);  int private_data_size = get_private_data_length_for_copy(common, ccbegin, ccend);
8275  int framesize = get_framesize(common, cc, TRUE);  int framesize = get_framesize(common, cc, TRUE);
8276  int alternativesize;  int alternativesize;
8277  BOOL needsframe;  BOOL needs_frame;
8278  backtrack_common altbacktrack;  backtrack_common altbacktrack;
 struct sljit_label *save_quit_label = common->quit_label;  
 jump_list *save_quit = common->quit;  
8279  struct sljit_jump *jump;  struct sljit_jump *jump;
8280    
8281  SLJIT_ASSERT(*cc == OP_BRA || *cc == OP_CBRA || *cc == OP_CBRAPOS || *cc == OP_SCBRA || *cc == OP_SCBRAPOS);  SLJIT_ASSERT(*cc == OP_BRA || *cc == OP_CBRA || *cc == OP_CBRAPOS || *cc == OP_SCBRA || *cc == OP_SCBRAPOS);
8282  needsframe = framesize >= 0;  needs_frame = framesize >= 0;
8283  if (!needsframe)  if (!needs_frame)
8284    framesize = 0;    framesize = 0;
8285  alternativesize = *(cc + GET(cc, 1)) == OP_ALT ? 1 : 0;  alternativesize = *(cc + GET(cc, 1)) == OP_ALT ? 1 : 0;
8286    
# Line 8030  sljit_emit_fast_enter(compiler, TMP2, 0) Line 8292  sljit_emit_fast_enter(compiler, TMP2, 0)
8292  allocate_stack(common, private_data_size + framesize + alternativesize);  allocate_stack(common, private_data_size + framesize + alternativesize);
8293  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);
8294  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);
8295    if (common->control_head_ptr != 0)
8296      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_IMM, 0);
8297  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, STACK_TOP, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, STACK_TOP, 0);
8298  if (needsframe)  if (needs_frame)
8299    init_frame(common, cc, framesize + alternativesize - 1, alternativesize, TRUE);    init_frame(common, cc, framesize + alternativesize - 1, alternativesize, TRUE);
8300    
8301  if (alternativesize > 0)  if (alternativesize > 0)
# Line 8054  while (1) Line 8318  while (1)
8318    
8319    compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);    compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);
8320    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
     {  
     common->quit_label = save_quit_label;  
     common->quit = save_quit;  
8321      return;      return;
     }  
8322    
8323    add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));    add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));
8324    
8325    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
8326    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
     {  
     common->quit_label = save_quit_label;  
     common->quit = save_quit;  
8327      return;      return;
     }  
8328    set_jumps(altbacktrack.topbacktracks, LABEL());    set_jumps(altbacktrack.topbacktracks, LABEL());
8329    
8330    if (*cc != OP_ALT)    if (*cc != OP_ALT)
# Line 8077  while (1) Line 8333  while (1)
8333    altbacktrack.cc = cc + 1 + LINK_SIZE;    altbacktrack.cc = cc + 1 + LINK_SIZE;
8334    cc += GET(cc, 1);    cc += GET(cc, 1);
8335    }    }
 /* None of them matched. */  
 if (common->quit != NULL)  
   set_jumps(common->quit, LABEL());  
8336    
8337    /* None of them matched. */
8338  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0);
8339  jump = JUMP(SLJIT_JUMP);  jump = JUMP(SLJIT_JUMP);
8340    
8341    if (common->quit != NULL)
8342      {
8343      set_jumps(common->quit, LABEL());
8344      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr);
8345      if (needs_frame)
8346        {
8347        OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
8348        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
8349        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
8350        }
8351      OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0);
8352      common->quit = NULL;
8353      add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
8354      }
8355    
8356  set_jumps(common->accept, LABEL());  set_jumps(common->accept, LABEL());
8357  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr);  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr);
8358  if (needsframe)  if (needs_frame)
8359    {    {
8360    OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));    OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
8361    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
# Line 8095  if (needsframe) Line 8364  if (needsframe)
8364  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);
8365    
8366  JUMPHERE(jump);  JUMPHERE(jump);
8367    if (common->quit != NULL)
8368      set_jumps(common->quit, LABEL());
8369  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);
8370  free_stack(common, private_data_size + framesize + alternativesize);  free_stack(common, private_data_size + framesize + alternativesize);
8371  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));  if (common->control_head_ptr != 0)
8372  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);    {
8373  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, TMP2, 0);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), 2 * sizeof(sljit_sw));
8374      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));
8375      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, TMP1, 0);
8376      OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
8377      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, TMP2, 0);
8378      }
8379    else
8380      {
8381      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));
8382      OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
8383      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, TMP2, 0);
8384      }
8385  sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);  sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);
   
 common->quit_label = save_quit_label;  
 common->quit = save_quit;  
8386  }  }
8387    
8388  #undef COMPILE_BACKTRACKINGPATH  #undef COMPILE_BACKTRACKINGPATH
# Line 8123  pcre_uchar *ccend; Line 8402  pcre_uchar *ccend;
8402  executable_functions *functions;  executable_functions *functions;
8403  void *executable_func;  void *executable_func;
8404  sljit_uw executable_size;  sljit_uw executable_size;
8405  struct sljit_label *mainloop = NULL;  struct sljit_label *mainloop_label = NULL;
8406  struct sljit_label *empty_match_found;  struct sljit_label *continue_match_label;
8407  struct sljit_label *empty_match_backtrack;  struct sljit_label *empty_match_found_label;
8408    struct sljit_label *empty_match_backtrack_label;
8409    struct sljit_label *reset_match_label;
8410  struct sljit_jump *jump;  struct sljit_jump *jump;
8411  struct sljit_jump *minlength_check_failed = NULL;  struct sljit_jump *minlength_check_failed = NULL;
8412  struct sljit_jump *reqbyte_notfound = NULL;  struct sljit_jump *reqbyte_notfound = NULL;
8413  struct sljit_jump *empty_match;  struct sljit_jump *empty_match;
8414    struct sljit_label *quit_label;
8415    
8416  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);
8417  study = extra->study_data;  study = extra->study_data;
# Line 8225  if (mode == JIT_COMPILE && (re->flags & Line 8507  if (mode == JIT_COMPILE && (re->flags &
8507  if (mode != JIT_COMPILE)  if (mode != JIT_COMPILE)
8508    {    {
8509    common->start_used_ptr = common->ovector_start;    common->start_used_ptr = common->ovector_start;
8510    common->ovector_start += 2 * sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
8511    if (mode == JIT_PARTIAL_SOFT_COMPILE)    if (mode == JIT_PARTIAL_SOFT_COMPILE)
8512      {      {
8513      common->hit_start = common->ovector_start;      common->hit_start = common->ovector_start;
8514      common->ovector_start += 2 * sizeof(sljit_sw);      common->ovector_start += 2 * sizeof(sljit_sw);
8515      }      }
8516      else
8517        {
8518        SLJIT_ASSERT(mode == JIT_PARTIAL_HARD_COMPILE);
8519        common->needs_start_ptr = TRUE;
8520        }
8521    }    }
8522  if ((re->options & PCRE_FIRSTLINE) != 0)  if ((re->options & PCRE_FIRSTLINE) != 0)
8523    {    {
8524    common->first_line_end = common->ovector_start;    common->first_line_end = common->ovector_start;
8525    common->ovector_start += sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
8526    }    }
8527    #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD
8528    common->control_head_ptr = 1;
8529    #endif
8530    if (common->control_head_ptr != 0)
8531      {
8532      common->control_head_ptr = common->ovector_start;
8533      common->ovector_start += sizeof(sljit_sw);
8534      }
8535    if (common->needs_start_ptr && common->has_set_som)
8536      {
8537      /* Saving the real start pointer is necessary. */
8538      common->start_ptr = common->ovector_start;
8539      common->ovector_start += sizeof(sljit_sw);
8540      }
8541    else
8542      common->needs_start_ptr = FALSE;
8543    
8544  /* Aligning ovector to even number of sljit words. */  /* Aligning ovector to even number of sljit words. */
8545  if ((common->ovector_start & sizeof(sljit_sw)) != 0)  if ((common->ovector_start & sizeof(sljit_sw)) != 0)
8546    common->ovector_start += sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
8547    
8548    if (common->start_ptr == 0)
8549      common->start_ptr = OVECTOR(0);
8550    
8551  /* Capturing brackets cannot be optimized if callouts are allowed. */  /* Capturing brackets cannot be optimized if callouts are allowed. */
8552  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
8553    memset(common->optimized_cbracket, 0, re->top_bracket + 1);    memset(common->optimized_cbracket, 0, re->top_bracket + 1);
8554    
8555  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
8556  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);  common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);
8557  private_data_size += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_sw);  private_data_size += common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw);
8558  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
8559    {    {
8560    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket);
# Line 8261  if (!common->private_data_ptrs) Line 8567  if (!common->private_data_ptrs)
8567    return;    return;
8568    }    }
8569  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));
8570  set_private_data_ptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_sw), ccend);  set_private_data_ptrs(common, common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw), ccend);
8571    
8572  compiler = sljit_create_compiler();  compiler = sljit_create_compiler();
8573  if (!compiler)  if (!compiler)
# Line 8291  OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM Line 8597  OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM
8597  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT, TMP1, 0);
8598    
8599  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8600    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);
8601    if (common->mark_ptr != 0)
8602      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, SLJIT_IMM, 0);
8603    if (common->control_head_ptr != 0)
8604      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, SLJIT_IMM, 0);
8605    
8606  /* Main part of the matching */  /* Main part of the matching */
8607  if ((re->options & PCRE_ANCHORED) == 0)  if ((re->options & PCRE_ANCHORED) == 0)
8608    {    {
8609    mainloop = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0, (re->options & PCRE_FIRSTLINE) != 0);    mainloop_label = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0, (re->options & PCRE_FIRSTLINE) != 0);
8610      continue_match_label = LABEL();
8611    /* Forward search if possible. */    /* Forward search if possible. */
8612    if ((re->options & PCRE_NO_START_OPTIMIZE) == 0)    if ((re->options & PCRE_NO_START_OPTIMIZE) == 0)
8613      {      {
# Line 8310  if ((re->options & PCRE_ANCHORED) == 0) Line 8621  if ((re->options & PCRE_ANCHORED) == 0)
8621        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);
8622      }      }
8623    }    }
8624    else
8625      continue_match_label = LABEL();
8626    
8627  if (mode == JIT_COMPILE && study->minlength > 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)  if (mode == JIT_COMPILE && study->minlength > 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
8628    {    {
8629    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
# Line 8323  if (common->req_char_ptr != 0) Line 8637  if (common->req_char_ptr != 0)
8637  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), STR_PTR, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), STR_PTR, 0);
8638  /* Copy the limit of allowed recursions. */  /* Copy the limit of allowed recursions. */
8639  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);
 if (common->mark_ptr != 0)  
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, SLJIT_IMM, 0);  
8640  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
8641    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->capture_last_ptr, SLJIT_IMM, -1);
8642    
8643    if (common->needs_start_ptr)
8644      {
8645      SLJIT_ASSERT(common->start_ptr != OVECTOR(0));
8646      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_ptr, STR_PTR, 0);
8647      }
8648    else
8649      SLJIT_ASSERT(common->start_ptr == OVECTOR(0));
8650    
8651  /* Copy the beginning of the string. */  /* Copy the beginning of the string. */
8652  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8653    {    {
8654    jump = CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0);    jump = CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);
8655    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0);
8656    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr + sizeof(sljit_sw), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start + sizeof(sljit_sw), STR_PTR, 0);
8657    JUMPHERE(jump);    JUMPHERE(jump);
8658    }    }
8659  else if (mode == JIT_PARTIAL_HARD_COMPILE)  else if (mode == JIT_PARTIAL_HARD_COMPILE)
   {  
8660    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, STR_PTR, 0);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr + sizeof(sljit_sw), STR_PTR, 0);  
   }  
8661    
8662  compile_matchingpath(common, rootbacktrack.cc, ccend, &rootbacktrack);  compile_matchingpath(common, rootbacktrack.cc, ccend, &rootbacktrack);
8663  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
# Line 8351  if (SLJIT_UNLIKELY(sljit_get_compiler_er Line 8669  if (SLJIT_UNLIKELY(sljit_get_compiler_er
8669    }    }
8670    
8671  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));
8672  empty_match_found = LABEL();  empty_match_found_label = LABEL();
8673    
8674  common->accept_label = LABEL();  common->accept_label = LABEL();
8675  if (common->accept != NULL)  if (common->accept != NULL)
# Line 8375  if (mode != JIT_COMPILE) Line 8693  if (mode != JIT_COMPILE)
8693    return_with_partial_match(common, common->quit_label);    return_with_partial_match(common, common->quit_label);
8694    }    }
8695    
8696  empty_match_backtrack = LABEL();  empty_match_backtrack_label = LABEL();
8697  compile_backtrackingpath(common, rootbacktrack.top);  compile_backtrackingpath(common, rootbacktrack.top);
8698  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
8699    {    {
# Line 8386  if (SLJIT_UNLIKELY(sljit_get_compiler_er Line 8704  if (SLJIT_UNLIKELY(sljit_get_compiler_er
8704    }    }
8705    
8706  SLJIT_ASSERT(rootbacktrack.prev == NULL);  SLJIT_ASSERT(rootbacktrack.prev == NULL);
8707    reset_match_label = LABEL();
8708    
8709  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8710    {    {
8711    /* Update hit_start only in the first time. */    /* Update hit_start only in the first time. */
8712    jump = CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, -1);    jump = CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, SLJIT_IMM, 0);
8713    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr);
   OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr + sizeof(sljit_sw));  
8714    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr, SLJIT_IMM, -1);
8715    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, TMP1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start, TMP1, 0);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->hit_start + sizeof(sljit_sw), TMP2, 0);  
8716    JUMPHERE(jump);    JUMPHERE(jump);
8717    }    }
8718    
# Line 8405  if ((re->options & PCRE_ANCHORED) == 0 & Line 8722  if ((re->options & PCRE_ANCHORED) == 0 &
8722    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
8723    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);
8724    }    }
8725  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));  
8726    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_ptr);
8727    
8728  if ((re->options & PCRE_ANCHORED) == 0)  if ((re->options & PCRE_ANCHORED) == 0)
8729    {    {
8730    if ((re->options & PCRE_FIRSTLINE) == 0)    if ((re->options & PCRE_FIRSTLINE) == 0)
8731      CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop);      CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop_label);
8732    else    else
8733      CMPTO(SLJIT_C_LESS, STR_PTR, 0, TMP1, 0, mainloop);      CMPTO(SLJIT_C_LESS, STR_PTR, 0, TMP1, 0, mainloop_label);
8734    }    }
8735    
8736  /* No more remaining characters. */  /* No more remaining characters. */
# Line 8420  if (reqbyte_notfound != NULL) Line 8738  if (reqbyte_notfound != NULL)
8738    JUMPHERE(reqbyte_notfound);    JUMPHERE(reqbyte_notfound);
8739    
8740  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8741    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, -1, common->partialmatchlabel);
8742    
8743  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);  OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8744  JUMPTO(SLJIT_JUMP, common->quit_label);  JUMPTO(SLJIT_JUMP, common->quit_label);
# Line 8430  flush_stubs(common); Line 8748  flush_stubs(common);
8748  JUMPHERE(empty_match);  JUMPHERE(empty_match);
8749  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
8750  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));
8751  CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack);  CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label);
8752  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));
8753  CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found);  CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label);
8754  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));
8755  CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found);  CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label);
8756  JUMPTO(SLJIT_JUMP, empty_match_backtrack);  JUMPTO(SLJIT_JUMP, empty_match_backtrack_label);
8757    
8758  common->currententry = common->entries;  common->currententry = common->entries;
8759    common->local_exit = TRUE;
8760    quit_label = common->quit_label;
8761  while (common->currententry != NULL)  while (common->currententry != NULL)
8762    {    {
8763    /* Might add new entries. */    /* Might add new entries. */
# Line 8452  while (common->currententry != NULL) Line 8772  while (common->currententry != NULL)
8772    flush_stubs(common);    flush_stubs(common);
8773    common->currententry = common->currententry->next;    common->currententry = common->currententry->next;
8774    }    }
8775    common->local_exit = FALSE;
8776    common->quit_label = quit_label;
8777    
8778  /* Allocating stack, returns with PCRE_ERROR_JIT_STACKLIMIT if fails. */  /* Allocating stack, returns with PCRE_ERROR_JIT_STACKLIMIT if fails. */
8779  /* This is a (really) rare case. */  /* This is a (really) rare case. */
# Line 8519  if (common->caselesscmp != NULL) Line 8841  if (common->caselesscmp != NULL)
8841    set_jumps(common->caselesscmp, LABEL());    set_jumps(common->caselesscmp, LABEL());
8842    do_caselesscmp(common);    do_caselesscmp(common);
8843    }    }
8844    if (common->reset_match != NULL)
8845      {
8846      set_jumps(common->reset_match, LABEL());
8847      do_reset_match(common, (re->top_bracket + 1) * 2);
8848      CMPTO(SLJIT_C_GREATER, STR_PTR, 0, TMP1, 0, continue_match_label);
8849      OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0);
8850      JUMPTO(SLJIT_JUMP, reset_match_label);
8851      }
8852  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
8853  #ifndef COMPILE_PCRE32  #ifndef COMPILE_PCRE32
8854  if (common->utfreadchar != NULL)  if (common->utfreadchar != NULL)

Legend:
Removed from v.1252  
changed lines
  Added in v.1275

  ViewVC Help
Powered by ViewVC 1.1.5