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

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

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

revision 987 by zherczeg, Sat Jul 7 04:11:29 2012 UTC revision 989 by zherczeg, Sat Jul 7 11:11:02 2012 UTC
# Line 1308  while (cc < ccend) Line 1308  while (cc < ccend)
1308      case OP_NCLASS:      case OP_NCLASS:
1309  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
1310      case OP_XCLASS:      case OP_XCLASS:
1311      size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 / sizeof(pcre_uchar);      size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 / (int)sizeof(pcre_uchar);
1312  #else  #else
1313      size = 1 + 32 / sizeof(pcre_uchar);      size = 1 + 32 / (int)sizeof(pcre_uchar);
1314  #endif  #endif
1315      if (PRIV_DATA(cc))      if (PRIV_DATA(cc))
1316        localsize += get_class_iterator_size(cc + size);        localsize += get_class_iterator_size(cc + size);
# Line 1501  while (status != end) Line 1501  while (status != end)
1501        case OP_NCLASS:        case OP_NCLASS:
1502  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
1503        case OP_XCLASS:        case OP_XCLASS:
1504        size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 / sizeof(pcre_uchar);        size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 / (int)sizeof(pcre_uchar);
1505  #else  #else
1506        size = 1 + 32 / sizeof(pcre_uchar);        size = 1 + 32 / (int)sizeof(pcre_uchar);
1507  #endif  #endif
1508        if (PRIV_DATA(cc))        if (PRIV_DATA(cc))
1509          switch(get_class_iterator_size(cc + size))          switch(get_class_iterator_size(cc + size))
# Line 2514  struct sljit_jump *leave; Line 2514  struct sljit_jump *leave;
2514  struct sljit_jump *found;  struct sljit_jump *found;
2515  pcre_int32 chars[4];  pcre_int32 chars[4];
2516  pcre_uchar *cc = common->start + 1 + IMM2_SIZE;  pcre_uchar *cc = common->start + 1 + IMM2_SIZE;
2517  int index = 0;  int location = 0;
2518  pcre_int32 len, c, bit;  pcre_int32 len, c, bit, caseless;
 unsigned int caseless;  
