/[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 1120 by chpe, Tue Oct 16 15:57:38 2012 UTC revision 1195 by zherczeg, Thu Nov 1 15:21:27 2012 UTC
# Line 170  typedef struct executable_functions { Line 170  typedef struct executable_functions {
170    void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];    void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];
171    PUBL(jit_callback) callback;    PUBL(jit_callback) callback;
172    void *userdata;    void *userdata;
173      pcre_uint32 top_bracket;
174    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];    sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
175  } executable_functions;  } executable_functions;
176    
# Line 300  typedef struct compiler_common { Line 301  typedef struct compiler_common {
301    
302    /* Flipped and lower case tables. */    /* Flipped and lower case tables. */
303    const pcre_uint8 *fcc;    const pcre_uint8 *fcc;
304    sljit_w lcc;    sljit_sw lcc;
305    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */    /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */
306    int mode;    int mode;
307    /* Newline control. */    /* Newline control. */
# Line 311  typedef struct compiler_common { Line 312  typedef struct compiler_common {
312    int endonly;    int endonly;
313    BOOL has_set_som;    BOOL has_set_som;
314    /* Tables. */    /* Tables. */
315    sljit_w ctypes;    sljit_sw ctypes;
316    int digits[2 + MAX_RANGE_SIZE];    int digits[2 + MAX_RANGE_SIZE];
317    /* Named capturing brackets. */    /* Named capturing brackets. */
318    sljit_uw name_table;    sljit_uw name_table;
319    sljit_w name_count;    sljit_sw name_count;
320    sljit_w name_entry_size;    sljit_sw name_entry_size;
321    
322    /* Labels and jump lists. */    /* Labels and jump lists. */
323    struct sljit_label *partialmatchlabel;    struct sljit_label *partialmatchlabel;
# Line 363  typedef struct compare_context { Line 364  typedef struct compare_context {
364  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED  #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
365    int ucharptr;    int ucharptr;
366    union {    union {
367      sljit_i asint;      sljit_si asint;
368      sljit_uh asushort;      sljit_uh asushort;
369  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
370      sljit_ub asbyte;      sljit_ub asbyte;
# Line 375  typedef struct compare_context { Line 376  typedef struct compare_context {
376  #endif  #endif
377    } c;    } c;
378    union {    union {
379      sljit_i asint;      sljit_si asint;
380      sljit_uh asushort;      sljit_uh asushort;
381  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
382      sljit_ub asbyte;      sljit_ub asbyte;
# Line 399  enum { Line 400  enum {
400  #undef CMP  #undef CMP
401    
402  /* Used for accessing the elements of the stack. */  /* Used for accessing the elements of the stack. */
403  #define STACK(i)      ((-(i) - 1) * (int)sizeof(sljit_w))  #define STACK(i)      ((-(i) - 1) * (int)sizeof(sljit_sw))
404    
405  #define TMP1          SLJIT_TEMPORARY_REG1  #define TMP1          SLJIT_TEMPORARY_REG1
406  #define TMP2          SLJIT_TEMPORARY_REG3  #define TMP2          SLJIT_TEMPORARY_REG3
# Line 414  enum { Line 415  enum {
415    
416  /* Local space layout. */  /* Local space layout. */
417  /* These two locals can be used by the current opcode. */  /* These two locals can be used by the current opcode. */
418  #define LOCALS0          (0 * sizeof(sljit_w))  #define LOCALS0          (0 * sizeof(sljit_sw))
419  #define LOCALS1          (1 * sizeof(sljit_w))  #define LOCALS1          (1 * sizeof(sljit_sw))
420  /* Two local variables for possessive quantifiers (char1 cannot use them). */  /* Two local variables for possessive quantifiers (char1 cannot use them). */
421  #define POSSESSIVE0      (2 * sizeof(sljit_w))  #define POSSESSIVE0      (2 * sizeof(sljit_sw))
422  #define POSSESSIVE1      (3 * sizeof(sljit_w))  #define POSSESSIVE1      (3 * sizeof(sljit_sw))
423  /* Max limit of recursions. */  /* Max limit of recursions. */
424  #define CALL_LIMIT       (4 * sizeof(sljit_w))  #define CALL_LIMIT       (4 * sizeof(sljit_sw))
425  /* The output vector is stored on the stack, and contains pointers  /* The output vector is stored on the stack, and contains pointers
426  to characters. The vector data is divided into two groups: the first  to characters. The vector data is divided into two groups: the first
427  group contains the start / end character pointers, and the second is  group contains the start / end character pointers, and the second is
428  the start pointers when the end of the capturing group has not yet reached. */  the start pointers when the end of the capturing group has not yet reached. */
429  #define OVECTOR_START    (common->ovector_start)  #define OVECTOR_START    (common->ovector_start)
430  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_sw))
431  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_sw))
432  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
433    
434  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
# Line 767  int private_data_length = 0; Line 768  int private_data_length = 0;
768  pcre_uchar *alternative;  pcre_uchar *alternative;
769  pcre_uchar *name;  pcre_uchar *name;
770  pcre_uchar *end = NULL;  pcre_uchar *end = NULL;
771  int space, size, bracketlen, i;  int space, size, i;
772    pcre_uint32 bracketlen;
773    
774  /* Calculate important variables (like stack size) and checks whether all opcodes are supported. */  /* Calculate important variables (like stack size) and checks whether all opcodes are supported. */
775  while (cc < ccend)  while (cc < ccend)
# Line 797  while (cc < ccend) Line 799  while (cc < ccend)
799      case OP_BRAPOS:      case OP_BRAPOS:
800      case OP_SBRA:      case OP_SBRA:
801      case OP_SBRAPOS:      case OP_SBRAPOS:
802      private_data_length += sizeof(sljit_w);      private_data_length += sizeof(sljit_sw);
803      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
804      break;      break;
805    
806      case OP_CBRAPOS:      case OP_CBRAPOS:
807      case OP_SCBRAPOS:      case OP_SCBRAPOS:
808      private_data_length += sizeof(sljit_w);      private_data_length += sizeof(sljit_sw);
809      common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;      common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;
810      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
811      break;      break;
# Line 841  while (cc < ccend) Line 843  while (cc < ccend)
843        /* Might be a hidden SCOND. */        /* Might be a hidden SCOND. */
844        alternative = cc + GET(cc, 1);        alternative = cc + GET(cc, 1);
845        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
846          private_data_length += sizeof(sljit_w);          private_data_length += sizeof(sljit_sw);
847        }        }
848      else      else
849        private_data_length += sizeof(sljit_w);        private_data_length += sizeof(sljit_sw);
850      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
851      break;      break;
852    
# Line 907  while (cc < ccend) Line 909  while (cc < ccend)
909      if (common->recursive_head == 0)      if (common->recursive_head == 0)
910        {        {
911        common->recursive_head = common->ovector_start;        common->recursive_head = common->ovector_start;
912        common->ovector_start += sizeof(sljit_w);        common->ovector_start += sizeof(sljit_sw);
913        }        }
914      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
915      break;      break;
# Line 916  while (cc < ccend) Line 918  while (cc < ccend)
918      if (common->mark_ptr == 0)      if (common->mark_ptr == 0)
919        {        {
920        common->mark_ptr = common->ovector_start;        common->mark_ptr = common->ovector_start;
921        common->ovector_start += sizeof(sljit_w);        common->ovector_start += sizeof(sljit_sw);
922        }        }
923      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
924      break;      break;
# Line 929  while (cc < ccend) Line 931  while (cc < ccend)
931      }      }
932    
933    if (space > 0 && cc >= end)    if (space > 0 && cc >= end)
934      private_data_length += sizeof(sljit_w) * space;      private_data_length += sizeof(sljit_sw) * space;
935    
936    if (size != 0)    if (size != 0)
937      {      {
# Line 944  while (cc < ccend) Line 946  while (cc < ccend)
946        cc += size;        cc += size;
947      }      }
948    
949    if (bracketlen > 0)    if (bracketlen != 0)
950      {      {
951      if (cc >= end)      if (cc >= end)
952        {        {
# Line 983  while (cc < ccend) Line 985  while (cc < ccend)
985      case OP_SBRAPOS:      case OP_SBRAPOS:
986      case OP_SCOND:      case OP_SCOND:
987      common->private_data_ptrs[cc - common->start] = private_data_ptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
988      private_data_ptr += sizeof(sljit_w);      private_data_ptr += sizeof(sljit_sw);
989      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
990      break;      break;
991    
992      case OP_CBRAPOS:      case OP_CBRAPOS:
993      case OP_SCBRAPOS:      case OP_SCBRAPOS:
994      common->private_data_ptrs[cc - common->start] = private_data_ptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
995      private_data_ptr += sizeof(sljit_w);      private_data_ptr += sizeof(sljit_sw);
996      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
997      break;      break;
998    
# Line 1000  while (cc < ccend) Line 1002  while (cc < ccend)
1002      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
1003        {        {
1004        common->private_data_ptrs[cc - common->start] = private_data_ptr;        common->private_data_ptrs[cc - common->start] = private_data_ptr;
1005        private_data_ptr += sizeof(sljit_w);        private_data_ptr += sizeof(sljit_sw);
1006        }        }
1007      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
1008      break;      break;
# Line 1068  while (cc < ccend) Line 1070  while (cc < ccend)
1070    if (space > 0 && cc >= end)    if (space > 0 && cc >= end)
1071      {      {
1072      common->private_data_ptrs[cc - common->start] = private_data_ptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
1073      private_data_ptr += sizeof(sljit_w) * space;      private_data_ptr += sizeof(sljit_sw) * space;
1074      }      }
1075    
1076    if (size != 0)    if (size != 0)
# Line 1199  while (cc < ccend) Line 1201  while (cc < ccend)
1201        {        {
1202        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
1203        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setstrbegin);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setstrbegin);
1204        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1205        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1206        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1207        setsom_found = TRUE;        setsom_found = TRUE;
1208        }        }
1209      cc += 1;      cc += 1;
# Line 1213  while (cc < ccend) Line 1215  while (cc < ccend)
1215        {        {
1216        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);
1217        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setmark);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setmark);
1218        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1219        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1220        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1221        setmark_found = TRUE;        setmark_found = TRUE;
1222        }        }
1223      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
# Line 1226  while (cc < ccend) Line 1228  while (cc < ccend)
1228        {        {
1229        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0));
1230        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setstrbegin);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setstrbegin);
1231        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1232        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1233        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1234        setsom_found = TRUE;        setsom_found = TRUE;
1235        }        }
1236      if (common->mark_ptr != 0 && !setmark_found)      if (common->mark_ptr != 0 && !setmark_found)
1237        {        {
1238        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr);
1239        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setmark);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, frame_setmark);
1240        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1241        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1242        stackpos += (int)sizeof(sljit_w);        stackpos += (int)sizeof(sljit_sw);
1243        setmark_found = TRUE;        setmark_found = TRUE;
1244        }        }
1245      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
# Line 1249  while (cc < ccend) Line 1251  while (cc < ccend)
1251      case OP_SCBRAPOS:      case OP_SCBRAPOS:
1252      offset = (GET2(cc, 1 + LINK_SIZE)) << 1;      offset = (GET2(cc, 1 + LINK_SIZE)) << 1;
1253      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, OVECTOR(offset));      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, OVECTOR(offset));
1254      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_sw);
1255      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset));
1256      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1));
1257      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
1258      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_sw);
1259      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);
1260      stackpos += (int)sizeof(sljit_w);      stackpos += (int)sizeof(sljit_sw);
1261    
1262      cc += 1 + LINK_SIZE + IMM2_SIZE;      cc += 1 + LINK_SIZE + IMM2_SIZE;
1263      break;      break;
# Line 1406  stacktop = STACK(stacktop - 1); Line 1408  stacktop = STACK(stacktop - 1);
1408    
1409  if (!save)  if (!save)
1410    {    {
1411    stackptr += sizeof(sljit_w);    stackptr += sizeof(sljit_sw);
1412    if (stackptr < stacktop)    if (stackptr < stacktop)
1413      {      {
1414      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1415      stackptr += sizeof(sljit_w);      stackptr += sizeof(sljit_sw);
1416      tmp1empty = FALSE;      tmp1empty = FALSE;
1417      }      }
1418    if (stackptr < stacktop)    if (stackptr < stacktop)
1419      {      {
1420      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1421      stackptr += sizeof(sljit_w);      stackptr += sizeof(sljit_sw);
1422      tmp2empty = FALSE;      tmp2empty = FALSE;
1423      }      }
1424    /* The tmp1next must be TRUE in either way. */    /* The tmp1next must be TRUE in either way. */
# Line 1507  while (status != end) Line 1509  while (status != end)
1509          {          {
1510          count = 2;          count = 2;
1511          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1512          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_sw);
1513          }          }
1514        cc += 2;        cc += 2;
1515  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 1520  while (status != end) Line 1522  while (status != end)
1522          {          {
1523          count = 2;          count = 2;
1524          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1525          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_sw);
1526          }          }
1527        cc += 2 + IMM2_SIZE;        cc += 2 + IMM2_SIZE;
1528  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 1542  while (status != end) Line 1544  while (status != end)
1544          {          {
1545          count = 2;          count = 2;
1546          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1547          srcw[1] = srcw[0] + sizeof(sljit_w);          srcw[1] = srcw[0] + sizeof(sljit_sw);
1548          }          }
1549        cc += 1;        cc += 1;
1550        break;        break;
# Line 1552  while (status != end) Line 1554  while (status != end)
1554          {          {
1555          count = 2;          count = 2;
1556          srcw[0] = PRIVATE_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1557          srcw[1] = srcw[0] + sizeof(sljit_w);          srcw[1] = srcw[0] + sizeof(sljit_sw);
1558          }          }
1559        cc += 1 + IMM2_SIZE;        cc += 1 + IMM2_SIZE;
1560        break;        break;
# Line 1576  while (status != end) Line 1578  while (status != end)
1578            case 2:            case 2:
1579            count = 2;            count = 2;
1580            srcw[0] = PRIVATE_DATA(cc);            srcw[0] = PRIVATE_DATA(cc);
1581            srcw[1] = srcw[0] + sizeof(sljit_w);            srcw[1] = srcw[0] + sizeof(sljit_sw);
1582            break;            break;
1583    
1584            default:            default:
# Line 1608  while (status != end) Line 1610  while (status != end)
1610          if (!tmp1empty)          if (!tmp1empty)
1611            {            {
1612            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
1613            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1614            }            }
1615          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);
1616          tmp1empty = FALSE;          tmp1empty = FALSE;
# Line 1619  while (status != end) Line 1621  while (status != end)
1621          if (!tmp2empty)          if (!tmp2empty)
1622            {            {
1623            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);            OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
1624            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1625            }            }
1626          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), srcw[count]);
1627          tmp2empty = FALSE;          tmp2empty = FALSE;
# Line 1636  while (status != end) Line 1638  while (status != end)
1638          if (!tmp1empty)          if (!tmp1empty)
1639            {            {
1640            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);            OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1641            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1642            }            }
1643          tmp1next = FALSE;          tmp1next = FALSE;
1644          }          }
# Line 1648  while (status != end) Line 1650  while (status != end)
1650          if (!tmp2empty)          if (!tmp2empty)
1651            {            {
1652            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);
1653            stackptr += sizeof(sljit_w);            stackptr += sizeof(sljit_sw);
1654            }            }
1655          tmp1next = TRUE;          tmp1next = TRUE;
1656          }          }
# Line 1663  if (save) Line 1665  if (save)
1665      if (!tmp1empty)      if (!tmp1empty)
1666        {        {
1667        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
1668        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1669        }        }
1670      if (!tmp2empty)      if (!tmp2empty)
1671        {        {
1672        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
1673        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1674        }        }
1675      }      }
1676    else    else
# Line 1676  if (save) Line 1678  if (save)
1678      if (!tmp2empty)      if (!tmp2empty)
1679        {        {
1680        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
1681        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1682        }        }
1683      if (!tmp1empty)      if (!tmp1empty)
1684        {        {
1685        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
1686        stackptr += sizeof(sljit_w);        stackptr += sizeof(sljit_sw);
1687        }        }
1688      }      }
1689    }    }
# Line 1771  static SLJIT_INLINE void allocate_stack( Line 1773  static SLJIT_INLINE void allocate_stack(
1773  /* May destroy all locals and registers except TMP2. */  /* May destroy all locals and registers except TMP2. */
1774  DEFINE_COMPILER;  DEFINE_COMPILER;
1775    
1776  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_w));  OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
1777  #ifdef DESTROY_REGISTERS  #ifdef DESTROY_REGISTERS
1778  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);
1779  OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);  OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
# Line 1785  add_stub(common, stack_alloc, 0, CMP(SLJ Line 1787  add_stub(common, stack_alloc, 0, CMP(SLJ
1787  static SLJIT_INLINE void free_stack(compiler_common *common, int size)  static SLJIT_INLINE void free_stack(compiler_common *common, int size)
1788  {  {
1789  DEFINE_COMPILER;  DEFINE_COMPILER;
1790  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_w));  OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
1791  }  }
1792    
1793  static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)  static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)
# Line 1803  if (length < 8) Line 1805  if (length < 8)
1805    }    }
1806  else  else
1807    {    {
1808    GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, OVECTOR_START - sizeof(sljit_w));    GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, OVECTOR_START - sizeof(sljit_sw));
1809    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, length);    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, length);
1810    loop = LABEL();    loop = LABEL();
1811    OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_w), SLJIT_TEMPORARY_REG1, 0);    OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_TEMPORARY_REG2), sizeof(sljit_sw), SLJIT_TEMPORARY_REG1, 0);
1812    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1);    OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_TEMPORARY_REG3, 0, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, 1);
1813    JUMPTO(SLJIT_C_NOT_ZERO, loop);    JUMPTO(SLJIT_C_NOT_ZERO, loop);
1814    }    }
# Line 1835  GET_LOCAL_BASE(SLJIT_SAVED_REG1, 0, OVEC Line 1837  GET_LOCAL_BASE(SLJIT_SAVED_REG1, 0, OVEC
1837  earlyexit = CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);  earlyexit = CMP(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 0);
1838  loop = LABEL();  loop = LABEL();
1839  OP2(SLJIT_SUB, SLJIT_SAVED_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);  OP2(SLJIT_SUB, SLJIT_SAVED_REG2, 0, SLJIT_MEM1(SLJIT_SAVED_REG1), 0, SLJIT_TEMPORARY_REG1, 0);
1840  OP2(SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_w));  OP2(SLJIT_ADD, SLJIT_SAVED_REG1, 0, SLJIT_SAVED_REG1, 0, SLJIT_IMM, sizeof(sljit_sw));
1841  /* Copy the integer value to the output buffer */  /* Copy the integer value to the output buffer */
1842  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
1843  OP2(SLJIT_ASHR, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, UCHAR_SHIFT);  OP2(SLJIT_ASHR, SLJIT_SAVED_REG2, 0, SLJIT_SAVED_REG2, 0, SLJIT_IMM, UCHAR_SHIFT);
# Line 1848  JUMPHERE(earlyexit); Line 1850  JUMPHERE(earlyexit);
1850  /* Calculate the return value, which is the maximum ovector value. */  /* Calculate the return value, which is the maximum ovector value. */
1851  if (topbracket > 1)  if (topbracket > 1)
1852    {    {
1853    GET_LOCAL_BASE(SLJIT_TEMPORARY_REG1, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_w));    GET_LOCAL_BASE(SLJIT_TEMPORARY_REG1, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_sw));
1854    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, topbracket + 1);    OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, topbracket + 1);
1855    
1856    /* OVECTOR(0) is never equal to SLJIT_SAVED_REG3. */    /* OVECTOR(0) is never equal to SLJIT_SAVED_REG3. */
1857    loop = LABEL();    loop = LABEL();
1858    OP1(SLJIT_MOVU, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), -(2 * (sljit_w)sizeof(sljit_w)));    OP1(SLJIT_MOVU, SLJIT_TEMPORARY_REG3, 0, SLJIT_MEM1(SLJIT_TEMPORARY_REG1), -(2 * (sljit_sw)sizeof(sljit_sw)));
1859    OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);    OP2(SLJIT_SUB, SLJIT_TEMPORARY_REG2, 0, SLJIT_TEMPORARY_REG2, 0, SLJIT_IMM, 1);
1860    CMPTO(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, loop);    CMPTO(SLJIT_C_EQUAL, SLJIT_TEMPORARY_REG3, 0, SLJIT_SAVED_REG3, 0, loop);
1861    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_TEMPORARY_REG2, 0);    OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_TEMPORARY_REG2, 0);
# Line 2379  sljit_emit_fast_return(compiler, RETURN_ Line 2381  sljit_emit_fast_return(compiler, RETURN_
2381  JUMPHERE(jump);  JUMPHERE(jump);
2382    
2383  /* We only have types for characters less than 256. */  /* We only have types for characters less than 256. */
2384  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_w)PRIV(utf8_table4) - 0xc0);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2385  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2386  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
2387  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
# Line 2432  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si Line 2434  SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && si
2434    
2435  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);  sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
2436  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
2437  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_w)PRIV(ucd_stage1));  OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));
2438  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);  OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
2439  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);  OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
2440  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
2441  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_stage2));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));
2442  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);  OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);
2443  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));  OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
2444  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);  OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);
2445  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);  sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
2446  }  }
# Line 2535  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S Line 2537  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S
2537  if (common->utf)  if (common->utf)
2538    {    {
2539    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);    singlechar = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
2540    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2541    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2542    JUMPHERE(singlechar);    JUMPHERE(singlechar);
2543    }    }
# Line 2921  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S Line 2923  OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, S
2923  if (common->utf)  if (common->utf)
2924    {    {
2925    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);    CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
2926    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
2927    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);    OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
2928    }    }
2929  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
# Line 3022  mainloop = LABEL(); Line 3024  mainloop = LABEL();
3024  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), 0);  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), 0);
3025  jump = CMP(SLJIT_C_SIG_LESS_EQUAL, TMP2, 0, SLJIT_IMM, frame_end);  jump = CMP(SLJIT_C_SIG_LESS_EQUAL, TMP2, 0, SLJIT_IMM, frame_end);
3026  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);  OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);
3027  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
3028  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), sizeof(sljit_w), SLJIT_MEM1(TMP1), 2 * sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), sizeof(sljit_sw), SLJIT_MEM1(TMP1), 2 * sizeof(sljit_sw));
3029  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_w));  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_sw));
3030  JUMPTO(SLJIT_JUMP, mainloop);  JUMPTO(SLJIT_JUMP, mainloop);
3031    
3032  JUMPHERE(jump);  JUMPHERE(jump);
# Line 3035  sljit_emit_fast_return(compiler, RETURN_ Line 3037  sljit_emit_fast_return(compiler, RETURN_
3037  JUMPHERE(jump);  JUMPHERE(jump);
3038  jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_setstrbegin);  jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_setstrbegin);
3039  /* Set string begin. */  /* Set string begin. */
3040  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), sizeof(sljit_w));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
3041  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_w));  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_sw));
3042  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(0), TMP2, 0);
3043  JUMPTO(SLJIT_JUMP, mainloop);  JUMPTO(SLJIT_JUMP, mainloop);
3044    
# Line 3044  JUMPHERE(jump); Line 3046  JUMPHERE(jump);
3046  if (common->mark_ptr != 0)  if (common->mark_ptr != 0)
3047    {    {
3048    jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_setmark);    jump = CMP(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, frame_setmark);
3049    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), sizeof(sljit_w));    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
3050    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_w));    OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_sw));
3051    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);
3052    JUMPTO(SLJIT_JUMP, mainloop);    JUMPTO(SLJIT_JUMP, mainloop);
3053    
# Line 3053  if (common->mark_ptr != 0) Line 3055  if (common->mark_ptr != 0)
3055    }    }
3056    
3057  /* Unknown command. */  /* Unknown command. */
3058  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_w));  OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_sw));
3059  JUMPTO(SLJIT_JUMP, mainloop);  JUMPTO(SLJIT_JUMP, mainloop);
3060  }  }
3061    
# Line 3529  if (caseless && char_has_othercase(commo Line 3531  if (caseless && char_has_othercase(commo
3531    othercasechar = cc + (othercasebit >> 8);    othercasechar = cc + (othercasebit >> 8);
3532    othercasebit &= 0xff;    othercasebit &= 0xff;
3533  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32  #elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
3534      /* Note that this code only handles characters in the BMP. If there
3535      ever are characters outside the BMP whose othercase differs in only one
3536      bit from itself (there currently are none), this code will need to be
3537      revised for COMPILE_PCRE32. */
3538    othercasechar = cc + (othercasebit >> 9);    othercasechar = cc + (othercasebit >> 9);
3539    if ((othercasebit & 0x100) != 0)    if ((othercasebit & 0x100) != 0)
3540      othercasebit = (othercasebit & 0xff) << 8;      othercasebit = (othercasebit & 0xff) << 8;
# Line 3729  if ((*cc++ & XCL_MAP) != 0) Line 3735  if ((*cc++ & XCL_MAP) != 0)
3735      {      {
3736      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);      OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
3737      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);      OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
3738      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)cc);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
3739      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);      OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
3740      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);
3741      add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));      add_jump(compiler, list, JUMP(SLJIT_C_NOT_ZERO));
# Line 3846  if (needstype || needsscript) Line 3852  if (needstype || needsscript)
3852      {      {
3853      if (scriptreg == TMP1)      if (scriptreg == TMP1)
3854        {        {
3855        OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));        OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
3856        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);
3857        }        }
3858      else      else
3859        {        {
3860        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);        OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
3861        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));        OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
3862        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);        OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);
3863        }        }
3864      }      }
# Line 4035  while (*cc != XCL_END) Line 4041  while (*cc != XCL_END)
4041            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4042          else          else
4043            {            {
4044            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_w)charoffset);            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);
4045            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4046            }            }
4047          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[1]);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[1]);
# Line 4048  while (*cc != XCL_END) Line 4054  while (*cc != XCL_END)
4054            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);            OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);
4055          else          else
4056            {            {
4057            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_w)charoffset);            OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);
4058            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);            OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
4059            }            }
4060          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]);          OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]);
# Line 4190  switch(type) Line 4196  switch(type)
4196  #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16  #if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
4197  #if defined COMPILE_PCRE8  #if defined COMPILE_PCRE8
4198      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
4199      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);      OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
4200      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);      OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4201  #elif defined COMPILE_PCRE16  #elif defined COMPILE_PCRE16
4202      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);      jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
# Line 4268  switch(type) Line 4274  switch(type)
4274    detect_partial_match(common, backtracks);    detect_partial_match(common, backtracks);
4275    read_char(common);    read_char(common);
4276    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
4277    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));
4278    /* Optimize register allocation: use a real register. */    /* Optimize register allocation: use a real register. */
4279    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
4280    OP1(SLJIT_MOV_UB, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3);    OP1(SLJIT_MOV_UB, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3);
# Line 4278  switch(type) Line 4284  switch(type)
4284    OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);    OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
4285    read_char(common);    read_char(common);
4286    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
4287    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_w)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));    OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));
4288    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3);    OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3);
4289    
4290    OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2);    OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2);
4291    OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_w)PRIV(ucp_gbtable));    OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_sw)PRIV(ucp_gbtable));
4292    OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);    OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);
4293    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
4294    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);
# Line 4533  switch(type) Line 4539  switch(type)
4539        /* Skip the variable-length character. */        /* Skip the variable-length character. */
4540        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));
4541        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);        jump[0] = CMP(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
4542        OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)PRIV(utf8_table4) - 0xc0);        OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
4543        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);        OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4544        JUMPHERE(jump[0]);        JUMPHERE(jump[0]);
4545        return cc + 1;        return cc + 1;
# Line 4596  switch(type) Line 4602  switch(type)
4602  #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */  #endif /* SUPPORT_UTF || !COMPILE_PCRE8 */
4603    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);    OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
4604    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);    OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
4605    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_w)cc);    OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
4606    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);    OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
4607    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);
4608    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));    add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));
# Line 4899  if (!minimize) Line 4905  if (!minimize)
4905      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
4906      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
4907      /* Temporary release of STR_PTR. */      /* Temporary release of STR_PTR. */
4908      OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));      OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
4909      zerolength = compile_ref_checks(common, ccbegin, NULL);      zerolength = compile_ref_checks(common, ccbegin, NULL);
4910      /* Restore if not zero length. */      /* Restore if not zero length. */
4911      OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));      OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
4912      }      }
4913    else    else
4914      {      {
# Line 5141  while (1) Line 5147  while (1)
5147      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)
5148        {        {
5149        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5150        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
5151        }        }
5152      else      else
5153        {        {
# Line 5161  while (1) Line 5167  while (1)
5167          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5168        else        else
5169          {          {
5170          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_w));          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5171          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_w));          OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_sw));
5172          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
5173          }          }
5174        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5175        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5176        }        }
5177      else if (framesize >= 0)      else if (framesize >= 0)
5178        {        {
5179        /* For OP_BRA and OP_BRAMINZERO. */        /* For OP_BRA and OP_BRAMINZERO. */
5180        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5181        }        }
5182      }      }
5183    add_jump(compiler, found, JUMP(SLJIT_JUMP));    add_jump(compiler, found, JUMP(SLJIT_JUMP));
# Line 5236  if (opcode == OP_ASSERT || opcode == OP_ Line 5242  if (opcode == OP_ASSERT || opcode == OP_
5242      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5243      /* Keep the STR_PTR on the top of the stack. */      /* Keep the STR_PTR on the top of the stack. */
5244      if (bra == OP_BRAZERO)      if (bra == OP_BRAZERO)
5245        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5246      else if (bra == OP_BRAMINZERO)      else if (bra == OP_BRAMINZERO)
5247        {        {
5248        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5249        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
5250        }        }
5251      }      }
# Line 5248  if (opcode == OP_ASSERT || opcode == OP_ Line 5254  if (opcode == OP_ASSERT || opcode == OP_
5254      if (bra == OP_BRA)      if (bra == OP_BRA)
5255        {        {
5256        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5257        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
5258        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5259        }        }
5260      else      else
5261        {        {
5262        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5263        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_sw));
5264        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
5265        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);
5266        }        }
# Line 5273  if (opcode == OP_ASSERT || opcode == OP_ Line 5279  if (opcode == OP_ASSERT || opcode == OP_
5279        {        {
5280        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5281        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5282        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
5283        }        }
5284      set_jumps(backtrack->common.topbacktracks, LABEL());      set_jumps(backtrack->common.topbacktracks, LABEL());
5285      }      }
# Line 5327  common->accept = save_accept; Line 5333  common->accept = save_accept;
5333  return cc + 1 + LINK_SIZE;  return cc + 1 + LINK_SIZE;
5334  }  }
5335    
5336  static sljit_w SLJIT_CALL do_searchovector(sljit_w refno, sljit_w* locals, pcre_uchar *name_table)  static sljit_sw SLJIT_CALL do_searchovector(sljit_uw refno, sljit_sw* locals, pcre_uchar *name_table)
5337  {  {
5338  int condition = FALSE;  int condition = FALSE;
5339  pcre_uchar *slotA = name_table;  pcre_uchar *slotA = name_table;
5340  pcre_uchar *slotB;  pcre_uchar *slotB;
5341  sljit_w name_count = locals[LOCALS0 / sizeof(sljit_w)];  sljit_sw name_count = locals[LOCALS0 / sizeof(sljit_sw)];
5342  sljit_w name_entry_size = locals[LOCALS1 / sizeof(sljit_w)];  sljit_sw name_entry_size = locals[LOCALS1 / sizeof(sljit_sw)];
5343  sljit_w no_capture;  sljit_sw no_capture;
5344  int i;  int i;
5345    
5346  locals += refno & 0xff;  locals += refno & 0xff;
# Line 5384  if (i < name_count) Line 5390  if (i < name_count)
5390  return condition;  return condition;
5391  }  }
5392    
5393  static sljit_w SLJIT_CALL do_searchgroups(sljit_w recno, sljit_w* locals, pcre_uchar *name_table)  static sljit_sw SLJIT_CALL do_searchgroups(sljit_uw recno, sljit_uw* locals, pcre_uchar *name_table)
5394  {  {
5395  int condition = FALSE;  int condition = FALSE;
5396  pcre_uchar *slotA = name_table;  pcre_uchar *slotA = name_table;
5397  pcre_uchar *slotB;  pcre_uchar *slotB;
5398  sljit_w name_count = locals[LOCALS0 / sizeof(sljit_w)];  sljit_uw name_count = locals[LOCALS0 / sizeof(sljit_sw)];
5399  sljit_w name_entry_size = locals[LOCALS1 / sizeof(sljit_w)];  sljit_uw name_entry_size = locals[LOCALS1 / sizeof(sljit_sw)];
5400  sljit_w group_num = locals[POSSESSIVE0 / sizeof(sljit_w)];  sljit_uw group_num = locals[POSSESSIVE0 / sizeof(sljit_sw)];
5401  int i;  sljit_uw i;
5402    
5403  for (i = 0; i < name_count; i++)  for (i = 0; i < name_count; i++)
5404    {    {
# Line 5547  if (SLJIT_UNLIKELY(opcode == OP_COND) || Line 5553  if (SLJIT_UNLIKELY(opcode == OP_COND) ||
5553      else if (common->currententry->start == 0)      else if (common->currententry->start == 0)
5554        has_alternatives = stacksize != 0;        has_alternatives = stacksize != 0;
5555      else      else
5556        has_alternatives = stacksize != GET2(common->start, common->currententry->start + 1 + LINK_SIZE);        has_alternatives = stacksize != (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
5557      }      }
5558    }    }
5559    
# Line 5631  if (bra == OP_BRAMINZERO) Line 5637  if (bra == OP_BRAMINZERO)
5637          {          {
5638          /* Except when the whole stack frame must be saved. */          /* Except when the whole stack frame must be saved. */
5639          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5640          braminzerojump = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (BACKTRACK_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_w));          braminzerojump = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (BACKTRACK_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_sw));
5641          }          }
5642        JUMPHERE(skip);        JUMPHERE(skip);
5643        }        }
# Line 5666  if (opcode == OP_ONCE) Line 5672  if (opcode == OP_ONCE)
5672        allocate_stack(common, 2);        allocate_stack(common, 2);
5673        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5674        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
5675        OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));        OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
5676        }        }
5677      else if (ket == OP_KETRMAX || has_alternatives)      else if (ket == OP_KETRMAX || has_alternatives)
5678        {        {
# Line 5719  else if (opcode == OP_CBRA || opcode == Line 5725  else if (opcode == OP_CBRA || opcode ==
5725      SLJIT_ASSERT(private_data_ptr == OVECTOR(offset));      SLJIT_ASSERT(private_data_ptr == OVECTOR(offset));
5726      allocate_stack(common, 2);      allocate_stack(common, 2);
5727      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5728      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr + sizeof(sljit_w));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr + sizeof(sljit_sw));
5729      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);
5730      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
5731      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
# Line 5759  if (opcode == OP_COND || opcode == OP_SC Line 5765  if (opcode == OP_COND || opcode == OP_SC
5765      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STACK_TOP, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), POSSESSIVE1, STACK_TOP, 0);
5766      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, SLJIT_IMM, common->name_count);
5767      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS1, SLJIT_IMM, common->name_entry_size);
5768      OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (stacksize << 8) | (common->ovector_start / sizeof(sljit_w)));      OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG1, 0, SLJIT_IMM, (stacksize << 8) | (common->ovector_start / sizeof(sljit_sw)));
5769      GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, 0);      GET_LOCAL_BASE(SLJIT_TEMPORARY_REG2, 0, 0);
5770      OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, common->name_table);      OP1(SLJIT_MOV, SLJIT_TEMPORARY_REG3, 0, SLJIT_IMM, common->name_table);
5771      sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchovector));      sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_searchovector));
# Line 5782  if (opcode == OP_COND || opcode == OP_SC Line 5788  if (opcode == OP_COND || opcode == OP_SC
5788      else if (common->currententry->start == 0)      else if (common->currententry->start == 0)
5789        stacksize = stacksize == 0;        stacksize = stacksize == 0;
5790      else      else
5791        stacksize = stacksize == GET2(common->start, common->currententry->start + 1 + LINK_SIZE);        stacksize = stacksize == (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
5792    
5793      if (*matchingpath == OP_RREF || stacksize || common->currententry == NULL)      if (*matchingpath == OP_RREF || stacksize || common->currententry == NULL)
5794        {        {
# Line 5853  if (opcode == OP_ONCE) Line 5859  if (opcode == OP_ONCE)
5859    else    else
5860      {      {
5861      stacksize = (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives) ? 2 : 1;      stacksize = (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives) ? 2 : 1;
5862      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (BACKTRACK_AS(bracket_backtrack)->u.framesize + stacksize) * sizeof(sljit_w));      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (BACKTRACK_AS(bracket_backtrack)->u.framesize + stacksize) * sizeof(sljit_sw));
5863      if (ket == OP_KETRMAX)      if (ket == OP_KETRMAX)
5864        {        {
5865        /* TMP2 which is set here used by OP_KETRMAX below. */        /* TMP2 which is set here used by OP_KETRMAX below. */
# Line 6100  while (*cc != OP_KETRPOS) Line 6106  while (*cc != OP_KETRPOS)
6106      {      {
6107      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)
6108        {        {
6109        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, stacksize * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, stacksize * sizeof(sljit_sw));
6110        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);
6111        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);
6112        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr, STR_PTR, 0);
# Line 6109  while (*cc != OP_KETRPOS) Line 6115  while (*cc != OP_KETRPOS)
6115      else      else
6116        {        {
6117        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6118        OP2(SLJIT_ADD, STACK_TOP, 0, TMP2, 0, SLJIT_IMM, stacksize * sizeof(sljit_w));        OP2(SLJIT_ADD, STACK_TOP, 0, TMP2, 0, SLJIT_IMM, stacksize * sizeof(sljit_sw));
6119        if (opcode == OP_SBRAPOS)        if (opcode == OP_SBRAPOS)
6120          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_w));          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw));
6121        OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_w), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw), STR_PTR, 0);
6122        }        }
6123    
6124      if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)      if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
# Line 6153  while (*cc != OP_KETRPOS) Line 6159  while (*cc != OP_KETRPOS)
6159      else      else
6160        {        {
6161        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6162        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_w));        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw));
6163        }        }
6164      }      }
6165    
# Line 6168  if (!zero) Line 6174  if (!zero)
6174    if (framesize < 0)    if (framesize < 0)
6175      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0));      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0));
6176    else /* TMP2 is set to [private_data_ptr] above. */    else /* TMP2 is set to [private_data_ptr] above. */
6177      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(TMP2), (stacksize - 1) * sizeof(sljit_w), SLJIT_IMM, 0));      add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(TMP2), (stacksize - 1) * sizeof(sljit_sw), SLJIT_IMM, 0));
6178    }    }
6179    
6180  /* None of them matched. */  /* None of them matched. */
# Line 6283  struct sljit_label *label; Line 6289  struct sljit_label *label;
6289  int private_data_ptr = PRIVATE_DATA(cc);  int private_data_ptr = PRIVATE_DATA(cc);
6290  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);
6291  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
6292  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_w);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
6293  int tmp_base, tmp_offset;  int tmp_base, tmp_offset;
6294    
6295  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
# Line 6769  while (cc < ccend) Line 6775  while (cc < ccend)
6775      allocate_stack(common, 1);      allocate_stack(common, 1);
6776      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);      OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
6777      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
6778      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_w)(cc + 2));      OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
6779      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->mark_ptr, TMP2, 0);
6780      OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
6781      cc += 1 + 2 + cc[1];      cc += 1 + 2 + cc[1];
# Line 6832  jump_list *jumplist = NULL; Line 6838  jump_list *jumplist = NULL;
6838  int private_data_ptr = PRIVATE_DATA(cc);  int private_data_ptr = PRIVATE_DATA(cc);
6839  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);  int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_LOCALS_REG);
6840  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
6841  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_w);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
6842    
6843  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);
6844    
# Line 7056  if (*cc == OP_ASSERT || *cc == OP_ASSERT Line 7062  if (*cc == OP_ASSERT || *cc == OP_ASSERT
7062    {    {
7063    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr);    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr);
7064    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7065    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(assert_backtrack)->framesize * sizeof(sljit_w));    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(assert_backtrack)->framesize * sizeof(sljit_sw));
7066    
7067    set_jumps(current->topbacktracks, LABEL());    set_jumps(current->topbacktracks, LABEL());
7068    }    }
# Line 7066  else Line 7072  else
7072  if (bra == OP_BRAZERO)  if (bra == OP_BRAZERO)
7073    {    {
7074    /* We know there is enough place on the stack. */    /* We know there is enough place on the stack. */
7075    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
7076    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
7077    JUMPTO(SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);    JUMPTO(SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);
7078    JUMPHERE(brajump);    JUMPHERE(brajump);
# Line 7137  else if (ket == OP_KETRMIN) Line 7143  else if (ket == OP_KETRMIN)
7143        else        else
7144          {          {
7145          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7146          CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (CURRENT_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_w), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);          CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (CURRENT_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_sw), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
7147          }          }
7148        if (opcode != OP_ONCE)        if (opcode != OP_ONCE)
7149          free_stack(common, 1);          free_stack(common, 1);
# Line 7226  if (SLJIT_UNLIKELY(opcode == OP_COND) || Line 7232  if (SLJIT_UNLIKELY(opcode == OP_COND) ||
7232        {        {
7233        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);
7234        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7235        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_sw));
7236        }        }
7237      cond = JUMP(SLJIT_JUMP);      cond = JUMP(SLJIT_JUMP);
7238      set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());      set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());
# Line 7283  if (has_alternatives) Line 7289  if (has_alternatives)
7289          }          }
7290        else        else
7291          {          {
7292          OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (CURRENT_AS(bracket_backtrack)->u.framesize + 2) * sizeof(sljit_w));          OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_IMM, (CURRENT_AS(bracket_backtrack)->u.framesize + 2) * sizeof(sljit_sw));
7293          if (ket == OP_KETRMAX)          if (ket == OP_KETRMAX)
7294            {            {
7295            /* TMP2 which is set here used by OP_KETRMAX below. */            /* TMP2 which is set here used by OP_KETRMAX below. */
# Line 7305  if (has_alternatives) Line 7311  if (has_alternatives)
7311          {          {
7312          /* We know we have place at least for one item on the top of the stack. */          /* We know we have place at least for one item on the top of the stack. */
7313          SLJIT_ASSERT(stacksize == 1);          SLJIT_ASSERT(stacksize == 1);
7314          OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_w));          OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
7315          }          }
7316      }      }
7317    
# Line 7355  if (has_alternatives) Line 7361  if (has_alternatives)
7361        {        {
7362        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);
7363        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7364        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_w));        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_sw));
7365        }        }
7366      JUMPHERE(cond);      JUMPHERE(cond);
7367      }      }
# Line 7410  else if (opcode == OP_ONCE) Line 7416  else if (opcode == OP_ONCE)
7416    JUMPHERE(once);    JUMPHERE(once);
7417    /* Restore previous private_data_ptr */    /* Restore previous private_data_ptr */
7418    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
7419      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracket_backtrack)->u.framesize * sizeof(sljit_w));      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracket_backtrack)->u.framesize * sizeof(sljit_sw));
7420    else if (ket == OP_KETRMIN)    else if (ket == OP_KETRMIN)
7421      {      {
7422      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
# Line 7489  if (current->topbacktracks) Line 7495  if (current->topbacktracks)
7495    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
7496    JUMPHERE(jump);    JUMPHERE(jump);
7497    }    }
7498  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracketpos_backtrack)->framesize * sizeof(sljit_w));  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracketpos_backtrack)->framesize * sizeof(sljit_sw));
7499  }  }
7500    
7501  static void compile_braminzero_backtrackingpath(compiler_common *common, struct backtrack_common *current)  static void compile_braminzero_backtrackingpath(compiler_common *common, struct backtrack_common *current)
# Line 7766  set_jumps(common->accept, LABEL()); Line 7772  set_jumps(common->accept, LABEL());
7772  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head);  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head);
7773  if (needsframe)  if (needsframe)
7774    {    {
7775    OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_w));    OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
7776    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7777    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_w));    OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
7778    }    }
7779  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);
7780    
7781  JUMPHERE(jump);  JUMPHERE(jump);
7782  copy_private_data(common, ccbegin, ccend, FALSE, private_data_size + framesize + alternativesize, framesize + alternativesize);  copy_private_data(common, ccbegin, ccend, FALSE, private_data_size + framesize + alternativesize, framesize + alternativesize);
7783  free_stack(common, private_data_size + framesize + alternativesize);  free_stack(common, private_data_size + framesize + alternativesize);
7784  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_w));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));
7785  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
7786  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head, TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head, TMP2, 0);
7787  sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);  sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);
# Line 7820  rootbacktrack.cc = (pcre_uchar *)re + re Line 7826  rootbacktrack.cc = (pcre_uchar *)re + re
7826    
7827  common->start = rootbacktrack.cc;  common->start = rootbacktrack.cc;
7828  common->fcc = tables + fcc_offset;  common->fcc = tables + fcc_offset;
7829  common->lcc = (sljit_w)(tables + lcc_offset);  common->lcc = (sljit_sw)(tables + lcc_offset);
7830  common->mode = mode;  common->mode = mode;
7831  common->nltype = NLTYPE_FIXED;  common->nltype = NLTYPE_FIXED;
7832  switch(re->options & PCRE_NEWLINE_BITS)  switch(re->options & PCRE_NEWLINE_BITS)
# Line 7855  else Line 7861  else
7861  #endif  #endif
7862    }    }
7863  common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;  common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
7864  common->ctypes = (sljit_w)(tables + ctypes_offset);  common->ctypes = (sljit_sw)(tables + ctypes_offset);
7865  common->digits[0] = -2;  common->digits[0] = -2;
7866  common->name_table = (sljit_w)((pcre_uchar *)re + re->name_table_offset);  common->name_table = (sljit_sw)((pcre_uchar *)re + re->name_table_offset);
7867  common->name_count = re->name_count;  common->name_count = re->name_count;
7868  common->name_entry_size = re->name_entry_size;  common->name_entry_size = re->name_entry_size;
7869  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;  common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
# Line 7871  common->use_ucp = (re->options & PCRE_UC Line 7877  common->use_ucp = (re->options & PCRE_UC
7877  ccend = bracketend(rootbacktrack.cc);  ccend = bracketend(rootbacktrack.cc);
7878    
7879  /* Calculate the local space size on the stack. */  /* Calculate the local space size on the stack. */
7880  common->ovector_start = CALL_LIMIT + sizeof(sljit_w);  common->ovector_start = CALL_LIMIT + sizeof(sljit_sw);
7881  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);  common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1);
7882  if (!common->optimized_cbracket)  if (!common->optimized_cbracket)
7883    return;    return;
# Line 7889  if (private_data_size < 0) Line 7895  if (private_data_size < 0)
7895  if (mode == JIT_COMPILE && (re->flags & PCRE_REQCHSET) != 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)  if (mode == JIT_COMPILE && (re->flags & PCRE_REQCHSET) != 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
7896    {    {
7897    common->req_char_ptr = common->ovector_start;    common->req_char_ptr = common->ovector_start;
7898    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
7899    }    }
7900  if (mode != JIT_COMPILE)  if (mode != JIT_COMPILE)
7901    {    {
7902    common->start_used_ptr = common->ovector_start;    common->start_used_ptr = common->ovector_start;
7903    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
7904    if (mode == JIT_PARTIAL_SOFT_COMPILE)    if (mode == JIT_PARTIAL_SOFT_COMPILE)
7905      {      {
7906      common->hit_start = common->ovector_start;      common->hit_start = common->ovector_start;
7907      common->ovector_start += sizeof(sljit_w);      common->ovector_start += sizeof(sljit_sw);
7908      }      }
7909    }    }
7910  if ((re->options & PCRE_FIRSTLINE) != 0)  if ((re->options & PCRE_FIRSTLINE) != 0)
7911    {    {
7912    common->first_line_end = common->ovector_start;    common->first_line_end = common->ovector_start;
7913    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
7914    }    }
7915    
7916  /* Aligning ovector to even number of sljit words. */  /* Aligning ovector to even number of sljit words. */
7917  if ((common->ovector_start & sizeof(sljit_w)) != 0)  if ((common->ovector_start & sizeof(sljit_sw)) != 0)
7918    common->ovector_start += sizeof(sljit_w);    common->ovector_start += sizeof(sljit_sw);
7919    
7920  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
7921  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_w);  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);
7922  private_data_size += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w);  private_data_size += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_sw);
7923  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
7924    {    {
7925    SLJIT_FREE(common->optimized_cbracket);    SLJIT_FREE(common->optimized_cbracket);
# Line 7926  if (!common->private_data_ptrs) Line 7932  if (!common->private_data_ptrs)
7932    return;    return;
7933    }    }
7934  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));
7935  set_private_data_ptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w), ccend);  set_private_data_ptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_sw), ccend);
7936    
7937  compiler = sljit_create_compiler();  compiler = sljit_create_compiler();
7938  if (!compiler)  if (!compiler)
# Line 8237  else Line 8243  else
8243      return;      return;
8244      }      }
8245    memset(functions, 0, sizeof(executable_functions));    memset(functions, 0, sizeof(executable_functions));
8246      functions->top_bracket = (re->top_bracket + 1) * 2;
8247    extra->executable_jit = functions;    extra->executable_jit = functions;
8248    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;    extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;
8249    }    }
# Line 8254  union { Line 8261  union {
8261  pcre_uint8 local_space[MACHINE_STACK_SIZE];  pcre_uint8 local_space[MACHINE_STACK_SIZE];
8262  struct sljit_stack local_stack;  struct sljit_stack local_stack;
8263    
8264  local_stack.top = (sljit_w)&local_space;  local_stack.top = (sljit_sw)&local_space;
8265  local_stack.base = local_stack.top;  local_stack.base = local_stack.top;
8266  local_stack.limit = local_stack.base + MACHINE_STACK_SIZE;  local_stack.limit = local_stack.base + MACHINE_STACK_SIZE;
8267  local_stack.max_limit = local_stack.limit;  local_stack.max_limit = local_stack.limit;
# Line 8264  return convert_executable_func.call_exec Line 8271  return convert_executable_func.call_exec
8271  }  }
8272    
8273  int  int
8274  PRIV(jit_exec)(const REAL_PCRE *re, const PUBL(extra) *extra_data, const pcre_uchar *subject,  PRIV(jit_exec)(const PUBL(extra) *extra_data, const pcre_uchar *subject,
8275    int length, int start_offset, int options, int *offsets, int offsetcount)    int length, int start_offset, int options, int *offsets, int offsetcount)
8276  {  {
8277  executable_functions *functions = (executable_functions *)extra_data->executable_jit;  executable_functions *functions = (executable_functions *)extra_data->executable_jit;
# Line 8283  else if ((options & PCRE_PARTIAL_SOFT) ! Line 8290  else if ((options & PCRE_PARTIAL_SOFT) !
8290    mode = JIT_PARTIAL_SOFT_COMPILE;    mode = JIT_PARTIAL_SOFT_COMPILE;
8291    
8292  if (functions->executable_funcs[mode] == NULL)  if (functions->executable_funcs[mode] == NULL)
8293    return PCRE_ERROR_NULL;    return PCRE_ERROR_JIT_BADOPTION;
8294    
8295  /* Sanity checks should be handled by pcre_exec. */  /* Sanity checks should be handled by pcre_exec. */
 arguments.stack = NULL;  
8296  arguments.str = subject + start_offset;  arguments.str = subject + start_offset;
8297  arguments.begin = subject;  arguments.begin = subject;
8298  arguments.end = subject + length;  arguments.end = subject + length;
# Line 8307  gets the same result with and without JI Line 8313  gets the same result with and without JI
8313    
8314  if (offsetcount != 2)  if (offsetcount != 2)
8315    offsetcount = ((offsetcount - (offsetcount % 3)) * 2) / 3;    offsetcount = ((offsetcount - (offsetcount % 3)) * 2) / 3;
8316  maxoffsetcount = (re->top_bracket + 1) * 2;  maxoffsetcount = functions->top_bracket;
8317  if (offsetcount > maxoffsetcount)  if (offsetcount > maxoffsetcount)
8318    offsetcount = maxoffsetcount;    offsetcount = maxoffsetcount;
8319  arguments.offsetcount = offsetcount;  arguments.offsetcount = offsetcount;
# Line 8327  else Line 8333  else
8333    
8334  if (retval * 2 > offsetcount)  if (retval * 2 > offsetcount)
8335    retval = 0;    retval = 0;
8336    if ((extra_data->flags & PCRE_EXTRA_MARK) != 0)
8337      *(extra_data->mark) = arguments.mark_ptr;
8338    
8339    return retval;
8340    }
8341    
8342    #if defined COMPILE_PCRE8
8343    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
8344    pcre_jit_exec(const pcre *argument_re, const pcre_extra *extra_data,
8345      PCRE_SPTR subject, int length, int start_offset, int options,
8346      int *offsets, int offsetcount, pcre_jit_stack *stack)
8347    #elif defined COMPILE_PCRE16
8348    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
8349    pcre16_jit_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
8350      PCRE_SPTR16 subject, int length, int start_offset, int options,
8351      int *offsets, int offsetcount, pcre16_jit_stack *stack)
8352    #elif defined COMPILE_PCRE32
8353    PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
8354    pcre32_jit_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
8355      PCRE_SPTR32 subject, int length, int start_offset, int options,
8356      int *offsets, int offsetcount, pcre32_jit_stack *stack)
8357    #endif
8358    {
8359    pcre_uchar *subject_ptr = (pcre_uchar *)subject;
8360    executable_functions *functions = (executable_functions *)extra_data->executable_jit;
8361    union {
8362       void* executable_func;
8363       jit_function call_executable_func;
8364    } convert_executable_func;
8365    jit_arguments arguments;
8366    int maxoffsetcount;
8367    int retval;
8368    int mode = JIT_COMPILE;
8369    
8370    SLJIT_UNUSED_ARG(argument_re);
8371    
8372    /* Plausibility checks */
8373    if ((options & ~PUBLIC_JIT_EXEC_OPTIONS) != 0) return PCRE_ERROR_JIT_BADOPTION;
8374    
8375    if ((options & PCRE_PARTIAL_HARD) != 0)
8376      mode = JIT_PARTIAL_HARD_COMPILE;
8377    else if ((options & PCRE_PARTIAL_SOFT) != 0)
8378      mode = JIT_PARTIAL_SOFT_COMPILE;
8379    
8380    if (functions->executable_funcs[mode] == NULL)
8381      return PCRE_ERROR_JIT_BADOPTION;
8382    
8383    /* Sanity checks should be handled by pcre_exec. */
8384    arguments.stack = (struct sljit_stack *)stack;
8385    arguments.str = subject_ptr + start_offset;
8386    arguments.begin = subject_ptr;
8387    arguments.end = subject_ptr + length;
8388    arguments.mark_ptr = NULL;
8389    /* JIT decreases this value less frequently than the interpreter. */
8390    arguments.calllimit = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : extra_data->match_limit;
8391    arguments.notbol = (options & PCRE_NOTBOL) != 0;
8392    arguments.noteol = (options & PCRE_NOTEOL) != 0;
8393    arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
8394    arguments.notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
8395    arguments.offsets = offsets;
8396    
8397    /* pcre_exec() rounds offsetcount to a multiple of 3, and then uses only 2/3 of
8398    the output vector for storing captured strings, with the remainder used as
8399    workspace. We don't need the workspace here. For compatibility, we limit the
8400    number of captured strings in the same way as pcre_exec(), so that the user
8401    gets the same result with and without JIT. */
8402    
8403    if (offsetcount != 2)
8404      offsetcount = ((offsetcount - (offsetcount % 3)) * 2) / 3;
8405    maxoffsetcount = functions->top_bracket;
8406    if (offsetcount > maxoffsetcount)
8407      offsetcount = maxoffsetcount;
8408    arguments.offsetcount = offsetcount;
8409    
8410    convert_executable_func.executable_func = functions->executable_funcs[mode];
8411    retval = convert_executable_func.call_executable_func(&arguments);
8412    
8413    if (retval * 2 > offsetcount)
8414      retval = 0;
8415  if ((extra_data->flags & PCRE_EXTRA_MARK) != 0)  if ((extra_data->flags & PCRE_EXTRA_MARK) != 0)
8416    *(extra_data->mark) = arguments.mark_ptr;    *(extra_data->mark) = arguments.mark_ptr;
8417    

Legend:
Removed from v.1120  
changed lines
  Added in v.1195

  ViewVC Help
Powered by ViewVC 1.1.5