* pcre2_jit_malloc(
size_t size,
void*allocator_data)
79 static voidpcre2_jit_free(
void*ptr,
void*allocator_data)
87 #if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED 88 #error Unsupported architecture 102 #define MACHINE_STACK_SIZE 32768 106 #define STACK_GROWTH_RATE 8192 109 #if defined SLJIT_DEBUG && SLJIT_DEBUG 110 #define DESTROY_REGISTERS 1 183 typedef structjit_arguments {
201 #define JIT_NUMBER_OF_COMPILE_MODES 3 203 typedef structexecutable_functions {
204 void*executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];
205 void*read_only_data_heads[JIT_NUMBER_OF_COMPILE_MODES];
206 sljit_uwexecutable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
209} executable_functions;
211 typedef structjump_list {
213 structjump_list *
next;
216 typedef structstub_list {
219 structstub_list *
next;
232 enumearly_fail_types {
238 typedef int(
SLJIT_FUNC*jit_function)(jit_arguments *args);
244 typedef structbacktrack_common {
247 structbacktrack_common *
prev;
251jump_list *simple_backtracks;
255 structbacktrack_common *top;
259jump_list *own_backtracks;
264 typedef structassert_backtrack {
265backtrack_common common;
266jump_list *condfailed;
270 intprivate_data_ptr;
275 typedef structbracket_backtrack {
276backtrack_common common;
286jump_list *condfailed;
287assert_backtrack *
assert;
294 intprivate_data_ptr;
297 typedef structbracketpos_backtrack {
298backtrack_common common;
300 intprivate_data_ptr;
305} bracketpos_backtrack;
307 typedef structbraminzero_backtrack {
308backtrack_common common;
310} braminzero_backtrack;
312 typedef structchar_iterator_backtrack {
313backtrack_common common;
317jump_list *backtracks;
319 unsigned intothercasebit;
324} char_iterator_backtrack;
326 typedef structref_iterator_backtrack {
327backtrack_common common;
330} ref_iterator_backtrack;
332 typedef structrecurse_entry {
333 structrecurse_entry *
next;
339jump_list *entry_calls;
341jump_list *backtrack_calls;
346 typedef structrecurse_backtrack {
347backtrack_common common;
351recurse_entry *entry;
353 BOOLinlined_pattern;
356 typedef structvreverse_backtrack {
357backtrack_common common;
360} vreverse_backtrack;
362 #define OP_THEN_TRAP OP_TABLE_LENGTH 364 typedef structthen_trap_backtrack {
365backtrack_common common;
368 structthen_trap_backtrack *then_trap;
375} then_trap_backtrack;
377 #define MAX_N_CHARS 12 378 #define MAX_DIFF_CHARS 5 380 typedef structfast_forward_char_data {
387} fast_forward_char_data;
389 #define MAX_CLASS_RANGE_SIZE 4 390 #define MAX_CLASS_CHARS_SIZE 3 392 typedef structcompiler_common {
402 void*read_only_data_head;
408then_trap_backtrack *then_trap;
449 BOOLallow_empty_partial;
459 BOOLhas_skip_in_assert_back;
461 BOOLlocal_quit_available;
463 BOOLin_positive_assertion;
489recurse_entry *currententry;
490jump_list *partialmatch;
492jump_list *positive_assertion_quit;
494jump_list *failed_match;
496jump_list *calllimit;
497jump_list *stackalloc;
498jump_list *revertframes;
499jump_list *wordboundary;
500jump_list *ucp_wordboundary;
501jump_list *anynewline;
504jump_list *casefulcmp;
505jump_list *caselesscmp;
506jump_list *reset_match;
508jump_list *restart_match;
511 #ifdef SUPPORT_UNICODE 518jump_list *getucdtype;
519 #if PCRE2_CODE_UNIT_WIDTH == 8 520jump_list *utfreadchar;
521jump_list *utfreadtype8;
522jump_list *utfpeakcharback;
524 #if PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16 525jump_list *utfreadchar_invalid;
526jump_list *utfreadnewline_invalid;
527jump_list *utfmoveback_invalid;
528jump_list *utfpeakcharback_invalid;
535 typedef structcompare_context {
538 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED 543 #if PCRE2_CODE_UNIT_WIDTH == 8 546 #elif PCRE2_CODE_UNIT_WIDTH == 16 548 #elif PCRE2_CODE_UNIT_WIDTH == 32 555 #if PCRE2_CODE_UNIT_WIDTH == 8 558 #elif PCRE2_CODE_UNIT_WIDTH == 16 560 #elif PCRE2_CODE_UNIT_WIDTH == 32 571 #define STACK(i) ((i) * SSIZE_OF(sw)) 573 #ifdef SLJIT_PREF_SHIFT_REG 574 #if SLJIT_PREF_SHIFT_REG == SLJIT_R2 576 #elif SLJIT_PREF_SHIFT_REG == SLJIT_R3 577 #define SHIFT_REG_IS_R3 579 #error "Unsupported shift register" 583 #define TMP1 SLJIT_R0 584 #ifdef SHIFT_REG_IS_R3 585 #define TMP2 SLJIT_R3 586 #define TMP3 SLJIT_R2 588 #define TMP2 SLJIT_R2 589 #define TMP3 SLJIT_R3 591 #define STR_PTR SLJIT_R1 592 #define STR_END SLJIT_S0 593 #define STACK_TOP SLJIT_S1 594 #define STACK_LIMIT SLJIT_S2 595 #define COUNT_MATCH SLJIT_S3 596 #define ARGUMENTS SLJIT_S4 597 #define RETURN_ADDR SLJIT_R4 599 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) 600 #define HAS_VIRTUAL_REGISTERS 1 602 #define HAS_VIRTUAL_REGISTERS 0 607 #define LOCALS0 (0 * sizeof(sljit_sw)) 608 #define LOCALS1 (1 * sizeof(sljit_sw)) 610 #define POSSESSIVE0 (2 * sizeof(sljit_sw)) 611 #define POSSESSIVE1 (3 * sizeof(sljit_sw)) 613 #define LIMIT_MATCH (4 * sizeof(sljit_sw)) 618 #define OVECTOR_START (common->ovector_start) 619 #define OVECTOR(i) (OVECTOR_START + (i) * SSIZE_OF(sw)) 620 #define OVECTOR_PRIV(i) (common->cbra_ptr + (i) * SSIZE_OF(sw)) 621 #define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start]) 623 #if PCRE2_CODE_UNIT_WIDTH == 8 624 #define MOV_UCHAR SLJIT_MOV_U8 625 #define IN_UCHARS(x) (x) 626 #elif PCRE2_CODE_UNIT_WIDTH == 16 627 #define MOV_UCHAR SLJIT_MOV_U16 628 #define UCHAR_SHIFT (1) 629 #define IN_UCHARS(x) ((x) * 2) 630 #elif PCRE2_CODE_UNIT_WIDTH == 32 631 #define MOV_UCHAR SLJIT_MOV_U32 632 #define UCHAR_SHIFT (2) 633 #define IN_UCHARS(x) ((x) * 4) 635 #error Unsupported compiling mode 639 #define DEFINE_COMPILER \ 640 struct sljit_compiler *compiler = common->compiler 641 #define OP1(op, dst, dstw, src, srcw) \ 642 sljit_emit_op1(compiler, (op), (dst), (dstw), (src), (srcw)) 643 #define OP2(op, dst, dstw, src1, src1w, src2, src2w) \ 644 sljit_emit_op2(compiler, (op), (dst), (dstw), (src1), (src1w), (src2), (src2w)) 645 #define OP2U(op, src1, src1w, src2, src2w) \ 646 sljit_emit_op2u(compiler, (op), (src1), (src1w), (src2), (src2w)) 647 #define OP_SRC(op, src, srcw) \ 648 sljit_emit_op_src(compiler, (op), (src), (srcw)) 650 sljit_emit_label(compiler) 652 sljit_emit_jump(compiler, (type)) 653 #define JUMPTO(type, label) \ 654 sljit_set_label(sljit_emit_jump(compiler, (type)), (label)) 655 #define JUMPHERE(jump) \ 656 sljit_set_label((jump), sljit_emit_label(compiler)) 657 #define SET_LABEL(jump, label) \ 658 sljit_set_label((jump), (label)) 659 #define CMP(type, src1, src1w, src2, src2w) \ 660 sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w)) 661 #define CMPTO(type, src1, src1w, src2, src2w, label) \ 662 sljit_set_label(sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w)), (label)) 663 #define OP_FLAGS(op, dst, dstw, type) \ 664 sljit_emit_op_flags(compiler, (op), (dst), (dstw), (type)) 665 #define SELECT(type, dst_reg, src1, src1w, src2_reg) \ 666 sljit_emit_select(compiler, (type), (dst_reg), (src1), (src1w), (src2_reg)) 667 #define GET_LOCAL_BASE(dst, dstw, offset) \ 668 sljit_get_local_base(compiler, (dst), (dstw), (offset)) 670 #define READ_CHAR_MAX 0x7fffffff 672 #define INVALID_UTF_CHAR -1 673 #define UNASSIGNED_UTF_CHAR 888 675 #if defined SUPPORT_UNICODE 676 #if PCRE2_CODE_UNIT_WIDTH == 8 678 #define GETCHARINC_INVALID(c, ptr, end, invalid_action) \ 680 if (ptr[0] <= 0x7f) \ 682 else if (ptr + 1 < end && ptr[1] >= 0x80 && ptr[1] < 0xc0) \ 686 if (ptr[0] >= 0xc2 && ptr[0] <= 0xdf) \ 688 c |= (ptr[0] - 0xc0) << 6; \ 691 else if (ptr + 2 < end && ptr[2] >= 0x80 && ptr[2] < 0xc0) \ 693 c = c << 6 | (ptr[2] - 0x80); \ 695 if (ptr[0] >= 0xe0 && ptr[0] <= 0xef) \ 697 c |= (ptr[0] - 0xe0) << 12; \ 700 if (c < 0x800 || (c >= 0xd800 && c < 0xe000)) \ 705 else if (ptr + 3 < end && ptr[3] >= 0x80 && ptr[3] < 0xc0) \ 707 c = c << 6 | (ptr[3] - 0x80); \ 709 if (ptr[0] >= 0xf0 && ptr[0] <= 0xf4) \ 711 c |= (ptr[0] - 0xf0) << 18; \ 714 if (c >= 0x110000 || c < 0x10000) \ 740 #define GETCHARBACK_INVALID(c, ptr, start, invalid_action) \ 745 else if (ptr - 1 > start && ptr[-1] >= 0x80 && ptr[-1] < 0xc0) \ 749 if (ptr[-2] >= 0xc2 && ptr[-2] <= 0xdf) \ 751 c |= (ptr[-2] - 0xc0) << 6; \ 754 else if (ptr - 2 > start && ptr[-2] >= 0x80 && ptr[-2] < 0xc0) \ 756 c = c << 6 | (ptr[-2] - 0x80); \ 758 if (ptr[-3] >= 0xe0 && ptr[-3] <= 0xef) \ 760 c |= (ptr[-3] - 0xe0) << 12; \ 763 if (c < 0x800 || (c >= 0xd800 && c < 0xe000)) \ 768 else if (ptr - 3 > start && ptr[-3] >= 0x80 && ptr[-3] < 0xc0) \ 770 c = c << 6 | (ptr[-3] - 0x80); \ 772 if (ptr[-4] >= 0xf0 && ptr[-4] <= 0xf4) \ 774 c |= (ptr[-4] - 0xf0) << 18; \ 777 if (c >= 0x110000 || c < 0x10000) \ 803 #elif PCRE2_CODE_UNIT_WIDTH == 16 805 #define GETCHARINC_INVALID(c, ptr, end, invalid_action) \ 807 if (ptr[0] < 0xd800 || ptr[0] >= 0xe000) \ 809 else if (ptr[0] < 0xdc00 && ptr + 1 < end && ptr[1] >= 0xdc00 && ptr[1] < 0xe000) \ 811 c = (((ptr[0] - 0xd800) << 10) | (ptr[1] - 0xdc00)) + 0x10000; \ 820 #define GETCHARBACK_INVALID(c, ptr, start, invalid_action) \ 823 if (c < 0xd800 || c >= 0xe000) \ 825 else if (c >= 0xdc00 && ptr - 1 > start && ptr[-2] >= 0xd800 && ptr[-2] < 0xdc00) \ 827 c = (((ptr[-2] - 0xd800) << 10) | (c - 0xdc00)) + 0x10000; \ 837 #elif PCRE2_CODE_UNIT_WIDTH == 32 839 #define GETCHARINC_INVALID(c, ptr, end, invalid_action) \ 841 if (ptr[0] < 0xd800 || (ptr[0] >= 0xe000 && ptr[0] < 0x110000)) \ 849 #define GETCHARBACK_INVALID(c, ptr, start, invalid_action) \ 852 if (ptr[-1] < 0xd800 || (ptr[-1] >= 0xe000 && ptr[-1] < 0x110000)) \ 866 docc += GET(cc, 1);
while(*cc ==
OP_ALT);
1069 #ifdef SUPPORT_UNICODE 1070 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1091 #ifdef SUPPORT_UNICODE 1092 if(common->utf)
return NULL;
1099 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 1101 returncc + GET(cc, 1);
1109 returncc + 1 + 2 + cc[1];
1130common->has_set_som =
TRUE;
1131common->might_be_empty =
TRUE;
1136 #ifdef SUPPORT_UNICODE 1137 if(common->iref_ptr == 0)
1139common->iref_ptr = common->ovector_start;
1140common->ovector_start += 3 *
sizeof(
sljit_sw);
1145common->optimized_cbracket[
GET2(cc, 1)] = 0;
1151slot = bracketend(cc);
1152 if(slot > assert_na_end)
1153assert_na_end = slot;
1173common->optimized_cbracket[
GET2(cc, 1)] = 0;
1181slot = common->name_table +
GET2(cc, 1) * common->name_entry_size;
1182 while(
count-- > 0)
1184common->optimized_cbracket[
GET2(slot, 0)] = 0;
1185slot += common->name_entry_size;
1192 if(common->recursive_head_ptr == 0)
1194common->recursive_head_ptr = common->ovector_start;
1195common->ovector_start +=
sizeof(
sljit_sw);
1202 if(common->capture_last_ptr == 0)
1204common->capture_last_ptr = common->ovector_start;
1205common->ovector_start +=
sizeof(
sljit_sw);
1211slot = bracketend(cc);
1212 if(slot > assert_back_end)
1213assert_back_end = slot;
1218common->has_then =
TRUE;
1219common->control_head_ptr = 1;
1224 if(cc < assert_na_end)
1228 if(common->mark_ptr == 0)
1230common->mark_ptr = common->ovector_start;
1231common->ovector_start +=
sizeof(
sljit_sw);
1233cc += 1 + 2 + cc[1];
1237common->has_then =
TRUE;
1238common->control_head_ptr = 1;
1243 if(cc < assert_back_end)
1244common->has_skip_in_assert_back =
TRUE;
1245 if(cc < assert_na_end)
1251common->control_head_ptr = 1;
1252common->has_skip_arg =
TRUE;
1253 if(cc < assert_back_end)
1254common->has_skip_in_assert_back =
TRUE;
1255 if(cc < assert_na_end)
1257cc += 1 + 2 + cc[1];
1263 if(cc < assert_na_end)
1269cc = next_opcode(common, cc);
1278 #define EARLY_FAIL_ENHANCE_MAX (3 + 3) 1292 static intdetect_early_fail(compiler_common *common,
PCRE2_SPTRcc,
1300 int count, prev_count;
1306next_alt = cc + GET(cc, 1);
1307 if(*next_alt ==
OP_ALT&& start < 1)
1317accelerated_start =
NULL;
1377 #ifdef SUPPORT_UNICODE 1378 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1397accelerated_start = cc - 1;
1457accelerated_start = cc;
1459 #ifdef SUPPORT_UNICODE 1460 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1468 #ifdef SUPPORT_UNICODE 1469 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1506 #ifdef SUPPORT_UNICODE 1507 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
1513 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 1515accelerated_start = cc;
1518accelerated_start = cc;
1569prev_count =
count;
1579end = bracketend(cc);
1583prev_count = detect_early_fail(common, cc, private_data_start,
depth+ 1, prev_count);
1585 if(prev_count >
count)
1588 if(PRIVATE_DATA(cc) != 0)
1589common->private_data_ptrs[begin - common->start] = 1;
1591 if(
count< EARLY_FAIL_ENHANCE_MAX)
1606 if(accelerated_start ==
NULL)
1611common->fast_forward_bc_ptr = accelerated_start;
1612common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_skip;
1613*private_data_start +=
sizeof(
sljit_sw);
1616 else if(
count< 3)
1618common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_fail;
1620 if(common->early_fail_start_ptr == 0)
1621common->early_fail_start_ptr = *private_data_start;
1623*private_data_start +=
sizeof(
sljit_sw);
1624common->early_fail_end_ptr = *private_data_start;
1627 returnEARLY_FAIL_ENHANCE_MAX;
1633common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_fail_range;
1635 if(common->early_fail_start_ptr == 0)
1636common->early_fail_start_ptr = *private_data_start;
1638*private_data_start += 2 *
sizeof(
sljit_sw);
1639common->early_fail_end_ptr = *private_data_start;
1642 returnEARLY_FAIL_ENHANCE_MAX;
1648common->private_data_ptrs[begin - common->start] = 1;
1650 if(
count>= EARLY_FAIL_ENHANCE_MAX)
1655 result= EARLY_FAIL_ENHANCE_MAX;
1660next_alt = cc + GET(cc, 1);
1667 static intget_class_iterator_size(
PCRE2_SPTRcc)
1699 static BOOLdetect_repeat(compiler_common *common,
PCRE2_SPTRbegin)
1715 if(PRIVATE_DATA(end -
LINK_SIZE) != 0)
1722 if(*
next!= *begin)
1724next_end = bracketend(
next);
1725 if(next_end -
next!= length || memcmp(begin,
next, IN_UCHARS(length)) != 0)
1752next_end = bracketend(
next+ 1);
1753 if(next_end -
next== (length + 1) && memcmp(begin,
next+ 1, IN_UCHARS(length)) == 0)
1756 if(*next_end !=
OP_KET)
1761common->private_data_ptrs[max_end - common->start -
LINK_SIZE] = next_end - max_end;
1764common->private_data_ptrs[max_end - common->start -
LINK_SIZE+ 2] =
max+ 2;
1776common->private_data_ptrs[end - common->start -
LINK_SIZE] = max_end - end;
1778common->private_data_ptrs[end - common->start -
LINK_SIZE+ 2] =
min;
1785 #define CASE_ITERATOR_PRIVATE_DATA_1 \ 1793 case OP_MINQUERYI: \ 1794 case OP_NOTMINSTAR: \ 1795 case OP_NOTMINPLUS: \ 1797 case OP_NOTMINQUERY: \ 1798 case OP_NOTMINSTARI: \ 1799 case OP_NOTMINPLUSI: \ 1800 case OP_NOTQUERYI: \ 1801 case OP_NOTMINQUERYI: 1803 #define CASE_ITERATOR_PRIVATE_DATA_2A \ 1813 #define CASE_ITERATOR_PRIVATE_DATA_2B \ 1819 case OP_NOTMINUPTO: \ 1821 case OP_NOTMINUPTOI: 1823 #define CASE_ITERATOR_TYPE_PRIVATE_DATA_1 \ 1824 case OP_TYPEMINSTAR: \ 1825 case OP_TYPEMINPLUS: \ 1826 case OP_TYPEQUERY: \ 1827 case OP_TYPEMINQUERY: 1829 #define CASE_ITERATOR_TYPE_PRIVATE_DATA_2A \ 1833 #define CASE_ITERATOR_TYPE_PRIVATE_DATA_2B \ 1835 case OP_TYPEMINUPTO: 1837 static voidset_private_data_ptrs(compiler_common *common,
int*private_data_start,
PCRE2_SPTRccend)
1842 intprivate_data_ptr = *private_data_start;
1843 intspace,
size, bracketlen;
1857 if(detect_repeat(common, cc))
1862end = bracketend(cc);
1865repeat_check =
TRUE;
1870 if(common->private_data_ptrs[cc + 1 - common->start] != 0)
1872common->private_data_ptrs[cc - common->start] = private_data_ptr;
1873private_data_ptr +=
sizeof(
sljit_sw);
1874cc += common->private_data_ptrs[cc + 1 - common->start];
1890common->private_data_ptrs[cc - common->start] = private_data_ptr;
1891private_data_ptr +=
sizeof(
sljit_sw);
1896common->private_data_ptrs[cc - common->start] = private_data_ptr;
1897private_data_ptr +=
sizeof(
sljit_sw);
1899 if(find_vreverse(cc))
1901common->private_data_ptrs[cc + 1 - common->start] = 1;
1902private_data_ptr +=
sizeof(
sljit_sw);
1910common->private_data_ptrs[cc - common->start] = private_data_ptr;
1911private_data_ptr +=
sizeof(
sljit_sw);
1917common->private_data_ptrs[cc - common->start] = 0;
1918alternative = cc + GET(cc, 1);
1921common->private_data_ptrs[cc - common->start] = private_data_ptr;
1922private_data_ptr +=
sizeof(
sljit_sw);
1940repeat_check =
FALSE;
1943CASE_ITERATOR_PRIVATE_DATA_1
1948CASE_ITERATOR_PRIVATE_DATA_2A
1953CASE_ITERATOR_PRIVATE_DATA_2B
1958CASE_ITERATOR_TYPE_PRIVATE_DATA_1
1963CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
1983space = get_class_iterator_size(cc +
size);
1986 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 1989space = get_class_iterator_size(cc +
size);
1994cc = next_opcode(common, cc);
2001 if(space > 0 && cc >= end)
2003common->private_data_ptrs[cc - common->start] = private_data_ptr;
2004private_data_ptr +=
sizeof(
sljit_sw) * space;
2012 #ifdef SUPPORT_UNICODE 2013 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2024end = bracketend(cc);
2031*private_data_start = private_data_ptr;
2040 BOOLsetsom_found = recursive;
2041 BOOLsetmark_found = recursive;
2045 #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD 2047*needs_control_head =
TRUE;
2049*needs_control_head =
FALSE;
2054ccend = bracketend(cc) - (1 +
LINK_SIZE);
2057possessive = length = (common->capture_last_ptr != 0) ? 5 : 3;
2059capture_last_found =
TRUE;
2061cc = next_opcode(common, cc);
2070stack_restore =
TRUE;
2074setsom_found =
TRUE;
2084stack_restore =
TRUE;
2088setmark_found =
TRUE;
2090 if(common->control_head_ptr != 0)
2091*needs_control_head =
TRUE;
2092cc += 1 + 2 + cc[1];
2096stack_restore =
TRUE;
2097 if(common->has_set_som && !setsom_found)
2100setsom_found =
TRUE;
2102 if(common->mark_ptr != 0 && !setmark_found)
2105setmark_found =
TRUE;
2107 if(common->capture_last_ptr != 0 && !capture_last_found)
2110capture_last_found =
TRUE;
2119stack_restore =
TRUE;
2120 if(common->capture_last_ptr != 0 && !capture_last_found)
2123capture_last_found =
TRUE;
2130stack_restore =
TRUE;
2131 if(common->control_head_ptr != 0)
2132*needs_control_head =
TRUE;
2137stack_restore =
TRUE;
2210cc = next_opcode(common, cc);
2217 returnstack_restore ? no_frame : no_stack;
2221 returnstack_restore ? no_frame : no_stack;
2224 static voidinit_frame(compiler_common *common,
PCRE2_SPTRcc,
PCRE2_SPTRccend,
intstackpos,
intstacktop)
2237stackpos = STACK(stackpos);
2240ccend = bracketend(cc) - (1 +
LINK_SIZE);
2242cc = next_opcode(common, cc);
2255stackpos -= SSIZE_OF(
sw);
2257stackpos -= SSIZE_OF(
sw);
2258setsom_found =
TRUE;
2272stackpos -= SSIZE_OF(
sw);
2274stackpos -= SSIZE_OF(
sw);
2275setmark_found =
TRUE;
2277cc += 1 + 2 + cc[1];
2281 if(common->has_set_som && !setsom_found)
2285stackpos -= SSIZE_OF(
sw);
2287stackpos -= SSIZE_OF(
sw);
2288setsom_found =
TRUE;
2290 if(common->mark_ptr != 0 && !setmark_found)
2294stackpos -= SSIZE_OF(
sw);
2296stackpos -= SSIZE_OF(
sw);
2297setmark_found =
TRUE;
2299 if(common->capture_last_ptr != 0 && !capture_last_found)
2303stackpos -= SSIZE_OF(
sw);
2305stackpos -= SSIZE_OF(
sw);
2306capture_last_found =
TRUE;
2315 if(common->capture_last_ptr != 0 && !capture_last_found)
2319stackpos -= SSIZE_OF(
sw);
2321stackpos -= SSIZE_OF(
sw);
2322capture_last_found =
TRUE;
2326stackpos -= SSIZE_OF(
sw);
2330stackpos -= SSIZE_OF(
sw);
2332stackpos -= SSIZE_OF(
sw);
2338cc = next_opcode(common, cc);
2347 #define RECURSE_TMP_REG_COUNT 3 2349 typedef structdelayed_mem_copy_status {
2351 intstore_bases[RECURSE_TMP_REG_COUNT];
2352 intstore_offsets[RECURSE_TMP_REG_COUNT];
2353 inttmp_regs[RECURSE_TMP_REG_COUNT];
2354 intsaved_tmp_regs[RECURSE_TMP_REG_COUNT];
2356} delayed_mem_copy_status;
2358 static voiddelayed_mem_copy_init(delayed_mem_copy_status *status, compiler_common *common)
2362 for(
i= 0;
i< RECURSE_TMP_REG_COUNT;
i++)
2367status->store_bases[
i] = -1;
2369status->next_tmp_reg = 0;
2370status->compiler = common->compiler;
2373 static voiddelayed_mem_copy_move(delayed_mem_copy_status *status,
intload_base,
sljit_swload_offset,
2374 intstore_base,
sljit_swstore_offset)
2377 intnext_tmp_reg = status->next_tmp_reg;
2378 inttmp_reg = status->tmp_regs[next_tmp_reg];
2382 if(status->store_bases[next_tmp_reg] == -1)
2386OP1(
SLJIT_MOV, status->saved_tmp_regs[next_tmp_reg], 0, tmp_reg, 0);
2389OP1(
SLJIT_MOV,
SLJIT_MEM1(status->store_bases[next_tmp_reg]), status->store_offsets[next_tmp_reg], tmp_reg, 0);
2392status->store_bases[next_tmp_reg] = store_base;
2393status->store_offsets[next_tmp_reg] = store_offset;
2395status->next_tmp_reg = (next_tmp_reg + 1) % RECURSE_TMP_REG_COUNT;
2398 static voiddelayed_mem_copy_finish(delayed_mem_copy_status *status)
2401 intnext_tmp_reg = status->next_tmp_reg;
2402 inttmp_reg, saved_tmp_reg,
i;
2404 for(
i= 0;
i< RECURSE_TMP_REG_COUNT;
i++)
2406 if(status->store_bases[next_tmp_reg] != -1)
2408tmp_reg = status->tmp_regs[next_tmp_reg];
2409saved_tmp_reg = status->saved_tmp_regs[next_tmp_reg];
2411OP1(
SLJIT_MOV,
SLJIT_MEM1(status->store_bases[next_tmp_reg]), status->store_offsets[next_tmp_reg], tmp_reg, 0);
2415OP1(
SLJIT_MOV, tmp_reg, 0, saved_tmp_reg, 0);
2418next_tmp_reg = (next_tmp_reg + 1) % RECURSE_TMP_REG_COUNT;
2422 #undef RECURSE_TMP_REG_COUNT 2424 static BOOLrecurse_check_bit(compiler_common *common,
sljit_swbit_index)
2433 SLJIT_ASSERT((bit_index >> 3) < common->recurse_bitset_size);
2435 mask= 1 << (bit_index & 0x7);
2436 byte= common->recurse_bitset + (bit_index >> 3);
2445 enumget_recurse_flags {
2446recurse_flag_quit_found = (1 << 0),
2447recurse_flag_accept_found = (1 << 1),
2448recurse_flag_setsom_found = (1 << 2),
2449recurse_flag_setmark_found = (1 << 3),
2450recurse_flag_control_head_found = (1 << 4),
2460memset(common->recurse_bitset, 0, common->recurse_bitset_size);
2462 #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD 2464recurse_flags |= recurse_flag_control_head_found;
2475recurse_flags |= recurse_flag_setsom_found;
2480 if(common->has_set_som)
2481recurse_flags |= recurse_flag_setsom_found;
2482 if(common->mark_ptr != 0)
2483recurse_flags |= recurse_flag_setmark_found;
2484 if(common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))
2490 offset= PRIVATE_DATA(cc);
2493 if(recurse_check_bit(common,
offset))
2496cc += PRIVATE_DATA(cc + 1);
2514 if(recurse_check_bit(common, PRIVATE_DATA(cc)))
2522 if(recurse_check_bit(common, OVECTOR(
offset<< 1)))
2527 if(common->optimized_cbracket[
offset] == 0 && recurse_check_bit(common, OVECTOR_PRIV(
offset)))
2529 if(common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))
2537 if(recurse_check_bit(common, OVECTOR(
offset<< 1)))
2542 if(recurse_check_bit(common, OVECTOR_PRIV(
offset)))
2544 if(recurse_check_bit(common, PRIVATE_DATA(cc)))
2546 if(common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))
2553alternative = cc + GET(cc, 1);
2554 if((*alternative ==
OP_KETRMAX|| *alternative ==
OP_KETRMIN) && recurse_check_bit(common, PRIVATE_DATA(cc)))
2559CASE_ITERATOR_PRIVATE_DATA_1
2560 offset= PRIVATE_DATA(cc);
2561 if(
offset!= 0 && recurse_check_bit(common,
offset))
2564 #ifdef SUPPORT_UNICODE 2565 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2569CASE_ITERATOR_PRIVATE_DATA_2A
2570 offset= PRIVATE_DATA(cc);
2571 if(
offset!= 0 && recurse_check_bit(common,
offset))
2577 #ifdef SUPPORT_UNICODE 2578 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2582CASE_ITERATOR_PRIVATE_DATA_2B
2583 offset= PRIVATE_DATA(cc);
2584 if(
offset!= 0 && recurse_check_bit(common,
offset))
2590 #ifdef SUPPORT_UNICODE 2591 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2595CASE_ITERATOR_TYPE_PRIVATE_DATA_1
2596 offset= PRIVATE_DATA(cc);
2597 if(
offset!= 0 && recurse_check_bit(common,
offset))
2602CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
2603 offset= PRIVATE_DATA(cc);
2604 if(
offset!= 0 && recurse_check_bit(common,
offset))
2612CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
2613 offset= PRIVATE_DATA(cc);
2614 if(
offset!= 0 && recurse_check_bit(common,
offset))
2624 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 2631 offset= PRIVATE_DATA(cc);
2632 if(
offset!= 0 && recurse_check_bit(common,
offset))
2633length += get_class_iterator_size(cc +
size);
2642recurse_flags |= recurse_flag_setmark_found;
2643 if(common->control_head_ptr != 0)
2644recurse_flags |= recurse_flag_control_head_found;
2646recurse_flags |= recurse_flag_quit_found;
2648cc += 1 + 2 + cc[1];
2654recurse_flags |= recurse_flag_quit_found;
2659recurse_flags |= recurse_flag_quit_found;
2660cc += 1 + 2 + cc[1];
2665recurse_flags |= recurse_flag_quit_found | recurse_flag_control_head_found;
2671recurse_flags |= recurse_flag_accept_found;
2676cc = next_opcode(common, cc);
2683 if(recurse_flags & recurse_flag_control_head_found)
2685 if(recurse_flags & recurse_flag_quit_found)
2687 if(recurse_flags & recurse_flag_setsom_found)
2689 if(recurse_flags & recurse_flag_setmark_found)
2693*result_flags = recurse_flags;
2697 enumcopy_recurse_data_types {
2698recurse_copy_from_global,
2699recurse_copy_private_to_global,
2700recurse_copy_shared_to_global,
2701recurse_copy_kept_shared_to_global,
2706 int type,
intstackptr,
intstacktop,
uint32_trecurse_flags)
2708delayed_mem_copy_status status;
2713 intprivate_count, shared_count, kept_shared_count;
2714 intfrom_sp, base_reg,
offset,
i;
2716memset(common->recurse_bitset, 0, common->recurse_bitset_size);
2718 #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD 2720recurse_check_bit(common, common->control_head_ptr);
2725 caserecurse_copy_from_global:
2727base_reg = STACK_TOP;
2730 caserecurse_copy_private_to_global:
2731 caserecurse_copy_shared_to_global:
2732 caserecurse_copy_kept_shared_to_global:
2734base_reg = STACK_TOP;
2744stackptr = STACK(stackptr);
2745stacktop = STACK(stacktop);
2747status.tmp_regs[0] = TMP1;
2748status.saved_tmp_regs[0] = TMP1;
2750 if(base_reg != TMP2)
2752status.tmp_regs[1] = TMP2;
2753status.saved_tmp_regs[1] = TMP2;
2757status.saved_tmp_regs[1] = RETURN_ADDR;
2758 if(HAS_VIRTUAL_REGISTERS)
2759status.tmp_regs[1] = STR_PTR;
2761status.tmp_regs[1] = RETURN_ADDR;
2764status.saved_tmp_regs[2] = TMP3;
2765 if(HAS_VIRTUAL_REGISTERS)
2766status.tmp_regs[2] = STR_END;
2768status.tmp_regs[2] = TMP3;
2770delayed_mem_copy_init(&status, common);
2772 if(
type!= recurse_copy_shared_to_global &&
type!= recurse_copy_kept_shared_to_global)
2774 SLJIT_ASSERT(
type== recurse_copy_from_global ||
type== recurse_copy_private_to_global ||
type== recurse_swap_global);
2777delayed_mem_copy_move(&status, base_reg, stackptr,
SLJIT_SP, common->recursive_head_ptr);
2779 if(from_sp ||
type== recurse_swap_global)
2780delayed_mem_copy_move(&status,
SLJIT_SP, common->recursive_head_ptr, base_reg, stackptr);
2785 #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD 2786 if(
type!= recurse_copy_shared_to_global)
2789delayed_mem_copy_move(&status, base_reg, stackptr,
SLJIT_SP, common->control_head_ptr);
2791 if(from_sp ||
type== recurse_swap_global)
2792delayed_mem_copy_move(&status,
SLJIT_SP, common->control_head_ptr, base_reg, stackptr);
2802kept_shared_count = 0;
2808 if((recurse_flags & recurse_flag_quit_found) && recurse_check_bit(common, OVECTOR(0)))
2810kept_shared_srcw[0] = OVECTOR(0);
2811kept_shared_count = 1;
2817 if(recurse_flags & recurse_flag_quit_found)
2819 if(common->has_set_som && recurse_check_bit(common, OVECTOR(0)))
2821kept_shared_srcw[0] = OVECTOR(0);
2822kept_shared_count = 1;
2824 if(common->mark_ptr != 0 && recurse_check_bit(common, common->mark_ptr))
2826kept_shared_srcw[kept_shared_count] = common->mark_ptr;
2827kept_shared_count++;
2830 if(common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))
2832shared_srcw[0] = common->capture_last_ptr;
2839private_srcw[0] = PRIVATE_DATA(cc);
2840 if(private_srcw[0] != 0)
2842 if(recurse_check_bit(common, private_srcw[0]))
2845cc += PRIVATE_DATA(cc + 1);
2862private_srcw[0] = PRIVATE_DATA(cc);
2863 if(recurse_check_bit(common, private_srcw[0]))
2871shared_srcw[0] = OVECTOR(
offset<< 1);
2872 if(recurse_check_bit(common, shared_srcw[0]))
2874shared_srcw[1] = shared_srcw[0] +
sizeof(
sljit_sw);
2875 SLJIT_ASSERT(recurse_check_bit(common, shared_srcw[1]));
2879 if(common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))
2881shared_srcw[shared_count] = common->capture_last_ptr;
2885 if(common->optimized_cbracket[
offset] == 0)
2887private_srcw[0] = OVECTOR_PRIV(
offset);
2888 if(recurse_check_bit(common, private_srcw[0]))
2898shared_srcw[0] = OVECTOR(
offset<< 1);
2899 if(recurse_check_bit(common, shared_srcw[0]))
2901shared_srcw[1] = shared_srcw[0] +
sizeof(
sljit_sw);
2902 SLJIT_ASSERT(recurse_check_bit(common, shared_srcw[1]));
2906 if(common->capture_last_ptr != 0 && recurse_check_bit(common, common->capture_last_ptr))
2908shared_srcw[shared_count] = common->capture_last_ptr;
2912private_srcw[0] = PRIVATE_DATA(cc);
2913 if(recurse_check_bit(common, private_srcw[0]))
2917 if(recurse_check_bit(common,
offset))
2919private_srcw[private_count] =
offset;
2927alternative = cc + GET(cc, 1);
2930private_srcw[0] = PRIVATE_DATA(cc);
2931 if(recurse_check_bit(common, private_srcw[0]))
2937CASE_ITERATOR_PRIVATE_DATA_1
2938private_srcw[0] = PRIVATE_DATA(cc);
2939 if(private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))
2942 #ifdef SUPPORT_UNICODE 2943 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2947CASE_ITERATOR_PRIVATE_DATA_2A
2948private_srcw[0] = PRIVATE_DATA(cc);
2949 if(private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))
2952private_srcw[1] = private_srcw[0] +
sizeof(
sljit_sw);
2953 SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));
2956 #ifdef SUPPORT_UNICODE 2957 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2961CASE_ITERATOR_PRIVATE_DATA_2B
2962private_srcw[0] = PRIVATE_DATA(cc);
2963 if(private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))
2966private_srcw[1] = private_srcw[0] +
sizeof(
sljit_sw);
2967 SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));
2970 #ifdef SUPPORT_UNICODE 2971 if(common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
2975CASE_ITERATOR_TYPE_PRIVATE_DATA_1
2976private_srcw[0] = PRIVATE_DATA(cc);
2977 if(private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))
2982CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
2983private_srcw[0] = PRIVATE_DATA(cc);
2984 if(private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))
2987private_srcw[1] = private_srcw[0] +
sizeof(
sljit_sw);
2988 SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));
2993CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
2994private_srcw[0] = PRIVATE_DATA(cc);
2995 if(private_srcw[0] != 0 && recurse_check_bit(common, private_srcw[0]))
2998private_srcw[1] = private_srcw[0] +
sizeof(
sljit_sw);
2999 SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));
3006 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 3012 if(PRIVATE_DATA(cc) != 0)
3015private_srcw[0] = PRIVATE_DATA(cc);
3016 switch(get_class_iterator_size(cc +
i))
3022 if(recurse_check_bit(common, private_srcw[0]))
3025private_srcw[1] = private_srcw[0] +
sizeof(
sljit_sw);
3026 SLJIT_ASSERT(recurse_check_bit(common, private_srcw[1]));
3043 if((recurse_flags & recurse_flag_quit_found) && recurse_check_bit(common, common->mark_ptr))
3045kept_shared_srcw[0] = common->mark_ptr;
3046kept_shared_count = 1;
3048 if(common->control_head_ptr != 0 && recurse_check_bit(common, common->control_head_ptr))
3050private_srcw[0] = common->control_head_ptr;
3053cc += 1 + 2 + cc[1];
3058 if(recurse_check_bit(common, common->control_head_ptr))
3060private_srcw[0] = common->control_head_ptr;
3067cc = next_opcode(common, cc);
3072 if(
type!= recurse_copy_shared_to_global &&
type!= recurse_copy_kept_shared_to_global)
3074 SLJIT_ASSERT(
type== recurse_copy_from_global ||
type== recurse_copy_private_to_global ||
type== recurse_swap_global);
3076 for(
i= 0;
i< private_count;
i++)
3081delayed_mem_copy_move(&status, base_reg, stackptr,
SLJIT_SP, private_srcw[
i]);
3083 if(from_sp ||
type== recurse_swap_global)
3084delayed_mem_copy_move(&status,
SLJIT_SP, private_srcw[
i], base_reg, stackptr);
3090stackptr +=
sizeof(
sljit_sw) * private_count;
3092 if(
type!= recurse_copy_private_to_global &&
type!= recurse_copy_kept_shared_to_global)
3094 SLJIT_ASSERT(
type== recurse_copy_from_global ||
type== recurse_copy_shared_to_global ||
type== recurse_swap_global);
3096 for(
i= 0;
i< shared_count;
i++)
3101delayed_mem_copy_move(&status, base_reg, stackptr,
SLJIT_SP, shared_srcw[
i]);
3103 if(from_sp ||
type== recurse_swap_global)
3104delayed_mem_copy_move(&status,
SLJIT_SP, shared_srcw[
i], base_reg, stackptr);
3110stackptr +=
sizeof(
sljit_sw) * shared_count;
3112 if(
type!= recurse_copy_private_to_global &&
type!= recurse_swap_global)
3114 SLJIT_ASSERT(
type== recurse_copy_from_global ||
type== recurse_copy_shared_to_global ||
type== recurse_copy_kept_shared_to_global);
3116 for(
i= 0;
i< kept_shared_count;
i++)
3121delayed_mem_copy_move(&status, base_reg, stackptr,
SLJIT_SP, kept_shared_srcw[
i]);
3123 if(from_sp ||
type== recurse_swap_global)
3124delayed_mem_copy_move(&status,
SLJIT_SP, kept_shared_srcw[
i], base_reg, stackptr);
3130stackptr +=
sizeof(
sljit_sw) * kept_shared_count;
3135delayed_mem_copy_finish(&status);
3141 BOOLhas_alternatives = cc[GET(cc, 1)] ==
OP_ALT;
3145current_offset =
NULL;
3148has_alternatives =
FALSE;
3150cc = next_opcode(common, cc);
3152 if(has_alternatives)
3159current_offset = common->then_offsets + (cc - common->start);
3165cc = set_then_offsets(common, cc, current_offset);
3168 if(*cc ==
OP_ALT&& has_alternatives)
3177current_offset = common->then_offsets + (cc - common->start);
3182*current_offset = 1;
3183cc = next_opcode(common, cc);
3190 #undef CASE_ITERATOR_PRIVATE_DATA_1 3191 #undef CASE_ITERATOR_PRIVATE_DATA_2A 3192 #undef CASE_ITERATOR_PRIVATE_DATA_2B 3193 #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_1 3194 #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2A 3195 #undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2B 3204 while(list !=
NULL)
3208SET_LABEL(list->jump,
label);
3218list_item->next = *list;
3219list_item->jump = jump;
3224 static voidadd_stub(compiler_common *common,
struct sljit_jump*start)
3231list_item->start = start;
3232list_item->quit =
LABEL();
3233list_item->next = common->stubs;
3234common->stubs = list_item;
3238 static voidflush_stubs(compiler_common *common)
3241stub_list *list_item = common->stubs;
3245JUMPHERE(list_item->start);
3248list_item = list_item->next;
3250common->stubs =
NULL;
3253 static SLJIT_INLINE voidcount_match(compiler_common *common)
3261 static SLJIT_INLINE voidallocate_stack(compiler_common *common,
int size)
3268 #ifdef DESTROY_REGISTERS 3271OP1(
SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
3275add_stub(common,
CMP(
SLJIT_LESS, STACK_TOP, 0, STACK_LIMIT, 0));
3301*(
void**)
result= common->read_only_data_head;
3302common->read_only_data_head = (
void*)
result;
3306 static SLJIT_INLINE voidreset_ovector(compiler_common *common,
intlength)
3318 for(
i= 1;
i< length;
i++)
3325GET_LOCAL_BASE(
SLJIT_R1, 0, OVECTOR_START);
3345 static SLJIT_INLINE voidreset_early_fail(compiler_common *common)
3354 SLJIT_ASSERT(common->early_fail_start_ptr < common->early_fail_end_ptr);
3370 for(
i= common->early_fail_start_ptr; i < common->early_fail_end_ptr;
i+=
sizeof(
sljit_sw))
3375GET_LOCAL_BASE(TMP1, 0, common->early_fail_start_ptr);
3388 if(uncleared_size >=
sizeof(
sljit_sw))
3391 if(uncleared_size >= 2 *
sizeof(
sljit_sw))
3395 static SLJIT_INLINE voiddo_reset_match(compiler_common *common,
intlength)
3407 for(
i= 2;
i< length;
i++)
3414GET_LOCAL_BASE(TMP2, 0, OVECTOR_START +
sizeof(
sljit_sw));
3423GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + 2 *
sizeof(
sljit_sw));
3433 if(!HAS_VIRTUAL_REGISTERS)
3436OP1(
SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0);
3438 if(common->mark_ptr != 0)
3440 if(common->control_head_ptr != 0)
3442 if(HAS_VIRTUAL_REGISTERS)
3451 while(current !=
NULL)
3455 casetype_then_trap:
3473 static SLJIT_INLINE voidcopy_ovector(compiler_common *common,
inttopbracket)
3483 if(HAS_VIRTUAL_REGISTERS)
3487 if(common->mark_ptr != 0)
3491 if(common->mark_ptr != 0)
3500 if(common->mark_ptr != 0)
3504 if(common->mark_ptr != 0)
3511GET_LOCAL_BASE(
SLJIT_S0, 0, OVECTOR_START - (has_pre ?
sizeof(
sljit_sw) : 0));
3527 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 3542GET_LOCAL_BASE(
SLJIT_R0, 0, OVECTOR_START + topbracket * 2 *
sizeof(
sljit_sw));
3554GET_LOCAL_BASE(
SLJIT_R0, 0, OVECTOR_START + (topbracket - 1) * 2 *
sizeof(
sljit_sw));
3577 SLJIT_ASSERT(common->start_used_ptr != 0 && common->start_ptr != 0
3580 if(arguments_reg != ARGUMENTS)
3581OP1(
SLJIT_MOV, arguments_reg, 0, ARGUMENTS, 0);
3594 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 3600 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 3608 static SLJIT_INLINE voidcheck_start_used_ptr(compiler_common *common)
3637 #ifdef SUPPORT_UNICODE 3638 if(common->utf || common->ucp)
3650 returncommon->fcc[c] != c;
3658 static SLJIT_INLINE unsigned intchar_othercase(compiler_common *common,
unsigned intc)
3661 #ifdef SUPPORT_UNICODE 3662 if((common->utf || common->ucp) && c > 127)
3668 static unsigned intchar_get_othercase_bit(compiler_common *common,
PCRE2_SPTRcc)
3671 unsigned intc, oc, bit;
3672 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 3676 #ifdef SUPPORT_UNICODE 3677 if(common->utf || common->ucp)
3687oc = common->fcc[c];
3705 if(c <= 127 && bit == 0x20)
3706 return(0 << 8) | 0x20;
3709 if(!is_powerof2(bit))
3712 #if PCRE2_CODE_UNIT_WIDTH == 8 3714 #ifdef SUPPORT_UNICODE 3715 if(common->utf && c > 127)
3717 n= GET_EXTRALEN(*cc);
3718 while((bit & 0x3f) == 0)
3723 return(
n<< 8) | bit;
3726 return(0 << 8) | bit;
3728 #elif PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 3730 #ifdef SUPPORT_UNICODE 3731 if(common->utf && c > 65535)
3733 if(bit >= (1u << 10))
3736 return(bit < 256) ? ((2 << 8) | bit) : ((3 << 8) | (bit >> 8));
3739 return(bit < 256) ? ((0
u<< 8) | bit) : ((1u << 8) | (bit >> 8));
3744 static voidcheck_partial(compiler_common *common,
BOOLforce)
3755 if(!force && !common->allow_empty_partial)
3764 if(common->partialmatchlabel !=
NULL)
3765JUMPTO(
SLJIT_JUMP, common->partialmatchlabel);
3774 static voidcheck_str_end(compiler_common *common, jump_list **end_reached)
3796 if(common->partialmatchlabel !=
NULL)
3797JUMPTO(
SLJIT_JUMP, common->partialmatchlabel);
3804 static voiddetect_partial_match(compiler_common *common, jump_list **backtracks)
3817 if(!common->allow_empty_partial)
3829 if(common->partialmatchlabel !=
NULL)
3830JUMPTO(
SLJIT_JUMP, common->partialmatchlabel);
3837 static voidprocess_partial_match(compiler_common *common)
3851 if(common->partialmatchlabel !=
NULL)
3858 static voiddetect_partial_match_to(compiler_common *common,
struct sljit_label*
label)
3863process_partial_match(common);
3871 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 3880OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
3882 #ifdef SUPPORT_UNICODE 3883 #if PCRE2_CODE_UNIT_WIDTH == 8 3886 if(
max< 128)
return;
3889OP1(
SLJIT_MOV, dst, dstw, STR_PTR, 0);
3891add_jump(compiler, common->invalid_utf ? &common->utfreadchar_invalid : &common->utfreadchar,
JUMP(
SLJIT_FAST_CALL));
3892OP1(
SLJIT_MOV, STR_PTR, 0, dst, dstw);
3893 if(backtracks && common->invalid_utf)
3897 #elif PCRE2_CODE_UNIT_WIDTH == 16 3900 if(
max< 0xd800)
return;
3904 if(common->invalid_utf)
3907OP1(
SLJIT_MOV, dst, dstw, STR_PTR, 0);
3910OP1(
SLJIT_MOV, STR_PTR, 0, dst, dstw);
3911 if(backtracks && common->invalid_utf)
3918OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
3921OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
3926 #elif PCRE2_CODE_UNIT_WIDTH == 32 3927 if(common->invalid_utf)
3929 if(
max< 0xd800)
return;
3931 if(backtracks !=
NULL)
3950 static voidpeek_char_back(compiler_common *common,
sljit_u32 max, jump_list **backtracks)
3956 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 3963OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
3965 #ifdef SUPPORT_UNICODE 3966 #if PCRE2_CODE_UNIT_WIDTH == 8 3969 if(
max< 128)
return;
3972 if(common->invalid_utf)
3975 if(backtracks !=
NULL)
3982 #elif PCRE2_CODE_UNIT_WIDTH == 16 3985 if(
max< 0xd800)
return;
3987 if(common->invalid_utf)
3991 if(backtracks !=
NULL)
3999OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
4003OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
4007 #elif PCRE2_CODE_UNIT_WIDTH == 32 4008 if(common->invalid_utf)
4018 #define READ_CHAR_UPDATE_STR_PTR 0x1 4019 #define READ_CHAR_UTF8_NEWLINE 0x2 4020 #define READ_CHAR_NEWLINE (READ_CHAR_UPDATE_STR_PTR | READ_CHAR_UTF8_NEWLINE) 4021 #define READ_CHAR_VALID_UTF 0x4 4024jump_list **backtracks,
sljit_u32options)
4030 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 4033 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 4043OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4046 #ifdef SUPPORT_UNICODE 4047 #if PCRE2_CODE_UNIT_WIDTH == 8 4050 if(
max< 128 && !(options & READ_CHAR_UPDATE_STR_PTR))
return;
4052 if(common->invalid_utf && !(options & READ_CHAR_VALID_UTF))
4056 if(options & READ_CHAR_UTF8_NEWLINE)
4061 if(backtracks !=
NULL)
4068 if(
min>= 0x10000)
4071 if(options & READ_CHAR_UPDATE_STR_PTR)
4073OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4077OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4078OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
4081OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4082OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
4083 if(!(options & READ_CHAR_UPDATE_STR_PTR))
4087OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4089 if(options & READ_CHAR_UPDATE_STR_PTR)
4090OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
4092 else if(
min>= 0x800 &&
max<= 0xffff)
4095 if(options & READ_CHAR_UPDATE_STR_PTR)
4097OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4101OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4102OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
4103 if(!(options & READ_CHAR_UPDATE_STR_PTR))
4107OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4109 if(options & READ_CHAR_UPDATE_STR_PTR)
4110OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
4112 else if(
max>= 0x800)
4116 else if(
max< 128)
4119OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
4123OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4124 if(!(options & READ_CHAR_UPDATE_STR_PTR))
4131OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4132 if(options & READ_CHAR_UPDATE_STR_PTR)
4133OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
4137 #elif PCRE2_CODE_UNIT_WIDTH == 16 4140 if(
max< 0xd800 && !(options & READ_CHAR_UPDATE_STR_PTR))
return;
4142 if(common->invalid_utf && !(options & READ_CHAR_VALID_UTF))
4147 if(options & READ_CHAR_UTF8_NEWLINE)
4152 if(backtracks !=
NULL)
4158 if(
max>= 0x10000)
4163OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4167OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
4177 if(options & READ_CHAR_UPDATE_STR_PTR)
4180 if(options & READ_CHAR_UPDATE_STR_PTR)
4188 if(options & READ_CHAR_UPDATE_STR_PTR)
4195 #elif PCRE2_CODE_UNIT_WIDTH == 32 4196 if(common->invalid_utf)
4198 if(backtracks !=
NULL)
4217 static voidskip_valid_char(compiler_common *common)
4220 #if (defined SUPPORT_UNICODE) && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16) 4224 #if (defined SUPPORT_UNICODE) && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16) 4227OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
4229 #if PCRE2_CODE_UNIT_WIDTH == 8 4232OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4233 #elif PCRE2_CODE_UNIT_WIDTH == 16 4239OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4248 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 4260 if(*bitset++ !=
value)
4263 while(bitset < end);
4267 static voidread_char7_type(compiler_common *common, jump_list **backtracks,
BOOLnegated)
4277OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), 0);
4287 if(common->invalid_utf)
4297OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
4305 static voidread_char8_type(compiler_common *common, jump_list **backtracks,
BOOLnegated)
4309 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 4312 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 4319OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), 0);
4322 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 4331 if(common->invalid_utf)
4334OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4337 if(common->invalid_utf)
4341OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
4343 if(common->invalid_utf)
4351 else if(common->invalid_utf)
4370 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 32 4371 if(common->invalid_utf && negated)
4375 #if PCRE2_CODE_UNIT_WIDTH != 8 4381 #if PCRE2_CODE_UNIT_WIDTH != 8 4385 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 16 4386 if(common->utf && negated)
4389 if(!common->invalid_utf)
4413OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4424 static voidmove_back(compiler_common *common, jump_list **backtracks,
BOOLmust_be_valid)
4431 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 4435 #ifdef SUPPORT_UNICODE 4436 #if PCRE2_CODE_UNIT_WIDTH == 8 4441 if(!must_be_valid && common->invalid_utf)
4443OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
4447 if(backtracks !=
NULL)
4454OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
4460 #elif PCRE2_CODE_UNIT_WIDTH == 16 4463OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
4466 if(!must_be_valid && common->invalid_utf)
4471 if(backtracks !=
NULL)
4482OP2(
SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4485 #elif PCRE2_CODE_UNIT_WIDTH == 32 4486 if(common->invalid_utf && !must_be_valid)
4488OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
4489 if(backtracks !=
NULL)
4499OP2(
SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
4511 static voidcheck_newlinechar(compiler_common *common,
intnltype, jump_list **backtracks,
BOOLjumpifmatch)
4544 #ifdef SUPPORT_UNICODE 4546 #if PCRE2_CODE_UNIT_WIDTH == 8 4547 static voiddo_utfreadchar(compiler_common *common)
4555OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4558OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4569OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
4572OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4583OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
4588OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4592 static voiddo_utfreadtype8(compiler_common *common)
4605OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4612OP2(
SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0);
4624OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
4628 static voiddo_utfreadchar_invalid(compiler_common *common)
4654OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-3));
4657OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
4670OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
4673OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4678exit_invalid[2] =
NULL;
4686three_byte_entry =
LABEL();
4693exit_invalid[3] =
NULL;
4704exit_invalid[4] =
NULL;
4713OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
4716OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4721exit_invalid[5] =
NULL;
4731exit_invalid[6] =
NULL;
4739JUMPHERE(buffer_end_close);
4744OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
4747OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
4760OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4763OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4768exit_invalid[10] =
NULL;
4779exit_invalid_label =
LABEL();
4780 for(
i= 0;
i< 11;
i++)
4787 static voiddo_utfreadnewline_invalid(compiler_common *common)
4811OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4827OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4833skip_start =
LABEL();
4840OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4848three_byte_exit =
LABEL();
4867OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4874OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4878 static voiddo_utfmoveback_invalid(compiler_common *common)
4895buffer_start_close =
CMP(
SLJIT_LESS, STR_PTR, 0, TMP2, 0);
4897OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
4910OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
4924OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4928exit_ok_label =
LABEL();
4933JUMPHERE(buffer_start_close);
4938OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4948OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
4955exit_invalid_label =
LABEL();
4962JUMPHERE(exit_invalid[4]);
4966exit_invalid_label =
LABEL();
4967 for(
i= 0;
i< 4;
i++)
4974 static voiddo_utfpeakcharback(compiler_common *common)
4982OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
4986OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-3));
4990OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-4));
4994OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
4997OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
5000OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
5003OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
5006OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
5011 static voiddo_utfpeakcharback_invalid(compiler_common *common)
5030OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
5034two_byte_entry =
LABEL();
5037OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5045OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
5048OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-3));
5052three_byte_entry =
LABEL();
5054OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
5061exit_invalid[2] =
NULL;
5071exit_invalid[3] =
NULL;
5082OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
5085OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-4));
5090OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5096exit_invalid[5] =
NULL;
5109OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
5117OP2(
SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
5120OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-3));
5131OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
5135exit_invalid_label =
LABEL();
5136 for(
i= 0;
i< 8;
i++)
5145 #if PCRE2_CODE_UNIT_WIDTH == 16 5147 static voiddo_utfreadchar_invalid(compiler_common *common)
5161OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
5169OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5172JUMPHERE(exit_invalid[0]);
5173JUMPHERE(exit_invalid[1]);
5174JUMPHERE(exit_invalid[2]);
5179 static voiddo_utfreadnewline_invalid(compiler_common *common)
5193OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
5201OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
5205JUMPHERE(exit_invalid[0]);
5206JUMPHERE(exit_invalid[1]);
5211 static voiddo_utfmoveback_invalid(compiler_common *common)
5222OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
5230JUMPHERE(exit_invalid[0]);
5231JUMPHERE(exit_invalid[1]);
5232JUMPHERE(exit_invalid[2]);
5239 static voiddo_utfpeakcharback_invalid(compiler_common *common)
5253OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
5258OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5263JUMPHERE(exit_invalid[0]);
5264JUMPHERE(exit_invalid[1]);
5265JUMPHERE(exit_invalid[2]);
5274 #define UCD_BLOCK_MASK 127 5275 #define UCD_BLOCK_SHIFT 7 5277 static voiddo_getucd(compiler_common *common)
5282 #if PCRE2_CODE_UNIT_WIDTH == 32 5286 #if defined SLJIT_DEBUG && SLJIT_DEBUG 5297 #if PCRE2_CODE_UNIT_WIDTH == 32 5311OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5317 static voiddo_getucdtype(compiler_common *common)
5322 #if PCRE2_CODE_UNIT_WIDTH == 32 5326 #if defined SLJIT_DEBUG && SLJIT_DEBUG 5337 #if PCRE2_CODE_UNIT_WIDTH == 32 5351OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5358OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
5374 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5378jump_list *newline =
NULL;
5379 sljit_u32overall_options = common->re->overall_options;
5386newlinecheck =
TRUE;
5396 if(common->nltype ==
NLTYPE_FIXED&& common->newline > 255)
5398mainloop =
LABEL();
5401OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
5402OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
5411mainloop =
LABEL();
5414read_char(common, common->nlmin, common->nlmax,
NULL, READ_CHAR_NEWLINE);
5415check_newlinechar(common, common->nltype, &newline,
TRUE);
5416CMPTO(
SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop);
5419set_jumps(newline,
LABEL());
5429 if(HAS_VIRTUAL_REGISTERS)
5431OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
5439 if(HAS_VIRTUAL_REGISTERS)
5440OP1(
SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
5444 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 5447 if(HAS_VIRTUAL_REGISTERS)
5450OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
5455add_jump(compiler, &common->abort,
CMP(
SLJIT_LESS, TMP2, 0, STR_PTR, 0));
5464newlinelabel =
LABEL();
5467OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
5470 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 5473OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
5477mainloop =
LABEL();
5480 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5481 if(common->utf && !common->invalid_utf) readuchar =
TRUE;
5483 if(newlinecheck) readuchar =
TRUE;
5486OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
5492 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5493 #if PCRE2_CODE_UNIT_WIDTH == 8 5494 if(common->invalid_utf)
5499OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
5506 else if(common->utf)
5510OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
5513 #elif PCRE2_CODE_UNIT_WIDTH == 16 5514 if(common->invalid_utf)
5519OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
5526 else if(common->utf)
5541OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
5568 chars->chars[0] = chr;
5571 chars->last_count = 1;
5576 if(
chars->chars[
i] == chr)
5579 if(
count>= MAX_DIFF_CHARS)
5581 chars->count = 255;
5589 chars->last_count++;
5592 static intscan_prefix(compiler_common *common,
PCRE2_SPTRcc, fast_forward_char_data *
chars,
intmax_chars,
sljit_u32*rec_count)
5596 int len, repeat, len_save, consumed = 0;
5600 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 5602 #elif defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 16 5611 if(*rec_count == 0)
5653cc = bracketend(cc);
5671repeat =
GET2(cc, 1);
5686 #ifdef SUPPORT_UNICODE 5687 if(common->utf && HAS_EXTRALEN(*cc))
len+= GET_EXTRALEN(*cc);
5689max_chars = scan_prefix(common, cc +
len,
chars, max_chars, rec_count);
5708alternative = cc + GET(cc, 1);
5709 while(*alternative ==
OP_ALT)
5711max_chars = scan_prefix(common, alternative + 1 +
LINK_SIZE,
chars, max_chars, rec_count);
5714alternative += GET(alternative, 1);
5723 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 5724 if(common->utf && !is_char7_bitset((
const sljit_u8*)(cc + 1),
FALSE))
5731 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5732 if(common->utf)
returnconsumed;
5737 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 5739 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5740 if(common->utf)
returnconsumed;
5748 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 5757 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 5766 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 5783 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5784 if(common->utf)
returnconsumed;
5790 #ifdef SUPPORT_UNICODE 5793 #if PCRE2_CODE_UNIT_WIDTH != 32 5794 if(common->utf)
returnconsumed;
5802repeat =
GET2(cc, 1);
5808 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 5809 if(common->utf)
returnconsumed;
5812repeat =
GET2(cc, 1);
5824 chars->count = 255;
5827 if(--max_chars == 0)
5831 while(--repeat > 0);
5850max_chars = scan_prefix(common, cc + 1,
chars, max_chars, rec_count);
5864repeat =
GET2(cc, 1);
5872 if(bytes[31] & 0x80)
5873 chars->count = 255;
5874 else if(
chars->count != 255)
5876bytes_end = bytes + 32;
5888 if((
byte& 0x1) != 0)
5897 while(
chars->count != 255 && bytes < bytes_end);
5898bytes = bytes_end - 32;
5902 if(--max_chars == 0)
5906 while(--repeat > 0);
5935 #ifdef SUPPORT_UNICODE 5936 if(common->utf && HAS_EXTRALEN(*cc))
len+= GET_EXTRALEN(*cc);
5939 if(caseless && char_has_othercase(common, cc))
5941 #ifdef SUPPORT_UNICODE 5945 if((
int)
PRIV(ord2utf)(char_othercase(common, chr), othercase) !=
len)
5952 #ifdef SUPPORT_UNICODE 5953 if(common->ucp && chr > 127)
5956othercase[0] = (chr == (
PCRE2_UCHAR)chr) ? chr : *cc;
5960othercase[0] =
TABLE_GET(chr, common->fcc, chr);
5980add_prefix_char(*cc,
chars,
len== 0);
5983add_prefix_char(*oc,
chars,
len== 0);
5985 if(--max_chars == 0)
6006 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 6009 #if PCRE2_CODE_UNIT_WIDTH == 8 6012 #elif PCRE2_CODE_UNIT_WIDTH == 16 6016 #error "Unknown code width" 6023 #ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD 6025 static BOOLcheck_fast_forward_char_pair_simd(compiler_common *common, fast_forward_char_data *
chars,
int max)
6029 sljit_s32max_offset = max_fast_forward_char_pair_offset();
6032 for(
i=
max- 1;
i>= 1;
i--)
6034 if(
chars[
i].last_count > 2)
6036a1 =
chars[
i].chars[0];
6037a2 =
chars[
i].chars[1];
6038a_pri =
chars[
i].last_count;
6046b_pri =
chars[j].last_count;
6049b1 =
chars[j].chars[0];
6050b2 =
chars[j].chars[1];
6052 if(a1 != b1 && a1 != b2 && a2 != b1 && a2 != b2)
6054max_pri = a_pri + b_pri;
6080 BOOLhas_match_end = (common->match_end_ptr != 0);
6099 #ifdef JIT_HAS_FAST_FORWARD_CHAR_SIMD 6101 if(JIT_HAS_FAST_FORWARD_CHAR_SIMD)
6103fast_forward_char_simd(common, char1, char2,
offset);
6119add_jump(compiler, &common->failed_match, partial_quit);
6121OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
6128 mask= char1 ^ char2;
6129 if(is_powerof2(
mask))
6142 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 6143 if(common->utf &&
offset> 0)
6146jumpto_if_not_utf_char_start(compiler, TMP1, start);
6153JUMPHERE(partial_quit);
6159 static SLJIT_INLINE BOOLfast_forward_first_n_chars(compiler_common *common)
6164fast_forward_char_data
chars[MAX_N_CHARS];
6169 intrange_right = -1, range_len;
6174 for(
i= 0;
i< MAX_N_CHARS;
i++)
6177 chars[
i].last_count = 0;
6181 max= scan_prefix(common, common->start,
chars, MAX_N_CHARS, &rec_count);
6187 for(
i= 0;
i<
max;
i++)
6195 chars[
i].last_count = 0;
6199 chars[
i].last_count = (
chars[
i].last_count == 1) ? 7 : 5;
6208 chars[
i].last_count = (
chars[
i].last_count == 2) ? 6 : 4;
6210 chars[
i].last_count = (
chars[
i].last_count == 2) ? 3 : 2;
6214 chars[
i].last_count = (
chars[
i].count == 255) ? 0 : 1;
6219 #ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD 6220 if(JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD && check_fast_forward_char_pair_simd(common,
chars,
max))
6228 for(
i= 0;
i<=
max;
i++)
6230 if(in_range && (
i- from) > range_len && (
chars[
i- 1].count < 255))
6232range_len =
i- from;
6233range_right =
i- 1;
6249 if(range_right >= 0)
6251update_table = (
sljit_u8*)allocate_read_only_data(common, 256);
6252 if(update_table ==
NULL)
6254memset(update_table, IN_UCHARS(range_len), 256);
6256 for(
i= 0;
i< range_len;
i++)
6260char_set =
chars[range_right -
i].chars;
6261char_set_end = char_set +
chars[range_right -
i].count;
6264 if(update_table[(*char_set) & 0xff] > IN_UCHARS(
i))
6265update_table[(*char_set) & 0xff] = IN_UCHARS(
i);
6268 while(char_set < char_set_end);
6274 for(
i= 0;
i<
max;
i++)
6276 if(range_right ==
i)
6281 if(
chars[
i].last_count >= 2)
6290 if(range_right < 0)
6301 if(common->match_end_ptr != 0)
6318 if(!HAS_VIRTUAL_REGISTERS)
6322add_jump(compiler, &common->failed_match,
CMP(
SLJIT_GREATER, STR_PTR, 0, STR_END, 0));
6324 #if PCRE2_CODE_UNIT_WIDTH == 8 || (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN) 6330 if(!HAS_VIRTUAL_REGISTERS)
6335OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
6348 if(is_powerof2(
mask))
6362 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 6363 if(common->utf &&
offset!= 0)
6367OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
6371OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
6373jumpto_if_not_utf_char_start(compiler, TMP1, start);
6383 if(common->match_end_ptr != 0)
6390 static SLJIT_INLINE voidfast_forward_first_char(compiler_common *common)
6398oc =
TABLE_GET(first_char, common->fcc, first_char);
6399 #if defined SUPPORT_UNICODE 6400 if(first_char > 127 && (common->utf || common->ucp))
6405fast_forward_first_char2(common, first_char, oc, 0);
6408 static SLJIT_INLINE voidfast_forward_newline(compiler_common *common)
6417jump_list *newline =
NULL;
6419 if(common->match_end_ptr != 0)
6425 if(common->nltype ==
NLTYPE_FIXED&& common->newline > 255)
6427 #ifdef JIT_HAS_FAST_FORWARD_CHAR_PAIR_SIMD 6430 if(HAS_VIRTUAL_REGISTERS)
6432OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
6446 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 6449OP2(
SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
6451fast_forward_char_pair_simd(common, 1, common->newline & 0xff, common->newline & 0xff, 0, (common->newline >> 8) & 0xff, (common->newline >> 8) & 0xff);
6458 if(HAS_VIRTUAL_REGISTERS)
6460OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
6474 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 6477OP2(
SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
6482OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
6483OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
6491JUMPHERE(firstchar);
6493 if(common->match_end_ptr != 0)
6498 if(HAS_VIRTUAL_REGISTERS)
6500OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
6515common->ff_newline_shortcut = loop;
6517 #ifdef JIT_HAS_FAST_FORWARD_CHAR_SIMD 6526OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
6532fast_forward_char_simd(common, common->newline, common->newline, 0);
6545read_char(common, common->nlmin, common->nlmax,
NULL, READ_CHAR_NEWLINE);
6549check_newlinechar(common, common->nltype, &newline,
FALSE);
6550set_jumps(newline, loop);
6562OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
6565 #if PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 6568OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
6569JUMPHERE(notfoundnl);
6575JUMPHERE(firstchar);
6577 if(common->match_end_ptr != 0)
6581 static BOOLoptimize_class(compiler_common *common,
const sljit_u8*bits,
BOOLnclass,
BOOL invert, jump_list **backtracks);
6583 static SLJIT_INLINE voidfast_forward_start_bits(compiler_common *common)
6586 const sljit_u8*start_bits = common->re->start_bitmap;
6589 #if PCRE2_CODE_UNIT_WIDTH != 8 6592jump_list *matches =
NULL;
6594 if(common->match_end_ptr != 0)
6597OP1(
SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);
6607add_jump(compiler, &common->failed_match, partial_quit);
6609OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
6612 if(!optimize_class(common, start_bits, (start_bits[31] & 0x80) != 0,
FALSE, &matches))
6614 #if PCRE2_CODE_UNIT_WIDTH != 8 6615 if((start_bits[31] & 0x80) != 0)
6619 #elif defined SUPPORT_UNICODE 6620 if(common->utf && is_char7_bitset(start_bits,
FALSE))
6626 if(!HAS_VIRTUAL_REGISTERS)
6639set_jumps(matches, start);
6641 #if PCRE2_CODE_UNIT_WIDTH != 8 6649JUMPHERE(partial_quit);
6651 if(common->match_end_ptr != 0)
6652OP1(
SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);
6680oc =
TABLE_GET(req_char, common->fcc, req_char);
6681 #if defined SUPPORT_UNICODE 6682 if(req_char > 127 && (common->utf || common->ucp))
6687 #ifdef JIT_HAS_FAST_REQUESTED_CHAR_SIMD 6688 if(JIT_HAS_FAST_REQUESTED_CHAR_SIMD)
6690 not_found= fast_requested_char_simd(common, req_char, oc);
6698OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(TMP1), 0);
6704bit = req_char ^ oc;
6705 if(is_powerof2(bit))
6726JUMPHERE(already_found);
6731 static voiddo_revertframes(compiler_common *common)
6738GET_LOCAL_BASE(TMP1, 0, 0);
6741mainloop =
LABEL();
6746OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
6747 if(HAS_VIRTUAL_REGISTERS)
6759GET_LOCAL_BASE(TMP1, 0, 0);
6772OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
6773 if(HAS_VIRTUAL_REGISTERS)
6787 #ifdef SUPPORT_UNICODE 6788 #define UCPCAT(bit) (1 << (bit)) 6789 #define UCPCAT2(bit1, bit2) (UCPCAT(bit1) | UCPCAT(bit2)) 6790 #define UCPCAT3(bit1, bit2, bit3) (UCPCAT(bit1) | UCPCAT(bit2) | UCPCAT(bit3)) 6791 #define UCPCAT_RANGE(start, end) (((1 << ((end) + 1)) - 1) - ((1 << (start)) - 1)) 6792 #define UCPCAT_L UCPCAT_RANGE(ucp_Ll, ucp_Lu) 6793 #define UCPCAT_N UCPCAT_RANGE(ucp_Nd, ucp_No) 6794 #define UCPCAT_ALL ((1 << (ucp_Zs + 1)) - 1) 6797 static voidcheck_wordboundary(compiler_common *common,
BOOLucp)
6801jump_list *skipread_list =
NULL;
6802 #ifdef SUPPORT_UNICODE 6804jump_list *invalid_utf1 =
NULL;
6806jump_list *invalid_utf2 =
NULL;
6807 #if PCRE2_CODE_UNIT_WIDTH != 8 || defined SUPPORT_UNICODE 6816OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
6821 #ifdef SUPPORT_UNICODE 6822 if(common->invalid_utf)
6824peek_char_back(common, READ_CHAR_MAX, &invalid_utf1);
6828OP1(
SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
6831check_start_used_ptr(common);
6832OP1(
SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
6840peek_char_back(common, READ_CHAR_MAX,
NULL);
6844check_start_used_ptr(common);
6845read_char(common, 0, READ_CHAR_MAX,
NULL, READ_CHAR_UPDATE_STR_PTR);
6850 #ifdef SUPPORT_UNICODE 6861 #if PCRE2_CODE_UNIT_WIDTH != 8 6863 #elif defined SUPPORT_UNICODE 6872 #if PCRE2_CODE_UNIT_WIDTH != 8 6874 #elif defined SUPPORT_UNICODE 6882check_str_end(common, &skipread_list);
6886 #ifdef SUPPORT_UNICODE 6900 #if PCRE2_CODE_UNIT_WIDTH != 8 6904 #elif defined SUPPORT_UNICODE 6913 #if PCRE2_CODE_UNIT_WIDTH != 8 6915 #elif defined SUPPORT_UNICODE 6920set_jumps(skipread_list,
LABEL());
6926 #ifdef SUPPORT_UNICODE 6927 if(common->invalid_utf)
6929set_jumps(invalid_utf1,
LABEL());
6938set_jumps(invalid_utf2,
LABEL());
6946 static BOOLoptimize_class_ranges(compiler_common *common,
const sljit_u8*bits,
BOOLnclass,
BOOL invert, jump_list **backtracks)
6950 intranges[MAX_CLASS_RANGE_SIZE];
6952 int i,
byte, length = 0;
6954bit = bits[0] & 0x1;
6958 for(
i= 0;
i< 256; )
6961 if((
i& 0x7) == 0 && bits[
byte] ==
all)
6965cbit = (bits[
byte] >> (
i& 0x7)) & 0x1;
6968 if(length >= MAX_CLASS_RANGE_SIZE)
6970ranges[length] =
i;
6979 if(((bit == 0) && nclass) || ((bit == 1) && !nclass))
6981 if(length >= MAX_CLASS_RANGE_SIZE)
6983ranges[length] = 256;
6987 if(length < 0 || length > 4)
6990bit = bits[0] & 0x1;
6991 if(
invert) bit ^= 0x1;
6994 if(length == 0 && bit == 0)
7008 if(ranges[0] + 1 != ranges[1])
7021 if(ranges[0] + 1 != ranges[1])
7032 if(ranges[1] + 1 != ranges[2])
7042 if((ranges[1] - ranges[0]) == (ranges[3] - ranges[2])
7043&& (ranges[0] | (ranges[2] - ranges[0])) == ranges[2]
7044&& (ranges[1] & (ranges[2] - ranges[0])) == 0
7045&& is_powerof2(ranges[2] - ranges[0]))
7047 SLJIT_ASSERT((ranges[0] & (ranges[2] - ranges[0])) == 0 && (ranges[2] & ranges[3] & (ranges[2] - ranges[0])) != 0);
7049 if(ranges[2] + 1 != ranges[3])
7062 if(ranges[0] + 1 != ranges[1])
7071 if(ranges[2] + 1 != ranges[3])
7083 if(ranges[1] + 1 != ranges[2])
7098 static BOOLoptimize_class_chars(compiler_common *common,
const sljit_u8*bits,
BOOLnclass,
BOOL invert, jump_list **backtracks)
7102 uint16_tchar_list[MAX_CLASS_CHARS_SIZE];
7105 int i, j, k,
len, c;
7112 for(
i= 0;
i< 32;
i++)
7128 if((c & 0x20) != 0)
7130 for(k = 0; k <
len; k++)
7131 if(char_list[k] == c - 0x20)
7133char_list[k] |= 0x120;
7140 if(
len>= MAX_CLASS_CHARS_SIZE)
7157 if(char_list[0] == 0)
7168 if((char_list[
i] & 0x100) != 0)
7182 for(
i= 0;
i<
len;
i++)
7183 if((char_list[
i] & 0x100) != 0)
7202 if(optimize_class_ranges(common, bits, nclass,
invert, backtracks))
7204 returnoptimize_class_chars(common, bits, nclass,
invert, backtracks);
7207 static voidcheck_anynewline(compiler_common *common)
7218 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 7219 #if PCRE2_CODE_UNIT_WIDTH == 8 7226 #if PCRE2_CODE_UNIT_WIDTH == 8 7234 static voidcheck_hspace(compiler_common *common)
7246 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 7247 #if PCRE2_CODE_UNIT_WIDTH == 8 7264 #if PCRE2_CODE_UNIT_WIDTH == 8 7273 static voidcheck_vspace(compiler_common *common)
7284 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 7285 #if PCRE2_CODE_UNIT_WIDTH == 8 7292 #if PCRE2_CODE_UNIT_WIDTH == 8 7301 static voiddo_casefulcmp(compiler_common *common)
7309 if(HAS_VIRTUAL_REGISTERS)
7311char1_reg = STR_END;
7312char2_reg = STACK_TOP;
7317char2_reg = RETURN_ADDR;
7321OP2(
SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
7323 if(char1_reg == STR_END)
7325OP1(
SLJIT_MOV, TMP3, 0, char1_reg, 0);
7326OP1(
SLJIT_MOV, RETURN_ADDR, 0, char2_reg, 0);
7360OP1(MOV_UCHAR, char1_reg, 0,
SLJIT_MEM1(TMP1), 0);
7361OP1(MOV_UCHAR, char2_reg, 0,
SLJIT_MEM1(STR_PTR), 0);
7372 if(char1_reg == STR_END)
7374OP1(
SLJIT_MOV, char1_reg, 0, TMP3, 0);
7375OP1(
SLJIT_MOV, char2_reg, 0, RETURN_ADDR, 0);
7381 static voiddo_caselesscmp(compiler_common *common)
7386 intchar1_reg = STR_END;
7391 if(HAS_VIRTUAL_REGISTERS)
7393char2_reg = STACK_TOP;
7394lcc_table = STACK_LIMIT;
7398char2_reg = RETURN_ADDR;
7408OP2(
SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
7412 if(char2_reg == STACK_TOP)
7414OP1(
SLJIT_MOV, TMP3, 0, char2_reg, 0);
7415OP1(
SLJIT_MOV, RETURN_ADDR, 0, lcc_table, 0);
7426 else if(opt_type == 2)
7438OP1(MOV_UCHAR, char1_reg, 0,
SLJIT_MEM1(TMP1), 0);
7439OP1(MOV_UCHAR, char2_reg, 0,
SLJIT_MEM1(STR_PTR), 0);
7443 #if PCRE2_CODE_UNIT_WIDTH != 8 7447 #if PCRE2_CODE_UNIT_WIDTH != 8 7452 #if PCRE2_CODE_UNIT_WIDTH != 8 7469 if(char2_reg == STACK_TOP)
7471OP1(
SLJIT_MOV, char2_reg, 0, TMP3, 0);
7472OP1(
SLJIT_MOV, lcc_table, 0, RETURN_ADDR, 0);
7480compare_context *
context, jump_list **backtracks)
7483 unsigned intothercasebit = 0;
7485 #ifdef SUPPORT_UNICODE 7489 if(caseless && char_has_othercase(common, cc))
7491othercasebit = char_get_othercase_bit(common, cc);
7494 #if PCRE2_CODE_UNIT_WIDTH == 8 7495othercasechar = cc + (othercasebit >> 8);
7496othercasebit &= 0xff;
7497 #elif PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 7502othercasechar = cc + (othercasebit >> 9);
7503 if((othercasebit & 0x100) != 0)
7504othercasebit = (othercasebit & 0xff) << 8;
7506othercasebit &= 0xff;
7510 if(
context->sourcereg == -1)
7512 #if PCRE2_CODE_UNIT_WIDTH == 8 7513 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED 7516 else if(
context->length >= 2)
7521 #elif PCRE2_CODE_UNIT_WIDTH == 16 7522 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED 7528 #elif PCRE2_CODE_UNIT_WIDTH == 32 7534 #ifdef SUPPORT_UNICODE 7536 if(common->utf && HAS_EXTRALEN(*cc))
7537utflength += GET_EXTRALEN(*cc);
7543 context->length -= IN_UCHARS(1);
7544 #if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED) && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16) 7547 if(othercasebit != 0 && othercasechar == cc)
7559 #if PCRE2_CODE_UNIT_WIDTH == 8 7567 else if(
context->length >= 2)
7569 #if PCRE2_CODE_UNIT_WIDTH == 8 7570 else if(
context->length >= 1)
7584 if(
context->oc.asushort != 0)
7589 #if PCRE2_CODE_UNIT_WIDTH == 8 7591 if(
context->oc.asbyte != 0)
7612 if(othercasebit != 0 && othercasechar == cc)
7623 #ifdef SUPPORT_UNICODE 7626 while(utflength > 0);
7632 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 7634 #define SET_CHAR_OFFSET(value) \ 7635 if ((value) != charoffset) \ 7637 if ((value) < charoffset) \ 7638 OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(charoffset - (value))); \ 7640 OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)((value) - charoffset)); \ 7642 charoffset = (value); 7646 #ifdef SUPPORT_UNICODE 7647 #define XCLASS_SAVE_CHAR 0x001 7648 #define XCLASS_CHAR_SAVED 0x002 7649 #define XCLASS_HAS_TYPE 0x004 7650 #define XCLASS_HAS_SCRIPT 0x008 7651 #define XCLASS_HAS_SCRIPT_EXTENSION 0x010 7652 #define XCLASS_HAS_BOOL 0x020 7653 #define XCLASS_HAS_BIDICL 0x040 7654 #define XCLASS_NEEDS_UCD (XCLASS_HAS_TYPE | XCLASS_HAS_SCRIPT | XCLASS_HAS_SCRIPT_EXTENSION | XCLASS_HAS_BOOL | XCLASS_HAS_BIDICL) 7655 #define XCLASS_SCRIPT_EXTENSION_NOTPROP 0x080 7656 #define XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR 0x100 7657 #define XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0 0x200 7660 static voidcompile_xclass_matchingpath(compiler_common *common,
PCRE2_SPTRcc, jump_list **backtracks)
7663jump_list *found =
NULL;
7664jump_list **list = (cc[0] &
XCL_NOT) == 0 ? &found : backtracks;
7668 intcompares, invertcmp, numberofcmps;
7669 #if defined SUPPORT_UNICODE && (PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16) 7673 #ifdef SUPPORT_UNICODE 7702 #ifdef SUPPORT_UNICODE 7703unicode_status |= XCLASS_SAVE_CHAR;
7713 #ifdef SUPPORT_UNICODE 7714unicode_status |= XCLASS_SAVE_CHAR;
7717 #ifdef SUPPORT_UNICODE 7725other_cases =
PRIV(ucd_caseless_sets) + cc[1];
7728 if(*other_cases >
max)
max= *other_cases;
7729 if(*other_cases <
min)
min= *other_cases;
7735 max= READ_CHAR_MAX;
7756items = UCPCAT_RANGE(
PRIV(ucp_typerange)[(
int)cc[1] * 2],
PRIV(ucp_typerange)[(
int)cc[1] * 2 + 1]);
7760items = UCPCAT(cc[1]);
7764items = UCPCAT2(
ucp_Mn,
ucp_Pc) | UCPCAT_L | UCPCAT_N;
7768items = UCPCAT_L | UCPCAT_N;
7772unicode_status |= XCLASS_HAS_SCRIPT_EXTENSION;
7775unicode_status |= XCLASS_SCRIPT_EXTENSION_NOTPROP;
7782unicode_status |= XCLASS_HAS_SCRIPT;
7790unicode_status |= XCLASS_SAVE_CHAR | XCLASS_HAS_TYPE;
7796unicode_status |= XCLASS_SAVE_CHAR;
7800unicode_status |= XCLASS_HAS_BOOL;
7804unicode_status |= XCLASS_HAS_BIDICL;
7815items ^= UCPCAT_ALL;
7816category_list |= items;
7817unicode_status |= XCLASS_HAS_TYPE;
7826 #ifdef SUPPORT_UNICODE 7827 if(category_list == UCPCAT_ALL)
7830compile_char1_matchingpath(common,
OP_ALLANY, cc, backtracks,
FALSE);
7831 if(list == backtracks)
7836 if(compares == 0 && category_list == 0)
7839compile_char1_matchingpath(common,
OP_ALLANY, cc, backtracks,
FALSE);
7840 if(list != backtracks)
7851read_char(common,
min,
max, backtracks, READ_CHAR_UPDATE_STR_PTR);
7854 #ifdef SUPPORT_UNICODE 7855read_char(common,
min,
max, (unicode_status & XCLASS_NEEDS_UCD) ? backtracks :
NULL, 0);
7866 if(!optimize_class(common, (
const sljit_u8*)cc, (((
const sljit_u8*)cc)[31] & 0x80) != 0,
TRUE, &found))
7887 else if((cc[-1] &
XCL_MAP) != 0)
7889OP1(
SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
7890 #ifdef SUPPORT_UNICODE 7891unicode_status |= XCLASS_CHAR_SAVED;
7895 #if PCRE2_CODE_UNIT_WIDTH == 8 7908 #if PCRE2_CODE_UNIT_WIDTH == 8 7914OP1(
SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
7918 #ifdef SUPPORT_UNICODE 7919 if(unicode_status & XCLASS_NEEDS_UCD)
7921 if((unicode_status & (XCLASS_SAVE_CHAR | XCLASS_CHAR_SAVED)) == XCLASS_SAVE_CHAR)
7922OP1(
SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
7924 #if PCRE2_CODE_UNIT_WIDTH == 32 7938OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
7943OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
7947 if(category_list != 0)
7950 if(unicode_status & XCLASS_HAS_BIDICL)
7975invertcmp = (compares == 0 && list != backtracks);
7979add_jump(compiler, compares > 0 ? list : backtracks, jump);
7988 if(unicode_status & XCLASS_HAS_BOOL)
8014invertcmp = (compares == 0 && list != backtracks);
8019add_jump(compiler, compares > 0 ? list : backtracks,
JUMP(
SLJIT_NOT_ZERO^ invertcmp));
8028 if(unicode_status & XCLASS_HAS_SCRIPT)
8058invertcmp = (compares == 0 && list != backtracks);
8062add_jump(compiler, compares > 0 ? list : backtracks,
CMP(
SLJIT_EQUAL^ invertcmp, TMP1, 0,
SLJIT_IMM, (
int)cc[1]));
8071 if(unicode_status & XCLASS_HAS_SCRIPT_EXTENSION)
8077 if(unicode_status & XCLASS_SCRIPT_EXTENSION_NOTPROP)
8079 if(unicode_status & XCLASS_HAS_TYPE)
8081 if(unicode_status & XCLASS_SAVE_CHAR)
8084unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0;
8088OP1(
SLJIT_MOV, RETURN_ADDR, 0, TMP2, 0);
8089unicode_status |= XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR;
8115invertcmp = (compares == 0 && list != backtracks);
8123add_jump(compiler, backtracks, jump);
8130add_jump(compiler, compares > 0 ? list : backtracks,
JUMP(
SLJIT_NOT_ZERO^ invertcmp));
8139 if(unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_LOCALS0)
8141 else if(unicode_status & XCLASS_SCRIPT_EXTENSION_RESTORE_RETURN_ADDR)
8142OP1(
SLJIT_MOV, TMP2, 0, RETURN_ADDR, 0);
8146 if(unicode_status & XCLASS_SAVE_CHAR)
8147OP1(
SLJIT_MOV, TMP1, 0, RETURN_ADDR, 0);
8149 if(unicode_status & XCLASS_HAS_TYPE)
8151 if(unicode_status & XCLASS_SAVE_CHAR)
8152typereg = RETURN_ADDR;
8157 if(category_list > 0)
8160invertcmp = (compares == 0 && list != backtracks);
8162add_jump(compiler, compares > 0 ? list : backtracks,
JUMP(
SLJIT_NOT_ZERO^ invertcmp));
8175invertcmp = (compares == 0 && list != backtracks);
8189 else if(numberofcmps > 0)
8215 else if(numberofcmps > 0)
8228 #ifdef SUPPORT_UNICODE 8269other_cases =
PRIV(ucd_caseless_sets) + cc[1];
8274 SLJIT_ASSERT(other_cases[0] < other_cases[1] && other_cases[1] < other_cases[2]);
8277 if(is_powerof2(other_cases[1] ^ other_cases[0]))
8279 if(charoffset == 0)
8290 else if(is_powerof2(other_cases[2] ^ other_cases[1]))
8292 if(charoffset == 0)
8329SET_CHAR_OFFSET(0xa0);
8347SET_CHAR_OFFSET(0x2066);
8373SET_CHAR_OFFSET(0x2066);
8401SET_CHAR_OFFSET(
CHAR_A);
8406SET_CHAR_OFFSET(
CHAR_0);
8410SET_CHAR_OFFSET(0xff10);
8416SET_CHAR_OFFSET(0xff21);
8420SET_CHAR_OFFSET(0xff41);
8424SET_CHAR_OFFSET(0xff10);
8440add_jump(compiler, compares > 0 ? list : backtracks, jump);
8445set_jumps(found,
LABEL());
8448 #undef SET_TYPE_OFFSET 8449 #undef SET_CHAR_OFFSET 8461 if(HAS_VIRTUAL_REGISTERS)
8463OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
8472 if(HAS_VIRTUAL_REGISTERS)
8474OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
8487 #ifdef SUPPORT_UNICODE 8488 if(common->invalid_utf)
8501 if(common->nltype ==
NLTYPE_FIXED&& common->newline > 255)
8504OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
8515check_partial(common,
TRUE);
8519OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
8526OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
8532OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
8539OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
8547add_jump(compiler, backtracks,
CMP(
SLJIT_LESS, TMP2, 0, STR_END, 0));
8553read_char(common, common->nlmin, common->nlmax, backtracks, READ_CHAR_UPDATE_STR_PTR);
8565check_partial(common,
TRUE);
8569add_jump(compiler, backtracks,
CMP(
SLJIT_LESS, STR_PTR, 0, STR_END, 0));
8571check_partial(common,
TRUE);
8575 if(HAS_VIRTUAL_REGISTERS)
8577OP1(
SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
8584 if(!common->endonly)
8585compile_simple_assertion_matchingpath(common,
OP_EODN, cc, backtracks);
8588add_jump(compiler, backtracks,
CMP(
SLJIT_LESS, STR_PTR, 0, STR_END, 0));
8589check_partial(common,
FALSE);
8595 if(HAS_VIRTUAL_REGISTERS)
8597OP1(
SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
8603check_partial(common,
FALSE);
8607 if(common->nltype ==
NLTYPE_FIXED&& common->newline > 255)
8610OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
8612add_jump(compiler, backtracks,
CMP(
SLJIT_GREATER, TMP2, 0, STR_END, 0));
8618check_partial(common,
TRUE);
8623OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
8629peek_char(common, common->nlmax, TMP3, 0,
NULL);
8630check_newlinechar(common, common->nltype, backtracks,
FALSE);
8636 if(HAS_VIRTUAL_REGISTERS)
8638OP1(
SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
8640add_jump(compiler, backtracks,
CMP(
SLJIT_GREATER, STR_PTR, 0, TMP1, 0));
8647add_jump(compiler, backtracks,
CMP(
SLJIT_GREATER, STR_PTR, 0, TMP1, 0));
8655 if(HAS_VIRTUAL_REGISTERS)
8657OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
8672 if(!common->alt_circumflex)
8675 if(common->nltype ==
NLTYPE_FIXED&& common->newline > 255)
8678add_jump(compiler, backtracks,
CMP(
SLJIT_LESS, TMP1, 0, TMP2, 0));
8679OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
8680OP1(MOV_UCHAR, TMP2, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
8686peek_char_back(common, common->nlmax, backtracks);
8687check_newlinechar(common, common->nltype, backtracks,
FALSE);
8696 #ifdef SUPPORT_UNICODE 8698 #if PCRE2_CODE_UNIT_WIDTH != 32 8708 int lgb, rgb, ricount;
8729 if((
PRIV(ucp_gbtable)[
lgb] & (1 << rgb)) == 0)
8747 while(bptr > start_subject)
8759 if((ricount & 1) != 0)
break;
8776 while(cc < end_subject);
8791 int lgb, rgb, ricount;
8801GETCHARINC_INVALID(c, cc, end_subject,
break);
8812 if((
PRIV(ucp_gbtable)[
lgb] & (1 << rgb)) == 0)
8830 while(bptr > start_subject)
8832GETCHARBACK_INVALID(c, bptr, start_subject,
break);
8840 if((ricount & 1) != 0)
8858 while(cc < end_subject);
8871 int lgb, rgb, ricount;
8880 #if PCRE2_CODE_UNIT_WIDTH == 32 8886 while(cc < end_subject)
8889 #if PCRE2_CODE_UNIT_WIDTH == 32 8895 if((
PRIV(ucp_gbtable)[
lgb] & (1 << rgb)) == 0)
8913 while(bptr > start_subject)
8917 #if PCRE2_CODE_UNIT_WIDTH == 32 8927 if((ricount & 1) != 0)
8954 unsigned intc, oc, bit;
8957jump_list *end_list;
8958 #ifdef SUPPORT_UNICODE 8968detect_partial_match(common, backtracks);
8969 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 8983detect_partial_match(common, backtracks);
8984 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 8997detect_partial_match(common, backtracks);
8998 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 9010detect_partial_match(common, backtracks);
9011read_char(common, common->nlmin, common->nlmax, backtracks, READ_CHAR_UPDATE_STR_PTR);
9012 if(common->nltype ==
NLTYPE_FIXED&& common->newline > 255)
9019check_str_end(common, &end_list);
9021OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
9023set_jumps(end_list,
LABEL());
9027check_newlinechar(common, common->nltype, backtracks,
TRUE);
9032detect_partial_match(common, backtracks);
9033 #ifdef SUPPORT_UNICODE 9034 if(common->utf && common->invalid_utf)
9036read_char(common, 0, READ_CHAR_MAX, backtracks, READ_CHAR_UPDATE_STR_PTR);
9041skip_valid_char(common);
9046detect_partial_match(common, backtracks);
9050 #ifdef SUPPORT_UNICODE 9055propdata[2] = cc[0];
9056propdata[3] = cc[1];
9059detect_partial_match(common, backtracks);
9060compile_xclass_matchingpath(common, propdata, backtracks);
9066detect_partial_match(common, backtracks);
9067read_char(common, common->bsr_nlmin, common->bsr_nlmax,
NULL, 0);
9074check_str_end(common, &end_list);
9075OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), 0);
9080check_newlinechar(common, common->bsr_nltype, backtracks,
FALSE);
9081set_jumps(end_list,
LABEL());
9089detect_partial_match(common, backtracks);
9092read_char(common, 0x9, 0x3000, backtracks, READ_CHAR_UPDATE_STR_PTR);
9094read_char(common, 0x9, 0x3000,
NULL, 0);
9104detect_partial_match(common, backtracks);
9107read_char(common, 0xa, 0x2029, backtracks, READ_CHAR_UPDATE_STR_PTR);
9109read_char(common, 0xa, 0x2029,
NULL, 0);
9116 #ifdef SUPPORT_UNICODE 9119detect_partial_match(common, backtracks);
9124 #if PCRE2_CODE_UNIT_WIDTH != 32 9127 if(common->invalid_utf)
9132 if(common->invalid_utf)
9142check_partial(common,
TRUE);
9151 #ifdef SUPPORT_UNICODE 9152 if(common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);
9156detect_partial_match(common, backtracks);
9158 if(
type==
OP_CHAR|| !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0)
9162add_jump(compiler, backtracks,
CMP(
SLJIT_GREATER, STR_PTR, 0, STR_END, 0));
9164 context.length = IN_UCHARS(length);
9166 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED 9172 #ifdef SUPPORT_UNICODE 9186oc = char_othercase(common, c);
9187read_char(common, c < oc ? c : oc, c > oc ? c : oc,
NULL, 0);
9208detect_partial_match(common, backtracks);
9211 #ifdef SUPPORT_UNICODE 9214 #if PCRE2_CODE_UNIT_WIDTH == 8 9216 if(c < 128 && !common->invalid_utf)
9219 if(
type==
OP_NOT|| !char_has_othercase(common, cc))
9231OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
9245 if(
type==
OP_NOT|| !char_has_othercase(common, cc))
9247read_char(common, c, c, backtracks, READ_CHAR_UPDATE_STR_PTR);
9252oc = char_othercase(common, c);
9253read_char(common, c < oc ? c : oc, c > oc ? c : oc, backtracks, READ_CHAR_UPDATE_STR_PTR);
9255 if(is_powerof2(bit))
9271detect_partial_match(common, backtracks);
9273 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 9276read_char(common, 0, bit, backtracks, READ_CHAR_UPDATE_STR_PTR);
9278read_char(common, 0, bit,
NULL, 0);
9281read_char(common, 0, 255, backtracks, READ_CHAR_UPDATE_STR_PTR);
9283read_char(common, 0, 255,
NULL, 0);
9289 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH == 8 9296add_jump(compiler, backtracks, jump[0]);
9300 #elif PCRE2_CODE_UNIT_WIDTH != 8 9304add_jump(compiler, backtracks, jump[0]);
9316 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 9317 if(jump[0] !=
NULL)
9322 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 9325detect_partial_match(common, backtracks);
9326compile_xclass_matchingpath(common, cc +
LINK_SIZE, backtracks);
9327 returncc + GET(cc, 0) - 1;
9352 #ifdef SUPPORT_UNICODE 9353 if(common->utf && HAS_EXTRALEN(cc[1]))
9354 size+= GET_EXTRALEN(cc[1]);
9360 #ifdef SUPPORT_UNICODE 9363 if(char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
9365 else if(HAS_EXTRALEN(cc[1]))
9366 size+= GET_EXTRALEN(cc[1]);
9370 if(char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
9386add_jump(compiler, backtracks,
CMP(
SLJIT_GREATER, STR_PTR, 0, STR_END, 0));
9389 #if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED 9392 docc = byte_sequence_compare(common, *cc ==
OP_CHARI, cc + 1, &
context, backtracks);
while(
context.length > 0);
9397 returncompile_char1_matchingpath(common, *cc, cc + 1, backtracks,
TRUE);
9401 static voidcompile_matchingpath(compiler_common *,
PCRE2_SPTR,
PCRE2_SPTR, backtrack_common *);
9402 static voidcompile_backtrackingpath(compiler_common *,
structbacktrack_common *);
9404 #define PUSH_BACKTRACK(size, ccstart, error) \ 9407 backtrack = sljit_alloc_memory(compiler, (size)); \ 9408 if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) \ 9410 memset(backtrack, 0, size); \ 9411 backtrack->prev = parent->top; \ 9412 backtrack->cc = (ccstart); \ 9413 parent->top = backtrack; \ 9417 #define PUSH_BACKTRACK_NOVALUE(size, ccstart) \ 9420 backtrack = sljit_alloc_memory(compiler, (size)); \ 9421 if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) \ 9423 memset(backtrack, 0, size); \ 9424 backtrack->prev = parent->top; \ 9425 backtrack->cc = (ccstart); \ 9426 parent->top = backtrack; \ 9430 #define BACKTRACK_AS(type) ((type *)backtrack) 9432 static voidcompile_dnref_search(compiler_common *common,
PCRE2_SPTRcc, jump_list **backtracks)
9437 PCRE2_SPTRslot = common->name_table +
GET2(cc, 1) * common->name_entry_size;
9439jump_list *found =
NULL;
9446 while(
count-- > 0)
9449GET_LOCAL_BASE(TMP2, 0, OVECTOR(
offset));
9451slot += common->name_entry_size;
9455GET_LOCAL_BASE(TMP2, 0, OVECTOR(
offset));
9456 if(backtracks !=
NULL&& !common->unset_backref)
9459set_jumps(found,
LABEL());
9462 static voidcompile_ref_matchingpath(compiler_common *common,
PCRE2_SPTRcc, jump_list **backtracks,
BOOLwithchecks,
BOOLemptyfail)
9470 #if defined SUPPORT_UNICODE 9473jump_list *no_match =
NULL;
9474 intsource_reg = COUNT_MATCH;
9475 intsource_end_reg = ARGUMENTS;
9476 intchar1_reg = STACK_LIMIT;
9484 if(withchecks && !common->unset_backref)
9490 #if defined SUPPORT_UNICODE 9491 if(common->utf && *cc ==
OP_REFI)
9500 if(withchecks && emptyfail)
9501add_jump(compiler, backtracks,
CMP(
SLJIT_EQUAL, TMP1, 0, TMP2, 0));
9507OP1(
SLJIT_MOV, source_reg, 0, TMP1, 0);
9508OP1(
SLJIT_MOV, source_end_reg, 0, TMP2, 0);
9516OP1(
SLJIT_MOV, STR_PTR, 0, source_reg, 0);
9518read_char(common, 0, READ_CHAR_MAX,
NULL, READ_CHAR_UPDATE_STR_PTR | READ_CHAR_VALID_UTF);
9520OP1(
SLJIT_MOV, source_reg, 0, STR_PTR, 0);
9522OP1(
SLJIT_MOV, char1_reg, 0, TMP1, 0);
9525read_char(common, 0, READ_CHAR_MAX, &no_match, READ_CHAR_UPDATE_STR_PTR);
9527CMPTO(
SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop);
9535OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
9541OP2(
SLJIT_ADD, TMP1, 0, TMP1, 0, TMP3, 0);
9542CMPTO(
SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop);
9548caseless_loop =
LABEL();
9555set_jumps(no_match,
LABEL());
9571check_partial(common,
FALSE);
9592OP2(
SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
9595add_jump(compiler, backtracks, partial);
9605OP2(
SLJIT_SUB, TMP2, 0, TMP2, 0, STR_PTR, 0);
9606OP2(
SLJIT_ADD, TMP2, 0, TMP2, 0, STR_END, 0);
9608OP1(
SLJIT_MOV, STR_PTR, 0, STR_END, 0);
9612check_partial(common,
FALSE);
9614JUMPHERE(nopartial);
9621add_jump(compiler, backtracks, jump);
9631backtrack_common *backtrack;
9641PUSH_BACKTRACK(
sizeof(ref_iterator_backtrack), cc,
NULL);
9650minimize = (
type& 0x1) != 0;
9686allocate_stack(common, 2);
9699compile_dnref_search(common, ccbegin,
NULL);
9709allocate_stack(common, 1);
9716 if(!common->unset_backref)
9722compile_dnref_search(common, ccbegin, &backtrack->own_backtracks);
9735compile_ref_matchingpath(common, ccbegin, &backtrack->own_backtracks,
FALSE,
FALSE);
9747allocate_stack(common, 1);
9757allocate_stack(common, 1);
9762JUMPHERE(zerolength);
9763BACKTRACK_AS(ref_iterator_backtrack)->matchingpath =
LABEL();
9765count_match(common);
9769allocate_stack(common, ref ? 2 : 3);
9784compile_dnref_search(common, ccbegin,
NULL);
9797 if(!common->unset_backref)
9803compile_dnref_search(common, ccbegin, &backtrack->own_backtracks);
9810BACKTRACK_AS(ref_iterator_backtrack)->matchingpath =
LABEL();
9816compile_ref_matchingpath(common, ccbegin, &backtrack->own_backtracks,
TRUE,
TRUE);
9831JUMPHERE(zerolength);
9833count_match(common);
9840backtrack_common *backtrack;
9841recurse_entry *entry = common->entries;
9845 BOOLneeds_control_head;
9847PUSH_BACKTRACK(
sizeof(recurse_backtrack), cc,
NULL);
9850 if(get_framesize(common, common->start + start,
NULL,
TRUE, &needs_control_head) == no_stack)
9852start_cc = common->start + start;
9853compile_matchingpath(common, next_opcode(common, start_cc), bracketend(start_cc) - (1 +
LINK_SIZE), backtrack);
9854BACKTRACK_AS(recurse_backtrack)->inlined_pattern =
TRUE;
9858 while(entry !=
NULL)
9860 if(entry->start == start)
9863entry = entry->next;
9871entry->next =
NULL;
9872entry->entry_label =
NULL;
9873entry->backtrack_label =
NULL;
9874entry->entry_calls =
NULL;
9875entry->backtrack_calls =
NULL;
9876entry->start = start;
9879 prev->next = entry;
9881common->entries = entry;
9884BACKTRACK_AS(recurse_backtrack)->entry = entry;
9886 if(entry->entry_label ==
NULL)
9892BACKTRACK_AS(recurse_backtrack)->matchingpath =
LABEL();
9902 if(arguments->callout ==
NULL)
9907begin = arguments->begin;
9908ovector = (
PCRE2_SIZE*)(callout_block + 1);
9909oveccount = callout_block->capture_top;
9913callout_block->version = 2;
9914callout_block->callout_flags = 0;
9917callout_block->subject_length = arguments->end - arguments->begin;
9918callout_block->start_match = jit_ovector[0] - begin;
9919callout_block->current_position = (
PCRE2_SPTR)callout_block->offset_vector - begin;
9920callout_block->subject = begin;
9923callout_block->capture_top = 1;
9924callout_block->offset_vector = ovector;
9933 while(--oveccount != 0)
9937ovector[0] = (
PCRE2_SIZE)(jit_ovector[0] - begin);
9938ovector[1] = (
PCRE2_SIZE)(jit_ovector[1] - begin);
9941callout_block->capture_top = capture_top;
9947 return(arguments->callout)(callout_block, arguments->callout_data);
9950 #define CALLOUT_ARG_OFFSET(arg) \ 9951 SLJIT_OFFSETOF(pcre2_callout_block, arg) 9956backtrack_common *backtrack;
9958 unsigned intcallout_length = (*cc ==
OP_CALLOUT)
9963 sljit_uwcallout_arg_size = (common->re->top_bracket + 1) * 2 * SSIZE_OF(
sw);
9965PUSH_BACKTRACK(
sizeof(backtrack_common), cc,
NULL);
9969allocate_stack(common, callout_arg_size);
9973OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
9982 if(common->mark_ptr != 0)
9985OP1(mov_opcode,
SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position),
SLJIT_IMM, GET(cc, 1));
9997value2 = (callout_length - (1 + 4*
LINK_SIZE+ 2));
10002OP1(mov_opcode,
SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_string_length),
SLJIT_IMM, value2);
10003OP1(mov_opcode,
SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_string_offset),
SLJIT_IMM, value3);
10012GET_LOCAL_BASE(
SLJIT_R2, 0, OVECTOR_START);
10015free_stack(common, callout_arg_size);
10020 if(common->abort_label ==
NULL)
10024 returncc + callout_length;
10027 #undef CALLOUT_ARG_SIZE 10028 #undef CALLOUT_ARG_OFFSET 10030 static PCRE2_SPTRcompile_reverse_matchingpath(compiler_common *common,
PCRE2_SPTRcc, backtrack_common *parent)
10033backtrack_common *backtrack =
NULL;
10034jump_list **reverse_failed;
10035 unsigned intlmin, lmax;
10036 #ifdef SUPPORT_UNICODE 10045reverse_failed = &parent->own_backtracks;
10046lmin =
GET2(cc, 1);
10055PUSH_BACKTRACK(
sizeof(vreverse_backtrack), cc,
NULL);
10057reverse_failed = &backtrack->own_backtracks;
10058lmin =
GET2(cc, 1);
10065 if(HAS_VIRTUAL_REGISTERS)
10067OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
10073 #ifdef SUPPORT_UNICODE 10081move_back(common, reverse_failed,
FALSE);
10093move_back(common, reverse_failed,
FALSE);
10107add_jump(compiler, reverse_failed,
CMP(
SLJIT_LESS, STR_PTR, 0, TMP2, 0));
10122check_start_used_ptr(common);
10125BACKTRACK_AS(vreverse_backtrack)->matchingpath =
LABEL();
10168 BOOLneeds_control_head;
10169 BOOLend_block_size = 0;
10171 intprivate_data_ptr;
10172backtrack_common altbacktrack;
10177jump_list **target = (
conditional) ? &backtrack->condfailed : &backtrack->common.own_backtracks;
10180 BOOLsave_local_quit_available = common->local_quit_available;
10181 BOOLsave_in_positive_assertion = common->in_positive_assertion;
10182then_trap_backtrack *save_then_trap = common->then_trap;
10183 struct sljit_label*save_quit_label = common->quit_label;
10184 struct sljit_label*save_accept_label = common->accept_label;
10185jump_list *save_quit = common->quit;
10186jump_list *save_positive_assertion_quit = common->positive_assertion_quit;
10187jump_list *save_accept = common->accept;
10192common->then_trap =
NULL;
10201private_data_ptr = PRIVATE_DATA(cc);
10203framesize = get_framesize(common, cc,
NULL,
FALSE, &needs_control_head);
10204backtrack->framesize = framesize;
10205backtrack->private_data_ptr = private_data_ptr;
10216free_stack(common, 1);
10221end_block_size = 3;
10226 if(bra ==
OP_BRA&& !assert_needs_str_ptr_saving(ccbegin + 1 +
LINK_SIZE))
10229extrasize += end_block_size;
10231 if(needs_control_head)
10234 if(framesize == no_frame)
10238allocate_stack(common, extrasize);
10240 if(needs_control_head)
10246 if(needs_control_head)
10255extrasize = (needs_control_head ? 3 : 2) + end_block_size;
10257OP1(
SLJIT_MOV, TMP2, 0, STACK_TOP, 0);
10258allocate_stack(common, framesize + extrasize);
10262 if(needs_control_head)
10266 if(needs_control_head)
10275init_frame(common, ccbegin,
NULL, framesize + extrasize - 1, extrasize);
10278 if(end_block_size > 0)
10281OP1(
SLJIT_MOV, STR_END, 0, STR_PTR, 0);
10284memset(&altbacktrack, 0,
sizeof(backtrack_common));
10288local_quit_available =
TRUE;
10289common->local_quit_available =
TRUE;
10290common->quit_label =
NULL;
10291common->quit =
NULL;
10295common->positive_assertion_quit =
NULL;
10299common->accept_label =
NULL;
10300common->accept =
NULL;
10301altbacktrack.top =
NULL;
10302altbacktrack.own_backtracks =
NULL;
10304 if(*ccbegin ==
OP_ALT&& extrasize > 0)
10307altbacktrack.cc = ccbegin;
10312ccbegin = compile_reverse_matchingpath(common, ccbegin, &altbacktrack);
10314compile_matchingpath(common, ccbegin, cc, &altbacktrack);
10317 if(local_quit_available)
10319common->local_quit_available = save_local_quit_available;
10320common->quit_label = save_quit_label;
10321common->quit = save_quit;
10323common->in_positive_assertion = save_in_positive_assertion;
10324common->then_trap = save_then_trap;
10325common->accept_label = save_accept_label;
10326common->positive_assertion_quit = save_positive_assertion_quit;
10327common->accept = save_accept;
10334add_jump(compiler, &altbacktrack.top->simple_backtracks,
CMP(
SLJIT_LESS, STR_PTR, 0, STR_END, 0));
10337common->accept_label =
LABEL();
10338 if(common->accept !=
NULL)
10339set_jumps(common->accept, common->accept_label);
10344 if(framesize == no_frame)
10346 else if(extrasize > 0)
10347free_stack(common, extrasize);
10349 if(end_block_size > 0)
10352 if(needs_control_head)
10362 if(end_block_size > 0)
10365 if(needs_control_head)
10372 if(end_block_size > 0)
10375 if(needs_control_head)
10388OP1(
SLJIT_MOV, STR_PTR, 0,
SLJIT_MEM1(STACK_TOP), STACK(-end_block_size - (needs_control_head ? 2 : 1)));
10403 else if(framesize >= 0)
10411compile_backtrackingpath(common, altbacktrack.top);
10414 if(local_quit_available)
10416common->local_quit_available = save_local_quit_available;
10417common->quit_label = save_quit_label;
10418common->quit = save_quit;
10420common->in_positive_assertion = save_in_positive_assertion;
10421common->then_trap = save_then_trap;
10422common->accept_label = save_accept_label;
10423common->positive_assertion_quit = save_positive_assertion_quit;
10424common->accept = save_accept;
10427set_jumps(altbacktrack.own_backtracks,
LABEL());
10436 if(local_quit_available)
10440common->positive_assertion_quit = common->quit;
10444 if(common->positive_assertion_quit !=
NULL)
10447set_jumps(common->positive_assertion_quit,
LABEL());
10460 if(end_block_size > 0)
10463 if(needs_control_head)
10477 if(extrasize >= 2)
10478free_stack(common, extrasize - 1);
10481 else if(extrasize > 0)
10482free_stack(common, extrasize);
10490free_stack(common, framesize + extrasize - 1);
10494free_stack(common, framesize + extrasize);
10499add_jump(compiler, target, jump);
10514 if(extrasize >= 2)
10536 if(extrasize == 2 + end_block_size)
10553backtrack->matchingpath =
LABEL();
10554SET_LABEL(jump, backtrack->matchingpath);
10558JUMPTO(
SLJIT_JUMP, backtrack->matchingpath);
10560 if(framesize >= 0)
10568set_jumps(backtrack->common.own_backtracks,
LABEL());
10581 if(extrasize >= 2)
10582free_stack(common, extrasize - 1);
10585 else if(extrasize > 0)
10586free_stack(common, extrasize);
10595free_stack(common, framesize + extrasize - 1);
10599free_stack(common, framesize + extrasize);
10604backtrack->matchingpath =
LABEL();
10607JUMPTO(
SLJIT_JUMP, backtrack->matchingpath);
10613 SLJIT_ASSERT(found == &backtrack->common.own_backtracks);
10614set_jumps(backtrack->common.own_backtracks,
LABEL());
10615backtrack->common.own_backtracks =
NULL;
10619 if(local_quit_available)
10621common->local_quit_available = save_local_quit_available;
10622common->quit_label = save_quit_label;
10623common->quit = save_quit;
10625common->in_positive_assertion = save_in_positive_assertion;
10626common->then_trap = save_then_trap;
10627common->accept_label = save_accept_label;
10628common->positive_assertion_quit = save_positive_assertion_quit;
10629common->accept = save_accept;
10633 static SLJIT_INLINE voidmatch_once_common(compiler_common *common,
PCRE2_UCHARket,
intframesize,
intprivate_data_ptr,
BOOLhas_alternatives,
BOOLneeds_control_head)
10640 if(framesize == no_frame)
10644stacksize = needs_control_head ? 1 : 0;
10645 if(ket !=
OP_KET|| has_alternatives)
10649free_stack(common, stacksize);
10652 if(needs_control_head)
10666stacksize = (ket !=
OP_KET|| has_alternatives) ? 2 : 1;
10668 if(needs_control_head)
10677 if(needs_control_head)
10681 static SLJIT_INLINE intmatch_capture_common(compiler_common *common,
intstacksize,
int offset,
intprivate_data_ptr)
10685 if(common->capture_last_ptr != 0)
10692 if(common->optimized_cbracket[
offset>> 1] == 0)
10708 if(
PRIV(script_run)(ptr, endptr,
FALSE))
10713 #ifdef SUPPORT_UNICODE 10717 if(
PRIV(script_run)(ptr, endptr,
TRUE))
10724 static voidmatch_script_run_common(compiler_common *common,
intprivate_data_ptr, backtrack_common *parent)
10731 #ifdef SUPPORT_UNICODE 10795 static PCRE2_SPTRcompile_bracket_matchingpath(compiler_common *common,
PCRE2_SPTRcc, backtrack_common *parent)
10798backtrack_common *backtrack;
10800 intprivate_data_ptr = 0;
10803 intrepeat_ptr = 0, repeat_length = 0;
10804 intrepeat_type = 0, repeat_count = 0;
10810assert_backtrack *
assert;
10811 BOOLhas_alternatives;
10819PUSH_BACKTRACK(
sizeof(bracket_backtrack), cc,
NULL);
10830matchingpath = bracketend(cc) - 1 -
LINK_SIZE;
10831ket = *matchingpath;
10832 if(ket ==
OP_KET&& PRIVATE_DATA(matchingpath) != 0)
10834repeat_ptr = PRIVATE_DATA(matchingpath);
10835repeat_length = PRIVATE_DATA(matchingpath + 1);
10836repeat_type = PRIVATE_DATA(matchingpath + 2);
10837repeat_count = PRIVATE_DATA(matchingpath + 3);
10838 SLJIT_ASSERT(repeat_length != 0 && repeat_type != 0 && repeat_count != 0);
10845matchingpath = ccbegin + 1 +
LINK_SIZE;
10850has_alternatives = *cc ==
OP_ALT;
10854compile_time_checks_must_be_grouped_together);
10865 if(common->optimized_cbracket[
offset] == 0)
10867private_data_ptr = OVECTOR_PRIV(
offset);
10873private_data_ptr = OVECTOR(
offset);
10875BACKTRACK_AS(bracket_backtrack)->private_data_ptr = private_data_ptr;
10881private_data_ptr = PRIVATE_DATA(ccbegin);
10883BACKTRACK_AS(bracket_backtrack)->private_data_ptr = private_data_ptr;
10885BACKTRACK_AS(bracket_backtrack)->u.framesize = get_framesize(common, ccbegin,
NULL,
FALSE, &needs_control_head);
10896allocate_stack(common, stacksize);
10914free_stack(common, 1);
10925 if(opcode !=
OP_ONCE|| BACKTRACK_AS(bracket_backtrack)->
u.framesize < 0)
10934braminzero =
CMP(
SLJIT_EQUAL, STR_PTR, 0,
SLJIT_MEM1(TMP1), STACK(-BACKTRACK_AS(bracket_backtrack)->
u.framesize - 2));
10946 if(repeat_type != 0)
10950rmax_label =
LABEL();
10954BACKTRACK_AS(bracket_backtrack)->recursive_matchingpath =
LABEL();
10958rmax_label =
LABEL();
10959 if(has_alternatives && opcode >=
OP_BRA&& opcode <
OP_SBRA&& repeat_type == 0)
10960BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath = rmax_label;
10967 if(needs_control_head)
10973 if(BACKTRACK_AS(bracket_backtrack)->
u.framesize < 0)
10979 if(!needs_control_head)
10984 if(BACKTRACK_AS(bracket_backtrack)->
u.framesize == no_frame)
10991allocate_stack(common, stacksize);
10994 if(needs_control_head)
11002 if(needs_control_head)
11005 if(BACKTRACK_AS(bracket_backtrack)->
u.framesize == no_frame)
11009 else if(ket ==
OP_KETRMAX|| has_alternatives)
11014 if(ket !=
OP_KET|| has_alternatives)
11017stacksize += BACKTRACK_AS(bracket_backtrack)->u.framesize + 1;
11018allocate_stack(common, stacksize);
11020 if(needs_control_head)
11026stacksize = needs_control_head ? 1 : 0;
11027 if(ket !=
OP_KET|| has_alternatives)
11039init_frame(common, ccbegin,
NULL, BACKTRACK_AS(bracket_backtrack)->
u.framesize + stacksize, stacksize + 1);
11045 if(common->optimized_cbracket[
offset>> 1] != 0)
11048allocate_stack(common, 2);
11058allocate_stack(common, 1);
11066allocate_stack(common, 4);
11072OP1(
SLJIT_MOV, STR_END, 0, STR_PTR, 0);
11075 if(*matchingpath ==
OP_REVERSE|| has_vreverse)
11076matchingpath = compile_reverse_matchingpath(common, matchingpath, backtrack);
11082allocate_stack(common, 1);
11087matchingpath = compile_reverse_matchingpath(common, matchingpath, backtrack);
11089 else if(has_alternatives)
11092allocate_stack(common, 1);
11099 if(*matchingpath ==
OP_CREF)
11102add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->
u.condfailed),
11111slot = common->name_table +
GET2(matchingpath, 1) * common->name_entry_size;
11115slot += common->name_entry_size;
11121slot += common->name_entry_size;
11124add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->
u.condfailed),
JUMP(
SLJIT_ZERO));
11130BACKTRACK_AS(bracket_backtrack)->u.condfailed =
NULL;
11133 if(*matchingpath ==
OP_TRUE)
11140 else if(*matchingpath ==
OP_RREF)
11142stacksize =
GET2(matchingpath, 1);
11143 if(common->currententry ==
NULL)
11147 else if(common->currententry->start == 0)
11148stacksize = stacksize == 0;
11150stacksize = stacksize == (
int)
GET2(common->start, common->currententry->start + 1 +
LINK_SIZE);
11152 if(stacksize != 0)
11157 if(common->currententry ==
NULL|| common->currententry->start == 0)
11162slot = common->name_table +
GET2(matchingpath, 1) * common->name_entry_size;
11163 i= (
int)
GET2(common->start, common->currententry->start + 1 +
LINK_SIZE);
11164 while(stacksize > 0)
11166 if((
int)
GET2(slot, 0) ==
i)
11168slot += common->name_entry_size;
11173 if(stacksize != 0)
11178 if(stacksize == 0)
11196memset(
assert, 0,
sizeof(assert_backtrack));
11197 assert->common.cc = matchingpath;
11198BACKTRACK_AS(bracket_backtrack)->u.assert =
assert;
11199matchingpath = compile_assert_matchingpath(common, matchingpath,
assert,
TRUE);
11203compile_matchingpath(common, matchingpath, cc, backtrack);
11213add_jump(compiler, &backtrack->top->simple_backtracks,
CMP(
SLJIT_LESS, STR_PTR, 0, STR_END, 0));
11216 if(PRIVATE_DATA(ccbegin + 1))
11223match_once_common(common, ket, BACKTRACK_AS(bracket_backtrack)->
u.framesize, private_data_ptr, has_alternatives, needs_control_head);
11226match_script_run_common(common, private_data_ptr, backtrack);
11241 if(common->capture_last_ptr != 0)
11243 if(common->optimized_cbracket[
offset>> 1] == 0)
11246 if(has_alternatives && opcode !=
OP_ONCE)
11250allocate_stack(common, stacksize);
11270stacksize = match_capture_common(common, stacksize,
offset, private_data_ptr);
11280 if(has_alternatives)
11290BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath =
LABEL();
11294 if(
offset!= 0 && common->optimized_cbracket[
offset>> 1] != 0)
11302 if(repeat_type != 0)
11304 if(has_alternatives)
11305BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath =
LABEL();
11310free_stack(common, 1);
11312 else if(opcode < OP_BRA || opcode >=
OP_SBRA)
11314 if(has_alternatives)
11315BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath =
LABEL();
11324free_stack(common, 1);
11332BACKTRACK_AS(bracket_backtrack)->recursive_matchingpath =
LABEL();
11337count_match(common);
11341 else if(repeat_type ==
OP_UPTO)
11345allocate_stack(common, 1);
11350BACKTRACK_AS(bracket_backtrack)->zero_matchingpath =
LABEL();
11355JUMPTO(
SLJIT_JUMP, ((braminzero_backtrack *)parent)->matchingpath);
11356 if(braminzero !=
NULL)
11358JUMPHERE(braminzero);
11362 if(opcode ==
OP_ONCE&& BACKTRACK_AS(bracket_backtrack)->
u.framesize >= 0)
11366OP2(
SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0,
SLJIT_IMM, (BACKTRACK_AS(bracket_backtrack)->
u.framesize - 1) *
sizeof(
sljit_sw));
11369free_stack(common, 1);
11375count_match(common);
11382 intframesize = BACKTRACK_AS(bracket_backtrack)->u.framesize;
11384 SLJIT_ASSERT(SHRT_MIN <= framesize && framesize < SHRT_MAX/2);
11388 data= (
int)((
short)((
unsignedshort)framesize << 1) | (needs_control_head ? 1 : 0));
11389BACKTRACK_AS(bracket_backtrack)->u.framesize =
data;
11391 returncc + repeat_length;
11394 static PCRE2_SPTRcompile_bracketpos_matchingpath(compiler_common *common,
PCRE2_SPTRcc, backtrack_common *parent)
11397backtrack_common *backtrack;
11399 intprivate_data_ptr;
11400 intcbraprivptr = 0;
11401 BOOLneeds_control_head;
11409 structjump_list *emptymatch =
NULL;
11411PUSH_BACKTRACK(
sizeof(bracketpos_backtrack), cc,
NULL);
11419private_data_ptr = PRIVATE_DATA(cc);
11421BACKTRACK_AS(bracketpos_backtrack)->private_data_ptr = private_data_ptr;
11435cbraprivptr = OVECTOR_PRIV(
offset);
11445framesize = get_framesize(common, cc,
NULL,
FALSE, &needs_control_head);
11446BACKTRACK_AS(bracketpos_backtrack)->framesize = framesize;
11452 if(common->capture_last_ptr != 0)
11458 if(needs_control_head)
11463BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
11464allocate_stack(common, stacksize);
11465 if(framesize == no_frame)
11475 if(common->capture_last_ptr != 0)
11478 if(needs_control_head)
11480 if(common->capture_last_ptr != 0)
11488 if(needs_control_head)
11494 if(needs_control_head)
11498 if(needs_control_head)
11506stacksize = framesize + 1;
11509 if(needs_control_head)
11513BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
11515allocate_stack(common, stacksize);
11517 if(needs_control_head)
11527 if(needs_control_head)
11538init_frame(common, cc,
NULL, stacksize - 1, stacksize - framesize);
11539stack -= 1 + (
offset== 0);
11548backtrack->top =
NULL;
11549backtrack->own_backtracks =
NULL;
11552compile_matchingpath(common, ccbegin, cc, backtrack);
11558 if(framesize == no_frame)
11566 if(common->capture_last_ptr != 0)
11578 if(needs_control_head)
11582add_jump(compiler, &emptymatch,
CMP(
SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
11595 if(common->capture_last_ptr != 0)
11609 if(needs_control_head)
11613add_jump(compiler, &emptymatch,
CMP(
SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
11625flush_stubs(common);
11627compile_backtrackingpath(common, backtrack->top);
11630set_jumps(backtrack->own_backtracks,
LABEL());
11662backtrack->own_backtracks =
NULL;
11672set_jumps(emptymatch,
LABEL());
11673count_match(common);
11719*opcode = cc[class_len - 1];
11724*end = cc + class_len;
11735*end = cc + class_len;
11747*exact =
GET2(cc, class_len);
11761 else if(*
max== 1)
11776*end = cc + class_len + 2 *
IMM2_SIZE;
11784*exact =
GET2(cc, 0);
11810*end = next_opcode(common, cc);
11816 #ifdef SUPPORT_UNICODE 11817 if(common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc);
11822 static PCRE2_SPTRcompile_iterator_matchingpath(compiler_common *common,
PCRE2_SPTRcc, backtrack_common *parent)
11825backtrack_common *backtrack;
11829 sljit_s32early_fail_ptr = PRIVATE_DATA(cc + 1);
11831 BOOLcharpos_enabled;
11833 unsigned intcharpos_othercasebit;
11835jump_list *no_match =
NULL;
11836jump_list *no_char1_match =
NULL;
11839 intprivate_data_ptr = PRIVATE_DATA(cc);
11841 intoffset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
11842 intoffset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + SSIZE_OF(
sw);
11843 inttmp_base, tmp_offset;
11844 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 11848PUSH_BACKTRACK(
sizeof(char_iterator_backtrack), cc,
NULL);
11850early_fail_type = (early_fail_ptr & 0x7);
11851early_fail_ptr >>= 3;
11854 if(common->early_fail_start_ptr == 0 && common->fast_forward_bc_ptr ==
NULL)
11856early_fail_ptr = 0;
11857early_fail_type = type_skip;
11861|| (early_fail_ptr >= common->early_fail_start_ptr && early_fail_ptr <= common->early_fail_end_ptr));
11863 if(early_fail_type == type_fail)
11866cc = get_iterator_parameters(common, cc, &opcode, &
type, &
max, &exact, &end);
11876tmp_offset = POSSESSIVE0;
11891add_jump(compiler, &backtrack->own_backtracks,
CMP(
SLJIT_GREATER, TMP1, 0, STR_END, 0));
11894compile_char1_matchingpath(common,
type, cc, &backtrack->own_backtracks,
FALSE);
11902compile_char1_matchingpath(common,
type, cc, &backtrack->own_backtracks,
TRUE);
11907 else if(exact == 1)
11908compile_char1_matchingpath(common,
type, cc, &backtrack->own_backtracks,
TRUE);
11910 if(early_fail_type == type_fail_range)
11915OP2(
SLJIT_SUB, TMP1, 0, TMP1, 0, TMP2, 0);
11916OP2(
SLJIT_SUB, TMP2, 0, STR_PTR, 0, TMP2, 0);
11917add_jump(compiler, &backtrack->own_backtracks,
CMP(
SLJIT_LESS_EQUAL, TMP2, 0, TMP1, 0));
11934allocate_stack(common, 2);
11942compile_char1_matchingpath(common,
type, cc, &BACKTRACK_AS(char_iterator_backtrack)->
u.backtracks,
TRUE);
11952allocate_stack(common, 1);
11957BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
11960 #ifdef SUPPORT_UNICODE 11968 if(private_data_ptr == 0)
11969allocate_stack(common, 2);
11971OP1(
SLJIT_MOV, base, offset0, STR_END, 0);
11972OP1(
SLJIT_MOV, base, offset1, STR_PTR, 0);
11974OP1(
SLJIT_MOV, STR_PTR, 0, STR_END, 0);
11975process_partial_match(common);
11977 if(early_fail_ptr != 0)
11979BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
11982 #ifdef SUPPORT_UNICODE 11983 else if(!common->utf)
11988 if(private_data_ptr == 0)
11989allocate_stack(common, 2);
11991OP1(
SLJIT_MOV, base, offset1, STR_PTR, 0);
12002process_partial_match(common);
12006OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12008 if(early_fail_ptr != 0)
12010BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
12015charpos_enabled =
FALSE;
12017charpos_othercasebit = 0;
12021 #ifdef SUPPORT_UNICODE 12022charpos_enabled = !common->utf || !HAS_EXTRALEN(end[1]);
12024charpos_enabled =
TRUE;
12026 if(charpos_enabled && *end ==
OP_CHARI&& char_has_othercase(common, end + 1))
12028charpos_othercasebit = char_get_othercase_bit(common, end + 1);
12029 if(charpos_othercasebit == 0)
12030charpos_enabled =
FALSE;
12033 if(charpos_enabled)
12035charpos_char = end[1];
12038 #if PCRE2_CODE_UNIT_WIDTH == 8 12040 #elif PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 12042 if((charpos_othercasebit & 0x100) != 0)
12043charpos_othercasebit = (charpos_othercasebit & 0xff) << 8;
12045 if(charpos_othercasebit != 0)
12046charpos_char |= charpos_othercasebit;
12048BACKTRACK_AS(char_iterator_backtrack)->u.charpos.enabled =
TRUE;
12049BACKTRACK_AS(char_iterator_backtrack)->u.charpos.chr = charpos_char;
12050BACKTRACK_AS(char_iterator_backtrack)->u.charpos.othercasebit = charpos_othercasebit;
12054 if(charpos_enabled)
12065add_jump(compiler, &backtrack->own_backtracks,
JUMP(
SLJIT_ZERO));
12067compile_char1_matchingpath(common,
type, cc, &backtrack->own_backtracks,
FALSE);
12068 if(early_fail_ptr != 0)
12072detect_partial_match(common, &backtrack->own_backtracks);
12073OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
12074 if(charpos_othercasebit != 0)
12078 if(private_data_ptr == 0)
12079allocate_stack(common, 2);
12080OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12081OP1(
SLJIT_MOV, base, offset1, STR_PTR, 0);
12091compile_char1_matchingpath(common,
type, cc, &no_match,
FALSE);
12092 if(early_fail_ptr != 0)
12094detect_partial_match(common, &no_match);
12095OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
12096 if(charpos_othercasebit != 0)
12102OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12108OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12114set_jumps(no_match,
LABEL());
12116OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12120 if(private_data_ptr == 0)
12121allocate_stack(common, 2);
12123OP1(
SLJIT_MOV, base, offset1, STR_PTR, 0);
12124 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 12125use_tmp = (!HAS_VIRTUAL_REGISTERS && opcode ==
OP_STAR);
12129OP1(
SLJIT_MOV, use_tmp ? TMP3 : base, use_tmp ? 0 : offset0, STR_PTR, 0);
12134detect_partial_match(common, &no_match);
12136compile_char1_matchingpath(common,
type, cc, &no_char1_match,
FALSE);
12137 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 12139OP1(
SLJIT_MOV, use_tmp ? TMP3 : base, use_tmp ? 0 : offset0, STR_PTR, 0);
12148detect_partial_match_to(common,
label);
12151set_jumps(no_char1_match,
LABEL());
12152 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 12155set_jumps(no_match,
LABEL());
12159OP1(
SLJIT_MOV, base, offset0, TMP3, 0);
12162OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12168set_jumps(no_match,
LABEL());
12169OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12172 if(early_fail_ptr != 0)
12176BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
12180 if(private_data_ptr == 0)
12181allocate_stack(common, 1);
12182OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12183BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
12184 if(early_fail_ptr != 0)
12190 if(private_data_ptr == 0)
12191allocate_stack(common, 2);
12192OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12194BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
12200 if(private_data_ptr == 0)
12201allocate_stack(common, 1);
12202OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12204compile_char1_matchingpath(common,
type, cc, &BACKTRACK_AS(char_iterator_backtrack)->
u.backtracks,
TRUE);
12205BACKTRACK_AS(char_iterator_backtrack)->matchingpath =
LABEL();
12212 #if defined SUPPORT_UNICODE 12218OP1(
SLJIT_MOV, STR_PTR, 0, STR_END, 0);
12219process_partial_match(common);
12220 if(early_fail_ptr != 0)
12225 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 12228OP1(
SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
12229detect_partial_match(common, &no_match);
12231compile_char1_matchingpath(common,
type, cc, &no_match,
FALSE);
12232OP1(
SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
12233detect_partial_match_to(common,
label);
12235set_jumps(no_match,
LABEL());
12236OP1(
SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
12237 if(early_fail_ptr != 0)
12239 if(!HAS_VIRTUAL_REGISTERS && tmp_base == TMP3)
12248detect_partial_match(common, &no_match);
12250compile_char1_matchingpath(common,
type, cc, &no_char1_match,
FALSE);
12251detect_partial_match_to(common,
label);
12254set_jumps(no_char1_match,
LABEL());
12256set_jumps(no_match,
LABEL());
12257 if(early_fail_ptr != 0)
12263 #if defined SUPPORT_UNICODE && PCRE2_CODE_UNIT_WIDTH != 32 12269detect_partial_match(common, &no_match);
12271compile_char1_matchingpath(common,
type, cc, &no_match,
FALSE);
12275detect_partial_match_to(common,
label);
12277set_jumps(no_match,
LABEL());
12295process_partial_match(common);
12303detect_partial_match(common, &no_match);
12305compile_char1_matchingpath(common,
type, cc, &no_char1_match,
FALSE);
12308detect_partial_match_to(common,
label);
12311set_jumps(no_char1_match,
LABEL());
12313set_jumps(no_match,
LABEL());
12318OP1(
SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
12319compile_char1_matchingpath(common,
type, cc, &no_match,
TRUE);
12320OP1(
SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
12321set_jumps(no_match,
LABEL());
12322OP1(
SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
12330count_match(common);
12337backtrack_common *backtrack;
12339PUSH_BACKTRACK(
sizeof(backtrack_common), cc,
NULL);
12343add_jump(compiler, &backtrack->own_backtracks,
JUMP(
SLJIT_JUMP));
12348add_jump(compiler, &common->restart_match,
CMP(
SLJIT_NOT_EQUAL, STR_PTR, 0, STR_END, 0));
12353 if(common->accept_label ==
NULL)
12360 if(common->accept_label ==
NULL)
12365 if(HAS_VIRTUAL_REGISTERS)
12367OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
12376 if(common->accept_label ==
NULL)
12382 if(common->accept_label ==
NULL)
12386add_jump(compiler, &backtrack->own_backtracks,
JUMP(
SLJIT_JUMP));
12394 BOOLoptimized_cbracket = common->optimized_cbracket[
offset] != 0;
12397 if(common->currententry !=
NULL)
12400 if(!optimized_cbracket)
12404 if(!optimized_cbracket)
12412backtrack_common *backtrack;
12418ccend += 2 + cc[1];
12420PUSH_BACKTRACK(
sizeof(backtrack_common), cc,
NULL);
12424allocate_stack(common, 1);
12431 if(HAS_VIRTUAL_REGISTERS)
12432OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
12441 static PCRE2_UCHARthen_trap_opcode[1] = { OP_THEN_TRAP };
12446backtrack_common *backtrack;
12447 BOOLneeds_control_head;
12450PUSH_BACKTRACK_NOVALUE(
sizeof(then_trap_backtrack), cc);
12451common->then_trap = BACKTRACK_AS(then_trap_backtrack);
12452BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;
12453BACKTRACK_AS(then_trap_backtrack)->start = (
sljit_sw)(cc - common->start);
12454BACKTRACK_AS(then_trap_backtrack)->framesize = get_framesize(common, cc, ccend,
FALSE, &needs_control_head);
12456 size= BACKTRACK_AS(then_trap_backtrack)->framesize;
12460allocate_stack(common,
size);
12469 size= BACKTRACK_AS(then_trap_backtrack)->framesize;
12471init_frame(common, cc, ccend,
size- 1, 0);
12474 static voidcompile_matchingpath(compiler_common *common,
PCRE2_SPTRcc,
PCRE2_SPTRccend, backtrack_common *parent)
12477backtrack_common *backtrack;
12479then_trap_backtrack *save_then_trap =
NULL;
12483 if(common->has_then && common->then_offsets[cc - common->start] != 0)
12486has_then_trap =
TRUE;
12487save_then_trap = common->then_trap;
12489compile_then_trap_matchingpath(common, cc, ccend, parent);
12508cc = compile_simple_assertion_matchingpath(common, *cc, cc + 1, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks);
12530cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks,
TRUE);
12534PUSH_BACKTRACK_NOVALUE(
sizeof(backtrack_common), cc);
12536allocate_stack(common, 1);
12545cc = compile_charn_matchingpath(common, cc, ccend, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks);
12547cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks,
TRUE);
12615cc = compile_iterator_matchingpath(common, cc, parent);
12621cc = compile_iterator_matchingpath(common, cc, parent);
12623cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks,
TRUE);
12626 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH == 16 || PCRE2_CODE_UNIT_WIDTH == 32 12629cc = compile_iterator_matchingpath(common, cc, parent);
12631cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks,
TRUE);
12638cc = compile_ref_iterator_matchingpath(common, cc, parent);
12641compile_ref_matchingpath(common, cc, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks,
TRUE,
FALSE);
12649cc = compile_ref_iterator_matchingpath(common, cc, parent);
12652compile_dnref_search(common, cc, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks);
12653compile_ref_matchingpath(common, cc, parent->top !=
NULL? &parent->top->simple_backtracks : &parent->own_backtracks,
TRUE,
FALSE);
12659cc = compile_recurse_matchingpath(common, cc, parent);
12664cc = compile_callout_matchingpath(common, cc, parent);
12671PUSH_BACKTRACK_NOVALUE(
sizeof(assert_backtrack), cc);
12672cc = compile_assert_matchingpath(common, cc, BACKTRACK_AS(assert_backtrack),
FALSE);
12676PUSH_BACKTRACK_NOVALUE(
sizeof(braminzero_backtrack), cc);
12677cc = bracketend(cc + 1);
12680allocate_stack(common, 1);
12685allocate_stack(common, 2);
12689BACKTRACK_AS(braminzero_backtrack)->matchingpath =
LABEL();
12690count_match(common);
12703cc = compile_bracket_matchingpath(common, cc, parent);
12708cc = compile_bracket_matchingpath(common, cc, parent);
12711PUSH_BACKTRACK_NOVALUE(
sizeof(assert_backtrack), cc);
12712cc = compile_assert_matchingpath(common, cc, BACKTRACK_AS(assert_backtrack),
FALSE);
12721cc = compile_bracketpos_matchingpath(common, cc, parent);
12725PUSH_BACKTRACK_NOVALUE(
sizeof(backtrack_common), cc);
12728allocate_stack(common, common->has_skip_arg ? 5 : 1);
12729 if(HAS_VIRTUAL_REGISTERS)
12730OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
12735 if(common->has_skip_arg)
12744cc += 1 + 2 + cc[1];
12755cc = compile_control_verb_matchingpath(common, cc, parent);
12761cc = compile_fail_accept_matchingpath(common, cc, parent);
12765cc = compile_close_matchingpath(common, cc);
12769cc = bracketend(cc + 1);
12783PUSH_BACKTRACK_NOVALUE(
sizeof(then_trap_backtrack), cc);
12784BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;
12785BACKTRACK_AS(then_trap_backtrack)->then_trap = common->then_trap;
12786common->then_trap = save_then_trap;
12791 #undef PUSH_BACKTRACK 12792 #undef PUSH_BACKTRACK_NOVALUE 12793 #undef BACKTRACK_AS 12795 #define COMPILE_BACKTRACKINGPATH(current) \ 12798 compile_backtrackingpath(common, (current)); \ 12799 if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) \ 12804 #define CURRENT_AS(type) ((type *)current) 12806 static voidcompile_iterator_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
12815jump_list *jumplist =
NULL;
12817 intprivate_data_ptr = PRIVATE_DATA(cc);
12819 intoffset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
12820 intoffset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + SSIZE_OF(
sw);
12822cc = get_iterator_parameters(common, cc, &opcode, &
type, &
max, &exact, &end);
12831set_jumps(CURRENT_AS(char_iterator_backtrack)->
u.backtracks,
LABEL());
12833free_stack(common, 1);
12838 if(CURRENT_AS(char_iterator_backtrack)->
u.charpos.enabled)
12840OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12841OP1(
SLJIT_MOV, TMP2, 0, base, offset1);
12846OP1(MOV_UCHAR, TMP1, 0,
SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
12847OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12848 if(CURRENT_AS(char_iterator_backtrack)->
u.charpos.othercasebit != 0)
12849OP2(
SLJIT_OR, TMP1, 0, TMP1, 0,
SLJIT_IMM, CURRENT_AS(char_iterator_backtrack)->
u.charpos.othercasebit);
12850CMPTO(
SLJIT_EQUAL, TMP1, 0,
SLJIT_IMM, CURRENT_AS(char_iterator_backtrack)->
u.charpos.chr, CURRENT_AS(char_iterator_backtrack)->matchingpath);
12856OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12859OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12860JUMPTO(
SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath);
12863 if(private_data_ptr == 0)
12864free_stack(common, 2);
12869OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12870compile_char1_matchingpath(common,
type, cc, &jumplist,
TRUE);
12871OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12872JUMPTO(
SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath);
12873set_jumps(jumplist,
LABEL());
12874 if(private_data_ptr == 0)
12875free_stack(common, 1);
12879OP1(
SLJIT_MOV, TMP1, 0, base, offset1);
12880OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12884OP1(
SLJIT_MOV, base, offset1, TMP1, 0);
12885compile_char1_matchingpath(common,
type, cc, &jumplist,
TRUE);
12886OP1(
SLJIT_MOV, base, offset0, STR_PTR, 0);
12887JUMPTO(
SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath);
12889set_jumps(jumplist,
LABEL());
12890 if(private_data_ptr == 0)
12891free_stack(common, 2);
12895OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12899set_jumps(CURRENT_AS(char_iterator_backtrack)->
u.backtracks,
LABEL());
12900OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12902JUMPTO(
SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath);
12904 if(private_data_ptr == 0)
12905free_stack(common, 1);
12909OP1(
SLJIT_MOV, STR_PTR, 0, base, offset0);
12912compile_char1_matchingpath(common,
type, cc, &jumplist,
TRUE);
12913JUMPTO(
SLJIT_JUMP, CURRENT_AS(char_iterator_backtrack)->matchingpath);
12914set_jumps(jumplist,
LABEL());
12916 if(private_data_ptr == 0)
12917free_stack(common, 1);
12931set_jumps(current->own_backtracks,
LABEL());
12934 static SLJIT_INLINE voidcompile_ref_iterator_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
12943 if((
type& 0x1) == 0)
12946set_jumps(current->own_backtracks,
LABEL());
12948free_stack(common, 1);
12955set_jumps(current->own_backtracks,
LABEL());
12956free_stack(common, ref ? 2 : 3);
12959 static SLJIT_INLINE voidcompile_recurse_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
12962recurse_entry *entry;
12964 if(!CURRENT_AS(recurse_backtrack)->inlined_pattern)
12966entry = CURRENT_AS(recurse_backtrack)->entry;
12967 if(entry->backtrack_label ==
NULL)
12974compile_backtrackingpath(common, current->top);
12976set_jumps(current->own_backtracks,
LABEL());
12979 static voidcompile_assert_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
12999 if(CURRENT_AS(assert_backtrack)->framesize < 0)
13001set_jumps(current->own_backtracks,
LABEL());
13007free_stack(common, 1);
13018free_stack(common, 1);
13021free_stack(common, 1);
13030OP2(
SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0,
SLJIT_IMM, (CURRENT_AS(assert_backtrack)->framesize - 1) *
sizeof(
sljit_sw));
13033set_jumps(current->own_backtracks,
LABEL());
13036set_jumps(current->own_backtracks,
LABEL());
13043JUMPTO(
SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);
13048 static voidcompile_bracket_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13051 intopcode, stacksize, alt_count, alt_max;
13053 intprivate_data_ptr = CURRENT_AS(bracket_backtrack)->private_data_ptr;
13054 intrepeat_ptr = 0, repeat_type = 0, repeat_count = 0;
13060assert_backtrack *
assert;
13061 BOOLhas_alternatives;
13079ccbegin = bracketend(cc) - 1 -
LINK_SIZE;
13081 if(ket ==
OP_KET&& PRIVATE_DATA(ccbegin) != 0)
13083repeat_ptr = PRIVATE_DATA(ccbegin);
13084repeat_type = PRIVATE_DATA(ccbegin + 2);
13085repeat_count = PRIVATE_DATA(ccbegin + 3);
13094has_alternatives = *cc ==
OP_ALT;
13102alt_max = has_alternatives ? no_alternatives(ccbegin) : 0;
13107needs_control_head = (CURRENT_AS(bracket_backtrack)->u.framesize & 0x1) != 0;
13108CURRENT_AS(bracket_backtrack)->u.framesize >>= 1;
13111 if(ket !=
OP_KET&& repeat_type != 0)
13115free_stack(common, 1);
13127free_stack(common, 1);
13136 if(repeat_type != 0)
13142free_stack(common, 1);
13147 if(opcode !=
OP_ONCE|| CURRENT_AS(bracket_backtrack)->
u.framesize < 0)
13152CMPTO(
SLJIT_NOT_EQUAL, STR_PTR, 0,
SLJIT_MEM1(TMP1), STACK(-CURRENT_AS(bracket_backtrack)->
u.framesize - 2), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
13156free_stack(common, 1);
13159JUMPTO(
SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
13161rmin_label =
LABEL();
13162 if(repeat_type != 0)
13168free_stack(common, 1);
13171 else if(repeat_type ==
OP_EXACT)
13174exact_label =
LABEL();
13179 if(common->capture_last_ptr != 0)
13186free_stack(common, 3);
13190 else if(common->optimized_cbracket[
offset>> 1] == 0)
13194free_stack(common, 2);
13202 if(CURRENT_AS(bracket_backtrack)->
u.framesize >= 0)
13206OP2(
SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0,
SLJIT_IMM, (CURRENT_AS(bracket_backtrack)->
u.framesize - 1) *
sizeof(
sljit_sw));
13212 if(has_alternatives)
13216free_stack(common, 1);
13222 else if(has_alternatives)
13225free_stack(common, 1);
13231 SLJIT_ASSERT(CURRENT_AS(bracket_backtrack)->
u.matching_mov_addr);
13239COMPILE_BACKTRACKINGPATH(current->top);
13240 if(current->own_backtracks)
13241set_jumps(current->own_backtracks,
LABEL());
13249 assert= CURRENT_AS(bracket_backtrack)->u.assert;
13259set_jumps(CURRENT_AS(bracket_backtrack)->
u.assert->condfailed,
LABEL());
13261 else if(CURRENT_AS(bracket_backtrack)->
u.condfailed !=
NULL)
13265set_jumps(CURRENT_AS(bracket_backtrack)->
u.condfailed,
LABEL());
13271 if(has_alternatives)
13276current->top =
NULL;
13277current->own_backtracks =
NULL;
13278current->simple_backtracks =
NULL;
13285has_vreverse =
FALSE;
13293ccprev = compile_reverse_matchingpath(common, ccprev, current);
13299 if(private_data_ptr != 0)
13308compile_matchingpath(common, ccprev, cc, current);
13318add_jump(compiler, ¤t->top->simple_backtracks,
CMP(
SLJIT_LESS, STR_PTR, 0, STR_END, 0));
13321 if(PRIVATE_DATA(ccbegin + 1))
13328match_script_run_common(common, private_data_ptr, current);
13336match_once_common(common, ket, CURRENT_AS(bracket_backtrack)->
u.framesize, private_data_ptr, has_alternatives, needs_control_head);
13349 if(common->capture_last_ptr != 0)
13351 if(common->optimized_cbracket[
offset>> 1] == 0)
13358allocate_stack(common, stacksize);
13378stacksize = match_capture_common(common, stacksize,
offset, private_data_ptr);
13395JUMPTO(
SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->alternative_matchingpath);
13401JUMPHERE(next_alt);
13403 if(alt_count < alt_max)
13416COMPILE_BACKTRACKINGPATH(current->top);
13417 if(current->own_backtracks)
13418set_jumps(current->own_backtracks,
LABEL());
13426 assert= CURRENT_AS(bracket_backtrack)->u.assert;
13439 if(private_data_ptr == 0)
13440free_stack(common, 1);
13446 if(common->optimized_cbracket[
offset>> 1] != 0)
13450free_stack(common, 2);
13457free_stack(common, 1);
13468free_stack(common, 4);
13473free_stack(common, 1);
13477cc = ccbegin + GET(ccbegin, 1);
13478stacksize = needs_control_head ? 1 : 0;
13480 if(CURRENT_AS(bracket_backtrack)->
u.framesize >= 0)
13483stacksize += CURRENT_AS(bracket_backtrack)->u.framesize + ((ket !=
OP_KET|| *cc ==
OP_ALT) ? 2 : 1);
13492free_stack(common, stacksize);
13496 if(CURRENT_AS(bracket_backtrack)->
u.framesize >= 0)
13502free_stack(common, 2);
13517free_stack(common, 1);
13523JUMPTO(
SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->zero_matchingpath);
13525free_stack(common, 1);
13536free_stack(common, 1);
13541free_stack(common, 1);
13546JUMPTO(
SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->zero_matchingpath);
13551 static SLJIT_INLINE voidcompile_bracketpos_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13559 if(CURRENT_AS(bracketpos_backtrack)->framesize < 0)
13572 if(common->capture_last_ptr != 0)
13575 if(common->capture_last_ptr != 0)
13578set_jumps(current->own_backtracks,
LABEL());
13579free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
13585OP2(
SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0,
SLJIT_IMM, (CURRENT_AS(bracketpos_backtrack)->framesize - 1) *
sizeof(
sljit_sw));
13587 if(current->own_backtracks)
13590set_jumps(current->own_backtracks,
LABEL());
13592free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
13598 static SLJIT_INLINE voidcompile_braminzero_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13600assert_backtrack backtrack;
13602current->top =
NULL;
13603current->own_backtracks =
NULL;
13604current->simple_backtracks =
NULL;
13608compile_bracket_matchingpath(common, current->cc, current);
13609compile_bracket_backtrackingpath(common, current->top);
13613memset(&backtrack, 0,
sizeof(backtrack));
13614backtrack.common.cc = current->cc;
13615backtrack.matchingpath = CURRENT_AS(braminzero_backtrack)->matchingpath;
13617compile_assert_matchingpath(common, current->cc, &backtrack,
FALSE);
13619 SLJIT_ASSERT(!current->simple_backtracks && !current->own_backtracks);
13622 static SLJIT_INLINE voidcompile_control_verb_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13631 if(common->then_trap !=
NULL)
13645add_jump(compiler, &common->then_trap->quit,
JUMP(
SLJIT_JUMP));
13648 else if(!common->local_quit_available && common->in_positive_assertion)
13650add_jump(compiler, &common->positive_assertion_quit,
JUMP(
SLJIT_JUMP));
13655 if(common->local_quit_available)
13658 if(common->quit_label ==
NULL)
13684 static SLJIT_INLINE voidcompile_vreverse_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13692skip_valid_char(common);
13694JUMPTO(
SLJIT_JUMP, CURRENT_AS(vreverse_backtrack)->matchingpath);
13698set_jumps(current->own_backtracks,
label);
13701 static SLJIT_INLINE voidcompile_then_trap_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13707 if(CURRENT_AS(then_trap_backtrack)->then_trap)
13709common->then_trap = CURRENT_AS(then_trap_backtrack)->then_trap;
13713 size= CURRENT_AS(then_trap_backtrack)->framesize;
13717free_stack(common,
size);
13720set_jumps(CURRENT_AS(then_trap_backtrack)->quit,
LABEL());
13722 if(CURRENT_AS(then_trap_backtrack)->framesize >= 0)
13725OP2(
SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0,
SLJIT_IMM, (CURRENT_AS(then_trap_backtrack)->framesize - 1) *
sizeof(
sljit_sw));
13728free_stack(common, 3);
13734 static voidcompile_backtrackingpath(compiler_common *common,
structbacktrack_common *current)
13737then_trap_backtrack *save_then_trap = common->then_trap;
13741 if(current->simple_backtracks !=
NULL)
13742set_jumps(current->simple_backtracks,
LABEL());
13743 switch(*current->cc)
13747free_stack(common, 1);
13818 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 13821compile_iterator_backtrackingpath(common, current);
13828compile_ref_iterator_backtrackingpath(common, current);
13832compile_recurse_backtrackingpath(common, current);
13839compile_assert_backtrackingpath(common, current);
13852compile_bracket_backtrackingpath(common, current);
13857compile_bracket_backtrackingpath(common, current);
13859compile_assert_backtrackingpath(common, current);
13867compile_bracketpos_backtrackingpath(common, current);
13871compile_braminzero_backtrackingpath(common, current);
13876 if(common->has_skip_arg)
13878free_stack(common, common->has_skip_arg ? 5 : 1);
13880 if(common->has_skip_arg)
13890compile_control_verb_backtrackingpath(common, current);
13895 if(!common->local_quit_available)
13897 if(common->quit_label ==
NULL)
13908set_jumps(current->own_backtracks,
LABEL());
13912compile_vreverse_backtrackingpath(common, current);
13917compile_then_trap_backtrackingpath(common, current);
13924current = current->prev;
13926common->then_trap = save_then_trap;
13929 static SLJIT_INLINE voidcompile_recurse(compiler_common *common)
13932 PCRE2_SPTRcc = common->start + common->currententry->start;
13936 intprivate_data_size = get_recurse_data_length(common, ccbegin, ccend, &recurse_flags);
13937 intalt_count, alt_max, local_size;
13938backtrack_common altbacktrack;
13946common->then_trap =
NULL;
13950alt_max = no_alternatives(cc);
13954 SLJIT_ASSERT(common->currententry->entry_label ==
NULL&& common->recursive_head_ptr != 0);
13955common->currententry->entry_label =
LABEL();
13956set_jumps(common->currententry->entry_calls, common->currententry->entry_label);
13959count_match(common);
13961local_size = (alt_max > 1) ? 2 : 1;
13966allocate_stack(common, private_data_size + local_size);
13970copy_recurse_data(common, ccbegin, ccend, recurse_copy_from_global, local_size, private_data_size + local_size, recurse_flags);
13975 if(recurse_flags & recurse_flag_control_head_found)
13981memset(&altbacktrack, 0,
sizeof(backtrack_common));
13982common->quit_label =
NULL;
13983common->accept_label =
NULL;
13984common->quit =
NULL;
13985common->accept =
NULL;
13986altbacktrack.cc = ccbegin;
13990altbacktrack.top =
NULL;
13991altbacktrack.own_backtracks =
NULL;
13993 if(altbacktrack.cc != ccbegin)
13996compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);
14000allocate_stack(common, (alt_max > 1 || (recurse_flags & recurse_flag_accept_found)) ? 2 : 1);
14003 if(alt_max > 1 || (recurse_flags & recurse_flag_accept_found))
14013 if(alt_count == 0)
14017common->currententry->backtrack_label =
LABEL();
14018set_jumps(common->currententry->backtrack_calls, common->currententry->backtrack_label);
14022 if(recurse_flags & recurse_flag_accept_found)
14029copy_recurse_data(common, ccbegin, ccend, recurse_swap_global, local_size, private_data_size + local_size, recurse_flags);
14034free_stack(common, 2);
14046free_stack(common, (recurse_flags & recurse_flag_accept_found) ? 2 : 1);
14048 else if(alt_max > 3)
14055JUMPHERE(next_alt);
14056 if(alt_count + 1 < alt_max)
14065compile_backtrackingpath(common, altbacktrack.top);
14068set_jumps(altbacktrack.own_backtracks,
LABEL());
14081copy_recurse_data(common, ccbegin, ccend, recurse_copy_private_to_global, local_size, private_data_size + local_size, recurse_flags);
14084free_stack(common, private_data_size + local_size);
14088 if(common->quit !=
NULL)
14090 SLJIT_ASSERT(recurse_flags & recurse_flag_quit_found);
14092set_jumps(common->quit,
LABEL());
14094copy_recurse_data(common, ccbegin, ccend, recurse_copy_shared_to_global, local_size, private_data_size + local_size, recurse_flags);
14098 if(recurse_flags & recurse_flag_accept_found)
14100JUMPHERE(accept_exit);
14101free_stack(common, 2);
14106copy_recurse_data(common, ccbegin, ccend, recurse_copy_kept_shared_to_global, local_size, private_data_size + local_size, recurse_flags);
14109free_stack(common, private_data_size + local_size);
14114 if(common->accept !=
NULL)
14116 SLJIT_ASSERT(recurse_flags & recurse_flag_accept_found);
14118set_jumps(common->accept,
LABEL());
14121OP1(
SLJIT_MOV, TMP2, 0, STACK_TOP, 0);
14123allocate_stack(common, 2);
14131copy_recurse_data(common, ccbegin, ccend, recurse_swap_global, local_size, private_data_size + local_size, recurse_flags);
14138 #undef COMPILE_BACKTRACKINGPATH 14141 #define PUBLIC_JIT_COMPILE_CONFIGURATION_OPTIONS \ 14142 (PCRE2_JIT_INVALID_UTF) 14148backtrack_common rootbacktrack;
14149compiler_common common_data;
14150compiler_common *common = &common_data;
14153 intprivate_data_size;
14155executable_functions *functions;
14156 void*executable_func;
14169jump_list *reqcu_not_found =
NULL;
14173 #if HAS_VIRTUAL_REGISTERS == 1 14175 #elif HAS_VIRTUAL_REGISTERS == 0 14178 #error "Invalid value for HAS_VIRTUAL_REGISTERS" 14181memset(&rootbacktrack, 0,
sizeof(backtrack_common));
14182memset(common, 0,
sizeof(compiler_common));
14187 #ifdef SUPPORT_UNICODE 14190 mode&= ~PUBLIC_JIT_COMPILE_CONFIGURATION_OPTIONS;
14192common->start = rootbacktrack.cc;
14193common->read_only_data_head =
NULL;
14196common->mode =
mode;
14210common->nlmax = READ_CHAR_MAX;
14224common->bsr_nlmax = READ_CHAR_MAX;
14225common->bsr_nlmin = 0;
14232 #ifdef SUPPORT_UNICODE 14239common->nlmax = 0x2029;
14245common->nlmax = common->newline & 0xff;
14249common->nlmin = common->newline & 0xff;
14254common->bsr_nlmax = 0x2029;
14260common->invalid_utf =
FALSE;
14262ccend = bracketend(common->start);
14265common->ovector_start = LIMIT_MATCH +
sizeof(
sljit_sw);
14267 if(!common->optimized_cbracket)
14269 #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1 14270memset(common->optimized_cbracket, 0, re->
top_bracket+ 1);
14272memset(common->optimized_cbracket, 1, re->
top_bracket+ 1);
14276 #if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 2 14277common->capture_last_ptr = common->ovector_start;
14278common->ovector_start +=
sizeof(
sljit_sw);
14280 if(!check_opcode_types(common, common->start, ccend))
14282 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14289common->req_char_ptr = common->ovector_start;
14290common->ovector_start +=
sizeof(
sljit_sw);
14294common->start_used_ptr = common->ovector_start;
14295common->ovector_start +=
sizeof(
sljit_sw);
14298common->hit_start = common->ovector_start;
14299common->ovector_start +=
sizeof(
sljit_sw);
14304common->match_end_ptr = common->ovector_start;
14305common->ovector_start +=
sizeof(
sljit_sw);
14307 #if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD 14308common->control_head_ptr = 1;
14310 if(common->control_head_ptr != 0)
14312common->control_head_ptr = common->ovector_start;
14313common->ovector_start +=
sizeof(
sljit_sw);
14315 if(common->has_set_som)
14318common->start_ptr = common->ovector_start;
14319common->ovector_start +=
sizeof(
sljit_sw);
14323 if((common->ovector_start &
sizeof(
sljit_sw)) != 0)
14324common->ovector_start +=
sizeof(
sljit_sw);
14326 if(common->start_ptr == 0)
14327common->start_ptr = OVECTOR(0);
14330 if(common->capture_last_ptr != 0)
14331memset(common->optimized_cbracket, 0, re->
top_bracket+ 1);
14333 SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
14336total_length = ccend - common->start;
14338 if(!common->private_data_ptrs)
14340 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14343memset(common->private_data_ptrs, 0, total_length *
sizeof(
sljit_s32));
14348detect_early_fail(common, common->start, &private_data_size, 0, 0);
14350set_private_data_ptrs(common, &private_data_size, ccend);
14352 SLJIT_ASSERT(common->early_fail_start_ptr <= common->early_fail_end_ptr);
14354 if(private_data_size > 65536)
14356 SLJIT_FREE(common->private_data_ptrs, allocator_data);
14357 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14361 if(common->has_then)
14363common->then_offsets = (
sljit_u8*)(common->private_data_ptrs + total_length);
14364memset(common->then_offsets, 0, total_length);
14365set_then_offsets(common, common->start,
NULL);
14371 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14372 SLJIT_FREE(common->private_data_ptrs, allocator_data);
14375common->compiler = compiler;
14382reset_ovector(common, (re->
top_bracket+ 1) * 2);
14383 if(common->req_char_ptr != 0)
14397 if(common->early_fail_start_ptr < common->early_fail_end_ptr)
14398reset_early_fail(common);
14402 if(common->mark_ptr != 0)
14404 if(common->control_head_ptr != 0)
14410mainloop_label = mainloop_entry(common);
14411continue_match_label =
LABEL();
14418fast_forward_first_char(common);
14420fast_forward_newline(common);
14422fast_forward_start_bits(common);
14426continue_match_label =
LABEL();
14434 if(common->req_char_ptr != 0)
14441 if(common->capture_last_ptr != 0)
14443 if(common->fast_forward_bc_ptr !=
NULL)
14446 if(common->start_ptr != OVECTOR(0))
14459compile_matchingpath(common, common->start, ccend, &rootbacktrack);
14463 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14464 SLJIT_FREE(common->private_data_ptrs, allocator_data);
14472 if(common->might_be_empty)
14475empty_match_found_label =
LABEL();
14478common->accept_label =
LABEL();
14479 if(common->accept !=
NULL)
14480set_jumps(common->accept, common->accept_label);
14484common->quit_label = common->abort_label =
LABEL();
14485 if(common->quit !=
NULL)
14486set_jumps(common->quit, common->quit_label);
14487 if(common->abort !=
NULL)
14488set_jumps(common->abort, common->abort_label);
14489 if(minlength_check_failed !=
NULL)
14490SET_LABEL(minlength_check_failed, common->abort_label);
14495 if(common->failed_match !=
NULL)
14498set_jumps(common->failed_match,
LABEL());
14504JUMPHERE(end_anchor_failed);
14508common->partialmatchlabel =
LABEL();
14509set_jumps(common->partialmatch, common->partialmatchlabel);
14510return_with_partial_match(common, common->quit_label);
14513 if(common->might_be_empty)
14514empty_match_backtrack_label =
LABEL();
14515compile_backtrackingpath(common, rootbacktrack.top);
14519 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14520 SLJIT_FREE(common->private_data_ptrs, allocator_data);
14526reset_match_label =
LABEL();
14545(common->fast_forward_bc_ptr !=
NULL) ? (PRIVATE_DATA(common->fast_forward_bc_ptr + 1) >> 3) : common->start_ptr);
14549 if(common->ff_newline_shortcut !=
NULL)
14554 if(common->match_end_ptr != 0)
14558CMPTO(
SLJIT_LESS, STR_PTR, 0, TMP1, 0, common->ff_newline_shortcut);
14562CMPTO(
SLJIT_LESS, STR_PTR, 0, STR_END, 0, common->ff_newline_shortcut);
14566CMPTO(
SLJIT_LESS, STR_PTR, 0, (common->match_end_ptr == 0) ? STR_END : TMP1, 0, mainloop_label);
14570 if(reqcu_not_found !=
NULL)
14571set_jumps(reqcu_not_found,
LABEL());
14579flush_stubs(common);
14581 if(common->might_be_empty)
14583JUMPHERE(empty_match);
14584OP1(
SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
14589JUMPTO(
SLJIT_ZERO, empty_match_found_label);
14591CMPTO(
SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label);
14592JUMPTO(
SLJIT_JUMP, empty_match_backtrack_label);
14595common->fast_forward_bc_ptr =
NULL;
14596common->early_fail_start_ptr = 0;
14597common->early_fail_end_ptr = 0;
14598common->currententry = common->entries;
14599common->local_quit_available =
TRUE;
14600quit_label = common->quit_label;
14601 if(common->currententry !=
NULL)
14604common->recurse_bitset_size = ((private_data_size / SSIZE_OF(
sw)) + 7) >> 3;
14606common->recurse_bitset = (
sljit_u8*)
SLJIT_MALLOC(common->recurse_bitset_size, allocator_data);;
14608 if(common->recurse_bitset !=
NULL)
14613compile_recurse(common);
14616flush_stubs(common);
14617common->currententry = common->currententry->next;
14619 while(common->currententry !=
NULL);
14621 SLJIT_FREE(common->recurse_bitset, allocator_data);
14624 if(common->currententry !=
NULL)
14630 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14631 SLJIT_FREE(common->private_data_ptrs, allocator_data);
14636common->local_quit_available =
FALSE;
14637common->quit_label = quit_label;
14641set_jumps(common->stackalloc,
LABEL());
14651OP1(
SLJIT_MOV, STACK_LIMIT, 0, TMP2, 0);
14656OP1(
SLJIT_MOV, TMP2, 0, STACK_LIMIT, 0);
14669set_jumps(common->calllimit,
LABEL());
14673 if(common->revertframes !=
NULL)
14675set_jumps(common->revertframes,
LABEL());
14676do_revertframes(common);
14678 if(common->wordboundary !=
NULL)
14680set_jumps(common->wordboundary,
LABEL());
14681check_wordboundary(common,
FALSE);
14683 if(common->ucp_wordboundary !=
NULL)
14685set_jumps(common->ucp_wordboundary,
LABEL());
14686check_wordboundary(common,
TRUE);
14688 if(common->anynewline !=
NULL)
14690set_jumps(common->anynewline,
LABEL());
14691check_anynewline(common);
14693 if(common->hspace !=
NULL)
14695set_jumps(common->hspace,
LABEL());
14696check_hspace(common);
14698 if(common->vspace !=
NULL)
14700set_jumps(common->vspace,
LABEL());
14701check_vspace(common);
14703 if(common->casefulcmp !=
NULL)
14705set_jumps(common->casefulcmp,
LABEL());
14706do_casefulcmp(common);
14708 if(common->caselesscmp !=
NULL)
14710set_jumps(common->caselesscmp,
LABEL());
14711do_caselesscmp(common);
14713 if(common->reset_match !=
NULL|| common->restart_match !=
NULL)
14715 if(common->restart_match !=
NULL)
14717set_jumps(common->restart_match,
LABEL());
14721set_jumps(common->reset_match,
LABEL());
14722do_reset_match(common, (re->
top_bracket+ 1) * 2);
14724CMPTO(
SLJIT_GREATER, STR_PTR, 0, TMP1, 0, continue_match_label);
14728 #ifdef SUPPORT_UNICODE 14729 #if PCRE2_CODE_UNIT_WIDTH == 8 14730 if(common->utfreadchar !=
NULL)
14732set_jumps(common->utfreadchar,
LABEL());
14733do_utfreadchar(common);
14735 if(common->utfreadtype8 !=
NULL)
14737set_jumps(common->utfreadtype8,
LABEL());
14738do_utfreadtype8(common);
14740 if(common->utfpeakcharback !=
NULL)
14742set_jumps(common->utfpeakcharback,
LABEL());
14743do_utfpeakcharback(common);
14746 #if PCRE2_CODE_UNIT_WIDTH == 8 || PCRE2_CODE_UNIT_WIDTH == 16 14747 if(common->utfreadchar_invalid !=
NULL)
14749set_jumps(common->utfreadchar_invalid,
LABEL());
14750do_utfreadchar_invalid(common);
14752 if(common->utfreadnewline_invalid !=
NULL)
14754set_jumps(common->utfreadnewline_invalid,
LABEL());
14755do_utfreadnewline_invalid(common);
14757 if(common->utfmoveback_invalid)
14759set_jumps(common->utfmoveback_invalid,
LABEL());
14760do_utfmoveback_invalid(common);
14762 if(common->utfpeakcharback_invalid)
14764set_jumps(common->utfpeakcharback_invalid,
LABEL());
14765do_utfpeakcharback_invalid(common);
14768 if(common->getucd !=
NULL)
14770set_jumps(common->getucd,
LABEL());
14773 if(common->getucdtype !=
NULL)
14775set_jumps(common->getucdtype,
LABEL());
14776do_getucdtype(common);
14780 SLJIT_FREE(common->optimized_cbracket, allocator_data);
14781 SLJIT_FREE(common->private_data_ptrs, allocator_data);
14787 if(executable_func ==
NULL)
14798functions =
SLJIT_MALLOC(
sizeof(executable_functions), allocator_data);
14799 if(functions ==
NULL)
14807memset(functions, 0,
sizeof(executable_functions));
14820functions->executable_funcs[
mode] = executable_func;
14821functions->read_only_data_heads[
mode] = common->read_only_data_head;
14822functions->executable_sizes[
mode] = executable_size;
14843 #define PUBLIC_JIT_COMPILE_OPTIONS \ 14844 (PCRE2_JIT_COMPLETE|PCRE2_JIT_PARTIAL_SOFT|PCRE2_JIT_PARTIAL_HARD|PCRE2_JIT_INVALID_UTF) 14851executable_functions *functions;
14852 static intexecutable_allocator_is_working = -1;
14907 #ifndef SUPPORT_JIT 14915 if(executable_allocator_is_working == -1)
14920 void*ptr = SLJIT_MALLOC_EXEC(32,
NULL);
14924executable_allocator_is_working = 1;
14926 elseexecutable_allocator_is_working = 0;
14929 if(!executable_allocator_is_working)
14936|| functions->executable_funcs[0] ==
NULL)) {
14938 int result= jit_compile(
code, options & ~excluded_options);
14944|| functions->executable_funcs[1] ==
NULL)) {
14946 int result= jit_compile(
code, options & ~excluded_options);
14952|| functions->executable_funcs[2] ==
NULL)) {
14954 int result= jit_compile(
code, options & ~excluded_options);
14967 #define INCLUDED_FROM_PCRE2_JIT_COMPILEncbi::TMaskedQueryRegions mask
#define CMP(a, b)
Return -1/0/1 if a is less than/equal to/greater than b.
static unsigned char depth[2 *(256+1+29)+1]
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static const char * str(char *buf, int n)
static const char label[]
unsigned int
A callback function used to compare two keys in a database.
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is smart and slim</td> n<td> orig</td> n</tr> n<tr> n<td> last_modified</td> n<td> optional</td> n<td> Integer</td> n<td class=\"description\"> The blob last modification If provided then the exact match will be requested with n the Cassandra storage corresponding field value</td> n<td> Positive integer Not provided means that the most recent match will be selected</td> n<td></td> n</tr> n<tr> n<td> use_cache</td> n<td> optional</td> n<td> String</td> n<td class=\"description\"> The option controls if the Cassandra LMDB cache and or database should be used It n affects the seq id resolution step and the blob properties lookup step The following n options are BIOSEQ_INFO and BLOB_PROP at all
while(yy_chk[yy_base[yy_current_state]+yy_c] !=yy_current_state)
if(yy_accept[yy_current_state])
static void byte(MDB_val *v)
typename conditional_helper< V >::template type< A, B > conditional
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
int strcmp(const char *str1, const char *str2)
static const BitmapCharRec *const chars[]
#define TRUE
bool replacment for C indicating true.
#define FALSE
bool replacment for C indicating false.
#define PCRE2_DOLLAR_ENDONLY
#define PCRE2_NOTEMPTY_ATSTART
#define PCRE2_ENDANCHORED
#define PCRE2_BSR_ANYCRLF
#define PCRE2_ERROR_NOMATCH
#define PCRE2_ERROR_INTERNAL
#define PCRE2_ERROR_JIT_BADOPTION
#define PCRE2_MATCH_INVALID_UTF
#define PCRE2_NEWLINE_ANYCRLF
#define PCRE2_MATCH_UNSET_BACKREF
#define PCRE2_ERROR_JIT_STACKLIMIT
#define PCRE2_USE_OFFSET_LIMIT
#define PCRE2_ERROR_MATCHLIMIT
#define PCRE2_JIT_PARTIAL_HARD
#define PCRE2_JIT_INVALID_UTF
#define PCRE2_CALL_CONVENTION
#define PCRE2_ALT_CIRCUMFLEX
#define PCRE2_JIT_COMPLETE
#define PCRE2_NEWLINE_CRLF
#define PCRE2_JIT_PARTIAL_SOFT
#define PCRE2_NEWLINE_NUL
#define PCRE2_BSR_UNICODE
#define PCRE2_NO_START_OPTIMIZE
#define pcre2_callout_block
#define PCRE2_ERROR_PARTIAL
#define PCRE2_NEWLINE_ANY
#define PCRE2_ERROR_NOMEMORY
#define PCRE2_FIRSTMAPSET
#define PCRE2_FIRSTCASELESS
#define CHAR_GRAVE_ACCENT
@ OP_NOT_UCP_WORD_BOUNDARY
#define PCRE2_LASTCASELESS
#define MAX_UTF_CODE_POINT
#define CHAR_COMMERCIAL_AT
#define UCD_BIDICLASS_SHIFT
#define UCD_OTHERCASE(ch)
#define PCRE2_MATCH_EMPTY
#define UCD_GRAPHBREAK(ch)
struct pcre2_real_code pcre2_real_code
#define TABLE_GET(c, table, default)
#define GETCHARINCTEST(c, eptr)
#define GETCHARLEN(c, eptr, len)
#define GETCHARINC(c, eptr)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_jit_compile(pcre2_code *code, uint32_t options)
#define PUBLIC_JIT_COMPILE_OPTIONS
void PRIV() jit_free_rodata(void *current, void *allocator_data)
static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)
@ ucp_gbRegional_Indicator
@ ucp_gbExtended_Pictographic
static pcre2_match_data * match_data
int valid_utf(PCRE2_SPTR8, PCRE2_SIZE, PCRE2_SIZE *)
#define SLJIT_UNREACHABLE()
unsigned short int sljit_u16
#define SLJIT_UNLIKELY(x)
#define SLJIT_COMPILE_ASSERT(x, description)
#define SLJIT_MALLOC(size, allocator_data)
#define SLJIT_FREE(ptr, allocator_data)
#define SLJIT_UNUSED_ARG(arg)
#define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS
#define SLJIT_EXEC_OFFSET(ptr)
#define SLJIT_ARGS3(ret, arg1, arg2, arg3)
#define SLJIT_SET_SIG_LESS_EQUAL
sljit_s32 sljit_emit_icall(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 arg_types, sljit_s32 src, sljit_sw srcw)
#define SLJIT_FAST_RETURN
#define SLJIT_SET_GREATER_EQUAL
#define SLJIT_HAS_ZERO_REGISTER
void sljit_set_current_flags(struct sljit_compiler *compiler, sljit_s32 current_flags)
#define SLJIT_MEM2(r1, r2)
static __inline sljit_s32 sljit_get_compiler_error(struct sljit_compiler *compiler)
#define SLJIT_FUNC_ADDR(func_name)
void * sljit_alloc_memory(struct sljit_compiler *compiler, sljit_s32 size)
void sljit_free_compiler(struct sljit_compiler *compiler)
#define SLJIT_CURRENT_FLAGS_COMPARE
#define SLJIT_SET_SIG_GREATER
sljit_s32 sljit_emit_ijump(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 src, sljit_sw srcw)
void sljit_set_label(struct sljit_jump *jump, struct sljit_label *label)
static __inline sljit_uw sljit_get_generated_code_size(struct sljit_compiler *compiler)
sljit_s32 sljit_emit_enter(struct sljit_compiler *compiler, sljit_s32 options, sljit_s32 arg_types, sljit_s32 scratches, sljit_s32 saveds, sljit_s32 fscratches, sljit_s32 fsaveds, sljit_s32 local_size)
struct sljit_compiler * sljit_create_compiler(void *allocator_data)
#define SLJIT_SIG_LESS_EQUAL
sljit_s32 sljit_get_register_index(sljit_s32 type, sljit_s32 reg)
void * sljit_generate_code(struct sljit_compiler *compiler, sljit_s32 options, void *exec_allocator_data)
sljit_s32 sljit_emit_return(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 src, sljit_sw srcw)
void sljit_free_code(void *code, void *exec_allocator_data)
#define SLJIT_ARGS1(ret, arg1)
struct sljit_jump * sljit_emit_mov_addr(struct sljit_compiler *compiler, sljit_s32 dst, sljit_sw dstw)
sljit_u8 * sljit_stack_resize(struct sljit_stack *stack, sljit_u8 *new_start)
sljit_s32 sljit_emit_op_dst(struct sljit_compiler *compiler, sljit_s32 op, sljit_s32 dst, sljit_sw dstw)
#define SLJIT_SIG_GREATER
sljit_s32 sljit_emit_mem_update(struct sljit_compiler *compiler, sljit_s32 type, sljit_s32 reg, sljit_s32 mem, sljit_sw memw)
#define SLJIT_GREATER_EQUAL
#define SLJIT_GP_REGISTER
#define SLJIT_SKIP_FRAMES_BEFORE_RETURN
#define SLJIT_OFFSETOF(base, member)
sljit_s32 sljit_emit_op0(struct sljit_compiler *compiler, sljit_s32 op)
sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
#define SLJIT_SET_LESS_EQUAL
#define SLJIT_SET_GREATER
#define SLJIT_MAX_LOCAL_SIZE
#define SLJIT_CURRENT_FLAGS_SUB
void sljit_set_compiler_memory_error(struct sljit_compiler *compiler)
#define SLJIT_ARGS2(ret, arg1, arg2)
static SLJIT_INLINE sljit_ins lgb(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
void *(* malloc)(size_t, void *)
void(* free)(void *, void *)
uint16_t newline_convention
union sljit_jump::@1235 u
union sljit_label::@1234 u
static CS_CONTEXT * context
static wxAcceleratorEntry entries[3]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4