/[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 1420 by zherczeg, Sun Dec 29 11:43:10 2013 UTC revision 1421 by zherczeg, Mon Dec 30 13:25:20 2013 UTC
# Line 407  typedef struct compiler_common { Line 407  typedef struct compiler_common {
407    jump_list *utfreadchar;    jump_list *utfreadchar;
408  #endif  #endif
409  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
410    jump_list *utfreadchar8;    jump_list *utfreadchar11;
411    jump_list *utfreadtype8;    jump_list *utfreadtype8;
412  #endif  #endif
413  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
# Line 2472  struct sljit_jump *jump; Line 2472  struct sljit_jump *jump;
2472  #endif  #endif
2473    
2474  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2475    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2476  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2477  if (common->utf)  if (common->utf)
2478    {    {
# Line 2484  if (common->utf) Line 2485  if (common->utf)
2485    JUMPHERE(jump);    JUMPHERE(jump);
2486    }    }
2487  #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */  #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */
 OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));  
2488  }  }
2489    
2490  static void peek_char(compiler_common *common)  static void peek_char(compiler_common *common)
# Line 2505  if (common->utf) Line 2505  if (common->utf)
2505  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
2506    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
2507  #endif /* COMPILE_PCRE[8|16] */  #endif /* COMPILE_PCRE[8|16] */
2508      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2509    add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
2510    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);    OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
2511    JUMPHERE(jump);    JUMPHERE(jump);
# Line 2512  if (common->utf) Line 2513  if (common->utf)
2513  #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */  #endif /* SUPPORT_UTF && !COMPILE_PCRE32 */
2514  }  }
2515    
2516  static void read_char8(compiler_common *common)  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
2517    
2518    static BOOL is_char7_bitset(const pcre_uint8* bitset, BOOL nclass)
2519    {
2520    const pcre_uint8 value = nclass ? 0xff : 0;
2521    const pcre_uint8* end = bitset + 32;
2522    
2523    bitset += 16;
2524    do
2525      {
2526      if (*bitset++ != value)
2527        return FALSE;
2528      }
2529    while (bitset < end);
2530    return TRUE;
2531    }
2532    
2533    static void read_char7_type(compiler_common *common, BOOL full_read)
2534    {
2535    /* Reads the precise character type of a character into TMP1, if the character is
2536    less than 128. Otherwise it returns with zero. */
2537    DEFINE_COMPILER;
2538    struct sljit_jump *jump;
2539    
2540    SLJIT_ASSERT(common->utf);
2541    
2542    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
2543    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2544    
2545    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
2546    
2547    if (full_read)
2548      {
2549      jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0);
2550      OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2551      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
2552      JUMPHERE(jump);
2553      }
2554    }
2555    
2556    #endif /* SUPPORT_UTF && COMPILE_PCRE8 */
2557    
2558    static void read_char_max(compiler_common *common, pcre_uint32 max, BOOL full_read)
2559  {  {
2560  /* Reads the precise value of a character into TMP1, if the character is  /* Reads the precise value of a character into TMP1, if the character is
2561  less than 256. Otherwise it returns with a value greater or equal than 256. */  less than or equal to max. Otherwise it returns with a value greater than max. */
2562  DEFINE_COMPILER;  DEFINE_COMPILER;
2563  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32
2564  struct sljit_jump *jump;  struct sljit_jump *jump;
2565  #endif  #endif
2566    
2567    SLJIT_UNUSED_ARG(full_read);
2568    SLJIT_UNUSED_ARG(max);
2569    
2570  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
2571  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));
2572    
2573  #if defined SUPPORT_UTF && !defined COMPILE_PCRE32  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
2574  if (common->utf)  if (common->utf)
2575    {    {
2576  #if defined COMPILE_PCRE8    if (max < 128 && !full_read)
2577        return;
2578    
2579    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2580    add_jump(compiler, &common->utfreadchar8, JUMP(SLJIT_FAST_CALL));    if (max < 128)
2581        {
2582        OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2583        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
2584        }
2585      else if (max < 0x400)
2586        {
2587        OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2588        if (!full_read)
2589          OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2590        else
2591          OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2592        OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
2593        OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
2594        OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2595        OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2596        if (full_read)
2597          OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
2598        }
2599      else
2600        add_jump(compiler, (max < 0x800) ? &common->utfreadchar11 : &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
2601    JUMPHERE(jump);    JUMPHERE(jump);
2602  #elif defined COMPILE_PCRE16    }
2603    #endif
2604    
2605    #if defined SUPPORT_UTF && defined COMPILE_PCRE16
2606    if (common->utf)
2607      {
2608      if (max < 0xd800 && !full_read)
2609        return;
2610    
2611      if (max >= 0x10000)
2612        {
2613        jump = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
2614        add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
2615        JUMPHERE(jump);
2616        return;
2617        }
2618    
2619    /* Skip low surrogate if necessary. */    /* Skip low surrogate if necessary. */
2620    OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);    OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);
2621    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
2622    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));    if (full_read)
2623        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2624      if (max >= 0xd800)
2625        OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0x10000);
2626    JUMPHERE(jump);    JUMPHERE(jump);
 #endif /* COMPILE_PCRE[8|16] */  
