/[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 1300 by zherczeg, Mon Mar 25 12:34:26 2013 UTC revision 1303 by zherczeg, Fri Mar 29 09:01:20 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. */    /* Currently in recurse or negative assert. */
360    BOOL local_exit;    BOOL local_exit;
361    /* Currently in assert. */    /* Currently in a positive assert. */
362    int then_local_exit;    BOOL positive_assert;
363    /* Newline control. */    /* Newline control. */
364    int nltype;    int nltype;
365    int newline;    int newline;
# Line 384  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;    jump_list *positive_assert_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 5503  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  int save_then_local_exit = common->then_local_exit;  BOOL save_local_exit = common->local_exit;
5507    BOOL save_positive_assert = common->positive_assert;
5508  then_trap_backtrack *save_then_trap = common->then_trap;  then_trap_backtrack *save_then_trap = common->then_trap;
5509    struct sljit_label *save_quit_label = common->quit_label;
5510  struct sljit_label *save_accept_label = common->accept_label;  struct sljit_label *save_accept_label = common->accept_label;
5511  jump_list *save_then_quit = common->then_quit;  jump_list *save_quit = common->quit;
5512    jump_list *save_positive_assert_quit = common->positive_assert_quit;
5513  jump_list *save_accept = common->accept;  jump_list *save_accept = common->accept;
5514  struct sljit_jump *jump;  struct sljit_jump *jump;
5515  struct sljit_jump *brajump = NULL;  struct sljit_jump *brajump = NULL;
# Line 5576  else Line 5579  else
5579    }    }
5580    
5581  memset(&altbacktrack, 0, sizeof(backtrack_common));  memset(&altbacktrack, 0, sizeof(backtrack_common));
5582  common->then_local_exit = (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) ? 1 : -1;  if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
5583  common->then_quit = NULL;    {
5584      /* Negative assert is stronger than positive assert. */
5585      common->local_exit = TRUE;
5586      common->quit_label = NULL;
5587      common->quit = NULL;
5588      common->positive_assert = FALSE;
5589      }
5590    else
5591      common->positive_assert = TRUE;
5592    common->positive_assert_quit = NULL;
5593    
5594  while (1)  while (1)
5595    {    {
5596    common->accept_label = NULL;    common->accept_label = NULL;
# Line 5592  while (1) Line 5605  while (1)
5605    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);    compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);
5606    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5607      {      {
5608      common->then_local_exit = save_then_local_exit;      if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
5609          {
5610          common->local_exit = save_local_exit;
5611          common->quit_label = save_quit_label;
5612          common->quit = save_quit;
5613          }
5614        common->positive_assert = save_positive_assert;
5615      common->then_trap = save_then_trap;      common->then_trap = save_then_trap;
5616      common->accept_label = save_accept_label;      common->accept_label = save_accept_label;
5617      common->then_quit = save_then_quit;      common->positive_assert_quit = save_positive_assert_quit;
5618      common->accept = save_accept;      common->accept = save_accept;
5619      return NULL;      return NULL;
5620      }      }
# Line 5660  while (1) Line 5679  while (1)
5679    compile_backtrackingpath(common, altbacktrack.top);    compile_backtrackingpath(common, altbacktrack.top);
5680    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
5681      {      {
5682      common->then_local_exit = save_then_local_exit;      if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
5683          {
5684          common->local_exit = save_local_exit;
5685          common->quit_label = save_quit_label;
5686          common->quit = save_quit;
5687          }
5688        common->positive_assert = save_positive_assert;
5689      common->then_trap = save_then_trap;      common->then_trap = save_then_trap;
5690      common->accept_label = save_accept_label;      common->accept_label = save_accept_label;
5691      common->then_quit = save_then_quit;      common->positive_assert_quit = save_positive_assert_quit;
5692      common->accept = save_accept;      common->accept = save_accept;
5693      return NULL;      return NULL;
5694      }      }
# Line 5676  while (1) Line 5701  while (1)
5701    cc += GET(cc, 1);    cc += GET(cc, 1);
5702    }    }
5703    
5704    if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
5705      {
5706      SLJIT_ASSERT(common->positive_assert_quit == NULL);
5707      /* Makes the check less complicated below. */
5708      common->positive_assert_quit = common->quit;
5709      }
5710    
5711  /* None of them matched. */  /* None of them matched. */
5712  if (common->then_quit != NULL)  if (common->positive_assert_quit != NULL)
5713    {    {
5714    jump = JUMP(SLJIT_JUMP);    jump = JUMP(SLJIT_JUMP);
5715    set_jumps(common->then_quit, LABEL());    set_jumps(common->positive_assert_quit, LABEL());
5716    SLJIT_ASSERT(framesize != no_stack);    SLJIT_ASSERT(framesize != no_stack);
5717    if (framesize < 0)    if (framesize < 0)
5718      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 5840  else Line 5872  else
5872      }      }
5873    }    }
5874    
5875  common->then_local_exit = save_then_local_exit;  if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
5876      {
5877      common->local_exit = save_local_exit;
5878      common->quit_label = save_quit_label;
5879      common->quit = save_quit;
5880      }
5881    common->positive_assert = save_positive_assert;
5882  common->then_trap = save_then_trap;  common->then_trap = save_then_trap;
5883  common->accept_label = save_accept_label;  common->accept_label = save_accept_label;
5884  common->then_quit = save_then_quit;  common->positive_assert_quit = save_positive_assert_quit;
5885  common->accept = save_accept;  common->accept = save_accept;
5886  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
5887  }  }
# Line 8343  if (opcode == OP_THEN || opcode == OP_TH Line 8381  if (opcode == OP_THEN || opcode == OP_TH
8381      add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));      add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));
8382      return;      return;
8383      }      }
8384    else if (common->then_local_exit != 0)    else if (common->positive_assert)
8385      {      {
8386      if (common->then_local_exit > 0)      add_jump(compiler, &common->positive_assert_quit, JUMP(SLJIT_JUMP));
       add_jump(compiler, &common->then_quit, JUMP(SLJIT_JUMP));  
     else if (common->accept_label == NULL)  
       add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));  
     else  
       JUMPTO(SLJIT_JUMP, common->accept_label);  
8387      return;      return;
8388      }      }
8389    }    }

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

  ViewVC Help
Powered by ViewVC 1.1.5