/[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 1434 by zherczeg, Mon Jan 6 20:04:50 2014 UTC revision 1435 by zherczeg, Tue Jan 7 07:47:12 2014 UTC
# Line 362  typedef struct compiler_common { Line 362  typedef struct compiler_common {
362    sljit_sw lcc;    sljit_sw lcc;
363    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */
364    int mode;    int mode;
365      /* TRUE, when minlength is greater than 0. */
366      BOOL might_be_empty;
367    /* \K is found in the pattern. */    /* \K is found in the pattern. */
368    BOOL has_set_som;    BOOL has_set_som;
369    /* (*SKIP:arg) is found in the pattern. */    /* (*SKIP:arg) is found in the pattern. */
# Line 789  while (cc < ccend) Line 791  while (cc < ccend)
791      {      {
792      case OP_SET_SOM:      case OP_SET_SOM:
793      common->has_set_som = TRUE;      common->has_set_som = TRUE;
794        common->might_be_empty = TRUE;
795      cc += 1;      cc += 1;
796      break;      break;
797    
# Line 7853  if (*cc == OP_FAIL) Line 7856  if (*cc == OP_FAIL)
7856    return cc + 1;    return cc + 1;
7857    }    }
7858    
7859  if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL)  if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL || !common->might_be_empty)
7860    {    {
7861    /* No need to check notempty conditions. */    /* No need to check notempty conditions. */
7862    if (common->accept_label == NULL)    if (common->accept_label == NULL)
# Line 9496  sljit_uw total_length; Line 9499  sljit_uw total_length;
9499  label_addr_list *label_addr;  label_addr_list *label_addr;
9500  struct sljit_label *mainloop_label = NULL;  struct sljit_label *mainloop_label = NULL;
9501  struct sljit_label *continue_match_label;  struct sljit_label *continue_match_label;
9502  struct sljit_label *empty_match_found_label;  struct sljit_label *empty_match_found_label = NULL;
9503  struct sljit_label *empty_match_backtrack_label;  struct sljit_label *empty_match_backtrack_label = NULL;
9504  struct sljit_label *reset_match_label;  struct sljit_label *reset_match_label;
9505  struct sljit_label *quit_label;  struct sljit_label *quit_label;
9506  struct sljit_jump *jump;  struct sljit_jump *jump;
9507  struct sljit_jump *minlength_check_failed = NULL;  struct sljit_jump *minlength_check_failed = NULL;
9508  struct sljit_jump *reqbyte_notfound = NULL;  struct sljit_jump *reqbyte_notfound = NULL;
9509  struct sljit_jump *empty_match;  struct sljit_jump *empty_match = NULL;
9510    
9511  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);  SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);
9512  study = extra->study_data;  study = extra->study_data;
# Line 9522  common->read_only_data_ptr = NULL; Line 9525  common->read_only_data_ptr = NULL;
9525  common->fcc = tables + fcc_offset;  common->fcc = tables + fcc_offset;
9526  common->lcc = (sljit_sw)(tables + lcc_offset);  common->lcc = (sljit_sw)(tables + lcc_offset);
9527  common->mode = mode;  common->mode = mode;
9528    common->might_be_empty = study->minlength == 0;
9529  common->nltype = NLTYPE_FIXED;  common->nltype = NLTYPE_FIXED;
9530  switch(re->options & PCRE_NEWLINE_BITS)  switch(re->options & PCRE_NEWLINE_BITS)
9531    {    {
# Line 9815  if (SLJIT_UNLIKELY(sljit_get_compiler_er Line 9819  if (SLJIT_UNLIKELY(sljit_get_compiler_er
9819    return;    return;
9820    }    }
9821    
9822  empty_match = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));  if (common->might_be_empty)
9823  empty_match_found_label = LABEL();    {
9824      empty_match = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
9825      empty_match_found_label = LABEL();
9826      }
9827    
9828  common->accept_label = LABEL();  common->accept_label = LABEL();
9829  if (common->accept != NULL)  if (common->accept != NULL)
# Line 9840  if (mode != JIT_COMPILE) Line 9847  if (mode != JIT_COMPILE)
9847    return_with_partial_match(common, common->quit_label);    return_with_partial_match(common, common->quit_label);
9848    }    }
9849    
9850  empty_match_backtrack_label = LABEL();  if (common->might_be_empty)
9851      empty_match_backtrack_label = LABEL();
9852  compile_backtrackingpath(common, rootbacktrack.top);  compile_backtrackingpath(common, rootbacktrack.top);
9853  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
9854    {    {
# Line 9894  JUMPTO(SLJIT_JUMP, common->quit_label); Line 9902  JUMPTO(SLJIT_JUMP, common->quit_label);
9902    
9903  flush_stubs(common);  flush_stubs(common);
9904    
9905  JUMPHERE(empty_match);  if (common->might_be_empty)
9906  OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);    {
9907  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty));    JUMPHERE(empty_match);
9908  CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label);    OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
9909  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));
9910  CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label);    CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label);
9911  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart));
9912  CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label);    CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label);
9913  JUMPTO(SLJIT_JUMP, empty_match_backtrack_label);    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
9914      CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label);
9915      JUMPTO(SLJIT_JUMP, empty_match_backtrack_label);
9916      }
9917    
9918  common->currententry = common->entries;  common->currententry = common->entries;
9919  common->local_exit = TRUE;  common->local_exit = TRUE;

Legend:
Removed from v.1434  
changed lines
  Added in v.1435

  ViewVC Help
Powered by ViewVC 1.1.5