/[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 1633 by zherczeg, Wed Feb 17 10:06:38 2016 UTC revision 1634 by zherczeg, Fri Feb 19 08:10:18 2016 UTC
# Line 183  typedef struct executable_functions { Line 183  typedef struct executable_functions {
183    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
184    PUBL(jit_callback) callback;    PUBL(jit_callback) callback;
185    void *userdata;    void *userdata;
186    pcre_uint32 top_bracket;    sljit_ui top_bracket;
187    pcre_uint32 limit_match;    sljit_ui limit_match;
188  } executable_functions;  } executable_functions;
189    
190  typedef struct jump_list {  typedef struct jump_list {
# Line 359  typedef struct compiler_common { Line 359  typedef struct compiler_common {
359    sljit_si start_used_ptr;    sljit_si start_used_ptr;
360    /* Starting pointer for partial soft matches. */    /* Starting pointer for partial soft matches. */
361    sljit_si hit_start;    sljit_si hit_start;
362    /* End pointer of the first line. */    /* Pointer of the match end position. */
363    sljit_si first_line_end;    sljit_si match_end_ptr;
364    /* Points to the marked string. */    /* Points to the marked string. */
365    sljit_si mark_ptr;    sljit_si mark_ptr;
366    /* Recursive control verb management chain. */    /* Recursive control verb management chain. */
# Line 3319  jump_list *newline = NULL; Line 3319  jump_list *newline = NULL;
3319  BOOL newlinecheck = FALSE;  BOOL newlinecheck = FALSE;
3320  BOOL readuchar = FALSE;  BOOL readuchar = FALSE;
3321    
3322  if (!(hascrorlf || (common->first_line_end != 0)) &&  if (!(hascrorlf || (common->match_end_ptr != 0)) &&
3323      (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF || common->newline > 255))      (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF || common->newline > 255))
3324    newlinecheck = TRUE;    newlinecheck = TRUE;
3325    
3326  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
3327    {    {
3328    /* Search for the end of the first line. */    /* Search for the end of the first line. */
3329    OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
# Line 3338  if (common->first_line_end != 0) Line 3338  if (common->first_line_end != 0)
3338      CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);      CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);
3339      CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);      CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);
3340      JUMPHERE(end);      JUMPHERE(end);
3341      OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));      OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3342      }      }
3343    else    else
3344      {      {
3345      end = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);      end = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
3346      mainloop = LABEL();      mainloop = LABEL();
3347      /* Continual stores does not cause data dependency. */      /* Continual stores does not cause data dependency. */
3348      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, STR_PTR, 0);
3349      read_char_range(common, common->nlmin, common->nlmax, TRUE);      read_char_range(common, common->nlmin, common->nlmax, TRUE);
3350      check_newlinechar(common, common->nltype, &newline, TRUE);      check_newlinechar(common, common->nltype, &newline, TRUE);
3351      CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop);      CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop);
3352      JUMPHERE(end);      JUMPHERE(end);
3353      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, STR_PTR, 0);
3354      set_jumps(newline, LABEL());      set_jumps(newline, LABEL());
3355      }      }
3356    
# Line 4145  pcre_uchar mask; Line 4145  pcre_uchar mask;
4145  struct sljit_label *utf_start = NULL;  struct sljit_label *utf_start = NULL;
4146  struct sljit_jump *utf_quit = NULL;  struct sljit_jump *utf_quit = NULL;
4147  #endif  #endif
4148  BOOL has_first_line_end = (common->first_line_end != 0);  BOOL has_match_end_ptr = (common->match_end_ptr != 0);
4149    
4150  if (offset > 0)  if (offset > 0)
4151    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset));    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset));
4152    
4153  if (has_first_line_end)  if (has_match_end_ptr)
4154    {    {
4155    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
4156    
4157    OP2(SLJIT_ADD, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end, SLJIT_IMM, IN_UCHARS(offset + 1));    OP2(SLJIT_ADD, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, SLJIT_IMM, IN_UCHARS(offset + 1));
4158  #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)  #if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
4159    if (sljit_x86_is_cmov_available())    if (sljit_x86_is_cmov_available())
4160      {      {
# Line 4216  if (sljit_x86_is_sse2_available()) Line 4216  if (sljit_x86_is_sse2_available())
4216    else if (sljit_x86_is_cmov_available())    else if (sljit_x86_is_cmov_available())
4217      {      {
4218      OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0);      OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, STR_END, 0);
4219      sljit_x86_emit_cmov(compiler, SLJIT_GREATER_EQUAL, STR_PTR, has_first_line_end ? SLJIT_MEM1(SLJIT_SP) : STR_END, has_first_line_end ? common->first_line_end : 0);      sljit_x86_emit_cmov(compiler, SLJIT_GREATER_EQUAL, STR_PTR, has_match_end_ptr ? SLJIT_MEM1(SLJIT_SP) : STR_END, has_match_end_ptr ? common->match_end_ptr : 0);
4220      }      }
4221    else    else
4222      {      {
4223      quit = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);      quit = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
4224      OP1(SLJIT_MOV, STR_PTR, 0, has_first_line_end ? SLJIT_MEM1(SLJIT_SP) : STR_END, has_first_line_end ? common->first_line_end : 0);      OP1(SLJIT_MOV, STR_PTR, 0, has_match_end_ptr ? SLJIT_MEM1(SLJIT_SP) : STR_END, has_match_end_ptr ? common->match_end_ptr : 0);
4225      JUMPHERE(quit);      JUMPHERE(quit);
4226      }      }
4227    
4228    if (has_first_line_end)    if (has_match_end_ptr)
4229      OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);      OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
4230    return;    return;
4231    }    }
# Line 4288  if (common->utf && offset > 0) Line 4288  if (common->utf && offset > 0)
4288    
4289  JUMPHERE(quit);  JUMPHERE(quit);
4290    
4291  if (has_first_line_end)  if (has_match_end_ptr)
4292    {    {
4293    quit = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);    quit = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
4294    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
4295    if (offset > 0)    if (offset > 0)
4296      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset));      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(offset));
4297    JUMPHERE(quit);    JUMPHERE(quit);
# Line 4318  int i, max, from; Line 4318  int i, max, from;
4318  int range_right = -1, range_len;  int range_right = -1, range_len;
4319  sljit_ub *update_table = NULL;  sljit_ub *update_table = NULL;
4320  BOOL in_range;  BOOL in_range;
4321  uint32_t rec_count;  sljit_ui rec_count;
4322    
4323  for (i = 0; i < MAX_N_CHARS; i++)  for (i = 0; i < MAX_N_CHARS; i++)
4324    chars[i * MAX_DIFF_CHARS] = 0;    chars[i * MAX_DIFF_CHARS] = 0;
# Line 4420  SLJIT_ASSERT(offset == -1 || (chars[offs Line 4420  SLJIT_ASSERT(offset == -1 || (chars[offs
4420    
4421  max -= 1;  max -= 1;
4422  SLJIT_ASSERT(max > 0);  SLJIT_ASSERT(max > 0);
4423  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
4424    {    {
4425    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
4426    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
4427    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));    OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));
4428    quit = CMP(SLJIT_LESS_EQUAL, STR_END, 0, TMP1, 0);    quit = CMP(SLJIT_LESS_EQUAL, STR_END, 0, TMP1, 0);
# Line 4508  if (offset >= 0) Line 4508  if (offset >= 0)
4508    
4509  JUMPHERE(quit);  JUMPHERE(quit);
4510    
4511  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
4512    {    {
4513    if (range_right >= 0)    if (range_right >= 0)
4514      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
4515    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
4516    if (range_right >= 0)    if (range_right >= 0)
4517      {      {
# Line 4556  struct sljit_jump *foundcr = NULL; Line 4556  struct sljit_jump *foundcr = NULL;
4556  struct sljit_jump *notfoundnl;  struct sljit_jump *notfoundnl;
4557  jump_list *newline = NULL;  jump_list *newline = NULL;
4558    
4559  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
4560    {    {
4561    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
4562    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
4563    }    }
4564    
4565  if (common->nltype == NLTYPE_FIXED && common->newline > 255)  if (common->nltype == NLTYPE_FIXED && common->newline > 255)
# Line 4590  if (common->nltype == NLTYPE_FIXED && co Line 4590  if (common->nltype == NLTYPE_FIXED && co
4590    JUMPHERE(firstchar);    JUMPHERE(firstchar);
4591    JUMPHERE(lastchar);    JUMPHERE(lastchar);
4592    
4593    if (common->first_line_end != 0)    if (common->match_end_ptr != 0)
4594      OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);      OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
4595    return;    return;
4596    }    }
# Line 4628  if (common->nltype == NLTYPE_ANY || comm Line 4628  if (common->nltype == NLTYPE_ANY || comm
4628  JUMPHERE(lastchar);  JUMPHERE(lastchar);
4629  JUMPHERE(firstchar);  JUMPHERE(firstchar);
4630    
4631  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
4632    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);    OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
4633  }  }
4634    
# Line 4645  jump_list *matches = NULL; Line 4645  jump_list *matches = NULL;
4645  struct sljit_jump *jump;  struct sljit_jump *jump;
4646  #endif  #endif
4647    
4648  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
4649    {    {
4650    OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);    OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);
4651    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);    OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
4652    }    }
4653    
4654  start = LABEL();  start = LABEL();
# Line 4706  if (matches != NULL) Line 4706  if (matches != NULL)
4706    set_jumps(matches, LABEL());    set_jumps(matches, LABEL());
4707  JUMPHERE(quit);  JUMPHERE(quit);
4708    
4709  if (common->first_line_end != 0)  if (common->match_end_ptr != 0)
4710    OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);    OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);
4711  }  }
4712    
# Line 10932  if (mode != JIT_COMPILE) Line 10932  if (mode != JIT_COMPILE)
10932    }    }
10933  if ((re->options & PCRE_FIRSTLINE) != 0)  if ((re->options & PCRE_FIRSTLINE) != 0)
10934    {    {
10935    common->first_line_end = common->ovector_start;    common->match_end_ptr = common->ovector_start;
10936    common->ovector_start += sizeof(sljit_sw);    common->ovector_start += sizeof(sljit_sw);
10937    }    }
10938  #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD  #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD
# Line 10977  private_data_size = common->cbra_ptr + ( Line 10977  private_data_size = common->cbra_ptr + (
10977  set_private_data_ptrs(common, &private_data_size, ccend);  set_private_data_ptrs(common, &private_data_size, ccend);
10978  if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)  if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
10979    {    {
10980    if (!common->has_skip_in_assert_back)    if (!detect_fast_forward_skip(common, &private_data_size) && !common->has_skip_in_assert_back)
10981      detect_fast_fail(common, common->start, &private_data_size, 4);      detect_fast_fail(common, common->start, &private_data_size, 4);
10982    }    }
10983    
# Line 11071  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVE Line 11071  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVE
11071  OP1(SLJIT_MOV, COUNT_MATCH, 0, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH);  OP1(SLJIT_MOV, COUNT_MATCH, 0, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH);
11072  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
11073    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, -1);
11074    if (common->fast_forward_bc_ptr != NULL)
11075      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), PRIVATE_DATA(common->fast_forward_bc_ptr + 1), STR_PTR, 0);
11076    
11077  if (common->start_ptr != OVECTOR(0))  if (common->start_ptr != OVECTOR(0))
11078    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_ptr, STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_ptr, STR_PTR, 0);
# Line 11152  if (mode == JIT_PARTIAL_SOFT_COMPILE) Line 11154  if (mode == JIT_PARTIAL_SOFT_COMPILE)
11154  /* Check we have remaining characters. */  /* Check we have remaining characters. */
11155  if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_FIRSTLINE) != 0)  if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_FIRSTLINE) != 0)
11156    {    {
11157    SLJIT_ASSERT(common->first_line_end != 0);    SLJIT_ASSERT(common->match_end_ptr != 0);
11158    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr);
11159    }    }
11160    
11161  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP),  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP),

Legend:
Removed from v.1633  
changed lines
  Added in v.1634

  ViewVC Help
Powered by ViewVC 1.1.5