/[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 1277 by zherczeg, Mon Mar 11 09:50:29 2013 UTC revision 1278 by zherczeg, Tue Mar 12 06:15:04 2013 UTC
# Line 204  enum frame_types { Line 204  enum frame_types {
204  enum control_types {  enum control_types {
205    type_commit = 0,    type_commit = 0,
206    type_prune = 1,    type_prune = 1,
207    type_skip = 2    type_skip = 2,
208      type_skip_arg = 3,
209      type_mark = 4
210  };  };
211    
212  typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);  typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);
# Line 332  typedef struct compiler_common { Line 334  typedef struct compiler_common {
334    int mode;    int mode;
335    /* \K is in the pattern. */    /* \K is in the pattern. */
336    BOOL has_set_som;    BOOL has_set_som;
337      /* (*SKIP:arg) is in the pattern. */
338      BOOL has_skip_arg;
339    /* Needs to know the start position anytime. */    /* Needs to know the start position anytime. */
340    BOOL needs_start_ptr;    BOOL needs_start_ptr;
341    /* Currently in recurse or assert. */    /* Currently in recurse or assert. */
# Line 696  switch(*cc) Line 700  switch(*cc)
700    
701    case OP_MARK:    case OP_MARK:
702    case OP_PRUNE_ARG:    case OP_PRUNE_ARG:
703      case OP_SKIP_ARG:
704    return cc + 1 + 2 + cc[1];    return cc + 1 + 2 + cc[1];
705    
706    default:    default:
# Line 964  while (cc < ccend) Line 969  while (cc < ccend)
969      case OP_PRUNE:      case OP_PRUNE:
970      case OP_SKIP:      case OP_SKIP:
971      common->needs_start_ptr = TRUE;      common->needs_start_ptr = TRUE;
     /* Fall through. */  
   
     case OP_COMMIT:  