2627    }    }
2628  #endif  #endif
2629  }  }
2630    
2631  static void read_char8_type(compiler_common *common)  static void read_char8_type(compiler_common *common, BOOL full_read)
2632  {  {
2633  /* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. */  /* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. */
2634  DEFINE_COMPILER;  DEFINE_COMPILER;
2635  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
2636  struct sljit_jump *jump;  struct sljit_jump *jump;
2637  #endif  #endif
2638    #if defined SUPPORT_UTF && defined COMPILE_PCRE8
2639    struct sljit_jump *jump2;
2640    #endif
2641    
2642  #ifdef SUPPORT_UTF  SLJIT_UNUSED_ARG(full_read);
2643    
2644    OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
2645    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2646    
2647    #if defined SUPPORT_UTF && defined COMPILE_PCRE8
2648  if (common->utf)  if (common->utf)
2649    {    {
   OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);  
   OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));  
 #if defined COMPILE_PCRE8  
2650    /* This can be an extra read in some situations, but hopefully    /* This can be an extra read in some situations, but hopefully
2651    it is needed in most cases. */    it is needed in most cases. */
2652    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
2653    jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0);    jump = CMP(SLJIT_C_LESS, TMP2, 0, SLJIT_IMM, 0xc0);
2654    add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL));    if (!full_read)
2655    JUMPHERE(jump);      {
2656  #elif defined COMPILE_PCRE16      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2657    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2658    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);      OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2659    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);      OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
2660    JUMPHERE(jump);      OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
2661    /* Skip low surrogate if necessary. */      OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0);
2662    OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2663    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);      jump2 = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);
2664    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
2665    JUMPHERE(jump);      JUMPHERE(jump2);
2666  #elif defined COMPILE_PCRE32      }
2667    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);    else
2668    jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);      add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL));
   OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);  
2669    JUMPHERE(jump);    JUMPHERE(jump);
 #endif /* COMPILE_PCRE[8|16|32] */  
2670    return;    return;
2671    }    }
2672  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF && COMPILE_PCRE8 */
2673  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);  
2674  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));  #if !defined COMPILE_PCRE8
 #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  
