/[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 1279 by zherczeg, Tue Mar 12 17:27:34 2013 UTC revision 1282 by zherczeg, Fri Mar 15 08:01:41 2013 UTC
# Line 291  typedef struct recurse_entry { Line 291  typedef struct recurse_entry {
291    /* Collects the calls until the function is not created. */    /* Collects the calls until the function is not created. */
292    jump_list *calls;    jump_list *calls;
293    /* Points to the starting opcode. */    /* Points to the starting opcode. */
294    int start;    sljit_sw start;
295  } recurse_entry;  } recurse_entry;
296    
297  typedef struct recurse_backtrack {  typedef struct recurse_backtrack {
# Line 299  typedef struct recurse_backtrack { Line 299  typedef struct recurse_backtrack {
299    BOOL inlined_pattern;    BOOL inlined_pattern;
300  } recurse_backtrack;  } recurse_backtrack;
301    
302    #define OP_THEN_TRAP OP_TABLE_LENGTH
303    
304  typedef struct then_trap_backtrack {  typedef struct then_trap_backtrack {
305    backtrack_common common;    backtrack_common common;
306      /* If then_trap is not NULL, this structure contains the real
307      then_trap for the backtracking path. */
308    struct then_trap_backtrack *then_trap;    struct then_trap_backtrack *then_trap;
309      /* Points to the starting opcode. */
310      sljit_sw start;
311      /* Exit point for the then opcodes of this alternative. */
312    jump_list *quit;    jump_list *quit;
313      /* Frame size of the current alternative. */
314    int framesize;    int framesize;
315  } then_trap_backtrack;  } then_trap_backtrack;
316    
# Line 725  switch(*cc) Line 733  switch(*cc)
733    return cc + 1 + 2 + cc[1];    return cc + 1 + 2 + cc[1];
734    
735    default:    default:
736      /* All opcodes are supported now! */
737      SLJIT_ASSERT_STOP();
738    return NULL;    return NULL;
739    }    }
740  }  }
# Line 2147  while (current != NULL); Line 2157  while (current != NULL);
2157  return (return_value != 0 || skip_arg == NULL) ? return_value : -2;  return (return_value != 0 || skip_arg == NULL) ? return_value : -2;
2158  }  }
2159    
2160  static sljit_sw SLJIT_CALL do_search_then_trap(sljit_sw *current)  static sljit_sw SLJIT_CALL do_search_then_trap(sljit_sw *current, sljit_sw start)
2161  {  {
2162  do  do
2163    {    {
# Line 2158  do Line 2168  do
2168      return 0;      return 0;
2169    
2170      case type_then_trap:      case type_then_trap:
2171      return (sljit_sw)current;      if (current[-3] == start)
2172          return (sljit_sw)current;
2173        break;
2174    
2175      case type_prune:      case type_prune:
2176      case type_skip:      case type_skip:
# Line 5381  DEFINE_COMPILER; Line 5393  DEFINE_COMPILER;
5393  backtrack_common *backtrack;  backtrack_common *backtrack;
5394  recurse_entry *entry = common->entries;  recurse_entry *entry = common->entries;
5395  recurse_entry *prev = NULL;  recurse_entry *prev = NULL;
5396  int start = GET(cc, 1);  sljit_sw start = GET(cc, 1);
5397  pcre_uchar *start_cc;  pcre_uchar *start_cc;
5398  BOOL needs_control_head;  BOOL needs_control_head;
5399    
# Line 7322  if (common->control_head_ptr != 0 && ((o Line 7334  if (common->control_head_ptr != 0 && ((o
7334  return ccend;  return ccend;
7335  }  }
7336    
7337  static pcre_uchar then_trap_opcode[1] = { OP_TABLE_LENGTH };  static pcre_uchar then_trap_opcode[1] = { OP_THEN_TRAP };
7338    
7339  static SLJIT_INLINE void compile_then_trap_matchingpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, backtrack_common *parent)  static SLJIT_INLINE void compile_then_trap_matchingpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, backtrack_common *parent)
7340  {  {
# Line 7334  int size; Line 7346  int size;
7346  PUSH_BACKTRACK_NOVALUE(sizeof(then_trap_backtrack), cc);  PUSH_BACKTRACK_NOVALUE(sizeof(then_trap_backtrack), cc);
7347  common->then_trap = BACKTRACK_AS(then_trap_backtrack);  common->then_trap = BACKTRACK_AS(then_trap_backtrack);
7348  BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;  BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;
7349    BACKTRACK_AS(then_trap_backtrack)->start = (sljit_sw)(cc - common->start);
7350  BACKTRACK_AS(then_trap_backtrack)->framesize = get_framesize(common, cc, ccend, FALSE, &needs_control_head);  BACKTRACK_AS(then_trap_backtrack)->framesize = get_framesize(common, cc, ccend, FALSE, &needs_control_head);
7351    
7352  size = BACKTRACK_AS(then_trap_backtrack)->framesize;  size = BACKTRACK_AS(then_trap_backtrack)->framesize;
7353  size = 2 + (size < 0 ? 0 : size);  size = 3 + (size < 0 ? 0 : size);
7354    
7355  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);
7356  allocate_stack(common, size);  allocate_stack(common, size);
7357  if (size > 2)  if (size > 3)
7358    OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0, SLJIT_IMM, (size - 2) * sizeof(sljit_sw));    OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, STACK_TOP, 0, SLJIT_IMM, (size - 3) * sizeof(sljit_sw));
7359  else  else
7360    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);
7361  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 1), SLJIT_IMM, type_then_trap);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 1), SLJIT_IMM, BACKTRACK_AS(then_trap_backtrack)->start);
7362  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 2), TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 2), SLJIT_IMM, type_then_trap);
7363    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 3), TMP2, 0);
7364    
7365  size = BACKTRACK_AS(then_trap_backtrack)->framesize;  size = BACKTRACK_AS(then_trap_backtrack)->framesize;
7366  if (size >= 0)  if (size >= 0)
# Line 8401  if ((opcode == OP_THEN || opcode == OP_T Line 8415  if ((opcode == OP_THEN || opcode == OP_T
8415    {    {
8416    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
8417    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
8418    sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_search_then_trap));    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, common->then_trap->start);
8419      sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_search_then_trap));
8420    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
8421    
8422      OP1(SLJIT_MOV, TMP2, 0, TMP1, 0);
8423      OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
8424    if (common->quit_label == NULL)    if (common->quit_label == NULL)
8425      add_jump(compiler, &common->quit, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, 0));      add_jump(compiler, &common->quit, CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0));
8426    else    else
8427      CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, 0, common->quit_label);      CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, common->quit_label);
8428    
8429    OP1(SLJIT_MOV, STACK_TOP, 0, TMP1, 0);    OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);
8430    add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));    add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));
8431    return;    return;
8432    }    }
# Line 8447  if (CURRENT_AS(then_trap_backtrack)->the Line 8464  if (CURRENT_AS(then_trap_backtrack)->the
8464    }    }
8465    
8466  size = CURRENT_AS(then_trap_backtrack)->framesize;  size = CURRENT_AS(then_trap_backtrack)->framesize;
8467  size = 2 + (size < 0 ? 0 : size);  size = 3 + (size < 0 ? 0 : size);
8468    
8469  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(size - 2));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(size - 3));
8470  free_stack(common, size);  free_stack(common, size);
8471  jump = JUMP(SLJIT_JUMP);  jump = JUMP(SLJIT_JUMP);
8472    
# Line 8458  set_jumps(CURRENT_AS(then_trap_backtrack Line 8475  set_jumps(CURRENT_AS(then_trap_backtrack
8475  if (CURRENT_AS(then_trap_backtrack)->framesize >= 0)  if (CURRENT_AS(then_trap_backtrack)->framesize >= 0)
8476    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
8477  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
8478  free_stack(common, 2);  free_stack(common, 3);
8479    
8480  JUMPHERE(jump);  JUMPHERE(jump);
8481  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr, TMP1, 0);
# Line 8667  while (current) Line 8684  while (current)
8684      set_jumps(current->topbacktracks, LABEL());      set_jumps(current->topbacktracks, LABEL());
8685      break;      break;
8686    
8687      case OP_TABLE_LENGTH:      case OP_THEN_TRAP:
8688      /* A virtual opcode for then traps. */      /* A virtual opcode for then traps. */
8689      compile_then_trap_backtrackingpath(common, current);      compile_then_trap_backtrackingpath(common, current);
8690      break;      break;

Legend:
Removed from v.1279  
changed lines
  Added in v.1282

  ViewVC Help
Powered by ViewVC 1.1.5