Revision: 1475
http://vcs.pcre.org/viewvc?view=rev&revision=1475
Author: zherczeg
Date: 2014-04-25 12:59:19 +0100 (Fri, 25 Apr 2014)
Log Message:
-----------
Fixed an issue with nested table jumps.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/pcre_jit_compile.c
code/trunk/testdata/testinput1
code/trunk/testdata/testoutput1
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2014-04-24 06:43:50 UTC (rev 1474)
+++ code/trunk/ChangeLog 2014-04-25 11:59:19 UTC (rev 1475)
@@ -20,7 +20,10 @@
backtracking, instead of returning with PCRE_ERROR_MATCHLIMIT. This
issue should be resolved now.
+5. Fixed an issue, which occures when nested alternatives are optimized
+ with table jumps.
+
Version 8.35 04-April-2014
--------------------------
Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c 2014-04-24 06:43:50 UTC (rev 1474)
+++ code/trunk/pcre_jit_compile.c 2014-04-25 11:59:19 UTC (rev 1475)
@@ -200,7 +200,7 @@
typedef struct label_addr_list {
struct sljit_label *label;
- sljit_uw *addr;
+ sljit_uw *update_addr;
struct label_addr_list *next;
} label_addr_list;
@@ -2070,7 +2070,7 @@
common->stubs = NULL;
}
-static void add_label_addr(compiler_common *common)
+static void add_label_addr(compiler_common *common, sljit_uw *update_addr)
{
DEFINE_COMPILER;
label_addr_list *label_addr;
@@ -2079,10 +2079,9 @@
if (label_addr == NULL)
return;
label_addr->label = LABEL();
-label_addr->addr = common->read_only_data_ptr;
+label_addr->update_addr = update_addr;
label_addr->next = common->label_addrs;
common->label_addrs = label_addr;
-common->read_only_data_ptr++;
}
static SLJIT_INLINE void count_match(compiler_common *common)
@@ -8813,6 +8812,7 @@
pcre_uchar bra = OP_BRA;
pcre_uchar ket;
assert_backtrack *assert;
+sljit_uw *next_update_addr;
BOOL has_alternatives;
BOOL needs_control_head = FALSE;
struct sljit_jump *brazero = NULL;
@@ -8982,8 +8982,10 @@
if (alt_max > 4)
{
/* Table jump if alt_max is greater than 4. */
- sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)common->read_only_data_ptr);
- add_label_addr(common);
+ next_update_addr = common->read_only_data_ptr;
+ common->read_only_data_ptr += alt_max;
+ sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)next_update_addr);
+ add_label_addr(common, next_update_addr++);
}
else
{
@@ -9115,7 +9117,7 @@
if (opcode != OP_ONCE)
{
if (alt_max > 4)
- add_label_addr(common);
+ add_label_addr(common, next_update_addr++);
else
{
if (alt_count != 2 * sizeof(sljit_uw))
@@ -10310,7 +10312,7 @@
label_addr = common->label_addrs;
while (label_addr != NULL)
{
- *label_addr->addr = sljit_get_label_addr(label_addr->label);
+ *label_addr->update_addr = sljit_get_label_addr(label_addr->label);
label_addr = label_addr->next;
}
sljit_free_compiler(compiler);
Modified: code/trunk/testdata/testinput1
===================================================================
--- code/trunk/testdata/testinput1 2014-04-24 06:43:50 UTC (rev 1474)
+++ code/trunk/testdata/testinput1 2014-04-25 11:59:19 UTC (rev 1475)
@@ -5666,4 +5666,7 @@
/(a\Kb)*/+
ababc
+/(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/
+ acb
+
/-- End of testinput1 --/
Modified: code/trunk/testdata/testoutput1
===================================================================
--- code/trunk/testdata/testoutput1 2014-04-24 06:43:50 UTC (rev 1474)
+++ code/trunk/testdata/testoutput1 2014-04-25 11:59:19 UTC (rev 1475)
@@ -9313,4 +9313,8 @@
0+ c
1: ab
+/(?:x|(?:(xx|yy)+|x|x|x|x|x)|a|a|a)bc/
+ acb
+No match
+
/-- End of testinput1 --/