2675  /* The ctypes array contains only 256 values. */  /* The ctypes array contains only 256 values. */
2676  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2677  jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);  jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 255);
2678  #endif  #endif
2679  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
2680  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if !defined COMPILE_PCRE8
2681  JUMPHERE(jump);  JUMPHERE(jump);
2682  #endif  #endif
2683    
2684    #if defined SUPPORT_UTF && defined COMPILE_PCRE16
2685    if (common->utf && full_read)
2686      {
2687      /* Skip low surrogate if necessary. */
2688      OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);
2689      jump = CMP(SLJIT_C_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
2690      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
2691      JUMPHERE(jump);
2692      }
2693    #endif /* SUPPORT_UTF && COMPILE_PCRE16 */
2694  }  }
2695    
2696  static void skip_char_back(compiler_common *common)  static void skip_char_back(compiler_common *common)
# Line 2669  sljit_emit_fast_enter(compiler, RETURN_A Line 2768  sljit_emit_fast_enter(compiler, RETURN_A
2768  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);
2769  jump = JUMP(SLJIT_C_NOT_ZERO);  jump = JUMP(SLJIT_C_NOT_ZERO);
2770  /* Two byte sequence. */  /* Two byte sequence. */
2771  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2772  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));
2773  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1f);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1f);
2774  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
2775  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2776  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2777  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2));
2778  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2779  JUMPHERE(jump);  JUMPHERE(jump);
2780    
2781  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10);  OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10);
2782  jump = JUMP(SLJIT_C_NOT_ZERO);  jump = JUMP(SLJIT_C_NOT_ZERO);
2783  /* Three byte sequence. */  /* Three byte sequence. */
2784  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2785  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0f);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0f);
2786  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 12);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 12);
2787  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2788  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
2789  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2790  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
2791  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
2792  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2793  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2794  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(3));
2795  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2796  JUMPHERE(jump);  JUMPHERE(jump);
2797    
2798  /* Four byte sequence. */  /* Four byte sequence. */
2799  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2800  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x07);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x07);
2801  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 18);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 18);
2802  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2803  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 12);
2804  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2805  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
2806  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2807  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
2808  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2809  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(3));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
2810  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3));  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3));
2811  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
2812  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2813  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(3));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(4));
2814  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2815  }  }
2816    
2817  static void do_utfreadchar8(compiler_common *common)  static void do_utfreadchar11(compiler_common *common)
2818  {  {
2819  /* Fast decoding a UTF-8 character. TMP1 contains the first byte  /* Fast decoding a UTF-8 character. TMP1 contains the first byte
2820  of the character (>= 0xc0). Return value in TMP1. */  of the character (>= 0xc0). Return value in TMP1. */
# Line 2794  sljit_emit_fast_return(compiler, RETURN_ Line 2893  sljit_emit_fast_return(compiler, RETURN_
2893    
2894  JUMPHERE(jump);  JUMPHERE(jump);
2895  /* Combine two 16 bit characters. */  /* Combine two 16 bit characters. */
2896  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));  OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
2897  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));
2898  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff);
2899  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 10);  OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 10);
2900  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3ff);  OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3ff);
2901  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
2902  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2));
2903  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000);  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000);
2904  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2905  }  }
# Line 2960  static int scan_prefix(compiler_common * Line 3059  static int scan_prefix(compiler_common *
3059  {  {
3060  /* Recursive function, which scans prefix literals. */  /* Recursive function, which scans prefix literals. */
3061  int len, repeat, len_save, consumed = 0;  int len, repeat, len_save, consumed = 0;
3062  pcre_int32 caseless, chr, mask;  pcre_uint32 caseless, chr, mask;
3063  pcre_uchar *alternative, *cc_save;  pcre_uchar *alternative, *cc_save;
3064  BOOL last, any;  BOOL last, any;
3065    
# Line 3763  OP2(SLJIT_XOR | SLJIT_SET_E, SLJIT_UNUSE Line 3862  OP2(SLJIT_XOR | SLJIT_SET_E, SLJIT_UNUSE
3862  sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);  sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
3863  }  }
3864    
3865  /*  static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks)
   range format:  
   
   ranges[0] = length of the range (max MAX_RANGE_SIZE, -1 means invalid range).  
   ranges[1] = first bit (0 or 1)  
   ranges[2-length] = position of the bit change (when the current bit is not equal to the previous)  
 */  
   
 static BOOL check_ranges(compiler_common *common, int *ranges, jump_list **backtracks, BOOL readch)  
