/[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 915 by zherczeg, Tue Feb 14 13:05:39 2012 UTC revision 918 by zherczeg, Thu Feb 16 06:39:20 2012 UTC
# Line 1452  return (bit < 256) ? ((0 << 8) | bit) : Line 1452  return (bit < 256) ? ((0 << 8) | bit) :
1452  #endif /* COMPILE_PCRE8 */  #endif /* COMPILE_PCRE8 */
1453  }  }
1454    
1455  static void check_partial(compiler_common *common)  static void check_partial(compiler_common *common, BOOL force)
1456  {  {
1457    /* Checks whether a partial matching is occured. Does not modify registers. */
1458  DEFINE_COMPILER;  DEFINE_COMPILER;
1459  struct sljit_jump *jump;  struct sljit_jump *jump = NULL;
1460    
1461    SLJIT_ASSERT(!force || common->mode != JIT_COMPILE);
1462    
1463  if (common->mode == JIT_COMPILE)  if (common->mode == JIT_COMPILE)
1464    return;    return;
1465    
1466  jump = CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), START_USED_PTR, STR_PTR, 0);  if (!force || common->mode == JIT_PARTIAL_SOFT_COMPILE)
1467      jump = CMP(SLJIT_C_GREATER_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), START_USED_PTR, STR_PTR, 0);
1468    
1469  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)  if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
1470    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), HIT_START, SLJIT_IMM, -1);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), HIT_START, SLJIT_IMM, -1);
1471  else  else
# Line 1470  else Line 1475  else
1475    else    else
1476      add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));      add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));
1477    }    }
1478  JUMPHERE(jump);  
1479    if (jump != NULL)
1480      JUMPHERE(jump);
1481  }  }
1482    
1483  static struct sljit_jump *check_str_end(compiler_common *common)  static struct sljit_jump *check_str_end(compiler_common *common)
# Line 3181  switch(type) Line 3188  switch(type)
3188    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
3189      {      {
3190      jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);      jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);
3191      jump[1] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);      if (common->mode == JIT_COMPILE)
3192          jump[1] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
3193        else
3194          {
3195          jump[1] = CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0);
3196          /* Since we successfully read a char above, partial matching must occure. */
3197          check_partial(common, TRUE);
3198          add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3199          JUMPHERE(jump[1]);
3200          jump[1] = NULL;
3201          }
3202    
3203      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
3204      add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff));      add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff));
3205      JUMPHERE(jump[1]);      if (jump[1] != NULL)
3206          JUMPHERE(jump[1]);
3207      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
3208      }      }
3209    else    else
# Line 3242  switch(type) Line 3261  switch(type)
3261    fallback_at_str_end(common, fallbacks);    fallback_at_str_end(common, fallbacks);
3262    read_char(common);    read_char(common);
3263    jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);    jump[0] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
3264    jump[1] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    /* We don't need to handle soft partial matching case. */
3265      if (common->mode != JIT_PARTIAL_HARD_COMPILE)
3266        jump[1] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
3267      else
3268        jump[1] = check_str_end(common);
3269    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
3270    jump[2] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);    jump[2] = CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);
3271    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
# Line 3291  switch(type) Line 3314  switch(type)
3314    if (common->mode == JIT_PARTIAL_HARD_COMPILE)    if (common->mode == JIT_PARTIAL_HARD_COMPILE)
3315      {      {
3316      jump[0] = CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0);      jump[0] = CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0);
3317      check_partial(common);      /* Since we successfully read a char above, partial matching must occure. */
3318        check_partial(common, TRUE);
3319      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
3320      }      }
3321    return cc;    return cc;
3322  #endif  #endif
3323    
3324    case OP_EODN:    case OP_EODN:
3325      /* Requires rather complex checks. */
3326    jump[0] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    jump[0] = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
3327    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
3328      {      {
3329      OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));      OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
3330      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
3331      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_END, 0));      if (common->mode == JIT_COMPILE)
3332          add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, STR_END, 0));
3333        else
3334          {
3335          jump[1] = CMP(SLJIT_C_EQUAL, TMP2, 0, STR_END, 0);
3336          OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP2, 0, STR_END, 0);
3337          COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_LESS);
3338          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);
3339          COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_NOT_EQUAL);
3340          add_jump(compiler, fallbacks, JUMP(SLJIT_C_NOT_EQUAL));
3341          check_partial(common, TRUE);
3342          add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3343          JUMPHERE(jump[1]);
3344          }
3345      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
3346      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
3347      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));
# Line 3348  switch(type) Line 3386  switch(type)
3386      JUMPHERE(jump[3]);      JUMPHERE(jump[3]);
3387      }      }
3388    JUMPHERE(jump[0]);    JUMPHERE(jump[0]);
3389    check_partial(common);    check_partial(common, FALSE);
3390    return cc;    return cc;
3391    
3392    case OP_EOD:    case OP_EOD:
3393    add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, STR_PTR, 0, STR_END, 0));    add_jump(compiler, fallbacks, CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0));
3394    check_partial(common);    check_partial(common, FALSE);
3395    return cc;    return cc;
3396    
3397    case OP_CIRC:    case OP_CIRC:
# Line 3402  switch(type) Line 3440  switch(type)
3440    else    else
3441      {      {
3442      add_jump(compiler, fallbacks, CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0));      add_jump(compiler, fallbacks, CMP(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0));
3443      check_partial(common);      check_partial(common, FALSE);
3444      }      }
3445    return cc;    return cc;
3446    
# Line 3411  switch(type) Line 3449  switch(type)
3449    OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);    OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
3450    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol));    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol));
3451    add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));    add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
3452    check_partial(common);    check_partial(common, FALSE);
3453    jump[0] = JUMP(SLJIT_JUMP);    jump[0] = JUMP(SLJIT_JUMP);
3454    JUMPHERE(jump[1]);    JUMPHERE(jump[1]);
3455    
3456    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
3457      {      {
3458      OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));      OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
     add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, TMP2, 0, STR_END, 0));  
3459      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
3460        if (common->mode == JIT_COMPILE)
3461          add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER, TMP2, 0, STR_END, 0));
3462        else
3463          {
3464          jump[1] = CMP(SLJIT_C_LESS_EQUAL, TMP2, 0, STR_END, 0);
3465          /* STR_PTR = STR_END - IN_UCHARS(1) */
3466          add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
3467          check_partial(common, TRUE);
3468          add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3469          JUMPHERE(jump[1]);
3470          }
3471    
3472      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
3473      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
3474      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));
# Line 3761  if (common->utf && *cc == OP_REFI) Line 3810  if (common->utf && *cc == OP_REFI)
3810      {      {
3811      add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));      add_jump(compiler, fallbacks, CMP(SLJIT_C_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));
3812      nopartial = CMP(SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);      nopartial = CMP(SLJIT_C_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
3813      check_partial(common);      check_partial(common, FALSE);
3814      add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));      add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3815      JUMPHERE(nopartial);      JUMPHERE(nopartial);
3816      }      }
# Line 3794  else Line 3843  else
3843      add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));      add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
3844      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
3845      JUMPHERE(partial);      JUMPHERE(partial);
3846      check_partial(common);      check_partial(common, FALSE);
3847      add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));      add_jump(compiler, fallbacks, JUMP(SLJIT_JUMP));
3848      JUMPHERE(nopartial);      JUMPHERE(nopartial);
3849      }      }

Legend:
Removed from v.915  
changed lines
  Added in v.918

  ViewVC Help
Powered by ViewVC 1.1.5