/[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 1271 by zherczeg, Tue Mar 5 08:05:17 2013 UTC revision 1272 by zherczeg, Thu Mar 7 11:30:01 2013 UTC
# Line 282  typedef struct recurse_backtrack { Line 282  typedef struct recurse_backtrack {
282  #define MAX_RANGE_SIZE 6  #define MAX_RANGE_SIZE 6
283    
284  typedef struct compiler_common {  typedef struct compiler_common {
285      /* The sljit ceneric compiler. */
286    struct sljit_compiler *compiler;    struct sljit_compiler *compiler;
287      /* First byte code. */
288    pcre_uchar *start;    pcre_uchar *start;
   
289    /* Maps private data offset to each opcode. */    /* Maps private data offset to each opcode. */
290    int *private_data_ptrs;    int *private_data_ptrs;
291    /* Tells whether the capturing bracket is optimized. */    /* Tells whether the capturing bracket is optimized. */
292    pcre_uint8 *optimized_cbracket;    pcre_uint8 *optimized_cbracket;
293    /* Starting offset of private data for capturing brackets. */    /* Starting offset of private data for capturing brackets. */
294    int cbraptr;    int cbra_ptr;
295    /* OVector starting point. Must be divisible by 2. */    /* Output vector starting point. Must be divisible by 2. */
296    int ovector_start;    int ovector_start;
297    /* Last known position of the requested byte. */    /* Last known position of the requested byte. */
298    int req_char_ptr;    int req_char_ptr;
# Line 307  typedef struct compiler_common { Line 308  typedef struct compiler_common {
308    int mark_ptr;    int mark_ptr;
309    /* Points to the last matched capture block index. */    /* Points to the last matched capture block index. */
310    int capture_last_ptr;    int capture_last_ptr;
311      /* Points to the starting position of the current match. */
312      int start_ptr;
313    
314    /* Flipped and lower case tables. */    /* Flipped and lower case tables. */
315    const pcre_uint8 *fcc;    const pcre_uint8 *fcc;
316    sljit_sw lcc;    sljit_sw lcc;
317    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */
318    int mode;    int mode;
319      /* \K is in the pattern. */
320      BOOL has_set_som;
321      /* Needs to know the start position anytime. */
322      BOOL needs_start_ptr;
323      /* Currently in compile_recurse. */
324      BOOL in_recurse;
325    /* Newline control. */    /* Newline control. */
326    int nltype;    int nltype;
327    int newline;    int newline;
328    int bsr_nltype;    int bsr_nltype;
329    /* Dollar endonly. */    /* Dollar endonly. */
330    int endonly;    int endonly;
   BOOL has_set_som;  
331    /* Tables. */    /* Tables. */
332    sljit_sw ctypes;    sljit_sw ctypes;
333    int digits[2 + MAX_RANGE_SIZE];    int digits[2 + MAX_RANGE_SIZE];
# Line 349  typedef struct compiler_common { Line 357  typedef struct compiler_common {
357    jump_list *vspace;    jump_list *vspace;
358    jump_list *casefulcmp;    jump_list *casefulcmp;
359    jump_list *caselesscmp;    jump_list *caselesscmp;
360      jump_list *reset_match;
361    BOOL jscript_compat;    BOOL jscript_compat;
362  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
363    BOOL utf;    BOOL utf;
# Line 433  group contains the start / end character Line 442  group contains the start / end character
442  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. */
443  #define OVECTOR_START    (common->ovector_start)  #define OVECTOR_START    (common->ovector_start)
444  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))
445  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_sw))  #define OVECTOR_PRIV(i)  (common->cbra_ptr + (i) * sizeof(sljit_sw))
446  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
447    
448  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
# Line 572  switch(*cc) Line 581  switch(*cc)
581    case OP_BRAZERO:    case OP_BRAZERO:
582    case OP_BRAMINZERO:    case OP_BRAMINZERO:
583    case OP_BRAPOSZERO:    case OP_BRAPOSZERO:
584      case OP_PRUNE:
585    case OP_COMMIT:    case OP_COMMIT:
586    case OP_FAIL:    case OP_FAIL:
587    case OP_ACCEPT:    case OP_ACCEPT:
# Line 670  switch(*cc) Line 680  switch(*cc)
680  #endif  #endif
681    
682    case OP_MARK:    case OP_MARK:
683      case OP_PRUNE_ARG:
684    return cc + 1 + 2 + cc[1];    return cc + 1 + 2 + cc[1];
685    
686    default:    default:
# Line 921  while (cc < ccend) Line 932  while (cc < ccend)
932      cc += 2 + 2 * LINK_SIZE;      cc += 2 + 2 * LINK_SIZE;
933      break;      break;
934    
935        case OP_PRUNE_ARG:
936        common->needs_start_ptr = TRUE;
937        /* Fall through. */
938    
939      case OP_MARK:      case OP_MARK:
940      if (common->mark_ptr == 0)      if (common->mark_ptr == 0)
941        {        {
# Line 930  while (cc < ccend) Line 945  while (cc < ccend)
945      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
946      break;      break;
947    
948        case OP_PRUNE:
949        common->needs_start_ptr = TRUE;
950        cc += 1;
951        break;
952    
953      default:      default:
954      cc = next_opcode(common, cc);      cc = next_opcode(common, cc);
955      if (cc == NULL)      if (cc == NULL)
# Line 1142  while (cc < ccend) Line 1162  while (cc < ccend)
1162      break;      break;
1163    
1164      case OP_MARK:      case OP_MARK:
1165        case OP_PRUNE_ARG:
1166      SLJIT_ASSERT(common->mark_ptr != 0);      SLJIT_ASSERT(common->mark_ptr != 0);
1167      stack_restore = TRUE;      stack_restore = TRUE;
1168      if (!setmark_found)      if (!setmark_found)
# Line 1304  while (cc < ccend) Line 1325  while (cc < ccend)
1325      break;      break;
1326    
1327      case OP_MARK:      case OP_MARK:
1328        case OP_PRUNE_ARG:
1329      SLJIT_ASSERT(common->mark_ptr != 0);      SLJIT_ASSERT(common->mark_ptr != 0);
1330      if (!setmark_found)      if (!setmark_found)
1331        {        {
# Line 1900  static SLJIT_INLINE void reset_ovector(c Line 1922  static SLJIT_INLINE void reset_ovector(c
1922  DEFINE_COMPILER;  DEFINE_COMPILER;
1923  struct sljit_label *loop;  struct sljit_label *loop;
1924  int i;  int i;
1925    
1926  /* At this point we can freely use all temporary registers. */  /* At this point we can freely use all temporary registers. */
1927    SLJIT_ASSERT(length > 1);
1928  /* TMP1 returns with begin - 1. */  /* TMP1 returns with begin - 1. */
1929  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));
1930  if (length < 8)  if (length < 8)
1931    {    {
1932    for (i = 0; i < length; i++)    for (i = 1; i < length; i++)
1933      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);
1934    }    }
1935  else  else
1936    {    {
1937    GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, OVECTOR_START - sizeof(sljit_sw));    GET_LOCAL_BASE(SLJIT_SCRATCH_REG2, 0, OVECTOR_START);
1938    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, length);    OP1(SLJIT_MOV, SLJIT_SCRATCH_REG3, 0, SLJIT_IMM, length - 1);
1939    loop = LABEL();    loop = LABEL();
1940    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);
1941    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 1943  else
1943    }    }
1944  }  }
1945    
1946    static void do_reset_match(compiler_common *common, int length)
1947    {
1948    DEFINE_COMPILER;
1949    struct sljit_label *loop;
1950    int i;
1951    
1952    SLJIT_ASSERT(length > 1);
1953    /* OVECTOR(1) contains the "string begin - 1" constant. */
1954    if (length > 2)
1955      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1));
1956    OP1(SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0);
1957    if (length < 8)
1958      {
1959      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack));
1960      for (i = 2; i < length; i++)
1961        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(i), TMP1, 0);
1962      }
1963    else
1964      {
1965      GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + sizeof(sljit_sw));
1966      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_IMM, length - 2);
1967      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack));
1968      loop = LABEL();
1969      OP1(SLJIT_MOVU, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);
1970      OP2(SLJIT_SUB | SLJIT_SET_E, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);
1971      JUMPTO(SLJIT_C_NOT_ZERO, loop);
1972      }
1973    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(struct sljit_stack, base));
1974    }
1975    
1976  static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)  static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)
1977  {  {
1978  DEFINE_COMPILER;  DEFINE_COMPILER;
# Line 1975  DEFINE_COMPILER; Line 2029  DEFINE_COMPILER;
2029  struct sljit_jump *jump;  struct sljit_jump *jump;
2030    
2031  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);
2032  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
2033      && (common->mode == JIT_PARTIAL_SOFT_COMPILE ? common->hit_start != 0 : common->hit_start == 0));
2034    
2035  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, SLJIT_SCRATCH_REG2, 0, ARGUMENTS, 0);
2036  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 2042  OP1(SLJIT_MOV, SLJIT_SAVED_REG1, 0, SLJI
2042  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));
2043    
2044  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);
2045  OP2(SLJIT_SUB, SLJIT_SCRATCH_REG3, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_used_ptr + 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);
2046  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
2047  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);
2048  #endif  #endif
# Line 7060  while (cc < ccend) Line 7115  while (cc < ccend)
7115      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
7116      break;      break;
7117    
7118        case OP_PRUNE_ARG:
7119        PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
7120        OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
7121        OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
7122        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);
7123        OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
7124        cc += 1 + 2 + cc[1];
7125        break;
7126    
7127        case OP_PRUNE:
7128      case OP_COMMIT:      case OP_COMMIT:
7129      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
7130      cc += 1;      cc += 1;
# Line 7998  while (current) Line 8063  while (current)
8063      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);
8064      break;      break;
8065    
8066        case OP_PRUNE:
8067        case OP_PRUNE_ARG:
8068        if (!common->in_recurse)
8069          add_jump(compiler, &common->reset_match, JUMP(SLJIT_JUMP));
8070        else if (common->quit_label == NULL)
8071          add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
8072        else
8073          JUMPTO(SLJIT_JUMP, common->quit_label);
8074        break;
8075    
8076      case OP_COMMIT:      case OP_COMMIT:
8077      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8078      if (common->quit_label == NULL)      if (common->quit_label == NULL)
# Line 8032  int framesize = get_framesize(common, cc Line 8107  int framesize = get_framesize(common, cc
8107  int alternativesize;  int alternativesize;
8108  BOOL needsframe;  BOOL needsframe;
8109  backtrack_common altbacktrack;  backtrack_common altbacktrack;
 struct sljit_label *save_quit_label = common->quit_label;  
 jump_list *save_quit = common->quit;  