3866  {  {
3867  DEFINE_COMPILER;  DEFINE_COMPILER;
3868  int offset;  int ranges[MAX_RANGE_SIZE];
3869    pcre_uint8 bit, cbit, all;
3870    int i, byte, length = 0;
3871    
3872    bit = bits[0] & 0x1;
3873    /* All bits will be zero or one (since bit is zero or one). */
3874    all = -bit;
3875    
3876    for (i = 0; i < 256; )
3877      {
3878      byte = i >> 3;
3879      if ((i & 0x7) == 0 && bits[byte] == all)
3880        i += 8;
3881      else
3882        {
3883        cbit = (bits[byte] >> (i & 0x7)) & 0x1;
3884        if (cbit != bit)
3885          {
3886          if (length >= MAX_RANGE_SIZE)
3887            return FALSE;
3888          ranges[length] = i;
3889          length++;
3890          bit = cbit;
3891          all = -cbit;
3892          }
3893        i++;
3894        }
3895      }
3896    
3897  if (ranges[0] < 0 || ranges[0] > 4)  if (((bit == 0) && nclass) || ((bit == 1) && !nclass))
3898      {
3899      if (length >= MAX_RANGE_SIZE)
3900        return FALSE;
3901      ranges[length] = 256;
3902      length++;
3903      }
3904    
3905    if (length < 0 || length > 4)
3906    return FALSE;    return FALSE;
3907    
3908    bit = bits[0] & 0x1;
3909    if (invert) bit ^= 0x1;
3910    
3911  /* No character is accepted. */  /* No character is accepted. */
3912  if (ranges[0] == 0 && ranges[1] == 0)  if (length == 0 && bit == 0)
3913    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));    add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
3914    
3915  if (readch)  switch(length)
   read_char8(common);  
   
 switch(ranges[0])  
3916    {    {
3917    case 0:    case 0:
3918    /* When ranges[1] != 0, all characters are accepted. */    /* When bit != 0, all characters are accepted. */
3919    return TRUE;    return TRUE;
3920    
3921    case 1:    case 1:
3922    add_jump(compiler, backtracks, CMP(ranges[1] == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));    add_jump(compiler, backtracks, CMP(bit == 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
3923    return TRUE;    return TRUE;
3924    
3925    case 2:    case 2:
3926    if (ranges[2] + 1 != ranges[3])    if (ranges[0] + 1 != ranges[1])
3927      {      {
3928      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
3929      add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));      add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
3930      }      }
3931    else    else
3932      add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));      add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
3933    return TRUE;    return TRUE;
3934    
3935    case 3:    case 3:
3936    if (ranges[1] != 0)    if (bit != 0)
3937      {      {
3938      add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));      add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3939      if (ranges[2] + 1 != ranges[3])      if (ranges[0] + 1 != ranges[1])
3940        {        {
3941        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
3942        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
3943        }        }
3944      else      else
3945        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
3946      return TRUE;      return TRUE;
3947      }      }
3948    
3949    add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2]));    add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[0]));
3950    if (ranges[3] + 1 != ranges[4])    if (ranges[1] + 1 != ranges[2])
3951      {      {
3952      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3]);      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1]);
3953      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1]));
3954      }      }
3955    else    else
3956      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3]));      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1]));
3957    return TRUE;    return TRUE;
3958    
3959    case 4:    case 4:
3960    if ((ranges[3] - ranges[2]) == (ranges[5] - ranges[4])    if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2])
3961        && (ranges[2] | (ranges[4] - ranges[2])) == ranges[4]        && (ranges[0] | (ranges[2] - ranges[0])) == ranges[2]
3962        && is_powerof2(ranges[4] - ranges[2]))        && is_powerof2(ranges[2] - ranges[0]))
3963      {      {
3964      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[2]);      OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]);
3965      if (ranges[4] + 1 != ranges[5])      if (ranges[2] + 1 != ranges[3])
3966        {        {
3967        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4]);        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
3968        add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));        add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_LESS : SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3969        }        }
3970      else      else
3971        add_jump(compiler, backtracks, CMP(ranges[1] != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4]));        add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_C_EQUAL : SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
3972      return TRUE;      return TRUE;
3973      }      }
3974    
3975    if (ranges[1] != 0)    if (bit != 0)
3976      {      {
3977      offset = 0;      i = 0;
3978      if (ranges[2] + 1 != ranges[3])      if (ranges[0] + 1 != ranges[1])
3979        {        {
3980        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
3981        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
3982        offset = ranges[2];        i = ranges[0];
3983        }        }
3984      else      else
3985        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
3986    
3987      if (ranges[4] + 1 != ranges[5])      if (ranges[2] + 1 != ranges[3])
3988        {        {
3989        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[4] - offset);        OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - i);
3990        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[4]));        add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
3991        }        }
3992      else      else
3993        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[4] - offset));        add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2] - i));
3994      return TRUE;      return TRUE;
3995      }      }
3996    
3997    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);    OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
3998    add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[5] - ranges[2]));    add_jump(compiler, backtracks, CMP(SLJIT_C_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[0]));
3999    if (ranges[3] + 1 != ranges[4])    if (ranges[1] + 1 != ranges[2])
4000      {      {
4001      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]);      OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]);
4002      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[4] - ranges[3]));      add_jump(compiler, backtracks, CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1]));
4003      }      }
4004    else    else
4005      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));      add_jump(compiler, backtracks, CMP(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
4006    return TRUE;    return TRUE;
4007    
4008    default:    default:
# Line 3885  switch(ranges[0]) Line 4011  switch(ranges[0])
4011    }    }
4012  }  }
4013    
 static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks)  
 {  
 int ranges[2 + MAX_RANGE_SIZE];  
 pcre_uint8 bit, cbit, all;  
 int i, byte, length = 0;  
   
 bit = bits[0] & 0x1;  
 ranges[1] = !invert ? bit : (bit ^ 0x1);  
 /* All bits will be zero or one (since bit is zero or one). */  
 all = -bit;  
   
 for (i = 0; i < 256; )  
   {  
   byte = i >> 3;  
   if ((i & 0x7) == 0 && bits[byte] == all)  
     i += 8;  
   else  
     {  
     cbit = (bits[byte] >> (i & 0x7)) & 0x1;  
     if (cbit != bit)  
       {  
       if (length >= MAX_RANGE_SIZE)  
         return FALSE;  
       ranges[2 + length] = i;  
       length++;  
       bit = cbit;  
       all = -cbit;  
       }  
     i++;  
     }  
   }  
   
 if (((bit == 0) && nclass) || ((bit == 1) && !nclass))  
   {  
   if (length >= MAX_RANGE_SIZE)  
     return FALSE;  
   ranges[2 + length] = 256;  
   length++;  
   }  
 ranges[0] = length;  
   
 return check_ranges(common, ranges, backtracks, FALSE);  
 }  
   
