Improve options passing.

This commit is contained in:
Zoltán Herczeg 2015-04-20 13:04:02 +00:00
parent 5b5cfed910
commit 53e25208d3
2 changed files with 28 additions and 43 deletions

View File

@ -183,10 +183,7 @@ typedef struct jit_arguments {
/* Everything else after. */ /* Everything else after. */
sljit_ui limit_match; sljit_ui limit_match;
uint32_t oveccount; uint32_t oveccount;
sljit_ub notbol; uint32_t options;
sljit_ub noteol;
sljit_ub notempty;
sljit_ub notempty_atstart;
} jit_arguments; } jit_arguments;
#define JIT_NUMBER_OF_COMPILE_MODES 3 #define JIT_NUMBER_OF_COMPILE_MODES 3
@ -1544,11 +1541,6 @@ while (cc < ccend)
switch(*cc) switch(*cc)
{ {
case OP_KET: case OP_KET:
if (PRIVATE_DATA(cc) != 0)
private_data_length++;
cc += 1 + LINK_SIZE;
break;
case OP_ASSERT: case OP_ASSERT:
case OP_ASSERT_NOT: case OP_ASSERT_NOT:
case OP_ASSERTBACK: case OP_ASSERTBACK:
@ -1559,6 +1551,7 @@ while (cc < ccend)
case OP_SBRA: case OP_SBRA:
case OP_SBRAPOS: case OP_SBRAPOS:
case OP_SCOND: case OP_SCOND:
if (PRIVATE_DATA(cc) != 0)
private_data_length++; private_data_length++;
cc += 1 + LINK_SIZE; cc += 1 + LINK_SIZE;
break; break;
@ -1718,14 +1711,6 @@ do
switch(*cc) switch(*cc)
{ {
case OP_KET: case OP_KET:
if (PRIVATE_DATA(cc) != 0)
{
count = 1;
srcw[0] = PRIVATE_DATA(cc);
}
cc += 1 + LINK_SIZE;
break;
case OP_ASSERT: case OP_ASSERT:
case OP_ASSERT_NOT: case OP_ASSERT_NOT:
case OP_ASSERTBACK: case OP_ASSERTBACK:
@ -1736,9 +1721,11 @@ do
case OP_SBRA: case OP_SBRA:
case OP_SBRAPOS: case OP_SBRAPOS:
case OP_SCOND: case OP_SCOND:
if (PRIVATE_DATA(cc) != 0)
{
count = 1; count = 1;
srcw[0] = PRIVATE_DATA(cc); srcw[0] = PRIVATE_DATA(cc);
SLJIT_ASSERT(srcw[0] != 0); }
cc += 1 + LINK_SIZE; cc += 1 + LINK_SIZE;
break; break;
@ -5518,16 +5505,16 @@ switch(type)
OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin));
add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0)); add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0));
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol)); OP2(SLJIT_IAND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL);
add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));
return cc; return cc;
case OP_CIRCM: case OP_CIRCM:
OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin)); OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin));
jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0); jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol)); OP2(SLJIT_IAND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTBOL);
add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));
jump[0] = JUMP(SLJIT_JUMP); jump[0] = JUMP(SLJIT_JUMP);
JUMPHERE(jump[1]); JUMPHERE(jump[1]);
@ -5552,8 +5539,8 @@ switch(type)
case OP_DOLL: case OP_DOLL:
OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol)); OP2(SLJIT_IAND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL);
add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));
if (!common->endonly) if (!common->endonly)
compile_char1_matchingpath(common, OP_EODN, cc, backtracks); compile_char1_matchingpath(common, OP_EODN, cc, backtracks);
@ -5567,8 +5554,8 @@ switch(type)
case OP_DOLLM: case OP_DOLLM:
jump[1] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0); jump[1] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol)); OP2(SLJIT_IAND | SLJIT_SET_E, SLJIT_UNUSED, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, options), SLJIT_IMM, PCRE2_NOTEOL);
add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); add_jump(compiler, backtracks, JUMP(SLJIT_NOT_ZERO));
check_partial(common, FALSE); check_partial(common, FALSE);
jump[0] = JUMP(SLJIT_JUMP); jump[0] = JUMP(SLJIT_JUMP);
JUMPHERE(jump[1]); JUMPHERE(jump[1]);
@ -8178,13 +8165,14 @@ if (common->accept_label == NULL)
else else
CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), common->accept_label); CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), common->accept_label);
OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); OP1(SLJIT_MOV_UI, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options));
add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, PCRE2_NOTEMPTY);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_NOT_ZERO));
OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, PCRE2_NOTEMPTY_ATSTART);
if (common->accept_label == NULL) if (common->accept_label == NULL)
add_jump(compiler, &common->accept, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0)); add_jump(compiler, &common->accept, JUMP(SLJIT_ZERO));
else else
CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0, common->accept_label); JUMPTO(SLJIT_ZERO, common->accept_label);
OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
if (common->accept_label == NULL) if (common->accept_label == NULL)
add_jump(compiler, &common->accept, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0)); add_jump(compiler, &common->accept, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0));
@ -10183,10 +10171,11 @@ if (common->might_be_empty)
{ {
JUMPHERE(empty_match); JUMPHERE(empty_match);
OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0); OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty)); OP1(SLJIT_MOV_UI, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, options));
CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, PCRE2_NOTEMPTY);
OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart)); JUMPTO(SLJIT_NOT_ZERO, empty_match_backtrack_label);
CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label); OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, PCRE2_NOTEMPTY_ATSTART);
JUMPTO(SLJIT_ZERO, empty_match_found_label);
OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str)); OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label); CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label);
JUMPTO(SLJIT_JUMP, empty_match_backtrack_label); JUMPTO(SLJIT_JUMP, empty_match_backtrack_label);

View File

@ -128,11 +128,7 @@ arguments.end = subject + length;
arguments.match_data = match_data; arguments.match_data = match_data;
arguments.startchar_ptr = subject; arguments.startchar_ptr = subject;
arguments.mark_ptr = NULL; arguments.mark_ptr = NULL;
/* JIT decreases this value less frequently than the interpreter. */ arguments.options = options;
arguments.notbol = (options & PCRE2_NOTBOL) != 0;
arguments.noteol = (options & PCRE2_NOTEOL) != 0;
arguments.notempty = (options & PCRE2_NOTEMPTY) != 0;
arguments.notempty_atstart = (options & PCRE2_NOTEMPTY_ATSTART) != 0;
if (mcontext != NULL) if (mcontext != NULL)
{ {
arguments.callout = mcontext->callout; arguments.callout = mcontext->callout;