Repository navigation
Conversation
| OP1(SLJIT_MOV, TMP2, 0, STR_END, 0); | ||
| if ((overall_options & PCRE2_FIRSTLINE) != 0) | ||
| { | ||
| OP1(SLJIT_MOV, TMP3, 0, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr); |
There was a problem hiding this comment.
I would use TMP1 here. TMP3 is memory on x86-32.
|
Thinking about it the offset limit could limit the newline search. Hence, if start+offset_limit<str_end it is better to search until that point. The str_end could be saved temporariliy, and restored afterwards. |
The JIT treated FIRSTLINE and USE_OFFSET_LIMIT as mutually exclusive, so enabling FIRSTLINE caused an explicit offset limit to be ignored. This allowed matches beyond the requested starting-offset limit, unlike the interpreter. Generate both checks and use the earlier of the FIRSTLINE boundary and the offset-limit boundary. Preserve the FIRSTLINE boundary when the offset limit is unset. Add shared interpreter/JIT regression tests covering inclusive limits, nonzero starting offsets, LF/CRLF, and start optimizations. Without the fix, 11 new cases fail under JIT at each code-unit width; with it, test 2 passes under both engines at all widths.
The offset in TMP1 has been used and can now be clobbered.
60b8b68 to
32966b2
Compare
Thanks Zoltan. I have kept the existing structure of the code unchanged, but added in an extra block of code for the newline checking, which activates when the offset_limit is also set. I have temporarily reduced STR_END for the newline scan, and restored it from LOCAL0. |
I opted to keep the existing structure, but add an offset_limit optimisation as a special case to the newline lookup. I am keeping the existing newline lookup, but with a temporarily-reduced STR_END value. The saved value goes in a blank LOCAL0 slot.
32966b2 to
595ec76
Compare
The JIT treated FIRSTLINE and USE_OFFSET_LIMIT as mutually exclusive, so enabling FIRSTLINE caused an explicit offset limit to be ignored. This allowed matches beyond the requested starting-offset limit, unlike the interpreter.
Note that the documentation explicitly says both are supported together, and if so, whichever limit is earlier applies.
Generate both checks and use the earlier of the FIRSTLINE boundary and the offset-limit boundary. Preserve the FIRSTLINE boundary when the offset limit is unset.
Add shared interpreter/JIT regression tests covering inclusive limits, nonzero starting offsets, LF/CRLF, and start optimizations. Without the fix, 11 new cases fail under JIT at each code-unit width; with it, test 2 passes under both engines at all widths.