4014  static void check_anynewline(compiler_common *common)  static void check_anynewline(compiler_common *common)
4015  {  {
4016  /* Check whether TMP1 contains a newline character. TMP2 destroyed. */  /* Check whether TMP1 contains a newline character. TMP2 destroyed. */
# Line 4828  struct sljit_label *label; Line 4910  struct sljit_label *label;
4910  #ifdef SUPPORT_UCP  #ifdef SUPPORT_UCP
4911  pcre_uchar propdata[5];  pcre_uchar propdata[5];
4912  #endif  #endif
4913  #endif  #endif /* SUPPORT_UTF */
4914    
4915  switch(type)  switch(type)
4916    {    {
# Line 4854  switch(type) Line 4936  switch(type)
4936    case OP_DIGIT:    case OP_DIGIT:
4937    /* Digits are usually 0-9, so it is worth to optimize them. */    /* Digits are usually 0-9, so it is worth to optimize them. */
4938    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
4939    /* Flip the starting bit in the negative case. */  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
4940    read_char8_type(common);    if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_digit, FALSE))
4941        read_char7_type(common, type == OP_NOT_DIGIT);
4942      else
4943    #endif
4944        read_char8_type(common, type == OP_NOT_DIGIT);
4945        /* Flip the starting bit in the negative case. */
4946    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit);    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit);
4947    add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));    add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));
4948    return cc;    return cc;
# Line 4863  switch(type) Line 4950  switch(type)
4950    case OP_NOT_WHITESPACE:    case OP_NOT_WHITESPACE:
4951    case OP_WHITESPACE:    case OP_WHITESPACE:
4952    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
4953    read_char8_type(common);  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
4954      if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_space, FALSE))
4955        read_char7_type(common, type == OP_NOT_WHITESPACE);
4956      else
4957    #endif
4958        read_char8_type(common, type == OP_NOT_WHITESPACE);
4959    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_space);    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_space);
4960    add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));    add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));
4961    return cc;    return cc;
# Line 4871  switch(type) Line 4963  switch(type)
4963    case OP_NOT_WORDCHAR:    case OP_NOT_WORDCHAR:
4964    case OP_WORDCHAR:    case OP_WORDCHAR:
4965    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
4966    read_char8_type(common);  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
4967      if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_word, FALSE))
4968        read_char7_type(common, type == OP_NOT_WORDCHAR);
4969      else
4970    #endif
4971        read_char8_type(common, type == OP_NOT_WORDCHAR);
4972    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_word);    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_word);
4973    add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));    add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_C_ZERO : SLJIT_C_NOT_ZERO));
4974    return cc;    return cc;
# Line 5292  switch(type) Line 5389  switch(type)
5389    case OP_CLASS:    case OP_CLASS:
5390    case OP_NCLASS:    case OP_NCLASS:
5391    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
5392    read_char8(common);  
5393    #if defined SUPPORT_UTF && defined COMPILE_PCRE8
5394      bit = (common->utf && is_char7_bitset((const pcre_uint8 *)cc, type == OP_NCLASS)) ? 127 : 255;
5395      read_char_max(common, bit, type == OP_NCLASS);
5396    #else
5397      read_char_max(common, 255, type == OP_NCLASS);
5398    #endif
5399    
5400    if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, FALSE, backtracks))    if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, FALSE, backtracks))
5401      return cc + 32 / sizeof(pcre_uchar);      return cc + 32 / sizeof(pcre_uchar);
5402    
5403  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF && defined COMPILE_PCRE8
5404    jump[0] = NULL;    jump[0] = NULL;
 #ifdef COMPILE_PCRE8  
   /* This check only affects 8 bit mode. In other modes, we  
   always need to compare the value with 255. */  
