Autor: Zoltán Herczeg Datum: To: Giuseppe D'Angelo CC: pcre-dev Betreff: Re: [pcre-dev] PCRE2 and thread safety of jit compilation?
>Do you mean that PCRE internally will read/save the JIT-compiled data >inside the pcre2_code using atomic operations?
Exactly. The JIT compiler produces a pointer, and storing that pointer is an atomic operation. When that pointer is stored, it becomes "active". If compilation fails, the pointer is not produced, and it never becomes "active". The default value of that pointer is NULL, which means machine code is not available. If one core stores the pointer, but that value has not been shared with another core yet, pcre2 simply chooses interpreted mode on those cores. Eventually all stores will be shared across cores, and all threads will use machine code. Probably a write barrier would make this perfect, but I am not an expert on that, and it requires CPU / OS dependent code.
Anyway, I don't want to limit JIT compilation to one thread.