8110  struct sljit_jump *jump;  struct sljit_jump *jump;
8111    
8112  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);
# Line 8074  while (1) Line 8147  while (1)
8147    
8148    compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);    compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);
8149    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;  
8150      return;      return;
     }  
8151    
8152    add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));    add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));
8153    
8154    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
8155    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;  
8156      return;      return;
     }  
8157    set_jumps(altbacktrack.topbacktracks, LABEL());    set_jumps(altbacktrack.topbacktracks, LABEL());
8158    
8159    if (*cc != OP_ALT)    if (*cc != OP_ALT)
# Line 8121  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK Line 8186  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK
8186  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
8187  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head_ptr, TMP2, 0);
8188  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;  
8189  }  }
8190    
8191  #undef COMPILE_BACKTRACKINGPATH  #undef COMPILE_BACKTRACKINGPATH
# Line 8144  executable_functions *functions; Line 8206  executable_functions *functions;
8206  void *executable_func;  void *executable_func;
8207  sljit_uw executable_size;  sljit_uw executable_size;
8208  struct sljit_label *mainloop = NULL;  struct sljit_label *mainloop = NULL;
8209  struct sljit_label *empty_match_found;  struct sljit_label *empty_match_found_label;
8210  struct sljit_label *empty_match_backtrack;  struct sljit_label *empty_match_backtrack_label;
8211    struct sljit_label *reset_match_label;
8212  struct sljit_jump *jump;  struct sljit_jump *jump;
8213  struct sljit_jump *minlength_check_failed = NULL;  struct sljit_jump *minlength_check_failed = NULL;
8214  struct sljit_jump *reqbyte_notfound = NULL;  struct sljit_jump *reqbyte_notfound = NULL;
8215  struct sljit_jump *empty_match;  struct sljit_jump *empty_match;
8216    struct sljit_label *quit_label;
8217    
8218  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);
8219  study = extra->study_data;  study = extra->study_data;
# Line 8245  if (mode == JIT_COMPILE && (re->flags & Line 8309  if (mode == JIT_COMPILE && (re->flags &
8309  if (mode != JIT_COMPILE)  if (mode != JIT_COMPILE)
8310    {    {
8311    common->start_used_ptr = common->ovector_start;    common->start_used_ptr = common->ovector_start;
8312    common->ovector_start += 2 * sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
8313    if (mode == JIT_PARTIAL_SOFT_COMPILE)    if (mode == JIT_PARTIAL_SOFT_COMPILE)
8314      {      {
8315      common->hit_start = common->ovector_start;      common->hit_start = common->ovector_start;
8316      common->ovector_start += sizeof(sljit_sw);      common->ovector_start += 2 * sizeof(sljit_sw);
8317        }
8318      else
8319        {
8320        SLJIT_ASSERT(mode == JIT_PARTIAL_HARD_COMPILE);
8321        common->needs_start_ptr = TRUE;
8322      }      }
8323    }    }
8324  if ((re->options & PCRE_FIRSTLINE) != 0)  if ((re->options & PCRE_FIRSTLINE) != 0)
# Line 8257  if ((re->options & PCRE_FIRSTLINE) != 0) Line 8326  if ((re->options & PCRE_FIRSTLINE) != 0)
8326    common->first_line_end = common->ovector_start;    common->first_line_end = common->ovector_start;
8327    common->ovector_start += sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
8328    }    }
8329    if (common->needs_start_ptr && common->has_set_som)
8330      {
8331      /* Saving the real start pointer is necessary. */
8332      common->start_ptr = common->ovector_start;
8333      common->ovector_start += sizeof(sljit_sw);
8334      }
8335    else
8336      common->needs_start_ptr = FALSE;
8337    
8338  /* Aligning ovector to even number of sljit words. */  /* Aligning ovector to even number of sljit words. */
8339  if ((common->ovector_start & sizeof(sljit_sw)) != 0)  if ((common->ovector_start & sizeof(sljit_sw)) != 0)
8340    common->ovector_start += sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
8341    
8342    if (common->start_ptr == 0)
8343      common->start_ptr = OVECTOR(0);
8344    
8345  /* Capturing brackets cannot be optimized if callouts are allowed. */  /* Capturing brackets cannot be optimized if callouts are allowed. */
8346  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
8347    memset(common->optimized_cbracket, 0, re->top_bracket + 1);    memset(common->optimized_cbracket, 0, re->top_bracket + 1);
8348    
8349  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
8350  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);
8351  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);
8352  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
8353    {    {
8354    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket);
# Line 8281  if (!common->private_data_ptrs) Line 8361  if (!common->private_data_ptrs)
8361    return;    return;
8362    }    }
8363  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));
8364  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);
8365    
8366  compiler = sljit_create_compiler();  compiler = sljit_create_compiler();
8367  if (!compiler)  if (!compiler)
# Line 8347  if (common->mark_ptr != 0) Line 8427  if (common->mark_ptr != 0)
8427    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);
8428  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
8429    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);
8430    
8431    if (common->needs_start_ptr)
8432      {
8433      SLJIT_ASSERT(common->start_ptr != OVECTOR(0));
8434      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_ptr, STR_PTR, 0);
8435      }
8436    else
8437      SLJIT_ASSERT(common->start_ptr == OVECTOR(0));
8438    
8439  /* Copy the beginning of the string. */  /* Copy the beginning of the string. */
8440  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8441    {    {
8442    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, -1);
8443    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);
8444    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);
8445    JUMPHERE(jump);    JUMPHERE(jump);
8446    }    }
8447  else if (mode == JIT_PARTIAL_HARD_COMPILE)  else if (mode == JIT_PARTIAL_HARD_COMPILE)
   {  
8448    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);  
   }  