5405    if (common->utf)    if (common->utf)
 #endif /* COMPILE_PCRE8 */  
5406      {      {
5407      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, bit);
5408      if (type == OP_CLASS)      if (type == OP_CLASS)
5409        {        {
5410        add_jump(compiler, backtracks, jump[0]);        add_jump(compiler, backtracks, jump[0]);
5411        jump[0] = NULL;        jump[0] = NULL;
5412        }        }
5413      }      }
5414  #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */  #elif !defined COMPILE_PCRE8
5415      jump[0] = CMP(SLJIT_C_GREATER, TMP1, 0, SLJIT_IMM, 255);
5416      if (type == OP_CLASS)
5417        {
5418        add_jump(compiler, backtracks, jump[0]);
5419        jump[0] = NULL;
5420        }
5421    #endif /* SUPPORT_UTF && COMPILE_PCRE8 */
5422    
5423    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
5424    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
5425    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
5426    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
5427    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);    OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
5428    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));
5429    
5430  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8  #if defined SUPPORT_UTF || !defined COMPILE_PCRE8
5431    if (jump[0] != NULL)    if (jump[0] != NULL)
5432      JUMPHERE(jump[0]);      JUMPHERE(jump[0]);
5433  #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */  #endif
5434    
5435    return cc + 32 / sizeof(pcre_uchar);    return cc + 32 / sizeof(pcre_uchar);
5436    
5437  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
# Line 9773  if (common->utfreadchar != NULL) Line 9883  if (common->utfreadchar != NULL)
9883    }    }
9884  #endif /* !COMPILE_PCRE32 */  #endif /* !COMPILE_PCRE32 */
9885  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
9886  if (common->utfreadchar8 != NULL)  if (common->utfreadchar11 != NULL)
9887    {    {
9888    set_jumps(common->utfreadchar8, LABEL());    set_jumps(common->utfreadchar11, LABEL());
9889    do_utfreadchar8(common);    do_utfreadchar11(common);
9890    }    }
9891  if (common->utfreadtype8 != NULL)  if (common->utfreadtype8 != NULL)
9892    {    {

Legend:
Removed from v.1420  
changed lines
  Added in v.1421

  ViewVC Help
Powered by ViewVC 1.1.5