/[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 1001 by zherczeg, Mon Aug 6 07:36:49 2012 UTC revision 1002 by zherczeg, Tue Aug 14 09:31:00 2012 UTC
# Line 65  system files. */ Line 65  system files. */
65  #error Unsupported architecture  #error Unsupported architecture
66  #endif  #endif
67    
68  /* Allocate memory on the stack. Fast, but limited size. */  /* Allocate memory for the regex stack on the real machine stack.
69  #define LOCAL_SPACE_SIZE 32768  Fast, but limited size. */
70    #define MACHINE_STACK_SIZE 32768
71    
72    /* Growth rate for stack allocated by the OS. Should be the multiply
73    of page size. */
74  #define STACK_GROWTH_RATE 8192  #define STACK_GROWTH_RATE 8192
75    
76  /* Enable to check that the allocation could destroy temporaries. */  /* Enable to check that the allocation could destroy temporaries. */
# Line 134  The generated code will be the following Line 137  The generated code will be the following
137  /*  /*
138  Saved stack frames:  Saved stack frames:
139    
140  Atomic blocks and asserts require reloading the values of local variables  Atomic blocks and asserts require reloading the values of private data
141  when the backtrack mechanism performed. Because of OP_RECURSE, the locals  when the backtrack mechanism performed. Because of OP_RECURSE, the data
142  are not necessarly known in compile time, thus we need a dynamic restore  are not necessarly known in compile time, thus we need a dynamic restore
143  mechanism.  mechanism.
144    
145  The stack frames are stored in a chain list, and have the following format:  The stack frames are stored in a chain list, and have the following format:
146  ([ capturing bracket offset ][ start value ][ end value ])+ ... [ 0 ] [ previous head ]  ([ capturing bracket offset ][ start value ][ end value ])+ ... [ 0 ] [ previous head ]
147    
148  Thus we can restore the locals to a particular point in the stack.  Thus we can restore the private data to a particular point in the stack.
149  */  */
150    
151  typedef struct jit_arguments {  typedef struct jit_arguments {
# Line 208  typedef struct assert_backtrack { Line 211  typedef struct assert_backtrack {
211    /* Less than 0 (-1) if a frame is not needed. */    /* Less than 0 (-1) if a frame is not needed. */
212    int framesize;    int framesize;
213    /* Points to our private memory word on the stack. */    /* Points to our private memory word on the stack. */
214    int localptr;    int private_data_ptr;
215    /* For iterators. */    /* For iterators. */
216    struct sljit_label *matchingpath;    struct sljit_label *matchingpath;
217  } assert_backtrack;  } assert_backtrack;
# Line 230  typedef struct bracket_backtrack { Line 233  typedef struct bracket_backtrack {
233      int framesize;      int framesize;
234    } u;    } u;
235    /* Points to our private memory word on the stack. */    /* Points to our private memory word on the stack. */
236    int localptr;    int private_data_ptr;
237  } bracket_backtrack;  } bracket_backtrack;
238    
239  typedef struct bracketpos_backtrack {  typedef struct bracketpos_backtrack {
240    backtrack_common common;    backtrack_common common;
241    /* Points to our private memory word on the stack. */    /* Points to our private memory word on the stack. */
242    int localptr;    int private_data_ptr;
243    /* Reverting stack is needed. */    /* Reverting stack is needed. */
244    int framesize;    int framesize;
245    /* Allocated stack size. */    /* Allocated stack size. */
# Line 274  typedef struct compiler_common { Line 277  typedef struct compiler_common {
277    struct sljit_compiler *compiler;    struct sljit_compiler *compiler;
278    pcre_uchar *start;    pcre_uchar *start;
279    
280    /* Opcode local area direct map. */    /* Maps private data offset to each opcode. */
281    int *localptrs;    int *private_data_ptrs;
282    int cbraptr;    int cbraptr;
283    /* OVector starting point. Must be divisible by 2. */    /* OVector starting point. Must be divisible by 2. */
284    int ovector_start;    int ovector_start;
# Line 404  enum { Line 407  enum {
407  #define CALL_COUNT    SLJIT_SAVED_EREG2  #define CALL_COUNT    SLJIT_SAVED_EREG2
408  #define RETURN_ADDR   SLJIT_TEMPORARY_EREG1  #define RETURN_ADDR   SLJIT_TEMPORARY_EREG1
409    
410  /* Locals layout. */  /* Local space layout. */
411  /* These two locals can be used by the current opcode. */  /* These two locals can be used by the current opcode. */
412  #define LOCALS0          (0 * sizeof(sljit_w))  #define LOCALS0          (0 * sizeof(sljit_w))
413  #define LOCALS1          (1 * sizeof(sljit_w))  #define LOCALS1          (1 * sizeof(sljit_w))
# Line 420  the start pointers when the end of the c Line 423  the start pointers when the end of the c
423  #define OVECTOR_START    (common->ovector_start)  #define OVECTOR_START    (common->ovector_start)
424  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))  #define OVECTOR(i)       (OVECTOR_START + (i) * sizeof(sljit_w))
425  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))  #define OVECTOR_PRIV(i)  (common->cbraptr + (i) * sizeof(sljit_w))
426  #define PRIV_DATA(cc)    (common->localptrs[(cc) - common->start])  #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
427    
428  #ifdef COMPILE_PCRE8  #ifdef COMPILE_PCRE8
429  #define MOV_UCHAR  SLJIT_MOV_UB  #define MOV_UCHAR  SLJIT_MOV_UB
# Line 469  return cc; Line 472  return cc;
472    
473  /* Functions whose might need modification for all new supported opcodes:  /* Functions whose might need modification for all new supported opcodes:
474   next_opcode   next_opcode
475   get_localspace   get_private_data_length
476   set_localptrs   set_private_data_ptrs
477   get_framesize   get_framesize
478   init_frame   init_frame
479   get_localsize   get_private_data_length_for_copy
480   copy_locals   copy_private_data
481   compile_matchingpath   compile_matchingpath
482   compile_backtrackingpath   compile_backtrackingpath
483  */  */
# Line 675  switch(*cc) Line 678  switch(*cc)
678    }    }
679  }  }
680    
681  #define CASE_ITERATOR_LOCAL1 \  #define CASE_ITERATOR_PRIVATE_DATA_1 \
682      case OP_MINSTAR: \      case OP_MINSTAR: \
683      case OP_MINPLUS: \      case OP_MINPLUS: \
684      case OP_QUERY: \      case OP_QUERY: \
# Line 693  switch(*cc) Line 696  switch(*cc)
696      case OP_NOTQUERYI: \      case OP_NOTQUERYI: \
697      case OP_NOTMINQUERYI:      case OP_NOTMINQUERYI:
698    
699  #define CASE_ITERATOR_LOCAL2A \  #define CASE_ITERATOR_PRIVATE_DATA_2A \
700      case OP_STAR: \      case OP_STAR: \
701      case OP_PLUS: \      case OP_PLUS: \
702      case OP_STARI: \      case OP_STARI: \
# Line 703  switch(*cc) Line 706  switch(*cc)
706      case OP_NOTSTARI: \      case OP_NOTSTARI: \
707      case OP_NOTPLUSI:      case OP_NOTPLUSI:
708    
709  #define CASE_ITERATOR_LOCAL2B \  #define CASE_ITERATOR_PRIVATE_DATA_2B \
710      case OP_UPTO: \      case OP_UPTO: \
711      case OP_MINUPTO: \      case OP_MINUPTO: \
712      case OP_UPTOI: \      case OP_UPTOI: \
# Line 713  switch(*cc) Line 716  switch(*cc)
716      case OP_NOTUPTOI: \      case OP_NOTUPTOI: \
717      case OP_NOTMINUPTOI:      case OP_NOTMINUPTOI:
718    
719  #define CASE_ITERATOR_TYPE_LOCAL1 \  #define CASE_ITERATOR_TYPE_PRIVATE_DATA_1 \
720      case OP_TYPEMINSTAR: \      case OP_TYPEMINSTAR: \
721      case OP_TYPEMINPLUS: \      case OP_TYPEMINPLUS: \
722      case OP_TYPEQUERY: \      case OP_TYPEQUERY: \
723      case OP_TYPEMINQUERY:      case OP_TYPEMINQUERY:
724    
725  #define CASE_ITERATOR_TYPE_LOCAL2A \  #define CASE_ITERATOR_TYPE_PRIVATE_DATA_2A \
726      case OP_TYPESTAR: \      case OP_TYPESTAR: \
727      case OP_TYPEPLUS:      case OP_TYPEPLUS:
728    
729  #define CASE_ITERATOR_TYPE_LOCAL2B \  #define CASE_ITERATOR_TYPE_PRIVATE_DATA_2B \
730      case OP_TYPEUPTO: \      case OP_TYPEUPTO: \
731      case OP_TYPEMINUPTO:      case OP_TYPEMINUPTO:
732    
# Line 752  switch(*cc) Line 755  switch(*cc)
755    }    }
756  }  }
757    
758  static int get_localspace(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)  static int get_private_data_length(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)
759  {  {
760  int localspace = 0;  int private_data_length = 0;
761  pcre_uchar *alternative;  pcre_uchar *alternative;
762  pcre_uchar *end = NULL;  pcre_uchar *end = NULL;
763  int space, size, bracketlen;  int space, size, bracketlen;
# Line 782  while (cc < ccend) Line 785  while (cc < ccend)
785      case OP_SBRA:      case OP_SBRA:
786      case OP_SBRAPOS:      case OP_SBRAPOS:
787      case OP_SCOND:      case OP_SCOND:
788      localspace += sizeof(sljit_w);      private_data_length += sizeof(sljit_w);
789      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
790      break;      break;
791    
792      case OP_CBRAPOS:      case OP_CBRAPOS:
793      case OP_SCBRAPOS:      case OP_SCBRAPOS:
794      localspace += sizeof(sljit_w);      private_data_length += sizeof(sljit_w);
795      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
796      break;      break;
797    
# Line 796  while (cc < ccend) Line 799  while (cc < ccend)
799      /* Might be a hidden SCOND. */      /* Might be a hidden SCOND. */
800      alternative = cc + GET(cc, 1);      alternative = cc + GET(cc, 1);
801      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
802        localspace += sizeof(sljit_w);        private_data_length += sizeof(sljit_w);
803      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
804      break;      break;
805    
# Line 809  while (cc < ccend) Line 812  while (cc < ccend)
812      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
813      break;      break;
814    
815      CASE_ITERATOR_LOCAL1      CASE_ITERATOR_PRIVATE_DATA_1
816      space = 1;      space = 1;
817      size = -2;      size = -2;
818      break;      break;
819    
820      CASE_ITERATOR_LOCAL2A      CASE_ITERATOR_PRIVATE_DATA_2A
821      space = 2;      space = 2;
822      size = -2;      size = -2;
823      break;      break;
824    
825      CASE_ITERATOR_LOCAL2B      CASE_ITERATOR_PRIVATE_DATA_2B
826      space = 2;      space = 2;
827      size = -(2 + IMM2_SIZE);      size = -(2 + IMM2_SIZE);
828      break;      break;
829    
830      CASE_ITERATOR_TYPE_LOCAL1      CASE_ITERATOR_TYPE_PRIVATE_DATA_1
831      space = 1;      space = 1;
832      size = 1;      size = 1;
833      break;      break;
834    
835      CASE_ITERATOR_TYPE_LOCAL2A      CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
836      if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)      if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)
837        space = 2;        space = 2;
838      size = 1;      size = 1;
839      break;      break;
840    
841      CASE_ITERATOR_TYPE_LOCAL2B      CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
842      if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)      if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
843        space = 2;        space = 2;
844      size = 1 + IMM2_SIZE;      size = 1 + IMM2_SIZE;
# Line 881  while (cc < ccend) Line 884  while (cc < ccend)
884      }      }
885    
886    if (space > 0 && cc >= end)    if (space > 0 && cc >= end)
887      localspace += sizeof(sljit_w) * space;      private_data_length += sizeof(sljit_w) * space;
888    
889    if (size != 0)    if (size != 0)
890      {      {
# Line 907  while (cc < ccend) Line 910  while (cc < ccend)
910      cc += bracketlen;      cc += bracketlen;
911      }      }
912    }    }
913  return localspace;  return private_data_length;
914  }  }
915    
916  static void set_localptrs(compiler_common *common, int localptr, pcre_uchar *ccend)  static void set_private_data_ptrs(compiler_common *common, int private_data_ptr, pcre_uchar *ccend)
917  {  {
918  pcre_uchar *cc = common->start;  pcre_uchar *cc = common->start;
919  pcre_uchar *alternative;  pcre_uchar *alternative;
# Line 934  while (cc < ccend) Line 937  while (cc < ccend)
937      case OP_SBRA:      case OP_SBRA:
938      case OP_SBRAPOS:      case OP_SBRAPOS:
939      case OP_SCOND:      case OP_SCOND:
940      common->localptrs[cc - common->start] = localptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
941      localptr += sizeof(sljit_w);      private_data_ptr += sizeof(sljit_w);
942      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
943      break;      break;
944    
945      case OP_CBRAPOS:      case OP_CBRAPOS:
946      case OP_SCBRAPOS:      case OP_SCBRAPOS:
947      common->localptrs[cc - common->start] = localptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
948      localptr += sizeof(sljit_w);      private_data_ptr += sizeof(sljit_w);
949      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
950      break;      break;
951    
# Line 951  while (cc < ccend) Line 954  while (cc < ccend)
954      alternative = cc + GET(cc, 1);      alternative = cc + GET(cc, 1);
955      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
956        {        {
957        common->localptrs[cc - common->start] = localptr;        common->private_data_ptrs[cc - common->start] = private_data_ptr;
958        localptr += sizeof(sljit_w);        private_data_ptr += sizeof(sljit_w);
959        }        }
960      bracketlen = 1 + LINK_SIZE;      bracketlen = 1 + LINK_SIZE;
961      break;      break;
# Line 966  while (cc < ccend) Line 969  while (cc < ccend)
969      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;      bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
970      break;      break;
971    
972      CASE_ITERATOR_LOCAL1      CASE_ITERATOR_PRIVATE_DATA_1
973      space = 1;      space = 1;
974      size = -2;      size = -2;
975      break;      break;
976    
977      CASE_ITERATOR_LOCAL2A      CASE_ITERATOR_PRIVATE_DATA_2A
978      space = 2;      space = 2;
979      size = -2;      size = -2;
980      break;      break;
981    
982      CASE_ITERATOR_LOCAL2B      CASE_ITERATOR_PRIVATE_DATA_2B
983      space = 2;      space = 2;
984      size = -(2 + IMM2_SIZE);      size = -(2 + IMM2_SIZE);
985      break;      break;
986    
987      CASE_ITERATOR_TYPE_LOCAL1      CASE_ITERATOR_TYPE_PRIVATE_DATA_1
988      space = 1;      space = 1;
989      size = 1;      size = 1;
990      break;      break;
991    
992      CASE_ITERATOR_TYPE_LOCAL2A      CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
993      if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)      if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)
994        space = 2;        space = 2;
995      size = 1;      size = 1;
996      break;      break;
997    
998      CASE_ITERATOR_TYPE_LOCAL2B      CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
999      if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)      if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
1000        space = 2;        space = 2;
1001      size = 1 + IMM2_SIZE;      size = 1 + IMM2_SIZE;
# Line 1019  while (cc < ccend) Line 1022  while (cc < ccend)
1022    
1023    if (space > 0 && cc >= end)    if (space > 0 && cc >= end)
1024      {      {
1025      common->localptrs[cc - common->start] = localptr;      common->private_data_ptrs[cc - common->start] = private_data_ptr;
1026      localptr += sizeof(sljit_w) * space;      private_data_ptr += sizeof(sljit_w) * space;
1027      }      }
1028    
1029    if (size != 0)    if (size != 0)
# Line 1222  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), st Line 1225  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), st
1225  SLJIT_ASSERT(stackpos == STACK(stacktop));  SLJIT_ASSERT(stackpos == STACK(stacktop));
1226  }  }
1227    
1228  static SLJIT_INLINE int get_localsize(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)  static SLJIT_INLINE int get_private_data_length_for_copy(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)
1229  {  {
1230  int localsize = 2;  int private_data_length = 2;
1231  int size;  int size;
1232  pcre_uchar *alternative;  pcre_uchar *alternative;
1233  /* Calculate the sum of the local variables. */  /* Calculate the sum of the private machine words. */
1234  while (cc < ccend)  while (cc < ccend)
1235    {    {
1236    size = 0;    size = 0;
# Line 1243  while (cc < ccend) Line 1246  while (cc < ccend)
1246      case OP_SBRA:      case OP_SBRA:
1247      case OP_SBRAPOS:      case OP_SBRAPOS:
1248      case OP_SCOND:      case OP_SCOND:
1249      localsize++;      private_data_length++;
1250      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
1251      break;      break;
1252    
1253      case OP_CBRA:      case OP_CBRA:
1254      case OP_SCBRA:      case OP_SCBRA:
1255      localsize++;      private_data_length++;
1256      cc += 1 + LINK_SIZE + IMM2_SIZE;      cc += 1 + LINK_SIZE + IMM2_SIZE;
1257      break;      break;
1258    
1259      case OP_CBRAPOS:      case OP_CBRAPOS:
1260      case OP_SCBRAPOS:      case OP_SCBRAPOS:
1261      localsize += 2;      private_data_length += 2;
1262      cc += 1 + LINK_SIZE + IMM2_SIZE;      cc += 1 + LINK_SIZE + IMM2_SIZE;
1263      break;      break;
1264    
# Line 1263  while (cc < ccend) Line 1266  while (cc < ccend)
1266      /* Might be a hidden SCOND. */      /* Might be a hidden SCOND. */
1267      alternative = cc + GET(cc, 1);      alternative = cc + GET(cc, 1);
1268      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)      if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
1269        localsize++;        private_data_length++;
1270      cc += 1 + LINK_SIZE;      cc += 1 + LINK_SIZE;
1271      break;      break;
1272    
1273      CASE_ITERATOR_LOCAL1      CASE_ITERATOR_PRIVATE_DATA_1
1274      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1275        localsize++;        private_data_length++;
1276      cc += 2;      cc += 2;
1277  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1278      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1279  #endif  #endif
1280      break;      break;
1281    
1282      CASE_ITERATOR_LOCAL2A      CASE_ITERATOR_PRIVATE_DATA_2A
1283      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1284        localsize += 2;        private_data_length += 2;
1285      cc += 2;      cc += 2;
1286  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1287      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1288  #endif  #endif
1289      break;      break;
1290    
1291      CASE_ITERATOR_LOCAL2B      CASE_ITERATOR_PRIVATE_DATA_2B
1292      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1293        localsize += 2;        private_data_length += 2;
1294      cc += 2 + IMM2_SIZE;      cc += 2 + IMM2_SIZE;
1295  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
1296      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);      if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1297  #endif  #endif
1298      break;      break;
1299    
1300      CASE_ITERATOR_TYPE_LOCAL1      CASE_ITERATOR_TYPE_PRIVATE_DATA_1
1301      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1302        localsize++;        private_data_length++;
1303      cc += 1;      cc += 1;
1304      break;      break;
1305    
1306      CASE_ITERATOR_TYPE_LOCAL2A      CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
1307      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1308        localsize += 2;        private_data_length += 2;
1309      cc += 1;      cc += 1;
1310      break;      break;
1311    
1312      CASE_ITERATOR_TYPE_LOCAL2B      CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
1313      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1314        localsize += 2;        private_data_length += 2;
1315      cc += 1 + IMM2_SIZE;      cc += 1 + IMM2_SIZE;
1316      break;      break;
1317    
# Line 1320  while (cc < ccend) Line 1323  while (cc < ccend)
1323  #else  #else
1324      size = 1 + 32 / (int)sizeof(pcre_uchar);      size = 1 + 32 / (int)sizeof(pcre_uchar);
1325  #endif  #endif
1326      if (PRIV_DATA(cc))      if (PRIVATE_DATA(cc))
1327        localsize += get_class_iterator_size(cc + size);        private_data_length += get_class_iterator_size(cc + size);
1328      cc += size;      cc += size;
1329      break;      break;
1330    
# Line 1332  while (cc < ccend) Line 1335  while (cc < ccend)
1335      }      }
1336    }    }
1337  SLJIT_ASSERT(cc == ccend);  SLJIT_ASSERT(cc == ccend);
1338  return localsize;  return private_data_length;
1339  }  }
1340    
1341  static void copy_locals(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend,  static void copy_private_data(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend,
1342    BOOL save, int stackptr, int stacktop)    BOOL save, int stackptr, int stacktop)
1343  {  {
1344  DEFINE_COMPILER;  DEFINE_COMPILER;
# Line 1405  while (status != end) Line 1408  while (status != end)
1408        case OP_SBRAPOS:        case OP_SBRAPOS:
1409        case OP_SCOND:        case OP_SCOND:
1410        count = 1;        count = 1;
1411        srcw[0] = PRIV_DATA(cc);        srcw[0] = PRIVATE_DATA(cc);
1412        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
1413        cc += 1 + LINK_SIZE;        cc += 1 + LINK_SIZE;
1414        break;        break;
# Line 1421  while (status != end) Line 1424  while (status != end)
1424        case OP_SCBRAPOS:        case OP_SCBRAPOS:
1425        count = 2;        count = 2;
1426        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));        srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
1427        srcw[1] = PRIV_DATA(cc);        srcw[1] = PRIVATE_DATA(cc);
1428        SLJIT_ASSERT(srcw[0] != 0);        SLJIT_ASSERT(srcw[0] != 0);
1429        cc += 1 + LINK_SIZE + IMM2_SIZE;        cc += 1 + LINK_SIZE + IMM2_SIZE;
1430        break;        break;
# Line 1432  while (status != end) Line 1435  while (status != end)
1435        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)        if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
1436          {          {
1437          count = 1;          count = 1;
1438          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1439          SLJIT_ASSERT(srcw[0] != 0);          SLJIT_ASSERT(srcw[0] != 0);
1440          }          }
1441        cc += 1 + LINK_SIZE;        cc += 1 + LINK_SIZE;
1442        break;        break;
1443    
1444        CASE_ITERATOR_LOCAL1        CASE_ITERATOR_PRIVATE_DATA_1
1445        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1446          {          {
1447          count = 1;          count = 1;
1448          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1449          }          }
1450        cc += 2;        cc += 2;
1451  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 1450  while (status != end) Line 1453  while (status != end)
1453  #endif  #endif
1454        break;        break;
1455    
1456        CASE_ITERATOR_LOCAL2A        CASE_ITERATOR_PRIVATE_DATA_2A
1457        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1458          {          {
1459          count = 2;          count = 2;
1460          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1461          srcw[1] = PRIV_DATA(cc) + sizeof(sljit_w);          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);
1462          }          }
1463        cc += 2;        cc += 2;
1464  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 1463  while (status != end) Line 1466  while (status != end)
1466  #endif  #endif
1467        break;        break;
1468    
1469        CASE_ITERATOR_LOCAL2B        CASE_ITERATOR_PRIVATE_DATA_2B
1470        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1471          {          {
1472          count = 2;          count = 2;
1473          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1474          srcw[1] = PRIV_DATA(cc) + sizeof(sljit_w);          srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_w);
1475          }          }
1476        cc += 2 + IMM2_SIZE;        cc += 2 + IMM2_SIZE;
1477  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
# Line 1476  while (status != end) Line 1479  while (status != end)
1479  #endif  #endif
1480        break;        break;
1481    
1482        CASE_ITERATOR_TYPE_LOCAL1        CASE_ITERATOR_TYPE_PRIVATE_DATA_1
1483        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1484          {          {
1485          count = 1;          count = 1;
1486          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1487          }          }
1488        cc += 1;        cc += 1;
1489        break;        break;
1490    
1491        CASE_ITERATOR_TYPE_LOCAL2A        CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
1492        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1493          {          {
1494          count = 2;          count = 2;
1495          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1496          srcw[1] = srcw[0] + sizeof(sljit_w);          srcw[1] = srcw[0] + sizeof(sljit_w);
1497          }          }
1498        cc += 1;        cc += 1;
1499        break;        break;
1500    
1501        CASE_ITERATOR_TYPE_LOCAL2B        CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
1502        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1503          {          {
1504          count = 2;          count = 2;
1505          srcw[0] = PRIV_DATA(cc);          srcw[0] = PRIVATE_DATA(cc);
1506          srcw[1] = srcw[0] + sizeof(sljit_w);          srcw[1] = srcw[0] + sizeof(sljit_w);
1507          }          }
1508        cc += 1 + IMM2_SIZE;        cc += 1 + IMM2_SIZE;
# Line 1513  while (status != end) Line 1516  while (status != end)
1516  #else  #else
1517        size = 1 + 32 / (int)sizeof(pcre_uchar);        size = 1 + 32 / (int)sizeof(pcre_uchar);
1518  #endif  #endif
1519        if (PRIV_DATA(cc))        if (PRIVATE_DATA(cc))
1520          switch(get_class_iterator_size(cc + size))          switch(get_class_iterator_size(cc + size))
1521            {            {
1522            case 1:            case 1:
1523            count = 1;            count = 1;
1524            srcw[0] = PRIV_DATA(cc);            srcw[0] = PRIVATE_DATA(cc);
1525            break;            break;
1526    
1527            case 2:            case 2:
1528            count = 2;            count = 2;
1529            srcw[0] = PRIV_DATA(cc);            srcw[0] = PRIVATE_DATA(cc);
1530            srcw[1] = srcw[0] + sizeof(sljit_w);            srcw[1] = srcw[0] + sizeof(sljit_w);
1531            break;            break;
1532    
# Line 1636  if (save) Line 1639  if (save)
1639  SLJIT_ASSERT(cc == ccend && stackptr == stacktop && (save || (tmp1empty && tmp2empty)));  SLJIT_ASSERT(cc == ccend && stackptr == stacktop && (save || (tmp1empty && tmp2empty)));
1640  }  }
1641    
1642  #undef CASE_ITERATOR_LOCAL1  #undef CASE_ITERATOR_PRIVATE_DATA_1
1643  #undef CASE_ITERATOR_LOCAL2A  #undef CASE_ITERATOR_PRIVATE_DATA_2A
1644  #undef CASE_ITERATOR_LOCAL2B  #undef CASE_ITERATOR_PRIVATE_DATA_2B
1645  #undef CASE_ITERATOR_TYPE_LOCAL1  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_1
1646  #undef CASE_ITERATOR_TYPE_LOCAL2A  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
1647  #undef CASE_ITERATOR_TYPE_LOCAL2B  #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
1648    
1649  static SLJIT_INLINE BOOL ispowerof2(unsigned int value)  static SLJIT_INLINE BOOL ispowerof2(unsigned int value)
1650  {  {
# Line 4940  static pcre_uchar *compile_assert_matchi Line 4943  static pcre_uchar *compile_assert_matchi
4943  {  {
4944  DEFINE_COMPILER;  DEFINE_COMPILER;
4945  int framesize;  int framesize;
4946  int localptr;  int private_data_ptr;
4947  backtrack_common altbacktrack;  backtrack_common altbacktrack;
4948  pcre_uchar *ccbegin;  pcre_uchar *ccbegin;
4949  pcre_uchar opcode;  pcre_uchar opcode;
# Line 4962  if (*cc == OP_BRAZERO || *cc == OP_BRAMI Line 4965  if (*cc == OP_BRAZERO || *cc == OP_BRAMI
4965    bra = *cc;    bra = *cc;
4966    cc++;    cc++;
4967    }    }
4968  localptr = PRIV_DATA(cc);  private_data_ptr = PRIVATE_DATA(cc);
4969  SLJIT_ASSERT(localptr != 0);  SLJIT_ASSERT(private_data_ptr != 0);
4970  framesize = get_framesize(common, cc, FALSE);  framesize = get_framesize(common, cc, FALSE);
4971  backtrack->framesize = framesize;  backtrack->framesize = framesize;
4972  backtrack->localptr = localptr;  backtrack->private_data_ptr = private_data_ptr;
4973  opcode = *cc;  opcode = *cc;
4974  SLJIT_ASSERT(opcode >= OP_ASSERT && opcode <= OP_ASSERTBACK_NOT);  SLJIT_ASSERT(opcode >= OP_ASSERT && opcode <= OP_ASSERTBACK_NOT);
4975  found = (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) ? &tmp : target;  found = (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) ? &tmp : target;
# Line 4983  if (bra == OP_BRAMINZERO) Line 4986  if (bra == OP_BRAMINZERO)
4986    
4987  if (framesize < 0)  if (framesize < 0)
4988    {    {
4989    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);
4990    allocate_stack(common, 1);    allocate_stack(common, 1);
4991    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
4992    }    }
4993  else  else
4994    {    {
4995    allocate_stack(common, framesize + 2);    allocate_stack(common, framesize + 2);
4996    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
4997    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(framesize + 1));    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(framesize + 1));
4998    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP2, 0);
4999    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5000    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
5001    init_frame(common, ccbegin, framesize + 1, 2, FALSE);    init_frame(common, ccbegin, framesize + 1, 2, FALSE);
# Line 5027  while (1) Line 5030  while (1)
5030    
5031    /* Reset stack. */    /* Reset stack. */
5032    if (framesize < 0)    if (framesize < 0)
5033      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5034    else {    else {
5035      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)      if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)
5036        {        {
5037        /* We don't need to keep the STR_PTR, only the previous localptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5038        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5039        }        }
5040      else      else
5041        {        {
5042        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5043        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5044        }        }
5045    }    }
# Line 5054  while (1) Line 5057  while (1)
5057          {          {
5058          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_w));
5059          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_w));
5060          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP1, 0);          OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
5061          }          }
5062        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_w));
5063        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
# Line 5062  while (1) Line 5065  while (1)
5065      else if (framesize >= 0)      else if (framesize >= 0)
5066        {        {
5067        /* For OP_BRA and OP_BRAMINZERO. */        /* For OP_BRA and OP_BRAMINZERO. */
5068        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5069        }        }
5070      }      }
5071    add_jump(compiler, found, JUMP(SLJIT_JUMP));    add_jump(compiler, found, JUMP(SLJIT_JUMP));
# Line 5113  if (opcode == OP_ASSERT || opcode == OP_ Line 5116  if (opcode == OP_ASSERT || opcode == OP_
5116        }        }
5117      else      else
5118        free_stack(common, framesize + 2);        free_stack(common, framesize + 2);
5119      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
5120      }      }
5121    jump = JUMP(SLJIT_JUMP);    jump = JUMP(SLJIT_JUMP);
5122    if (bra != OP_BRAZERO)    if (bra != OP_BRAZERO)
# Line 5138  if (opcode == OP_ASSERT || opcode == OP_ Line 5141  if (opcode == OP_ASSERT || opcode == OP_
5141      {      {
5142      if (bra == OP_BRA)      if (bra == OP_BRA)
5143        {        {
5144        /* We don't need to keep the STR_PTR, only the previous localptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5145        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5146        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
5147        }        }
5148      else      else
5149        {        {
5150        /* We don't need to keep the STR_PTR, only the previous localptr. */        /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
5151        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5152        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
5153        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);
5154        }        }
# Line 5162  if (opcode == OP_ASSERT || opcode == OP_ Line 5165  if (opcode == OP_ASSERT || opcode == OP_
5165      JUMPHERE(brajump);      JUMPHERE(brajump);
5166      if (framesize >= 0)      if (framesize >= 0)
5167        {        {
5168        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5169        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5170        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5171        }        }
5172      set_jumps(backtrack->common.topbacktracks, LABEL());      set_jumps(backtrack->common.topbacktracks, LABEL());
5173      }      }
# Line 5192  else Line 5195  else
5195        }        }
5196      else      else
5197        free_stack(common, framesize + 2);        free_stack(common, framesize + 2);
5198      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
5199      }      }
5200    
5201    if (bra == OP_BRAZERO)    if (bra == OP_BRAZERO)
# Line 5387  static pcre_uchar *compile_bracket_match Line 5390  static pcre_uchar *compile_bracket_match
5390  DEFINE_COMPILER;  DEFINE_COMPILER;
5391  backtrack_common *backtrack;  backtrack_common *backtrack;
5392  pcre_uchar opcode;  pcre_uchar opcode;
5393  int localptr = 0;  int private_data_ptr = 0;
5394  int offset = 0;  int offset = 0;
5395  int stacksize;  int stacksize;
5396  pcre_uchar *ccbegin;  pcre_uchar *ccbegin;
# Line 5451  if (opcode == OP_CBRA || opcode == OP_SC Line 5454  if (opcode == OP_CBRA || opcode == OP_SC
5454    {    {
5455    /* Capturing brackets has a pre-allocated space. */    /* Capturing brackets has a pre-allocated space. */
5456    offset = GET2(ccbegin, 1 + LINK_SIZE);    offset = GET2(ccbegin, 1 + LINK_SIZE);
5457    localptr = OVECTOR_PRIV(offset);    private_data_ptr = OVECTOR_PRIV(offset);
5458    offset <<= 1;    offset <<= 1;
5459    BACKTRACK_AS(bracket_backtrack)->localptr = localptr;    BACKTRACK_AS(bracket_backtrack)->private_data_ptr = private_data_ptr;
5460    matchingpath += IMM2_SIZE;    matchingpath += IMM2_SIZE;
5461    }    }
5462  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)
5463    {    {
5464    /* Other brackets simply allocate the next entry. */    /* Other brackets simply allocate the next entry. */
5465    localptr = PRIV_DATA(ccbegin);    private_data_ptr = PRIVATE_DATA(ccbegin);
5466    SLJIT_ASSERT(localptr != 0);    SLJIT_ASSERT(private_data_ptr != 0);
5467    BACKTRACK_AS(bracket_backtrack)->localptr = localptr;    BACKTRACK_AS(bracket_backtrack)->private_data_ptr = private_data_ptr;
5468    if (opcode == OP_ONCE)    if (opcode == OP_ONCE)
5469      BACKTRACK_AS(bracket_backtrack)->u.framesize = get_framesize(common, ccbegin, FALSE);      BACKTRACK_AS(bracket_backtrack)->u.framesize = get_framesize(common, ccbegin, FALSE);
5470    }    }
# Line 5507  if (bra == OP_BRAMINZERO) Line 5510  if (bra == OP_BRAMINZERO)
5510        /* Checking zero-length iteration. */        /* Checking zero-length iteration. */
5511        if (opcode != OP_ONCE || BACKTRACK_AS(bracket_backtrack)->u.framesize < 0)        if (opcode != OP_ONCE || BACKTRACK_AS(bracket_backtrack)->u.framesize < 0)
5512          {          {
5513          /* When we come from outside, localptr contains the previous STR_PTR. */          /* When we come from outside, private_data_ptr contains the previous STR_PTR. */
5514          braminzerojump = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);          braminzerojump = CMP(SLJIT_C_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5515          }          }
5516        else        else
5517          {          {
5518          /* Except when the whole stack frame must be saved. */          /* Except when the whole stack frame must be saved. */
5519          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5520          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_w));
5521          }          }
5522        JUMPHERE(skip);        JUMPHERE(skip);
# Line 5545  if (opcode == OP_ONCE) Line 5548  if (opcode == OP_ONCE)
5548      /* Neither capturing brackets nor recursions are not found in the block. */      /* Neither capturing brackets nor recursions are not found in the block. */
5549      if (ket == OP_KETRMIN)      if (ket == OP_KETRMIN)
5550        {        {
5551        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5552        allocate_stack(common, 2);        allocate_stack(common, 2);
5553        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5554        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
5555        OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5556        }        }
5557      else if (ket == OP_KETRMAX || has_alternatives)      else if (ket == OP_KETRMAX || has_alternatives)
5558        {        {
5559        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STACK_TOP, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);
5560        allocate_stack(common, 1);        allocate_stack(common, 1);
5561        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5562        }        }
5563      else      else
5564        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STACK_TOP, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);
5565      }      }
5566    else    else
5567      {      {
5568      if (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives)      if (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives)
5569        {        {
5570        allocate_stack(common, BACKTRACK_AS(bracket_backtrack)->u.framesize + 2);        allocate_stack(common, BACKTRACK_AS(bracket_backtrack)->u.framesize + 2);
5571        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5572        OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(BACKTRACK_AS(bracket_backtrack)->u.framesize + 1));        OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(BACKTRACK_AS(bracket_backtrack)->u.framesize + 1));
5573        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
5574        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP2, 0);
5575        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
5576        init_frame(common, ccbegin, BACKTRACK_AS(bracket_backtrack)->u.framesize + 1, 2, FALSE);        init_frame(common, ccbegin, BACKTRACK_AS(bracket_backtrack)->u.framesize + 1, 2, FALSE);
5577        }        }
5578      else      else
5579        {        {
5580        allocate_stack(common, BACKTRACK_AS(bracket_backtrack)->u.framesize + 1);        allocate_stack(common, BACKTRACK_AS(bracket_backtrack)->u.framesize + 1);
5581        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5582        OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(BACKTRACK_AS(bracket_backtrack)->u.framesize));        OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(BACKTRACK_AS(bracket_backtrack)->u.framesize));
5583        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP2, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP2, 0);
5584        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
5585        init_frame(common, ccbegin, BACKTRACK_AS(bracket_backtrack)->u.framesize, 1, FALSE);        init_frame(common, ccbegin, BACKTRACK_AS(bracket_backtrack)->u.framesize, 1, FALSE);
5586        }        }
# Line 5591  else if (opcode == OP_CBRA || opcode == Line 5594  else if (opcode == OP_CBRA || opcode ==
5594    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));
5595    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
5596    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
5597    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5598    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);
5599    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);
5600    }    }
5601  else if (opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_SBRA || opcode == OP_SCOND)
5602    {    {
5603    /* Saving the previous value. */    /* Saving the previous value. */
5604    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5605    allocate_stack(common, 1);    allocate_stack(common, 1);
5606    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STR_PTR, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0);
5607    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
5608    }    }
5609  else if (has_alternatives)  else if (has_alternatives)
# Line 5710  if (opcode == OP_ONCE) Line 5713  if (opcode == OP_ONCE)
5713    {    {
5714    if (BACKTRACK_AS(bracket_backtrack)->u.framesize < 0)    if (BACKTRACK_AS(bracket_backtrack)->u.framesize < 0)
5715      {      {
5716      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5717      /* TMP2 which is set here used by OP_KETRMAX below. */      /* TMP2 which is set here used by OP_KETRMAX below. */
5718      if (ket == OP_KETRMAX)      if (ket == OP_KETRMAX)
5719        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), 0);
5720      else if (ket == OP_KETRMIN)      else if (ket == OP_KETRMIN)
5721        {        {
5722        /* Move the STR_PTR to the localptr. */        /* Move the STR_PTR to the private_data_ptr. */
5723        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, SLJIT_MEM1(STACK_TOP), 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), 0);
5724        }        }
5725      }      }
5726    else    else
5727      {      {
5728      stacksize = (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives) ? 2 : 1;      stacksize = (ket == OP_KETRMIN || ket == OP_KETRMAX || has_alternatives) ? 2 : 1;
5729      OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5730      if (ket == OP_KETRMAX)      if (ket == OP_KETRMAX)
5731        {        {
5732        /* TMP2 which is set here used by OP_KETRMAX below. */        /* TMP2 which is set here used by OP_KETRMAX below. */
# Line 5764  if (has_alternatives) Line 5767  if (has_alternatives)
5767  /* Must be after the matchingpath label. */  /* Must be after the matchingpath label. */
5768  if (offset != 0)  if (offset != 0)
5769    {    {
5770    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5771    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);
5772    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 0), TMP1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 0), TMP1, 0);
5773    }    }
# Line 5778  if (ket == OP_KETRMAX) Line 5781  if (ket == OP_KETRMAX)
5781      /* Checking zero-length iteration. */      /* Checking zero-length iteration. */
5782      if (opcode != OP_ONCE)      if (opcode != OP_ONCE)
5783        {        {
5784        CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STR_PTR, 0, rmaxlabel);        CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STR_PTR, 0, rmaxlabel);
5785        /* Drop STR_PTR for greedy plus quantifier. */        /* Drop STR_PTR for greedy plus quantifier. */
5786        if (bra != OP_BRAZERO)        if (bra != OP_BRAZERO)
5787          free_stack(common, 1);          free_stack(common, 1);
# Line 5807  if (bra == OP_BRAMINZERO) Line 5810  if (bra == OP_BRAMINZERO)
5810      framesize is < 0, OP_ONCE will do the release itself. */      framesize is < 0, OP_ONCE will do the release itself. */
5811      if (opcode == OP_ONCE && BACKTRACK_AS(bracket_backtrack)->u.framesize >= 0)      if (opcode == OP_ONCE && BACKTRACK_AS(bracket_backtrack)->u.framesize >= 0)
5812        {        {
5813        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5814        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
5815        }        }
5816      else if (ket == OP_KETRMIN && opcode != OP_ONCE)      else if (ket == OP_KETRMIN && opcode != OP_ONCE)
# Line 5831  static pcre_uchar *compile_bracketpos_ma Line 5834  static pcre_uchar *compile_bracketpos_ma
5834  DEFINE_COMPILER;  DEFINE_COMPILER;
5835  backtrack_common *backtrack;  backtrack_common *backtrack;
5836  pcre_uchar opcode;  pcre_uchar opcode;
5837  int localptr;  int private_data_ptr;
5838  int cbraprivptr = 0;  int cbraprivptr = 0;
5839  int framesize;  int framesize;
5840  int stacksize;  int stacksize;
# Line 5850  if (*cc == OP_BRAPOSZERO) Line 5853  if (*cc == OP_BRAPOSZERO)
5853    }    }
5854    
5855  opcode = *cc;  opcode = *cc;
5856  localptr = PRIV_DATA(cc);  private_data_ptr = PRIVATE_DATA(cc);
5857  SLJIT_ASSERT(localptr != 0);  SLJIT_ASSERT(private_data_ptr != 0);
5858  BACKTRACK_AS(bracketpos_backtrack)->localptr = localptr;  BACKTRACK_AS(bracketpos_backtrack)->private_data_ptr = private_data_ptr;
5859  switch(opcode)  switch(opcode)
5860    {    {
5861    case OP_BRAPOS:    case OP_BRAPOS:
# Line 5882  if (framesize < 0) Line 5885  if (framesize < 0)
5885      stacksize++;      stacksize++;
5886    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
5887    allocate_stack(common, stacksize);    allocate_stack(common, stacksize);
5888    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, STACK_TOP, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, STACK_TOP, 0);
5889    
5890    if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)    if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)
5891      {      {
# Line 5907  else Line 5910  else
5910    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;    BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
5911    allocate_stack(common, stacksize);    allocate_stack(common, stacksize);
5912    
5913    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);    OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5914    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(stacksize - 1));    OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, -STACK(stacksize - 1));
5915    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP2, 0);
5916    stack = 0;    stack = 0;
5917    if (!zero)    if (!zero)
5918      {      {
# Line 5941  while (*cc != OP_KETRPOS) Line 5944  while (*cc != OP_KETRPOS)
5944    
5945    if (framesize < 0)    if (framesize < 0)
5946      {      {
5947      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5948    
5949      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)
5950        {        {
# Line 5967  while (*cc != OP_KETRPOS) Line 5970  while (*cc != OP_KETRPOS)
5970      {      {
5971      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)      if (opcode == OP_CBRAPOS || opcode == OP_SCBRAPOS)
5972        {        {
5973        OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
5974        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);
5975        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);
5976        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 5975  while (*cc != OP_KETRPOS) Line 5978  while (*cc != OP_KETRPOS)
5978        }        }
5979      else      else
5980        {        {
5981        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
5982        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_w));
5983        if (opcode == OP_SBRAPOS)        if (opcode == OP_SBRAPOS)
5984          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_w));
# Line 6014  while (*cc != OP_KETRPOS) Line 6017  while (*cc != OP_KETRPOS)
6017        {        {
6018        /* Last alternative. */        /* Last alternative. */
6019        if (*cc == OP_KETRPOS)        if (*cc == OP_KETRPOS)
6020          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);          OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6021        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);        OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), cbraprivptr);
6022        }        }
6023      else      else
6024        {        {
6025        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
6026        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_w));
6027        }        }
6028      }      }
# Line 6034  if (!zero) Line 6037  if (!zero)
6037    {    {
6038    if (framesize < 0)    if (framesize < 0)
6039      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));
6040    else /* TMP2 is set to [localptr] above. */    else /* TMP2 is set to [private_data_ptr] above. */
6041      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_w), SLJIT_IMM, 0));
6042    }    }
6043    
# Line 6147  pcre_uchar* end; Line 6150  pcre_uchar* end;
6150  jump_list *nomatch = NULL;  jump_list *nomatch = NULL;
6151  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
6152  struct sljit_label *label;  struct sljit_label *label;
6153  int localptr = PRIV_DATA(cc);  int private_data_ptr = PRIVATE_DATA(cc);
6154  int base = (localptr == 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);
6155  int offset0 = (localptr == 0) ? STACK(0) : localptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
6156  int offset1 = (localptr == 0) ? STACK(1) : localptr + (int)sizeof(sljit_w);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_w);
6157  int tmp_base, tmp_offset;  int tmp_base, tmp_offset;
6158    
6159  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);  PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
# Line 6204  switch(opcode) Line 6207  switch(opcode)
6207    case OP_CRRANGE:    case OP_CRRANGE:
6208    if (type == OP_ANYNL || type == OP_EXTUNI)    if (type == OP_ANYNL || type == OP_EXTUNI)
6209      {      {
6210      SLJIT_ASSERT(localptr == 0);      SLJIT_ASSERT(private_data_ptr == 0);
6211      if (opcode == OP_STAR || opcode == OP_UPTO)      if (opcode == OP_STAR || opcode == OP_UPTO)
6212        {        {
6213        allocate_stack(common, 2);        allocate_stack(common, 2);
# Line 6244  switch(opcode) Line 6247  switch(opcode)
6247      {      {
6248      if (opcode == OP_PLUS)      if (opcode == OP_PLUS)
6249        compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);        compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
6250      if (localptr == 0)      if (private_data_ptr == 0)
6251        allocate_stack(common, 2);        allocate_stack(common, 2);
6252      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);      OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6253      if (opcode <= OP_PLUS)      if (opcode <= OP_PLUS)
# Line 6280  switch(opcode) Line 6283  switch(opcode)
6283    case OP_MINPLUS:    case OP_MINPLUS:
6284    if (opcode == OP_MINPLUS)    if (opcode == OP_MINPLUS)
6285      compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);      compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
6286    if (localptr == 0)    if (private_data_ptr == 0)
6287      allocate_stack(common, 1);      allocate_stack(common, 1);
6288    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6289    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();    BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
# Line 6288  switch(opcode) Line 6291  switch(opcode)
6291    
6292    case OP_MINUPTO:    case OP_MINUPTO:
6293    case OP_CRMINRANGE:    case OP_CRMINRANGE:
6294    if (localptr == 0)    if (private_data_ptr == 0)
6295      allocate_stack(common, 2);      allocate_stack(common, 2);
6296    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6297    OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1);    OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1);
# Line 6299  switch(opcode) Line 6302  switch(opcode)
6302    
6303    case OP_QUERY:    case OP_QUERY:
6304    case OP_MINQUERY:    case OP_MINQUERY:
6305    if (localptr == 0)    if (private_data_ptr == 0)
6306      allocate_stack(common, 1);      allocate_stack(common, 1);
6307    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6308    if (opcode == OP_QUERY)    if (opcode == OP_QUERY)
# Line 6693  int arg1 = -1, arg2 = -1; Line 6696  int arg1 = -1, arg2 = -1;
6696  struct sljit_label *label = NULL;  struct sljit_label *label = NULL;
6697  struct sljit_jump *jump = NULL;  struct sljit_jump *jump = NULL;
6698  jump_list *jumplist = NULL;  jump_list *jumplist = NULL;
6699  int localptr = PRIV_DATA(cc);  int private_data_ptr = PRIVATE_DATA(cc);
6700  int base = (localptr == 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);
6701  int offset0 = (localptr == 0) ? STACK(0) : localptr;  int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
6702  int offset1 = (localptr == 0) ? STACK(1) : localptr + (int)sizeof(sljit_w);  int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_w);
6703    
6704  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);  cc = get_iterator_parameters(common, cc, &opcode, &type, &arg1, &arg2, NULL);
6705    
# Line 6708  switch(opcode) Line 6711  switch(opcode)
6711    case OP_CRRANGE:    case OP_CRRANGE:
6712    if (type == OP_ANYNL || type == OP_EXTUNI)    if (type == OP_ANYNL || type == OP_EXTUNI)
6713      {      {
6714      SLJIT_ASSERT(localptr == 0);      SLJIT_ASSERT(private_data_ptr == 0);
6715      set_jumps(current->topbacktracks, LABEL());      set_jumps(current->topbacktracks, LABEL());
6716      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));      OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
6717      free_stack(common, 1);      free_stack(common, 1);
# Line 6736  switch(opcode) Line 6739  switch(opcode)
6739      if (opcode == OP_CRRANGE)      if (opcode == OP_CRRANGE)
6740        set_jumps(current->topbacktracks, LABEL());        set_jumps(current->topbacktracks, LABEL());
6741      JUMPHERE(jump);      JUMPHERE(jump);
6742      if (localptr == 0)      if (private_data_ptr == 0)
6743        free_stack(common, 2);        free_stack(common, 2);
6744      if (opcode == OP_PLUS)      if (opcode == OP_PLUS)
6745        set_jumps(current->topbacktracks, LABEL());        set_jumps(current->topbacktracks, LABEL());
# Line 6750  switch(opcode) Line 6753  switch(opcode)
6753    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);    OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
6754    JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);    JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
6755    set_jumps(jumplist, LABEL());    set_jumps(jumplist, LABEL());
6756    if (localptr == 0)    if (private_data_ptr == 0)
6757      free_stack(common, 1);      free_stack(common, 1);
6758    if (opcode == OP_MINPLUS)    if (opcode == OP_MINPLUS)
6759      set_jumps(current->topbacktracks, LABEL());      set_jumps(current->topbacktracks, LABEL());
# Line 6780  switch(opcode) Line 6783  switch(opcode)
6783      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg1 + 2, CURRENT_AS(iterator_backtrack)->matchingpath);      CMPTO(SLJIT_C_LESS, TMP1, 0, SLJIT_IMM, arg1 + 2, CURRENT_AS(iterator_backtrack)->matchingpath);
6784    
6785    set_jumps(jumplist, LABEL());    set_jumps(jumplist, LABEL());
6786    if (localptr == 0)    if (private_data_ptr == 0)
6787      free_stack(common, 2);      free_stack(common, 2);
6788    break;    break;
6789    
# Line 6794  switch(opcode) Line 6797  switch(opcode)
6797    OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0);    OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0);
6798    JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);    JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
6799    JUMPHERE(jump);    JUMPHERE(jump);
6800    if (localptr == 0)    if (private_data_ptr == 0)
6801      free_stack(common, 1);      free_stack(common, 1);
6802    break;    break;
6803    
# Line 6806  switch(opcode) Line 6809  switch(opcode)
6809    JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);    JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
6810    set_jumps(jumplist, LABEL());    set_jumps(jumplist, LABEL());
6811    JUMPHERE(jump);    JUMPHERE(jump);
6812    if (localptr == 0)    if (private_data_ptr == 0)
6813      free_stack(common, 1);      free_stack(common, 1);
6814    break;    break;
6815    
# Line 6918  if (bra == OP_BRAZERO) Line 6921  if (bra == OP_BRAZERO)
6921    
6922  if (*cc == OP_ASSERT || *cc == OP_ASSERTBACK)  if (*cc == OP_ASSERT || *cc == OP_ASSERTBACK)
6923    {    {
6924    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->localptr);    OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->private_data_ptr);
6925    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));    add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
6926    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(assert_backtrack)->localptr, 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_w));
6927    
6928    set_jumps(current->topbacktracks, LABEL());    set_jumps(current->topbacktracks, LABEL());
6929    }    }
# Line 6942  static void compile_bracket_backtracking Line 6945  static void compile_bracket_backtracking
6945  DEFINE_COMPILER;  DEFINE_COMPILER;
6946  int opcode;  int opcode;
6947  int offset = 0;  int offset = 0;
6948  int localptr = CURRENT_AS(bracket_backtrack)->localptr;  int private_data_ptr = CURRENT_AS(bracket_backtrack)->private_data_ptr;
6949  int stacksize;  int stacksize;
6950  int count;  int count;
6951  pcre_uchar *cc = current->cc;  pcre_uchar *cc = current->cc;
# Line 6997  else if (ket == OP_KETRMIN) Line 7000  else if (ket == OP_KETRMIN)
7000        {        {
7001        /* Checking zero-length iteration. */        /* Checking zero-length iteration. */
7002        if (opcode != OP_ONCE || CURRENT_AS(bracket_backtrack)->u.framesize < 0)        if (opcode != OP_ONCE || CURRENT_AS(bracket_backtrack)->u.framesize < 0)
7003          CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);          CMPTO(SLJIT_C_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
7004        else        else
7005          {          {
7006          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);          OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7007          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_w), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
7008          }          }
7009        if (opcode != OP_ONCE)        if (opcode != OP_ONCE)
# Line 7022  if (SLJIT_UNLIKELY(opcode == OP_ONCE)) Line 7025  if (SLJIT_UNLIKELY(opcode == OP_ONCE))
7025    {    {
7026    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
7027      {      {
7028      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);      OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7029      add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));      add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7030      }      }
7031    once = JUMP(SLJIT_JUMP);    once = JUMP(SLJIT_JUMP);
# Line 7088  if (SLJIT_UNLIKELY(opcode == OP_COND) || Line 7091  if (SLJIT_UNLIKELY(opcode == OP_COND) ||
7091      assert = CURRENT_AS(bracket_backtrack)->u.assert;      assert = CURRENT_AS(bracket_backtrack)->u.assert;
7092      if (assert->framesize >= 0 && (ccbegin[1 + LINK_SIZE] == OP_ASSERT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK))      if (assert->framesize >= 0 && (ccbegin[1 + LINK_SIZE] == OP_ASSERT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK))
7093        {        {
7094        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->localptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);
7095        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7096        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->localptr, 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_w));
7097        }        }
7098      cond = JUMP(SLJIT_JUMP);      cond = JUMP(SLJIT_JUMP);
7099      set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());      set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());
# Line 7119  if (has_alternatives) Line 7122  if (has_alternatives)
7122        cc += GET(cc, 1);        cc += GET(cc, 1);
7123        if (opcode != OP_COND && opcode != OP_SCOND)        if (opcode != OP_COND && opcode != OP_SCOND)
7124          {          {
7125          if (localptr != 0 && opcode != OP_ONCE)          if (private_data_ptr != 0 && opcode != OP_ONCE)
7126            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7127          else          else
7128            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));            OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
7129          }          }
# Line 7135  if (has_alternatives) Line 7138  if (has_alternatives)
7138        {        {
7139        if (CURRENT_AS(bracket_backtrack)->u.framesize < 0)        if (CURRENT_AS(bracket_backtrack)->u.framesize < 0)
7140          {          {
7141          OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);          OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7142          /* TMP2 which is set here used by OP_KETRMAX below. */          /* TMP2 which is set here used by OP_KETRMAX below. */
7143          if (ket == OP_KETRMAX)          if (ket == OP_KETRMAX)
7144            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), 0);            OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), 0);
7145          else if (ket == OP_KETRMIN)          else if (ket == OP_KETRMIN)
7146            {            {
7147            /* Move the STR_PTR to the localptr. */            /* Move the STR_PTR to the private_data_ptr. */
7148            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, SLJIT_MEM1(STACK_TOP), 0);            OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), 0);
7149            }            }
7150          }          }
7151        else        else
7152          {          {
7153          OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
7154          if (ket == OP_KETRMAX)          if (ket == OP_KETRMAX)
7155            {            {
7156            /* TMP2 which is set here used by OP_KETRMAX below. */            /* TMP2 which is set here used by OP_KETRMAX below. */
# Line 7188  if (has_alternatives) Line 7191  if (has_alternatives)
7191    
7192      if (offset != 0)      if (offset != 0)
7193        {        {
7194        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr);        OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr);
7195        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);
7196        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 0), TMP1, 0);        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 0), TMP1, 0);
7197        }        }
# Line 7217  if (has_alternatives) Line 7220  if (has_alternatives)
7220      if ((ccbegin[1 + LINK_SIZE] == OP_ASSERT_NOT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK_NOT) && assert->framesize >= 0)      if ((ccbegin[1 + LINK_SIZE] == OP_ASSERT_NOT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK_NOT) && assert->framesize >= 0)
7221    
7222        {        {
7223        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->localptr);        OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->private_data_ptr);
7224        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));        add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7225        OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), assert->localptr, 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_w));
7226        }        }
7227      JUMPHERE(cond);      JUMPHERE(cond);
7228      }      }
7229    
7230    /* Free the STR_PTR. */    /* Free the STR_PTR. */
7231    if (localptr == 0)    if (private_data_ptr == 0)
7232      free_stack(common, 1);      free_stack(common, 1);
7233    }    }
7234    
# Line 7236  if (offset != 0) Line 7239  if (offset != 0)
7239    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));    OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
7240    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset), TMP1, 0);
7241    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), OVECTOR(offset + 1), TMP2, 0);
7242    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, SLJIT_MEM1(STACK_TOP), STACK(2));    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), STACK(2));
7243    free_stack(common, 3);    free_stack(common, 3);
7244    }    }
7245  else if (opcode == OP_SBRA || opcode == OP_SCOND)  else if (opcode == OP_SBRA || opcode == OP_SCOND)
7246    {    {
7247    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, SLJIT_MEM1(STACK_TOP), STACK(0));    OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, SLJIT_MEM1(STACK_TOP), STACK(0));
7248    free_stack(common, 1);    free_stack(common, 1);
7249    }    }
7250  else if (opcode == OP_ONCE)  else if (opcode == OP_ONCE)
# Line 7260  else if (opcode == OP_ONCE) Line 7263  else if (opcode == OP_ONCE)
7263      }      }
7264    
7265    JUMPHERE(once);    JUMPHERE(once);
7266    /* Restore previous localptr */    /* Restore previous private_data_ptr */
7267    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)    if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
7268      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, 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_w));
7269    else if (ket == OP_KETRMIN)    else if (ket == OP_KETRMIN)
7270      {      {
7271      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));      OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
7272      /* See the comment below. */      /* See the comment below. */
7273      free_stack(common, 2);      free_stack(common, 2);
7274      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), localptr, TMP1, 0);      OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), private_data_ptr, TMP1, 0);
7275      }      }
7276    }    }
7277    
# Line 7330  if (CURRENT_AS(bracketpos_backtrack)->fr Line 7333  if (CURRENT_AS(bracketpos_backtrack)->fr
7333    return;    return;
7334    }    }
7335    
7336  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->localptr);  OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->private_data_ptr);
7337  add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));  add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
7338    
7339  if (current->topbacktracks)  if (current->topbacktracks)
# Line 7341  if (current->topbacktracks) Line 7344  if (current->topbacktracks)
7344    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);    free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
7345    JUMPHERE(jump);    JUMPHERE(jump);
7346    }    }
7347  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), CURRENT_AS(bracketpos_backtrack)->localptr, 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_w));
7348  }  }
7349    
7350  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 7537  DEFINE_COMPILER; Line 7540  DEFINE_COMPILER;
7540  pcre_uchar *cc = common->start + common->currententry->start;  pcre_uchar *cc = common->start + common->currententry->start;
7541  pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);  pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
7542  pcre_uchar *ccend = bracketend(cc);  pcre_uchar *ccend = bracketend(cc);
7543  int localsize = get_localsize(common, ccbegin, ccend);  int private_data_size = get_private_data_length_for_copy(common, ccbegin, ccend);
7544  int framesize = get_framesize(common, cc, TRUE);  int framesize = get_framesize(common, cc, TRUE);
7545  int alternativesize;  int alternativesize;
7546  BOOL needsframe;  BOOL needsframe;
# Line 7557  common->currententry->entry = LABEL(); Line 7560  common->currententry->entry = LABEL();
7560  set_jumps(common->currententry->calls, common->currententry->entry);  set_jumps(common->currententry->calls, common->currententry->entry);
7561    
7562  sljit_emit_fast_enter(compiler, TMP2, 0);  sljit_emit_fast_enter(compiler, TMP2, 0);
7563  allocate_stack(common, localsize + framesize + alternativesize);  allocate_stack(common, private_data_size + framesize + alternativesize);
7564  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(localsize + framesize + alternativesize - 1), TMP2, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0);
7565  copy_locals(common, ccbegin, ccend, TRUE, localsize + framesize + alternativesize, framesize + alternativesize);  copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize);
7566  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head, STACK_TOP, 0);  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->recursive_head, STACK_TOP, 0);
7567  if (needsframe)  if (needsframe)
7568    init_frame(common, cc, framesize + alternativesize - 1, alternativesize, TRUE);    init_frame(common, cc, framesize + alternativesize - 1, alternativesize, TRUE);
# Line 7625  if (needsframe) Line 7628  if (needsframe)
7628  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);  OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);
7629    
7630  JUMPHERE(jump);  JUMPHERE(jump);
7631  copy_locals(common, ccbegin, ccend, FALSE, localsize + framesize + alternativesize, framesize + alternativesize);  copy_private_data(common, ccbegin, ccend, FALSE, private_data_size + framesize + alternativesize, framesize + alternativesize);
7632  free_stack(common, localsize + framesize + alternativesize);  free_stack(common, private_data_size + framesize + alternativesize);
7633  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_w));  OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_w));
7634  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);  OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
7635  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);
# Line 7648  compiler_common common_data; Line 7651  compiler_common common_data;
7651  compiler_common *common = &common_data;  compiler_common *common = &common_data;
7652  const pcre_uint8 *tables = re->tables;  const pcre_uint8 *tables = re->tables;
7653  pcre_study_data *study;  pcre_study_data *study;
7654  int localsize;  int private_data_size;
7655  pcre_uchar *ccend;  pcre_uchar *ccend;
7656  executable_functions *functions;  executable_functions *functions;
7657  void *executable_func;  void *executable_func;
# Line 7726  ccend = bracketend(rootbacktrack.cc); Line 7729  ccend = bracketend(rootbacktrack.cc);
7729  common->ovector_start = CALL_LIMIT + sizeof(sljit_w);  common->ovector_start = CALL_LIMIT + sizeof(sljit_w);
7730    
7731  SLJIT_ASSERT(*rootbacktrack.cc == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET);  SLJIT_ASSERT(*rootbacktrack.cc == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET);
7732  localsize = get_localspace(common, rootbacktrack.cc, ccend);  private_data_size = get_private_data_length(common, rootbacktrack.cc, ccend);
7733  if (localsize < 0)  if (private_data_size < 0)
7734    return;    return;
7735    
7736  /* Checking flags and updating ovector_start. */  /* Checking flags and updating ovector_start. */
# Line 7758  if ((common->ovector_start & sizeof(slji Line 7761  if ((common->ovector_start & sizeof(slji
7761    
7762  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));  SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
7763  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_w);  common->cbraptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_w);
7764  localsize += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w);  private_data_size += common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w);
7765  if (localsize > SLJIT_MAX_LOCAL_SIZE)  if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
7766    return;    return;
7767  common->localptrs = (int *)SLJIT_MALLOC((ccend - rootbacktrack.cc) * sizeof(int));  common->private_data_ptrs = (int *)SLJIT_MALLOC((ccend - rootbacktrack.cc) * sizeof(int));
7768  if (!common->localptrs)  if (!common->private_data_ptrs)
7769    return;    return;
7770  memset(common->localptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));  memset(common->private_data_ptrs, 0, (ccend - rootbacktrack.cc) * sizeof(int));
7771  set_localptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w), ccend);  set_private_data_ptrs(common, common->cbraptr + (re->top_bracket + 1) * sizeof(sljit_w), ccend);
7772    
7773  compiler = sljit_create_compiler();  compiler = sljit_create_compiler();
7774  if (!compiler)  if (!compiler)
7775    {    {
7776    SLJIT_FREE(common->localptrs);    SLJIT_FREE(common->private_data_ptrs);
7777    return;    return;
7778    }    }
7779  common->compiler = compiler;  common->compiler = compiler;
7780    
7781  /* Main pcre_jit_exec entry. */  /* Main pcre_jit_exec entry. */
7782  sljit_emit_enter(compiler, 1, 5, 5, localsize);  sljit_emit_enter(compiler, 1, 5, 5, private_data_size);
7783    
7784  /* Register init. */  /* Register init. */
7785  reset_ovector(common, (re->top_bracket + 1) * 2);  reset_ovector(common, (re->top_bracket + 1) * 2);
# Line 7836  compile_matchingpath(common, rootbacktra Line 7839  compile_matchingpath(common, rootbacktra
7839  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
7840    {    {
7841    sljit_free_compiler(compiler);    sljit_free_compiler(compiler);
7842    SLJIT_FREE(common->localptrs);    SLJIT_FREE(common->private_data_ptrs);
7843    return;    return;
7844    }    }
7845    
# Line 7866  compile_backtrackingpath(common, rootbac Line 7869  compile_backtrackingpath(common, rootbac
7869  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))  if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
7870    {    {
7871    sljit_free_compiler(compiler);    sljit_free_compiler(compiler);
7872    SLJIT_FREE(common->localptrs);    SLJIT_FREE(common->private_data_ptrs);
7873    return;    return;
7874    }    }
7875    
# Line 7944  while (common->currententry != NULL) Line 7947  while (common->currententry != NULL)
7947    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))    if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
7948      {      {
7949      sljit_free_compiler(compiler);      sljit_free_compiler(compiler);
7950      SLJIT_FREE(common->localptrs);      SLJIT_FREE(common->private_data_ptrs);
7951      return;      return;
7952      }      }
7953    flush_stubs(common);    flush_stubs(common);
# Line 8039  if (common->getucd != NULL) Line 8042  if (common->getucd != NULL)
8042    }    }
8043  #endif  #endif
8044    
8045  SLJIT_FREE(common->localptrs);  SLJIT_FREE(common->private_data_ptrs);
8046  executable_func = sljit_generate_code(compiler);  executable_func = sljit_generate_code(compiler);
8047  executable_size = sljit_get_generated_code_size(compiler);  executable_size = sljit_get_generated_code_size(compiler);
8048  sljit_free_compiler(compiler);  sljit_free_compiler(compiler);
# Line 8083  union { Line 8086  union {
8086     void* executable_func;     void* executable_func;
8087     jit_function call_executable_func;     jit_function call_executable_func;
8088  } convert_executable_func;  } convert_executable_func;
8089  pcre_uint8 local_area[LOCAL_SPACE_SIZE];  pcre_uint8 local_space[MACHINE_STACK_SIZE];
8090  struct sljit_stack local_stack;  struct sljit_stack local_stack;
8091    
8092  local_stack.top = (sljit_w)&local_area;  local_stack.top = (sljit_w)&local_space;
8093  local_stack.base = local_stack.top;  local_stack.base = local_stack.top;
8094  local_stack.limit = local_stack.base + LOCAL_SPACE_SIZE;  local_stack.limit = local_stack.base + MACHINE_STACK_SIZE;
8095  local_stack.max_limit = local_stack.limit;  local_stack.max_limit = local_stack.limit;
8096  arguments->stack = &local_stack;  arguments->stack = &local_stack;
8097  convert_executable_func.executable_func = executable_func;  convert_executable_func.executable_func = executable_func;

Legend:
Removed from v.1001  
changed lines
  Added in v.1002

  ViewVC Help
Powered by ViewVC 1.1.5