/[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 766 by zherczeg, Wed Nov 23 17:23:20 2011 UTC revision 767 by zherczeg, Sat Nov 26 12:48:56 2011 UTC
# Line 62  system files. */ Line 62  system files. */
62  #include "sljit/sljitLir.c"  #include "sljit/sljitLir.c"
63    
64  #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED  #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED
65  #error "Unsupported architecture"  #error Unsupported architecture
66  #endif  #endif
67    
68  /* Allocate memory on the stack. Fast, but limited size. */  /* Allocate memory on the stack. Fast, but limited size. */
# Line 148  Thus we can restore the locals to a part Line 148  Thus we can restore the locals to a part
148  typedef struct jit_arguments {  typedef struct jit_arguments {
149    /* Pointers first. */    /* Pointers first. */
150    struct sljit_stack *stack;    struct sljit_stack *stack;
151    PCRE_SPTR str;    const pcre_uchar *str;
152    PCRE_SPTR begin;    const pcre_uchar *begin;
153    PCRE_SPTR end;    const pcre_uchar *end;
154    int *offsets;    int *offsets;
155    pcre_uchar *ptr;    pcre_uchar *ptr;
156    /* Everything else after. */    /* Everything else after. */
# Line 316  typedef struct compare_context { Line 316  typedef struct compare_context {
316    int length;    int length;
317    int sourcereg;    int sourcereg;
318  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
319    int byteptr;    int ucharptr;
320    union {    union {
321      int asint;      sljit_i asint;
322      short asshort;      sljit_h asshort;
323    #ifdef COMPILE_PCRE8
324      sljit_ub asbyte;      sljit_ub asbyte;
325      sljit_ub asbytes[4];      sljit_ub asuchars[4];
326    #else
327    #ifdef COMPILE_PCRE16
328        sljit_uh asuchars[2];
329    #endif
330    #endif
331    } c;    } c;
332    union {    union {
333      int asint;      sljit_i asint;
334      short asshort;      sljit_h asshort;
335    #ifdef COMPILE_PCRE8
336      sljit_ub asbyte;      sljit_ub asbyte;
337      sljit_ub asbytes[4];      sljit_ub asuchars[4];
338    #else
339    #ifdef COMPILE_PCRE16
340        sljit_uh asuchars[2];
341    #endif
342    #endif
343    } oc;    } oc;
344  #endif  #endif
345  } compare_context;  } compare_context;
# Line 375  the start pointers when the end of the c Line 387  the start pointers when the end of the c
387  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))
388  #define PRIV_DATA(cc)    (common->localptrs[(cc) - common->start])  #define PRIV_DATA(cc)    (common->localptrs[(cc) - common->start])
389    
390    #ifdef COMPILE_PCRE8
391    #define MOV_UCHAR SLJIT_MOV_UB
392    #else
393    #ifdef COMPILE_PCRE16
394    #define MOV_UCHAR SLJIT_MOV_UH
395    #else
396    #error Unsupported compiling mode
397    #endif
398    #endif
399    
400  /* Shortcuts. */  /* Shortcuts. */
401  #define DEFINE_COMPILER \  #define DEFINE_COMPILER \
402    struct sljit_compiler *compiler = common->compiler    struct sljit_compiler *compiler = common->compiler
# Line 1173  struct sljit_label *loop; Line 1195  struct sljit_label *loop;
1195  int i;  int i;
1196  /* At this point we can freely use all temporary registers. */  /* At this point we can freely use all temporary registers. */
1197  /* TMP1 returns with begin - 1. */  /* TMP1 returns with begin - 1. */
1198  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, 1);  OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG1, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, IN_UCHARS(1));
1199  if (length < 8)  if (length < 8)
1200    {    {
1201    for (i = 0; i < length; i++)    for (i = 0; i < length; i++)
# Line 1211  loop = LABEL(); Line 1233  loop = LABEL();
1233  OP2(SLJIT_SUB, SLJIT_GENERAL_REG2, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), 0, SLJIT_TEMPORARY_REG1, 0);  OP2(SLJIT_SUB, SLJIT_GENERAL_REG2, 0, SLJIT_MEM1(SLJIT_GENERAL_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
1234  OP2(SLJIT_ADD, SLJIT_GENERAL_REG1, 0, SLJIT_GENERAL_REG1, 0, SLJIT_IMM, sizeof(sljit_w));  OP2(SLJIT_ADD, SLJIT_GENERAL_REG1, 0, SLJIT_GENERAL_REG1, 0, SLJIT_IMM, sizeof(sljit_w));
1235  /* Copy the integer value to the output buffer */  /* Copy the integer value to the output buffer */
1236    #ifdef COMPILE_PCRE16
1237    OP2(SLJIT_LSHR, SLJIT_GENERAL_REG2, 0, SLJIT_GENERAL_REG2, 0, SLJIT_IMM, 1);
1238    #endif
1239  OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), sizeof(int), SLJIT_GENERAL_REG2, 0);  OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_TEMPORARY_REG3), sizeof(int), SLJIT_GENERAL_REG2, 0);
1240  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
1241  JUMPTO(SLJIT_C_NOT_ZERO, loop);  JUMPTO(SLJIT_C_NOT_ZERO, loop);
# Line 1347  DEFINE_COMPILER; Line 1372  DEFINE_COMPILER;
1372  struct sljit_jump *jump;  struct sljit_jump *jump;
1373  #endif  #endif
1374    
1375  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);  OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1376  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1377  if (common->utf8)  if (common->utf8)
1378    {    {
# Line 1356  if (common->utf8) Line 1381  if (common->utf8)
1381    JUMPHERE(jump);    JUMPHERE(jump);
1382    }    }
1383  #endif  #endif
1384  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));
1385  }  }
1386    
1387  static void peek_char(compiler_common *common)  static void peek_char(compiler_common *common)
# Line 1614  struct sljit_jump *singlebyte; Line 1639  struct sljit_jump *singlebyte;
1639  #endif  #endif
1640  jump_list *newline = NULL;  jump_list *newline = NULL;
1641  BOOL newlinecheck = FALSE;  BOOL newlinecheck = FALSE;
1642  BOOL readbyte = FALSE;  BOOL readuchar = FALSE;
1643    
1644  if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||  if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||
1645      common->nltype == NLTYPE_ANYCRLF || common->newline > 255))      common->nltype == NLTYPE_ANYCRLF || common->newline > 255))
# Line 1629  if (firstline) Line 1654  if (firstline)
1654    if (common->nltype == NLTYPE_FIXED && common->newline > 255)    if (common->nltype == NLTYPE_FIXED && common->newline > 255)
1655      {      {
1656      mainloop = LABEL();      mainloop = LABEL();
1657      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));
1658      end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);      end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1659      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -1);      OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
1660      OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);      OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
1661      CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);      CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);
1662      CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);      CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);
1663      OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END, STR_PTR, 0, SLJIT_IMM, 1);      OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
1664      }      }
1665    else    else
1666      {      {
# Line 1659  start = JUMP(SLJIT_JUMP); Line 1684  start = JUMP(SLJIT_JUMP);
1684  if (newlinecheck)  if (newlinecheck)
1685    {    {
1686    newlinelabel = LABEL();    newlinelabel = LABEL();
1687    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));
1688    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);    end = CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
1689    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1690    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);
1691    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);    COND_VALUE(SLJIT_MOV, TMP1, 0, SLJIT_C_EQUAL);
1692    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
# Line 1672  mainloop = LABEL(); Line 1697  mainloop = LABEL();
1697    
1698  /* Increasing the STR_PTR here requires one less jump in the most common case. */  /* Increasing the STR_PTR here requires one less jump in the most common case. */
1699  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1700  if (common->utf8) readbyte = TRUE;  if (common->utf8) readuchar = TRUE;
1701  #endif  #endif
1702  if (newlinecheck) readbyte = TRUE;  if (newlinecheck) readuchar = TRUE;
1703    
1704  if (readbyte)  if (readuchar)
1705    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);    OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
1706    
1707  if (newlinecheck)  if (newlinecheck)
1708    CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, newlinelabel);    CMPTO(SLJIT_C_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, newlinelabel);
1709    
1710  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));
1711  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1712  if (common->utf8)  if (common->utf8)
1713    {    {
# Line 1743  else Line 1768  else
1768      }      }
1769    }    }
1770    
1771  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));
1772  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
1773  if (common->utf8)  if (common->utf8)
1774    {    {
# Line 2257  static pcre_uchar *byte_sequence_compare Line 2282  static pcre_uchar *byte_sequence_compare
2282  {  {
2283  DEFINE_COMPILER;  DEFINE_COMPILER;
2284  unsigned int othercasebit = 0;  unsigned int othercasebit = 0;
2285  pcre_uint8 *othercasebyte = NULL;  pcre_uchar *othercasechar = NULL;
2286  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
2287  int utf8length;  int utf8length;
2288  #endif  #endif
# Line 2267  if (caseless && char_has_othercase(commo Line 2292  if (caseless && char_has_othercase(commo
2292    othercasebit = char_get_othercase_bit(common, cc);    othercasebit = char_get_othercase_bit(common, cc);
2293    SLJIT_ASSERT(othercasebit);    SLJIT_ASSERT(othercasebit);
2294    /* Extracting bit difference info. */    /* Extracting bit difference info. */
2295    othercasebyte = cc + (othercasebit >> 8);  #ifdef COMPILE_PCRE8
2296      othercasechar = cc + (othercasebit >> 8);
2297    othercasebit &= 0xff;    othercasebit &= 0xff;
2298    #else
2299    #ifdef COMPILE_PCRE16
2300      othercasechar = cc + (othercasebit >> 9);
2301      if ((othercasebit & 0x100) != 0)
2302        othercasebit = (othercasebit & 0xff) << 8;
2303      else
2304        othercasebit &= 0xff;
2305    #endif
2306    #endif
2307    }    }
2308    
2309  if (context->sourcereg == -1)  if (context->sourcereg == -1)
2310    {    {
2311    #ifdef COMPILE_PCRE8
2312  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2313    if (context->length >= 4)    if (context->length >= 4)
2314      OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
# Line 2281  if (context->sourcereg == -1) Line 2317  if (context->sourcereg == -1)
2317    else    else
2318  #endif  #endif
2319      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2320    #else
2321    #ifdef COMPILE_PCRE16
2322    #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2323      if (context->length >= 4)
2324        OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2325      else
2326    #endif
2327        OP1(SLJIT_MOV_SH, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
2328    #endif
2329    #endif /* COMPILE_PCRE8 */
2330    context->sourcereg = TMP2;    context->sourcereg = TMP2;
2331    }    }
2332    
# Line 2293  do Line 2339  do
2339    {    {
2340  #endif  #endif
2341    
2342    context->length--;    context->length -= IN_UCHARS(1);
2343  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
2344    
2345    /* Unaligned read is supported. */    /* Unaligned read is supported. */
2346    if (othercasebit != 0 && othercasebyte == cc)    if (othercasebit != 0 && othercasechar == cc)
2347      {      {
2348      context->c.asbytes[context->byteptr] = *cc | othercasebit;      context->c.asuchars[context->ucharptr] = *cc | othercasebit;
2349      context->oc.asbytes[context->byteptr] = othercasebit;      context->oc.asuchars[context->ucharptr] = othercasebit;
2350      }      }
2351    else    else
2352      {      {
2353      context->c.asbytes[context->byteptr] = *cc;      context->c.asuchars[context->ucharptr] = *cc;
2354      context->oc.asbytes[context->byteptr] = 0;      context->oc.asuchars[context->ucharptr] = 0;
2355      }      }
2356    context->byteptr++;    context->ucharptr++;
2357    
2358    if (context->byteptr >= 4 || context->length == 0 || (context->byteptr == 2 && context->length == 1))  #ifdef COMPILE_PCRE8
2359      if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
2360    #else
2361      if (context->ucharptr >= 2 || context->length == 0)
2362    #endif
2363      {      {
2364      if (context->length >= 4)      if (context->length >= 4)
2365        OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2366    #ifdef COMPILE_PCRE8
2367      else if (context->length >= 2)      else if (context->length >= 2)
2368        OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2369      else if (context->length >= 1)      else if (context->length >= 1)
2370        OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);        OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2371    #else
2372        else if (context->length >= 2)
2373          OP1(SLJIT_MOV_SH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2374    #endif
2375      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;      context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
2376    
2377      switch(context->byteptr)      switch(context->ucharptr)
2378        {        {
2379        case 4:        case 4 / sizeof(pcre_uchar):
2380        if (context->oc.asint != 0)        if (context->oc.asint != 0)
2381          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asint);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asint);
2382        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));
2383        break;        break;
2384    
2385        case 2:        case 2 / sizeof(pcre_uchar):
2386        if (context->oc.asshort != 0)        if (context->oc.asshort != 0)
2387          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asshort);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asshort);
2388        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asshort | context->oc.asshort));        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asshort | context->oc.asshort));
2389        break;        break;
2390    
2391    #ifdef COMPILE_PCRE8
2392        case 1:        case 1:
2393        if (context->oc.asbyte != 0)        if (context->oc.asbyte != 0)
2394          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asbyte);          OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asbyte);
2395        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asbyte | context->oc.asbyte));        add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asbyte | context->oc.asbyte));
2396        break;        break;
2397    #endif
2398    
2399        default:        default:
2400        SLJIT_ASSERT_STOP();        SLJIT_ASSERT_STOP();
2401        break;        break;
2402        }        }
2403      context->byteptr = 0;      context->ucharptr = 0;
2404      }      }
2405    
2406  #else  #else
2407    
2408    /* Unaligned read is unsupported. */    /* Unaligned read is unsupported. */
2409    #ifdef COMPILE_PCRE8
2410    if (context->length > 0)    if (context->length > 0)
2411      OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);      OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2412    #else
2413      if (context->length > 0)
2414        OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
2415    #endif
2416    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;    context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
2417    
2418    if (othercasebit != 0 && othercasebyte == cc)    if (othercasebit != 0 && othercasechar == cc)
2419      {      {
2420      OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);      OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);
2421      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, *cc | othercasebit));      add_jump(compiler, fallbacks, CMP(SLJIT_C_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, *cc | othercasebit));
# Line 3019  switch(type) Line 3081  switch(type)
3081    
3082    case OP_CHAR:    case OP_CHAR:
3083    case OP_CHARI:    case OP_CHARI:
3084    length = 1;    length = IN_UCHARS(1);
3085  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3086    if (common->utf8 && *cc >= 0xc0) length += PRIV(utf8_table4)[*cc & 0x3f];    if (common->utf8 && *cc >= 0xc0) length += PRIV(utf8_table4)[*cc & 0x3f];
3087  #endif  #endif
# Line 3031  switch(type) Line 3093  switch(type)
3093      context.length = length;      context.length = length;
3094      context.sourcereg = -1;      context.sourcereg = -1;
3095  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
3096      context.byteptr = 0;      context.ucharptr = 0;
3097  #endif  #endif
3098      return byte_sequence_compare(common, type == OP_CHARI, cc, &context, fallbacks);      return byte_sequence_compare(common, type == OP_CHARI, cc, &context, fallbacks);
3099      }      }
3100    add_jump(compiler, fallbacks, CMP(SLJIT_C_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));    check_input_end(common, fallbacks);
3101    read_char(common);    read_char(common);
3102  #ifdef SUPPORT_UTF8  #ifdef SUPPORT_UTF8
3103    if (common->utf8)    if (common->utf8)
# Line 3215  do Line 3277  do
3277      size = 0;      size = 0;
3278    
3279    cc += 1 + size;    cc += 1 + size;
3280    context.length += size;    context.length += IN_UCHARS(size);
3281    }    }
3282  while (size > 0 && context.length <= 128);  while (size > 0 && context.length <= 128);
3283    
# Line 3228  if (context.length > 0) Line 3290  if (context.length > 0)
3290    
3291    context.sourcereg = -1;    context.sourcereg = -1;
3292  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
3293    context.byteptr = 0;    context.ucharptr = 0;
3294  #endif  #endif
3295    do cc = byte_sequence_compare(common, *cc == OP_CHARI, cc + 1, &context, fallbacks); while (context.length > 0);    do cc = byte_sequence_compare(common, *cc == OP_CHARI, cc + 1, &context, fallbacks); while (context.length > 0);
3296    sljit_emit_op0(compiler, SLJIT_NOP);
3297    return cc;    return cc;
3298    }    }
3299    
# Line 6284  if ((re->options & PCRE_ANCHORED) == 0) Line 6347  if ((re->options & PCRE_ANCHORED) == 0)
6347      {      {
6348      if (study != NULL && study->minlength > 1)      if (study != NULL && study->minlength > 1)
6349        {        {
6350        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, study->minlength);        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength));
6351        CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);        CMPTO(SLJIT_C_LESS_EQUAL, TMP1, 0, STR_END, 0, mainloop);
6352        }        }
6353      else      else
# Line 6294  if ((re->options & PCRE_ANCHORED) == 0) Line 6357  if ((re->options & PCRE_ANCHORED) == 0)
6357      {      {
6358      if (study != NULL && study->minlength > 1)      if (study != NULL && study->minlength > 1)
6359        {        {
6360        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, study->minlength);        OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength));
6361        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, STR_END, 0);
6362        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);        COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_GREATER);
6363        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END);        OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), FIRSTLINE_END);
# Line 6468  return convert_executable_func.call_exec Line 6531  return convert_executable_func.call_exec
6531    
6532  int  int
6533  PRIV(jit_exec)(const real_pcre *re, void *executable_func,  PRIV(jit_exec)(const real_pcre *re, void *executable_func,
6534    PCRE_SPTR subject, int length, int start_offset, int options,    const pcre_uchar *subject, int length, int start_offset, int options,
6535    int match_limit, int *offsets, int offsetcount)    int match_limit, int *offsets, int offsetcount)
6536  {  {
6537  executable_function *function = (executable_function*)executable_func;  executable_function *function = (executable_function*)executable_func;
# Line 6530  sljit_free_code(function->executable_fun Line 6593  sljit_free_code(function->executable_fun
6593  SLJIT_FREE(function);  SLJIT_FREE(function);
6594  }  }
6595    
6596    #ifdef COMPILE_PCRE8
6597  PCRE_EXP_DECL pcre_jit_stack *  PCRE_EXP_DECL pcre_jit_stack *
6598  pcre_jit_stack_alloc(int startsize, int maxsize)  pcre_jit_stack_alloc(int startsize, int maxsize)
6599    #else
6600    PCRE_EXP_DECL pcre_jit_stack *
6601    pcre16_jit_stack_alloc(int startsize, int maxsize)
6602    #endif
6603  {  {
6604  if (startsize < 1 || maxsize < 1)  if (startsize < 1 || maxsize < 1)
6605    return NULL;    return NULL;
# Line 6542  maxsize = (maxsize + STACK_GROWTH_RATE - Line 6610  maxsize = (maxsize + STACK_GROWTH_RATE -
6610  return (pcre_jit_stack*)sljit_allocate_stack(startsize, maxsize);  return (pcre_jit_stack*)sljit_allocate_stack(startsize, maxsize);
6611  }  }
6612    
6613    #ifdef COMPILE_PCRE8
6614  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6615  pcre_jit_stack_free(pcre_jit_stack *stack)  pcre_jit_stack_free(pcre_jit_stack *stack)
6616    #else
6617    PCRE_EXP_DECL void
6618    pcre16_jit_stack_free(pcre_jit_stack *stack)
6619    #endif
6620  {  {
6621  sljit_free_stack((struct sljit_stack*)stack);  sljit_free_stack((struct sljit_stack*)stack);
6622  }  }
6623    
6624    #ifdef COMPILE_PCRE8
6625  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6626  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6627    #else
6628    PCRE_EXP_DECL void
6629    pcre16_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6630    #endif
6631  {  {
6632  executable_function *function;  executable_function *function;
6633  if (extra != NULL &&  if (extra != NULL &&
# Line 6567  if (extra != NULL && Line 6645  if (extra != NULL &&
6645  /* These are dummy functions to avoid linking errors when JIT support is not  /* These are dummy functions to avoid linking errors when JIT support is not
6646  being compiled. */  being compiled. */
6647    
6648    #ifdef COMPILE_PCRE8
6649  PCRE_EXP_DECL pcre_jit_stack *  PCRE_EXP_DECL pcre_jit_stack *
6650  pcre_jit_stack_alloc(int startsize, int maxsize)  pcre_jit_stack_alloc(int startsize, int maxsize)
6651    #else
6652    PCRE_EXP_DECL pcre_jit_stack *
6653    pcre16_jit_stack_alloc(int startsize, int maxsize)
6654    #endif
6655  {  {
6656  (void)startsize;  (void)startsize;
6657  (void)maxsize;  (void)maxsize;
6658  return NULL;  return NULL;
6659  }  }
6660    
6661    #ifdef COMPILE_PCRE8
6662  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6663  pcre_jit_stack_free(pcre_jit_stack *stack)  pcre_jit_stack_free(pcre_jit_stack *stack)
6664    #else
6665    PCRE_EXP_DECL void
6666    pcre16_jit_stack_free(pcre_jit_stack *stack)
6667    #endif
6668  {  {
6669  (void)stack;  (void)stack;
6670  }  }
6671    
6672    #ifdef COMPILE_PCRE8
6673  PCRE_EXP_DECL void  PCRE_EXP_DECL void
6674  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)  pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6675    #else
6676    PCRE_EXP_DECL void
6677    pcre16_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
6678    #endif
6679  {  {
6680  (void)extra;  (void)extra;
6681  (void)callback;  (void)callback;

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

  ViewVC Help
Powered by ViewVC 1.1.5