Hi,
hm, interesting problem. I don't remember how this should work. Anyway, I checked the code:
pcre2_jit_compile:
if ((re->flags & PCRE2_NOJIT) != 0) return 0;
So it returns with success if NOJIT is present. That is perhaps misleading. I wouldn't mind changing this.
pcre2_jit_match:
if (functions->executable_funcs[index] == NULL) return PCRE2_ERROR_JIT_BADOPTION;
It checks that the function (normal, partial, etc.) is present, but does not check that functions->executable_funcs is non NULL. The point of pcre2_jit_match is doing as few checks as possible to maintain high performance, but I don't mind adding this extra check.
The pcre2_pattern_info(...INFO_JITSIZE...) returns 0 if no code is compiled.
Perhaps you can do the following now (for compatibility):
1) size = pcre2_pattern_info(...INFO_JITSIZE...)
2) call pcre2_jit_compile(...) if it returns non-0, compilation is failed.
3) if (size == pcre2_pattern_info(...INFO_JITSIZE...)) -> NO_JIT is present or the code was compiled before :)
I am open to any solution to improve this situation.
Philip, your opinion?
Regards,
Zoltan
-------- Eredeti levél --------
Feladó: Ævar Arnfjörð Bjarmason via Pcre-dev < pcre-dev@??? (Link ->
mailto:pcre-dev@exim.org) >
Dátum: 2017 november 21 20:27:30
Tárgy: [pcre-dev] How am I supposed to use PCRE2 JIT in the face of (*NO_JIT) ?
Címzett: pcre-dev@??? (Link ->
mailto:pcre-dev@exim.org)
I'm doing the following:
1. pcre2_compile
2. pcre2_config(...CONFIG_JIT
3. pcre2_pattern_info(...INFO_JITSIZE...)
Then if the JIT is on according to the pcre2_config() return value,
call pcre2_jit_match() later instead of pcre2_match() (and earlier
jit_compile, jit stack etc.).
The problem is that if the pattern has (*NO_JIT) in it calling
pcre2_jit_match() will segfault, which I get, it says "no JIT" so
presumably some internal thing didn't compile the appropriate
structures.
But I can't find any way to figure out from pcre2_config() or anything
else whether the string I just compiled contains (*NO_JIT). Is there
such an API, or do I need to do a string match against the pattern
itself?
--
## List details at
https://lists.exim.org/mailman/listinfo/pcre-dev