2519  BOOL must_end;  BOOL must_end;
2520    
2521  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
# Line 2614  while (TRUE) Line 2613  while (TRUE)
2613    else    else
2614      caseless = 0;      caseless = 0;
2615    
2616    while (len > 0 && index < 2 * 2)    while (len > 0 && location < 2 * 2)
2617      {      {
2618      c = *cc;      c = *cc;
2619      bit = 0;      bit = 0;
# Line 2624  while (TRUE) Line 2623  while (TRUE)
2623        c |= bit;        c |= bit;
2624        }        }
2625    
2626      chars[index] = c;      chars[location] = c;
2627      chars[index + 1] = bit;      chars[location + 1] = bit;
2628    
2629      len--;      len--;
2630      index += 2;      location += 2;
2631      cc++;      cc++;
2632      }      }
2633    
2634    if (index == 2 * 2)    if (location == 2 * 2)
2635      break;      break;
2636    else if (must_end)    else if (must_end)
2637      return FALSE;      return FALSE;
# Line 5981  struct sljit_label *label; Line 5980  struct sljit_label *label;
5980  int localptr = PRIV_DATA(cc);  int localptr = PRIV_DATA(cc);
5981  int base = (localptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);  int base = (localptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);
5982  int offset0 = (localptr == 0) ? STACK(0) : localptr;  int offset0 = (localptr == 0) ? STACK(0) : localptr;
5983  int offset1 = (localptr == 0) ? STACK(1) : localptr + sizeof(sljit_w);  int offset1 = (localptr == 0) ? STACK(1) : localptr + (int)sizeof(sljit_w);
5984    int tmp_base, tmp_offset;
5985    
5986  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
5987    
5988  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, &end);  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, &end);
5989    
5990    switch (type)
5991      {
5992      case OP_NOT_DIGIT:
5993      case OP_DIGIT:
5994      case OP_NOT_WHITESPACE:
5995      case OP_WHITESPACE:
5996      case OP_NOT_WORDCHAR:
5997      case OP_WORDCHAR:
5998      case OP_ANY:
5999      case OP_ALLANY:
6000      case OP_ANYBYTE:
6001      case OP_ANYNL:
6002      case OP_NOT_HSPACE:
6003      case OP_HSPACE:
6004      case OP_NOT_VSPACE:
6005      case OP_VSPACE:
6006      case OP_CHAR:
6007      case OP_CHARI:
6008      case OP_NOT:
6009      case OP_NOTI:
6010      case OP_CLASS:
6011      case OP_NCLASS:
6012      tmp_base = TMP3;
6013      tmp_offset = 0;
6014      break;
6015    
6016      default:
6017      SLJIT_ASSERT_STOP();
6018      /* Fall through. */
6019    
6020      case OP_EXTUNI:
6021      case OP_XCLASS:
6022      case OP_NOTPROP:
6023      case OP_PROP:
6024      tmp_base = SLJIT_MEM1(SLJIT_LOCALS_REG);
6025      tmp_offset = POSSESSIVE0;
6026      break;
6027      }
6028    
6029  switch(opcode)  switch(opcode)
6030    {    {
6031    case OP_STAR:    case OP_STAR:
# Line 6007  switch(opcode) Line 6046  switch(opcode)
6046        allocate_stack(common, 1);        allocate_stack(common, 1);
6047        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
6048        }        }
6049    
6050      if (opcode == OP_UPTO || opcode == OP_CRRANGE)      if (opcode == OP_UPTO || opcode == OP_CRRANGE)
6051        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 0);
6052    
# Line 6023  switch(opcode) Line 6063  switch(opcode)
6063        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, TMP1, 0);
6064        }        }
6065    
6066        /* We cannot use TMP3 because of this allocate_stack. */
6067      allocate_stack(common, 1);      allocate_stack(common, 1);
6068      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
6069      JUMPTO(SLJIT_JUMP, label);      JUMPTO(SLJIT_JUMP, label);
# Line 6036  switch(opcode) Line 6077  switch(opcode)
6077      if (localptr == 0)      if (localptr == 0)
6078        allocate_stack(common, 2);        allocate_stack(common, 2);
6079      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6080      OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1);      if (opcode <= OP_PLUS)
6081          OP1(SLJIT_MOV, base, offset1, STR_PTR, 0);
6082        else
6083          OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1);
6084      label = LABEL();      label = LABEL();
6085      compile_char1_trypath(common, type, cc, &nomatch);      compile_char1_trypath(common, type, cc, &nomatch);
6086      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6087      if (opcode <= OP_PLUS || (opcode == OP_CRRANGE && arg1 == 0))      if (opcode <= OP_PLUS)
6088          JUMPTO(SLJIT_JUMP, label);
6089        else if (opcode == OP_CRRANGE && arg1 == 0)
6090        {        {
6091        OP2(SLJIT_ADD, base, offset1, base, offset1, SLJIT_IMM, 1);        OP2(SLJIT_ADD, base, offset1, base, offset1, SLJIT_IMM, 1);
6092        JUMPTO(SLJIT_JUMP, label);        JUMPTO(SLJIT_JUMP, label);
# Line 6092  switch(opcode) Line 6138  switch(opcode)
6138    break;    break;
6139    
6140    case OP_EXACT:    case OP_EXACT:
6141    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 1);    OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, arg1);
6142    label = LABEL();    label = LABEL();
6143    compile_char1_trypath(common, type, cc, &backtrack->topbacktracks);    compile_char1_trypath(common, type, cc, &backtrack->topbacktracks);
6144    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);    OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);
6145    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);    JUMPTO(SLJIT_C_NOT_ZERO, label);
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, TMP1, 0);  
   CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg1 + 1, label);  
