summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>2013-03-17 05:27:48 +0000
committerzherczeg <zherczeg@2f5784b3-3f2a-0410-8824-cb99058d5e15>2013-03-17 05:27:48 +0000
commite0621f32a18551cdb02b3c4a6fb73cef5c2a2625 (patch)
treecbf8d880085ab1a0838e87f78b3f208ef67dafbd
parent2dff9fece42d022b3ee8ff22fde1144f9b80f74d (diff)
downloadpcre-e0621f32a18551cdb02b3c4a6fb73cef5c2a2625.tar.gz
Improve performance of then verb in JIT.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1291 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--pcre_jit_compile.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/pcre_jit_compile.c b/pcre_jit_compile.c
index a8dd1e9..8b69471 100644
--- a/pcre_jit_compile.c
+++ b/pcre_jit_compile.c
@@ -2118,30 +2118,6 @@ while (current != NULL)
return -1;
}
-static sljit_sw SLJIT_CALL do_search_then_trap(sljit_sw *current, sljit_sw start)
-{
-do
- {
- SLJIT_ASSERT(current != NULL);
- switch (current[-2])
- {
- case type_then_trap:
- if (current[-3] == start)
- return (sljit_sw)current;
- break;
-
- case type_mark:
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
- current = (sljit_sw*)current[-1];
- }
-while (TRUE);
-}
-
static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)
{
DEFINE_COMPILER;
@@ -8347,24 +8323,23 @@ static SLJIT_INLINE void compile_control_verb_backtrackingpath(compiler_common *
{
DEFINE_COMPILER;
pcre_uchar opcode = *current->cc;
+struct sljit_label *loop;
+struct sljit_jump *jump;
if ((opcode == OP_THEN || opcode == OP_THEN_ARG) && common->then_trap != NULL)
{
SLJIT_ASSERT(common->control_head_ptr != 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0, STACK_TOP, 0);
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, common->then_trap->start);
- sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_search_then_trap));
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), LOCALS0);
- OP1(SLJIT_MOV, TMP2, 0, TMP1, 0);
- OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
- if (common->quit_label == NULL)
- add_jump(compiler, &common->quit, CMP(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0));
- else
- CMPTO(SLJIT_C_EQUAL, TMP2, 0, SLJIT_IMM, 0, common->quit_label);
+ OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->control_head_ptr);
+ OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, type_then_trap);
+ OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, common->then_trap->start);
+ jump = JUMP(SLJIT_JUMP);
- OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);
+ loop = LABEL();
+ OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), -(int)sizeof(sljit_sw));
+ JUMPHERE(jump);
+ CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(2 * sizeof(sljit_sw)), TMP1, 0, loop);
+ CMPTO(SLJIT_C_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(3 * sizeof(sljit_sw)), TMP2, 0, loop);
add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));
return;
}