972      common->control_head_ptr = 1;      common->control_head_ptr = 1;
973      cc += 1;      cc += 1;
974      break;      break;
975    
976        case OP_SKIP_ARG:
977        common->control_head_ptr = 1;
978        common->has_skip_arg = TRUE;
979        cc += 1 + 2 + cc[1];
980        break;
981    
982      default:      default:
983      cc = next_opcode(common, cc);      cc = next_opcode(common, cc);
984      if (cc == NULL)      if (cc == NULL)
# Line 1239  while (cc < ccend) Line 1247  while (cc < ccend)
1247    
1248      case OP_PRUNE:      case OP_PRUNE:
1249      case OP_SKIP:      case OP_SKIP:
1250        case OP_SKIP_ARG:
1251      case OP_COMMIT:      case OP_COMMIT:
1252      if (common->control_head_ptr != 0)      if (common->control_head_ptr != 0)
1253        *needs_control_head = TRUE;        *needs_control_head = TRUE;
# Line 2025  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1( Line 2034  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(
2034  static sljit_sw SLJIT_CALL do_check_control_chain(sljit_sw *current)  static sljit_sw SLJIT_CALL do_check_control_chain(sljit_sw *current)
2035  {  {
2036  sljit_sw return_value = 0;  sljit_sw return_value = 0;
2037    const pcre_uchar *skip_arg = NULL;
2038    
2039  SLJIT_ASSERT(current != NULL);  SLJIT_ASSERT(current != NULL);
2040  do  do
# Line 2040  do Line 2050  do
2050    
2051      case type_skip:      case type_skip:
2052      /* Overwrites prune, but not other skips. */      /* Overwrites prune, but not other skips. */
2053      if (return_value == 0)      if (return_value == 0 && skip_arg == NULL)
2054        return_value = current[-3];        return_value = current[-3];
2055      break;      break;
2056    
2057        case type_skip_arg:
2058        if (return_value == 0 && skip_arg == NULL)
2059          skip_arg = (pcre_uchar *)current[-3];
2060        break;
2061    
2062        case type_mark:
2063        if (return_value == 0 && skip_arg != NULL)
2064          if (STRCMP_UC_UC(skip_arg, (pcre_uchar *)current[-3]) == 0)
2065            return_value = current[-4];
2066        break;
2067    
2068      default:      default:
2069      SLJIT_ASSERT_STOP();      SLJIT_ASSERT_STOP();
2070      break;      break;
# Line 2051  do Line 2072  do
2072    current = (sljit_sw*)current[-1];    current = (sljit_sw*)current[-1];
2073    }    }
2074  while (current != NULL);  while (current != NULL);
2075  return return_value;  return (return_value != 0 || skip_arg == NULL) ? return_value : -2;
2076  }  }
2077    
2078  static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)  static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)
# Line 7368  while (cc < ccend) Line 7389  while (cc < ccend)
7389      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
7390      SLJIT_ASSERT(common->mark_ptr != 0);      SLJIT_ASSERT(common->mark_ptr != 0);
7391      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);
7392      allocate_stack(common, 1);      allocate_stack(common, common->has_skip_arg ? 5 : 1);
7393      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
7394      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(common->has_skip_arg ? 4 : 0), TMP2, 0);
7395      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
7396      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);
7397      OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
7398        if (common->has_skip_arg)
7399          {
7400          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
7401          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0);
7402          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, type_mark);
7403          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), SLJIT_IMM, (sljit_sw)(cc + 2));
7404          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(3), STR_PTR, 0);
7405          OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
7406          }
7407      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
7408      break;      break;
7409    
# Line 7397  while (cc < ccend) Line 7427  while (cc < ccend)
7427      break;      break;
7428    
7429      case OP_SKIP:      case OP_SKIP:
7430        case OP_SKIP_ARG:
7431      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);      PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
7432      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
7433      allocate_stack(common, 3);      allocate_stack(common, 3);
7434      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0);
7435      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, type_skip);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, *cc == OP_SKIP ? type_skip : type_skip_arg);
7436      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), *cc == OP_SKIP ? STR_PTR : SLJIT_IMM, *cc == OP_SKIP ? 0 : (sljit_sw)(cc + 2));
7437      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
7438      cc += 1;      cc += (*cc == OP_SKIP_ARG) ? (1 + 2 + cc[1]) : 1;
7439      break;      break;
7440    
7441      case OP_FAIL:      case OP_FAIL:
# Line 8310  while (current) Line 8341  while (current)
8341      break;      break;
8342    
8343      case OP_MARK:      case OP_MARK:
8344      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(common->has_skip_arg ? 4 : 0));
8345      free_stack(common, 1);      if (common->has_skip_arg)
8346          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
8347        free_stack(common, common->has_skip_arg ? 5 : 1);
8348      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);
8349        if (common->has_skip_arg)
8350          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, TMP2, 0);
8351      break;      break;
8352    
8353      case OP_PRUNE:      case OP_PRUNE:
# Line 8339  while (current) Line 8374  while (current)
8374        JUMPTO(SLJIT_JUMP, common->quit_label);        JUMPTO(SLJIT_JUMP, common->quit_label);
8375      break;      break;
8376    
8377        case OP_SKIP_ARG:
8378        if (!common->local_exit)
8379          {
8380          SLJIT_ASSERT(common->control_head_ptr != 0);
8381          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
8382          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
8383          sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_check_control_chain));
8384          OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
8385    
8386          OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0);
8387          add_jump(compiler, &common->reset_match, CMP(SLJIT_C_LESS, STR_PTR, 0, SLJIT_IMM, -2));
8388    
8389          /* May not find suitable mark. */
8390          OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8391          if (common->quit_label == NULL)
8392            add_jump(compiler, &common->quit, CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_IMM, -1));
8393          else
8394            CMPTO(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_IMM, -1, common->quit_label);
8395    
8396          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
8397          free_stack(common, 3);
8398          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, TMP1, 0);
8399          }
8400        else
8401          {
8402          /* In recurse or accept. */
8403          if (common->quit_label == NULL)
8404            add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
8405          else
8406            JUMPTO(SLJIT_JUMP, common->quit_label);
8407          }
8408        break;
8409    
8410      case OP_COMMIT:      case OP_COMMIT:
8411      if (!common->local_exit)      if (!common->local_exit)
8412        OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);        OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);

Legend:
Removed from v.1277  
changed lines
  Added in v.1278

  ViewVC Help
Powered by ViewVC 1.1.5