8449    
8450  compile_matchingpath(common, rootbacktrack.cc, ccend, &rootbacktrack);  compile_matchingpath(common, rootbacktrack.cc, ccend, &rootbacktrack);
8451  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
# Line 8371  if (SLJIT_UNLIKELY(sljit_get_compiler_er Line 8457  if (SLJIT_UNLIKELY(sljit_get_compiler_er
8457    }    }
8458    
8459  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));
8460  empty_match_found = LABEL();  empty_match_found_label = LABEL();
8461    
8462  common->accept_label = LABEL();  common->accept_label = LABEL();
8463  if (common->accept != NULL)  if (common->accept != NULL)
# Line 8395  if (mode != JIT_COMPILE) Line 8481  if (mode != JIT_COMPILE)
8481    return_with_partial_match(common, common->quit_label);    return_with_partial_match(common, common->quit_label);
8482    }    }
8483    
8484  empty_match_backtrack = LABEL();  empty_match_backtrack_label = LABEL();
8485  compile_backtrackingpath(common, rootbacktrack.top);  compile_backtrackingpath(common, rootbacktrack.top);
8486  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
8487    {    {
# Line 8406  if (SLJIT_UNLIKELY(sljit_get_compiler_er Line 8492  if (SLJIT_UNLIKELY(sljit_get_compiler_er
8492    }    }
8493    
8494  SLJIT_ASSERT(rootbacktrack.prev == NULL);  SLJIT_ASSERT(rootbacktrack.prev == NULL);
8495    reset_match_label = LABEL();
8496    
8497  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
8498    {    {
# Line 8423  if ((re->options & PCRE_ANCHORED) == 0 & Line 8510  if ((re->options & PCRE_ANCHORED) == 0 &
8510    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->first_line_end != 0);
8511    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);
8512    }    }
8513  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));  
8514    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->start_ptr);
8515    
8516  if ((re->options & PCRE_ANCHORED) == 0)  if ((re->options & PCRE_ANCHORED) == 0)
8517    {    {
# Line 8448  flush_stubs(common); Line 8536  flush_stubs(common);
8536  JUMPHERE(empty_match);  JUMPHERE(empty_match);
8537  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
8538  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));
8539  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);
8540  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));
8541  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);
8542  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));
8543  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);
8544  JUMPTO(SLJIT_JUMP, empty_match_backtrack);  JUMPTO(SLJIT_JUMP, empty_match_backtrack_label);
8545    
8546  common->currententry = common->entries;  common->currententry = common->entries;
8547    common->in_recurse = TRUE;
8548    quit_label = common->quit_label;
8549  while (common->currententry != NULL)  while (common->currententry != NULL)
8550    {    {
8551    /* Might add new entries. */    /* Might add new entries. */
# Line 8470  while (common->currententry != NULL) Line 8560  while (common->currententry != NULL)
8560    flush_stubs(common);    flush_stubs(common);
8561    common->currententry = common->currententry->next;    common->currententry = common->currententry->next;
8562    }    }
8563    common->in_recurse = FALSE;
8564    common->quit_label = quit_label;
8565    
8566  /* Allocating stack, returns with PCRE_ERROR_JIT_STACKLIMIT if fails. */  /* Allocating stack, returns with PCRE_ERROR_JIT_STACKLIMIT if fails. */
8567  /* This is a (really) rare case. */  /* This is a (really) rare case. */
# Line 8537  if (common->caselesscmp != NULL) Line 8629  if (common->caselesscmp != NULL)
8629    set_jumps(common->caselesscmp, LABEL());    set_jumps(common->caselesscmp, LABEL());
8630    do_caselesscmp(common);    do_caselesscmp(common);
8631    }    }
8632    if (common->reset_match != NULL)
8633      {
8634      set_jumps(common->reset_match, LABEL());
8635      do_reset_match(common, (re->top_bracket + 1) * 2);
8636      JUMPTO(SLJIT_JUMP, reset_match_label);
8637      }
8638  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
8639  #ifndef COMPILE_PCRE32  #ifndef COMPILE_PCRE32
8640  if (common->utfreadchar != NULL)  if (common->utfreadchar != NULL)

Legend:
Removed from v.1271  
changed lines
  Added in v.1272

  ViewVC Help
Powered by ViewVC 1.1.5