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

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

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

revision 1291 by zherczeg, Sun Mar 17 05:27:48 2013 UTC revision 1300 by zherczeg, Mon Mar 25 12:34:26 2013 UTC
# Line 356  typedef struct compiler_common { Line 356  typedef struct compiler_common {
356    BOOL has_then;    BOOL has_then;
357    /* Needs to know the start position anytime. */    /* Needs to know the start position anytime. */
358    BOOL needs_start_ptr;    BOOL needs_start_ptr;
359    /* Currently in recurse or assert. */    /* Currently in recurse. */
360    BOOL local_exit;    BOOL local_exit;
361      /* Currently in assert. */
362      int then_local_exit;
363    /* Newline control. */    /* Newline control. */
364    int nltype;    int nltype;
365    int newline;    int newline;
# Line 382  typedef struct compiler_common { Line 384  typedef struct compiler_common {
384    recurse_entry *currententry;    recurse_entry *currententry;
385    jump_list *partialmatch;    jump_list *partialmatch;
386    jump_list *quit;    jump_list *quit;
387      jump_list *then_quit;
388    jump_list *forced_quit;    jump_list *forced_quit;
389    jump_list *accept;    jump_list *accept;
390    jump_list *calllimit;    jump_list *calllimit;
# Line 5500  jump_list *tmp = NULL; Line 5503  jump_list *tmp = NULL;
5503  jump_list **target = (conditional) ? &backtrack->condfailed : &backtrack->common.topbacktracks;  jump_list **target = (conditional) ? &backtrack->condfailed : &backtrack->common.topbacktracks;
5504  jump_list **found;  jump_list **found;
5505  /* Saving previous accept variables. */  /* Saving previous accept variables. */
5506  BOOL save_local_exit = common->local_exit;  int save_then_local_exit = common->then_local_exit;
5507  then_trap_backtrack *save_then_trap = common->then_trap;  then_trap_backtrack *save_then_trap = common->then_trap;
 struct sljit_label *save_quit_label = common->quit_label;  
5508  struct sljit_label *save_accept_label = common->accept_label;  struct sljit_label *save_accept_label = common->accept_label;
5509  jump_list *save_quit = common->quit;  jump_list *save_then_quit = common->then_quit;
5510  jump_list *save_accept = common->accept;  jump_list *save_accept = common->accept;
5511  struct sljit_jump *jump;  struct sljit_jump *jump;
5512  struct sljit_jump *brajump = NULL;  struct sljit_jump *brajump = NULL;
# Line 5574  else Line 5576  else
5576    }    }
5577    
5578  memset(&altbacktrack, 0, sizeof(backtrack_common));  memset(&altbacktrack, 0, sizeof(backtrack_common));
5579  common->local_exit = TRUE;  common->then_local_exit = (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) ? 1 : -1;
5580  common->quit_label = NULL;  common->then_quit = NULL;
 common->quit = NULL;  
5581  while (1)  while (1)
5582    {    {
5583    common->accept_label = NULL;    common->accept_label = NULL;
# Line 5591  while (1) Line 5592  while (1)
5592    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);
5593    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5594      {      {
5595      common->local_exit = save_local_exit;      common->then_local_exit = save_then_local_exit;
5596      common->then_trap = save_then_trap;      common->then_trap = save_then_trap;
     common->quit_label = save_quit_label;  
5597      common->accept_label = save_accept_label;      common->accept_label = save_accept_label;
5598      common->quit = save_quit;      common->then_quit = save_then_quit;
5599      common->accept = save_accept;      common->accept = save_accept;
5600      return NULL;      return NULL;
5601      }      }
# Line 5660  while (1) Line 5660  while (1)
5660    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
5661    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5662      {      {
5663      common->local_exit = save_local_exit;      common->then_local_exit = save_then_local_exit;
5664      common->then_trap = save_then_trap;      common->then_trap = save_then_trap;
     common->quit_label = save_quit_label;  
5665      common->accept_label = save_accept_label;      common->accept_label = save_accept_label;
5666      common->quit = save_quit;      common->then_quit = save_then_quit;
5667      common->accept = save_accept;      common->accept = save_accept;
5668      return NULL;      return NULL;
5669      }      }
# Line 5678  while (1) Line 5677  while (1)
5677    }    }
5678    
5679  /* None of them matched. */  /* None of them matched. */
5680  if (common->quit != NULL)  if (common->then_quit != NULL)
5681    {    {
5682    jump = JUMP(SLJIT_JUMP);    jump = JUMP(SLJIT_JUMP);
5683    set_jumps(common->quit, LABEL());    set_jumps(common->then_quit, LABEL());
5684    SLJIT_ASSERT(framesize != no_stack);    SLJIT_ASSERT(framesize != no_stack);
5685    if (framesize < 0)    if (framesize < 0)
5686      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, extrasize * sizeof(sljit_sw));      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, extrasize * sizeof(sljit_sw));
# Line 5841  else Line 5840  else
5840      }      }
5841    }    }
5842    
5843  common->local_exit = save_local_exit;  common->then_local_exit = save_then_local_exit;
5844  common->then_trap = save_then_trap;  common->then_trap = save_then_trap;
 common->quit_label = save_quit_label;  
5845  common->accept_label = save_accept_label;  common->accept_label = save_accept_label;
5846  common->quit = save_quit;  common->then_quit = save_then_quit;
5847  common->accept = save_accept;  common->accept = save_accept;
5848  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
5849  }  }
# Line 8326  pcre_uchar opcode = *current->cc; Line 8324  pcre_uchar opcode = *current->cc;
8324  struct sljit_label *loop;  struct sljit_label *loop;
8325  struct sljit_jump *jump;  struct sljit_jump *jump;
8326    
8327  if ((opcode == OP_THEN || opcode == OP_THEN_ARG) && common->then_trap != NULL)  if (opcode == OP_THEN || opcode == OP_THEN_ARG)
8328    {    {
8329    SLJIT_ASSERT(common->control_head_ptr != 0);    if (common->then_trap != NULL)
8330        {
8331        SLJIT_ASSERT(common->control_head_ptr != 0);
8332    
8333    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
8334    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, type_then_trap);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, type_then_trap);
8335    OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, common->then_trap->start);      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, common->then_trap->start);
8336    jump = JUMP(SLJIT_JUMP);      jump = JUMP(SLJIT_JUMP);
8337    
8338    loop = LABEL();      loop = LABEL();
8339    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), -(int)sizeof(sljit_sw));      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), -(int)sizeof(sljit_sw));
8340    JUMPHERE(jump);      JUMPHERE(jump);
8341    CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(2 * sizeof(sljit_sw)), TMP1, 0, loop);      CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(2 * sizeof(sljit_sw)), TMP1, 0, loop);
8342    CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(3 * sizeof(sljit_sw)), TMP2, 0, loop);      CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(3 * sizeof(sljit_sw)), TMP2, 0, loop);
8343    add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));      add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));
8344    return;      return;
8345        }
8346      else if (common->then_local_exit != 0)
8347        {
8348        if (common->then_local_exit > 0)
8349          add_jump(compiler, &common->then_quit, JUMP(SLJIT_JUMP));
8350        else if (common->accept_label == NULL)
8351          add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));
8352        else
8353          JUMPTO(SLJIT_JUMP, common->accept_label);
8354        return;
8355        }
8356    }    }
8357    
8358  if (common->local_exit)  if (common->local_exit)

Legend:
Removed from v.1291  
changed lines
  Added in v.1300

  ViewVC Help
Powered by ViewVC 1.1.5