6146    break;    break;
6147    
6148    case OP_POSSTAR:    case OP_POSSTAR:
6149    case OP_POSPLUS:    case OP_POSPLUS:
6150    case OP_POSUPTO:    case OP_POSUPTO:
6151    if (opcode != OP_POSSTAR)    if (opcode == OP_POSPLUS)
6152      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 1);      compile_char1_trypath(common, type, cc, &backtrack->topbacktracks);
6153    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STR_PTR, 0);    if (opcode == OP_POSUPTO)
6154        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_IMM, arg1);
6155      OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
6156    label = LABEL();    label = LABEL();
6157    compile_char1_trypath(common, type, cc, &nomatch);    compile_char1_trypath(common, type, cc, &nomatch);
6158    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STR_PTR, 0);    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
6159    if (opcode != OP_POSUPTO)    if (opcode != OP_POSUPTO)
     {  
     if (opcode == OP_POSPLUS)  
       OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 2);  
6160      JUMPTO(SLJIT_JUMP, label);      JUMPTO(SLJIT_JUMP, label);
     }  
6161    else    else
6162      {      {
6163      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0);      OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, SLJIT_IMM, 1);
6164      OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);      JUMPTO(SLJIT_C_NOT_ZERO, label);
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, TMP1, 0);  
     CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg1 + 1, label);  
6165      }      }
6166    set_jumps(nomatch, LABEL());    set_jumps(nomatch, LABEL());
6167    if (opcode == OP_POSPLUS)    OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
     add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_LESS, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE0, SLJIT_IMM, 2));  
   OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);  
6168    break;    break;
6169    
6170    case OP_POSQUERY:    case OP_POSQUERY:
6171    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STR_PTR, 0);    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
6172    compile_char1_trypath(common, type, cc, &nomatch);    compile_char1_trypath(common, type, cc, &nomatch);
6173    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STR_PTR, 0);    OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
6174    set_jumps(nomatch, LABEL());    set_jumps(nomatch, LABEL());
6175    OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1);    OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
6176    break;    break;
6177    
6178    default:    default:
# Line 6488  jump_list *jumplist = NULL; Line 6526  jump_list *jumplist = NULL;
6526  int localptr = PRIV_DATA(cc);  int localptr = PRIV_DATA(cc);
6527  int base = (localptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);  int base = (localptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);
6528  int offset0 = (localptr == 0) ? STACK(0) : localptr;  int offset0 = (localptr == 0) ? STACK(0) : localptr;
6529  int offset1 = (localptr == 0) ? STACK(1) : localptr + sizeof(sljit_w);  int offset1 = (localptr == 0) ? STACK(1) : localptr + (int)sizeof(sljit_w);
6530    
6531  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);
6532    
# Line 6508  switch(opcode) Line 6546  switch(opcode)
6546      }      }
6547    else    else
6548      {      {
6549      if (opcode <= OP_PLUS || opcode == OP_UPTO)      if (opcode == OP_UPTO)
6550        arg2 = 0;        arg2 = 0;
6551      OP1(SLJIT_MOV, TMP1, 0, base, offset1);      if (opcode <= OP_PLUS)
6552      jump = CMP(SLJIT_C_LESS_EQUAL, TMP1, 0, SLJIT_IMM, arg2 + 1);        {
6553      OP2(SLJIT_SUB, base, offset1, TMP1, 0, SLJIT_IMM, 1);        OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
6554      OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);        jump = CMP(SLJIT_C_LESS_EQUAL, STR_PTR, 0, base, offset1);
6555          }
6556        else
6557          {
6558          OP1(SLJIT_MOV, TMP1, 0, base, offset1);
6559          OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
6560          jump = CMP(SLJIT_C_LESS_EQUAL, TMP1, 0, SLJIT_IMM, arg2 + 1);
6561          OP2(SLJIT_SUB, base, offset1, TMP1, 0, SLJIT_IMM, 1);
6562          }
6563      skip_char_back(common);      skip_char_back(common);
6564      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6565      JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->trypath);      JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->trypath);

Legend:
Removed from v.987  
changed lines
  Added in v.989

  ViewVC Help
Powered by ViewVC 1.1.5