/[pcre]/code/branches/pcre16/pcre_jit_compile.c
ViewVC logotype

Diff of /code/branches/pcre16/pcre_jit_compile.c

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

revision 767 by zherczeg, Sat Nov 26 12:48:56 2011 UTC revision 769 by zherczeg, Sun Nov 27 17:40:33 2011 UTC
# Line 564  switch(*cc) Line 564  switch(*cc)
564    case OP_NOTMINUPTOI:    case OP_NOTMINUPTOI:
565    case OP_NOTEXACTI:    case OP_NOTEXACTI:
566    case OP_NOTPOSUPTOI:    case OP_NOTPOSUPTOI:
567    cc += 4;    cc += 2 + IMM2_SIZE;
568  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
569    if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];    if (common->utf8 && cc[-1] >= 0xc0) cc += PRIV(utf8_table4)[cc[-1] & 0x3f];
570  #endif  #endif
# Line 583  switch(*cc) Line 583  switch(*cc)
583    case OP_RREF:    case OP_RREF:
584    case OP_NRREF:    case OP_NRREF:
585    case OP_CLOSE:    case OP_CLOSE:
586    cc += 3;    cc += 1 + IMM2_SIZE;
587    return cc;    return cc;
588    
589    case OP_CRRANGE:    case OP_CRRANGE:
590    case OP_CRMINRANGE:    case OP_CRMINRANGE:
591    return cc + 5;    return cc + 1 + 2 * IMM2_SIZE;
592    
593    case OP_CLASS:    case OP_CLASS:
594    case OP_NCLASS:    case OP_NCLASS:
# Line 624  switch(*cc) Line 624  switch(*cc)
624    case OP_CBRAPOS:    case OP_CBRAPOS:
625    case OP_SCBRA:    case OP_SCBRA:
626    case OP_SCBRAPOS:    case OP_SCBRAPOS:
627    return cc + 1 + LINK_SIZE + 2;    return cc + 1 + LINK_SIZE + IMM2_SIZE;
628    
629    default:    default:
630    return NULL;    return NULL;
# Line 657  while (cc < ccend) Line 657  while (cc < ccend)
657      case OP_CBRAPOS:      case OP_CBRAPOS:
658      case OP_SCBRAPOS:      case OP_SCBRAPOS:
659      localspace += sizeof(sljit_w);      localspace += sizeof(sljit_w);
660      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
661      break;      break;
662    
663      case OP_COND:      case OP_COND:
# Line 705  while (cc < ccend) Line 705  while (cc < ccend)
705      case OP_SCBRAPOS:      case OP_SCBRAPOS:
706      common->localptrs[cc - common->start] = localptr;      common->localptrs[cc - common->start] = localptr;
707      localptr += sizeof(sljit_w);      localptr += sizeof(sljit_w);
708      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
709      break;      break;
710    
711      case OP_COND:      case OP_COND:
# Line 761  while (cc < ccend) Line 761  while (cc < ccend)
761      case OP_SCBRA:      case OP_SCBRA:
762      case OP_SCBRAPOS:      case OP_SCBRAPOS:
763      length += 3;      length += 3;
764      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
765      break;      break;
766    
767      default:      default:
# Line 824  while (cc < ccend) Line 824  while (cc < ccend)
824      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);
825      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_w);
826    
827      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
828      break;      break;
829    
830      default:      default:
# Line 863  while (cc < ccend) Line 863  while (cc < ccend)
863      case OP_CBRA:      case OP_CBRA:
864      case OP_SCBRA:      case OP_SCBRA:
865      localsize++;      localsize++;
866      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
867      break;      break;
868    
869      case OP_CBRAPOS:      case OP_CBRAPOS:
870      case OP_SCBRAPOS:      case OP_SCBRAPOS:
871      localsize += 2;      localsize += 2;
872      cc += 1 + LINK_SIZE + 2;      cc += 1 + LINK_SIZE + IMM2_SIZE;
873      break;      break;
874    
875      case OP_COND:      case OP_COND:
# Line 969  while (status != end) Line 969  while (status != end)
969        case OP_SCBRA:        case OP_SCBRA:
970        count = 1;        count = 1;
971        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
972        cc += 1 + LINK_SIZE + 2;        cc += 1 + LINK_SIZE + IMM2_SIZE;
973        break;        break;
974    
975        case OP_CBRAPOS:        case OP_CBRAPOS:
# Line 978  while (status != end) Line 978  while (status != end)
978        srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
979        srcw[0] = PRIV_DATA(cc);        srcw[0] = PRIV_DATA(cc);
980        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
981        cc += 1 + LINK_SIZE + 2;        cc += 1 + LINK_SIZE + IMM2_SIZE;
982        break;        break;
983    
984        case OP_COND:        case OP_COND:
# Line 1427  if (common->utf8) Line 1427  if (common->utf8)
1427    return;    return;
1428    }    }
1429  #endif  #endif
1430  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1431  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1432  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);
1433  }  }
1434    
# Line 1449  if (common->utf8) Line 1449  if (common->utf8)
1449    return;    return;
1450    }    }
1451  #endif  #endif
1452  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1453  }  }
1454    
1455  static void check_newlinechar(compiler_common *common, int nltype, jump_list **fallbacks, BOOL jumpiftrue)  static void check_newlinechar(compiler_common *common, int nltype, jump_list **fallbacks, BOOL jumpiftrue)
# Line 3116  switch(type) Line 3116  switch(type)
3116    
3117    case OP_NOT:    case OP_NOT:
3118    case OP_NOTI:    case OP_NOTI:
   length = 1;  
