/[pcre]/code/tags/pcre-8.38/pcre_jit_compile.c
ViewVC logotype

Diff of /code/tags/pcre-8.38/pcre_jit_compile.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1310 by zherczeg, Sat Apr 6 06:51:09 2013 UTC revision 1316 by zherczeg, Sun Apr 28 08:54:42 2013 UTC
# Line 168  typedef struct jit_arguments { Line 168  typedef struct jit_arguments {
168    pcre_uchar *mark_ptr;    pcre_uchar *mark_ptr;
169    void *callout_data;    void *callout_data;
170    /* Everything else after. */    /* Everything else after. */
171      pcre_uint32 limit_match;
172    int real_offset_count;    int real_offset_count;
173    int offset_count;    int offset_count;
   int call_limit;  
174    pcre_uint8 notbol;    pcre_uint8 notbol;
175    pcre_uint8 noteol;    pcre_uint8 noteol;
176    pcre_uint8 notempty;    pcre_uint8 notempty;
# Line 182  typedef struct executable_functions { Line 182  typedef struct executable_functions {
182    PUBL(jit_callback) callback;    PUBL(jit_callback) callback;
183    void *userdata;    void *userdata;
184    pcre_uint32 top_bracket;    pcre_uint32 top_bracket;
185      pcre_uint32 limit_match;
186    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
187  } executable_functions;  } executable_functions;
188    
# Line 463  typedef struct compare_context { Line 464  typedef struct compare_context {
464  #define STACK_TOP     SLJIT_SCRATCH_REG2  #define STACK_TOP     SLJIT_SCRATCH_REG2
465  #define STACK_LIMIT   SLJIT_SAVED_REG3  #define STACK_LIMIT   SLJIT_SAVED_REG3
466  #define ARGUMENTS     SLJIT_SAVED_EREG1  #define ARGUMENTS     SLJIT_SAVED_EREG1
467  #define CALL_COUNT    SLJIT_SAVED_EREG2  #define COUNT_MATCH   SLJIT_SAVED_EREG2
468  #define RETURN_ADDR   SLJIT_TEMPORARY_EREG1  #define RETURN_ADDR   SLJIT_TEMPORARY_EREG1
469    
470  /* Local space layout. */  /* Local space layout. */
# Line 474  typedef struct compare_context { Line 475  typedef struct compare_context {
475  #define POSSESSIVE0      (2 * sizeof(sljit_sw))  #define POSSESSIVE0      (2 * sizeof(sljit_sw))
476  #define POSSESSIVE1      (3 * sizeof(sljit_sw))  #define POSSESSIVE1      (3 * sizeof(sljit_sw))
477  /* Max limit of recursions. */  /* Max limit of recursions. */
478  #define CALL_LIMIT       (4 * sizeof(sljit_sw))  #define LIMIT_MATCH      (4 * sizeof(sljit_sw))
479  /* The output vector is stored on the stack, and contains pointers  /* The output vector is stored on the stack, and contains pointers
480  to characters. The vector data is divided into two groups: the first  to characters. The vector data is divided into two groups: the first
481  group contains the start / end character pointers, and the second is  group contains the start / end character pointers, and the second is
# Line 2022  while (list_item) Line 2023  while (list_item)
2023  common->stubs = NULL;  common->stubs = NULL;
2024  }  }
2025    
2026  static SLJIT_INLINE void decrease_call_count(compiler_common *common)  static SLJIT_INLINE void count_match(compiler_common *common)
2027  {  {
2028  DEFINE_COMPILER;  DEFINE_COMPILER;
2029    
2030  OP2(SLJIT_SUB | SLJIT_SET_E, CALL_COUNT, 0, CALL_COUNT, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB | SLJIT_SET_E, COUNT_MATCH, 0, COUNT_MATCH, 0, SLJIT_IMM, 1);
2031  add_jump(compiler, &common->calllimit, JUMP(SLJIT_C_ZERO));  add_jump(compiler, &common->calllimit, JUMP(SLJIT_C_ZERO));
2032  }  }
2033    
# Line 5292  if (!minimize) Line 5293  if (!minimize)
5293    JUMPHERE(zerolength);    JUMPHERE(zerolength);
5294    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
5295    
5296    decrease_call_count(common);    count_match(common);
5297    return cc;    return cc;
5298    }    }
5299    
# Line 5331  if (jump != NULL) Line 5332  if (jump != NULL)
5332    JUMPHERE(jump);    JUMPHERE(jump);
5333  JUMPHERE(zerolength);  JUMPHERE(zerolength);
5334    
5335  decrease_call_count(common);  count_match(common);
5336  return cc;  return cc;
5337  }  }
5338    
# Line 6664  if (bra == OP_BRAMINZERO) Line 6665  if (bra == OP_BRAMINZERO)
6665    }    }
6666    
6667  if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO)  if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO)
6668    decrease_call_count(common);    count_match(common);
6669    
6670  /* Skip the other alternatives. */  /* Skip the other alternatives. */
6671  while (*cc == OP_ALT)  while (*cc == OP_ALT)
# Line 6951  if (!zero) Line 6952  if (!zero)
6952    
6953  /* None of them matched. */  /* None of them matched. */
6954  set_jumps(emptymatch, LABEL());  set_jumps(emptymatch, LABEL());
6955  decrease_call_count(common);  count_match(common);
6956  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
6957  }  }
6958    
# Line 7261  switch(opcode) Line 7262  switch(opcode)
7262    break;    break;
7263    }    }
7264    
7265  decrease_call_count(common);  count_match(common);
7266  return end;  return end;
7267  }  }
7268    
# Line 7588  while (cc < ccend) Line 7589  while (cc < ccend)
7589        }        }
7590      BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();      BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();
7591      if (cc[1] > OP_ASSERTBACK_NOT)      if (cc[1] > OP_ASSERTBACK_NOT)
7592        decrease_call_count(common);        count_match(common);
7593      break;      break;
7594    
7595      case OP_ONCE:      case OP_ONCE:
# Line 8971  common->use_ucp = (re->options & PCRE_UC Line 8972  common->use_ucp = (re->options & PCRE_UC
8972  ccend = bracketend(rootbacktrack.cc);  ccend = bracketend(rootbacktrack.cc);
8973    
8974  /* Calculate the local space size on the stack. */  /* Calculate the local space size on the stack. */
8975  common->ovector_start = CALL_LIMIT + sizeof(sljit_sw);  common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw);
8976  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);
8977  if (!common->optimized_cbracket)  if (!common->optimized_cbracket)
8978    return;    return;
# Line 9103  OP1(SLJIT_MOV, TMP1, 0, SLJIT_SAVED_REG1 Line 9104  OP1(SLJIT_MOV, TMP1, 0, SLJIT_SAVED_REG1
9104  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));  OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
9105  OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end));  OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end));
9106  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));
9107  OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, call_limit));  OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match));
9108  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));
9109  OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));  OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));
9110  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LIMIT_MATCH, TMP1, 0);
9111    
9112  if (mode == JIT_PARTIAL_SOFT_COMPILE)  if (mode == JIT_PARTIAL_SOFT_COMPILE)
9113    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, -1);
# Line 9148  if (common->req_char_ptr != 0) Line 9149  if (common->req_char_ptr != 0)
9149  /* Store the current STR_PTR in OVECTOR(0). */  /* Store the current STR_PTR in OVECTOR(0). */
9150  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);
9151  /* Copy the limit of allowed recursions. */  /* Copy the limit of allowed recursions. */
9152  OP1(SLJIT_MOV, CALL_COUNT, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CALL_LIMIT);  OP1(SLJIT_MOV, COUNT_MATCH, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LIMIT_MATCH);
9153  if (common->capture_last_ptr != 0)  if (common->capture_last_ptr != 0)
9154    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);
9155    
# Line 9426  else Line 9427  else
9427      }      }
9428    memset(functions, 0, sizeof(executable_functions));    memset(functions, 0, sizeof(executable_functions));
9429    functions->top_bracket = (re->top_bracket + 1) * 2;    functions->top_bracket = (re->top_bracket + 1) * 2;
9430      functions->limit_match = (re->flags & PCRE_MLSET) != 0 ? re->limit_match : 0;
9431    extra->executable_jit = functions;    extra->executable_jit = functions;
9432    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;
9433    }    }
# Line 9480  arguments.begin = subject; Line 9482  arguments.begin = subject;
9482  arguments.end = subject + length;  arguments.end = subject + length;
9483  arguments.mark_ptr = NULL;  arguments.mark_ptr = NULL;
9484  /* JIT decreases this value less frequently than the interpreter. */  /* JIT decreases this value less frequently than the interpreter. */
9485  arguments.call_limit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;  arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit);
9486    if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match)
9487      arguments.limit_match = functions->limit_match;
9488  arguments.notbol = (options & PCRE_NOTBOL) != 0;  arguments.notbol = (options & PCRE_NOTBOL) != 0;
9489  arguments.noteol = (options & PCRE_NOTEOL) != 0;  arguments.noteol = (options & PCRE_NOTEOL) != 0;
9490  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
# Line 9571  arguments.begin = subject_ptr; Line 9575  arguments.begin = subject_ptr;
9575  arguments.end = subject_ptr + length;  arguments.end = subject_ptr + length;
9576  arguments.mark_ptr = NULL;  arguments.mark_ptr = NULL;
9577  /* JIT decreases this value less frequently than the interpreter. */  /* JIT decreases this value less frequently than the interpreter. */
9578  arguments.call_limit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;  arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit);
9579    if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match)
9580      arguments.limit_match = functions->limit_match;
9581  arguments.notbol = (options & PCRE_NOTBOL) != 0;  arguments.notbol = (options & PCRE_NOTBOL) != 0;
9582  arguments.noteol = (options & PCRE_NOTEOL) != 0;  arguments.noteol = (options & PCRE_NOTEOL) != 0;
9583  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;  arguments.notempty = (options & PCRE_NOTEMPTY) != 0;

Legend:
Removed from v.1310  
changed lines
  Added in v.1316

  ViewVC Help
Powered by ViewVC 1.1.5