/[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 1623 by zherczeg, Thu Feb 4 17:13:10 2016 UTC revision 1624 by zherczeg, Fri Feb 5 13:47:43 2016 UTC
# Line 1406  while (cc < ccend) Line 1406  while (cc < ccend)
1406      case OP_CLASS:      case OP_CLASS:
1407      case OP_NCLASS:      case OP_NCLASS:
1408      case OP_XCLASS:      case OP_XCLASS:
1409        case OP_CALLOUT:
1410    
1411      cc = next_opcode(common, cc);      cc = next_opcode(common, cc);
1412      SLJIT_ASSERT(cc != NULL);      SLJIT_ASSERT(cc != NULL);
# Line 2113  static SLJIT_INLINE void allocate_stack( Line 2114  static SLJIT_INLINE void allocate_stack(
2114  /* May destroy all locals and registers except TMP2. */  /* May destroy all locals and registers except TMP2. */
2115  DEFINE_COMPILER;  DEFINE_COMPILER;
2116    
2117    SLJIT_ASSERT(size > 0);
2118  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
2119  #ifdef DESTROY_REGISTERS  #ifdef DESTROY_REGISTERS
2120  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);
# Line 2127  add_stub(common, CMP(SLJIT_GREATER, STAC Line 2129  add_stub(common, CMP(SLJIT_GREATER, STAC
2129  static SLJIT_INLINE void free_stack(compiler_common *common, int size)  static SLJIT_INLINE void free_stack(compiler_common *common, int size)
2130  {  {
2131  DEFINE_COMPILER;  DEFINE_COMPILER;
2132    
2133    SLJIT_ASSERT(size > 0);
2134  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
2135  }  }
2136    
# Line 6485  return cc + 2 + 2 * LINK_SIZE; Line 6489  return cc + 2 + 2 * LINK_SIZE;
6489  #undef CALLOUT_ARG_SIZE  #undef CALLOUT_ARG_SIZE
6490  #undef CALLOUT_ARG_OFFSET  #undef CALLOUT_ARG_OFFSET
6491    
6492    static SLJIT_INLINE BOOL assert_needs_str_ptr_saving(pcre_uchar *cc)
6493    {
6494    while (TRUE)
6495      {
6496      switch (*cc)
6497        {
6498        case OP_NOT_WORD_BOUNDARY:
6499        case OP_WORD_BOUNDARY:
6500        case OP_CIRC:
6501        case OP_CIRCM:
6502        case OP_DOLL:
6503        case OP_DOLLM:
6504        case OP_CALLOUT:
6505        case OP_ALT:
6506        cc += PRIV(OP_lengths)[*cc];
6507        break;
6508    
6509        case OP_KET:
6510        return FALSE;
6511    
6512        default:
6513        return TRUE;
6514        }
6515      }
6516    }
6517    
6518  static pcre_uchar *compile_assert_matchingpath(compiler_common *common, pcre_uchar *cc, assert_backtrack *backtrack, BOOL conditional)  static pcre_uchar *compile_assert_matchingpath(compiler_common *common, pcre_uchar *cc, assert_backtrack *backtrack, BOOL conditional)
6519  {  {
6520  DEFINE_COMPILER;  DEFINE_COMPILER;
# Line 6541  if (bra == OP_BRAMINZERO) Line 6571  if (bra == OP_BRAMINZERO)
6571    
6572  if (framesize < 0)  if (framesize < 0)
6573    {    {
6574    extrasize = needs_control_head ? 2 : 1;    extrasize = 1;
6575      if (bra == OP_BRA && !assert_needs_str_ptr_saving(ccbegin + 1 + LINK_SIZE))
6576        extrasize = 0;
6577    
6578      if (needs_control_head)
6579        extrasize++;
6580    
6581    if (framesize == no_frame)    if (framesize == no_frame)
6582      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0);
6583    allocate_stack(common, extrasize);  
6584      if (extrasize > 0)
6585        allocate_stack(common, extrasize);
6586    
6587    if (needs_control_head)    if (needs_control_head)
6588      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
6589    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);  
6590      if (extrasize > 0)
6591        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
6592    
6593    if (needs_control_head)    if (needs_control_head)
6594      {      {
6595        SLJIT_ASSERT(extrasize == 2);
6596      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);
6597      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
6598      }      }
# Line 6558  else Line 6601  else
6601    {    {
6602    extrasize = needs_control_head ? 3 : 2;    extrasize = needs_control_head ? 3 : 2;
6603    allocate_stack(common, framesize + extrasize);    allocate_stack(common, framesize + extrasize);
6604    
6605    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
6606    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw));    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw));
6607    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP2, 0);
# Line 6572  else Line 6616  else
6616      }      }
6617    else    else
6618      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
6619    
6620    init_frame(common, ccbegin, NULL, framesize + extrasize - 1, extrasize, FALSE);    init_frame(common, ccbegin, NULL, framesize + extrasize - 1, extrasize, FALSE);
6621    }    }
6622    
# Line 6595  while (1) Line 6640  while (1)
6640    altbacktrack.top = NULL;    altbacktrack.top = NULL;
6641    altbacktrack.topbacktracks = NULL;    altbacktrack.topbacktracks = NULL;
6642    
6643    if (*ccbegin == OP_ALT)    if (*ccbegin == OP_ALT && extrasize > 0)
6644      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
6645    
6646    altbacktrack.cc = ccbegin;    altbacktrack.cc = ccbegin;
# Line 6624  while (1) Line 6669  while (1)
6669      {      {
6670      if (framesize == no_frame)      if (framesize == no_frame)
6671        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
6672      else      else if (extrasize > 0)
6673        free_stack(common, extrasize);        free_stack(common, extrasize);
6674    
6675      if (needs_control_head)      if (needs_control_head)
6676        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0);
6677      }      }
# Line 6651  while (1) Line 6697  while (1)
6697      {      {
6698      /* We know that STR_PTR was stored on the top of the stack. */      /* We know that STR_PTR was stored on the top of the stack. */
6699      if (conditional)      if (conditional)
6700        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? sizeof(sljit_sw) : 0);        {
6701          if (extrasize > 0)
6702            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? sizeof(sljit_sw) : 0);
6703          }
6704      else if (bra == OP_BRAZERO)      else if (bra == OP_BRAZERO)
6705        {        {
6706        if (framesize < 0)        if (framesize < 0)
# Line 6728  if (needs_control_head) Line 6777  if (needs_control_head)
6777  if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK)  if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK)
6778    {    {
6779    /* Assert is failed. */    /* Assert is failed. */
6780    if (conditional || bra == OP_BRAZERO)    if ((conditional && extrasize > 0) || bra == OP_BRAZERO)
6781      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
6782    
6783    if (framesize < 0)    if (framesize < 0)
# Line 6740  if (opcode == OP_ASSERT || opcode == OP_ Line 6789  if (opcode == OP_ASSERT || opcode == OP_
6789          free_stack(common, 1);          free_stack(common, 1);
6790        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
6791        }        }
6792      else      else if (extrasize > 0)
6793        free_stack(common, extrasize);        free_stack(common, extrasize);
6794      }      }
6795    else    else
# Line 6765  if (opcode == OP_ASSERT || opcode == OP_ Line 6814  if (opcode == OP_ASSERT || opcode == OP_
6814    if (framesize < 0)    if (framesize < 0)
6815      {      {
6816      /* We know that STR_PTR was stored on the top of the stack. */      /* We know that STR_PTR was stored on the top of the stack. */
6817      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw));      if (extrasize > 0)
6818          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw));
6819    
6820      /* Keep the STR_PTR on the top of the stack. */      /* Keep the STR_PTR on the top of the stack. */
6821      if (bra == OP_BRAZERO)      if (bra == OP_BRAZERO)
6822        {        {
# Line 6828  else Line 6879  else
6879    /* AssertNot is successful. */    /* AssertNot is successful. */
6880    if (framesize < 0)    if (framesize < 0)
6881      {      {
6882      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      if (extrasize > 0)
6883          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
6884    
6885      if (bra != OP_BRA)      if (bra != OP_BRA)
6886        {        {
6887        if (extrasize == 2)        if (extrasize == 2)
6888          free_stack(common, 1);          free_stack(common, 1);
6889        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
6890        }        }
6891      else      else if (extrasize > 0)
6892        free_stack(common, extrasize);        free_stack(common, extrasize);
6893      }      }
6894    else    else
# Line 6897  if (framesize < 0) Line 6950  if (framesize < 0)
6950      stacksize = needs_control_head ? 1 : 0;      stacksize = needs_control_head ? 1 : 0;
6951      if (ket != OP_KET || has_alternatives)      if (ket != OP_KET || has_alternatives)
6952        stacksize++;        stacksize++;
6953      free_stack(common, stacksize);  
6954        if (stacksize > 0)
6955          free_stack(common, stacksize);
6956      }      }
6957    
6958    if (needs_control_head)    if (needs_control_head)

Legend:
Removed from v.1623  
changed lines
  Added in v.1624

  ViewVC Help
Powered by ViewVC 1.1.5