3119  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3120    if (common->utf8)    if (common->utf8)
3121      {      {
3122        length = 1;
3123      if (*cc >= 0xc0) length += PRIV(utf8_table4)[*cc & 0x3f];      if (*cc >= 0xc0) length += PRIV(utf8_table4)[*cc & 0x3f];
3124    
3125      check_input_end(common, fallbacks);      check_input_end(common, fallbacks);
# Line 3150  switch(type) Line 3150  switch(type)
3150    else    else
3151  #endif  #endif
3152      {      {
3153      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
3154      add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));      add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, STR_PTR, 0, STR_END, 0));
3155      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -1);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
3156      c = *cc;      c = *cc;
3157      }      }
3158    
# Line 3173  switch(type) Line 3173  switch(type)
3173        add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, oc));        add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, oc));
3174        }        }
3175      }      }
3176    return cc + length;    return cc + 1;
3177    
3178    case OP_CLASS:    case OP_CLASS:
3179    case OP_NCLASS:    case OP_NCLASS:
# Line 3403  if (jump != NULL) Line 3403  if (jump != NULL)
3403    else    else
3404      JUMPHERE(jump);      JUMPHERE(jump);
3405    }    }
3406  return cc + 3;  return cc + 1 + IMM2_SIZE;
3407  }  }
3408    
3409  static SLJIT_INLINE pcre_uchar *compile_ref_iterator_hotpath(compiler_common *common, pcre_uchar *cc, fallback_common *parent)  static SLJIT_INLINE pcre_uchar *compile_ref_iterator_hotpath(compiler_common *common, pcre_uchar *cc, fallback_common *parent)
# Line 3420  BOOL minimize; Line 3420  BOOL minimize;
3420    
3421  PUSH_FALLBACK(sizeof(iterator_fallback), cc, NULL);  PUSH_FALLBACK(sizeof(iterator_fallback), cc, NULL);
3422    
3423  type = cc[3];  type = cc[1 + IMM2_SIZE];
3424  minimize = (type & 0x1) != 0;  minimize = (type & 0x1) != 0;
3425  switch(type)  switch(type)
3426    {    {
# Line 3428  switch(type) Line 3428  switch(type)
3428    case OP_CRMINSTAR:    case OP_CRMINSTAR:
3429    min = 0;    min = 0;
3430    max = 0;    max = 0;
3431    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3432    break;    break;
3433    case OP_CRPLUS:    case OP_CRPLUS:
3434    case OP_CRMINPLUS:    case OP_CRMINPLUS:
3435    min = 1;    min = 1;
3436    max = 0;    max = 0;
3437    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3438    break;    break;
3439    case OP_CRQUERY:    case OP_CRQUERY:
3440    case OP_CRMINQUERY:    case OP_CRMINQUERY:
3441    min = 0;    min = 0;
3442    max = 1;    max = 1;
3443    cc += 4;    cc += 1 + IMM2_SIZE + 1;
3444    break;    break;
3445    case OP_CRRANGE:    case OP_CRRANGE:
3446    case OP_CRMINRANGE:    case OP_CRMINRANGE:
3447    min = GET2(cc, 3 + 1);    min = GET2(cc, 1 + IMM2_SIZE + 1);
3448    max = GET2(cc, 3 + 3);    max = GET2(cc, 1 + IMM2_SIZE + 1 + IMM2_SIZE);
3449    cc += 8;    cc += 1 + IMM2_SIZE + 1 + 2 * IMM2_SIZE;
3450    break;    break;
3451    default:    default:
3452    SLJIT_ASSERT_STOP();    SLJIT_ASSERT_STOP();
# Line 4101  if (opcode == OP_CBRA || opcode == OP_SC Line 4101  if (opcode == OP_CBRA || opcode == OP_SC
4101    localptr = OVECTOR_PRIV(offset);    localptr = OVECTOR_PRIV(offset);
4102    offset <<= 1;    offset <<= 1;
4103    FALLBACK_AS(bracket_fallback)->localptr = localptr;    FALLBACK_AS(bracket_fallback)->localptr = localptr;
4104    hotpath += 2;    hotpath += IMM2_SIZE;
4105    }    }
4106  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)
4107    {    {
# Line 4265  if (opcode == OP_COND || opcode == OP_SC Line 4265  if (opcode == OP_COND || opcode == OP_SC
4265      SLJIT_ASSERT(has_alternatives);      SLJIT_ASSERT(has_alternatives);
4266      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed),      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed),
4267        CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(hotpath, 1) << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));        CMP(SLJIT_C_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(GET2(hotpath, 1) << 1), SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(1)));
4268      hotpath += 3;      hotpath += 1 + IMM2_SIZE;
4269      }      }
4270    else if (*hotpath == OP_NCREF)    else if (*hotpath == OP_NCREF)
4271      {      {
# Line 4284  if (opcode == OP_COND || opcode == OP_SC Line 4284  if (opcode == OP_COND || opcode == OP_SC
4284      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));      add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));
4285    
4286      JUMPHERE(jump);      JUMPHERE(jump);
4287      hotpath += 3;      hotpath += 1 + IMM2_SIZE;
4288      }      }
4289    else if (*hotpath == OP_RREF || *hotpath == OP_NRREF)    else if (*hotpath == OP_RREF || *hotpath == OP_NRREF)
4290      {      {
# Line 4305  if (opcode == OP_COND || opcode == OP_SC Line 4305  if (opcode == OP_COND || opcode == OP_SC
4305        {        {
4306        SLJIT_ASSERT(!has_alternatives);        SLJIT_ASSERT(!has_alternatives);
4307        if (stacksize != 0)        if (stacksize != 0)
4308          hotpath += 3;          hotpath += 1 + IMM2_SIZE;
4309        else        else
4310          {          {
4311          if (*cc == OP_ALT)          if (*cc == OP_ALT)
# Line 4332  if (opcode == OP_COND || opcode == OP_SC Line 4332  if (opcode == OP_COND || opcode == OP_SC
4332        sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));        sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchgroups));
4333        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);
4334        add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));        add_jump(compiler, &(FALLBACK_AS(bracket_fallback)->u.condfailed), CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, 0));
4335        hotpath += 3;        hotpath += 1 + IMM2_SIZE;
4336        }        }
4337      }      }
4338    else    else
# Line 4507  switch(opcode) Line 4507  switch(opcode)
4507    offset = GET2(cc, 1 + LINK_SIZE);    offset = GET2(cc, 1 + LINK_SIZE);
4508    cbraprivptr = OVECTOR_PRIV(offset);    cbraprivptr = OVECTOR_PRIV(offset);
4509    offset <<= 1;    offset <<= 1;
4510    ccbegin = cc + 1 + LINK_SIZE + 2;    ccbegin = cc + 1 + LINK_SIZE + IMM2_SIZE;
4511    break;    break;
4512    
4513    default:    default:
# Line 4736  else Line 4736  else
4736    else    else
4737      {      {
4738      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);      SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE);
4739      *arg1 = GET2(cc, (class_len + 2));      *arg1 = GET2(cc, (class_len + IMM2_SIZE));
4740      *arg2 = GET2(cc, class_len);      *arg2 = GET2(cc, class_len);
4741    
4742      if (*arg2 == 0)      if (*arg2 == 0)
# Line 4748  else Line 4748  else
4748        *opcode = OP_EXACT;        *opcode = OP_EXACT;
4749    
4750      if (end != NULL)      if (end != NULL)
4751        *end = cc + class_len + 4;        *end = cc + class_len + 2 * IMM2_SIZE;
4752      }      }
4753    return cc;    return cc;
4754    }    }
# Line 4756  else Line 4756  else
4756  if (*opcode == OP_UPTO || *opcode == OP_MINUPTO || *opcode == OP_EXACT || *opcode == OP_POSUPTO)  if (*opcode == OP_UPTO || *opcode == OP_MINUPTO || *opcode == OP_EXACT || *opcode == OP_POSUPTO)
4757    {    {
4758    *arg1 = GET2(cc, 0);    *arg1 = GET2(cc, 0);
4759    cc += 2;    cc += IMM2_SIZE;
4760    }    }
4761    
4762  if (*type == 0)  if (*type == 0)
# Line 4998  int offset = GET2(cc, 1); Line 4998  int offset = GET2(cc, 1);
4998    
4999  /* Data will be discarded anyway... */  /* Data will be discarded anyway... */
5000  if (common->currententry != NULL)  if (common->currententry != NULL)
5001    return cc + 3;    return cc + 1 + IMM2_SIZE;
5002    
5003  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR_PRIV(offset));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR_PRIV(offset));
5004  offset <<= 1;  offset <<= 1;
5005  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), STR_PTR, 0);
5006  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
5007  return cc + 3;  return cc + 1 + IMM2_SIZE;
5008  }  }
5009    
5010  static void compile_hotpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, fallback_common *parent)  static void compile_hotpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, fallback_common *parent)
# Line 5150  while (cc < ccend) Line 5150  while (cc < ccend)
5150    
5151      case OP_REF:      case OP_REF:
5152      case OP_REFI:      case OP_REFI:
5153      if (cc[3] >= OP_CRSTAR && cc[3] <= OP_CRMINRANGE)      if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRMINRANGE)
5154        cc = compile_ref_iterator_hotpath(common, cc, parent);        cc = compile_ref_iterator_hotpath(common, cc, parent);
5155      else      else
5156        cc = compile_ref_hotpath(common, cc, parent->top != NULL ? &parent->top->nextfallbacks : &parent->topfallbacks, TRUE, FALSE);        cc = compile_ref_hotpath(common, cc, parent->top != NULL ? &parent->top->nextfallbacks : &parent->topfallbacks, TRUE, FALSE);
# Line 5388  DEFINE_COMPILER; Line 5388  DEFINE_COMPILER;
5388  pcre_uchar *cc = current->cc;  pcre_uchar *cc = current->cc;
5389  pcre_uchar type;  pcre_uchar type;
5390    
5391  type = cc[3];  type = cc[1 + IMM2_SIZE];
5392  if ((type & 0x1) == 0)  if ((type & 0x1) == 0)
5393    {    {
5394    set_jumps(current->topfallbacks, LABEL());    set_jumps(current->topfallbacks, LABEL());
# Line 6062  static SLJIT_INLINE void compile_recurse Line 6062  static SLJIT_INLINE void compile_recurse
6062  {  {
6063  DEFINE_COMPILER;  DEFINE_COMPILER;
6064  pcre_uchar *cc = common->start + common->currententry->start;  pcre_uchar *cc = common->start + common->currententry->start;
6065  pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : 2);  pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
6066  pcre_uchar *ccend = bracketend(cc);  pcre_uchar *ccend = bracketend(cc);
6067  int localsize = get_localsize(common, ccbegin, ccend);  int localsize = get_localsize(common, ccbegin, ccend);
6068  int framesize = get_framesize(common, cc, TRUE);  int framesize = get_framesize(common, cc, TRUE);

Legend:
Removed from v.767  
changed lines
  Added in v.769

  ViewVC Help
Powered by ViewVC 1.1.5