3 ms·
Aside from technical difficulty, there's really nothing stopping the V8 guys from spitting out native code to match their regular expressions. And, in fact, the
by pjscott 13y ago
Aside from technical difficulty, there's really nothing stopping the V8 guys from spitting out native code to match their regular expressions. And, in fact, they seem to do this:
http://blog.chromium.org/2009/02/irregexp-google-chromes-new-regexp.html http://blog.chromium.org/2009/02/irregexp-google-chromes-new...
With a sufficiently smart regular expression engine and JIT, they should be able to do about as well as an equivalent hand-rolled thing.
- eliben 13y agoYep, compiling the regex into some sort of "VM" is not a new technique, but eventually the algorithm this bytecode implements is what matters most. The article you linked to suggests that even after the rewrite, V8's regexes are backtracking rather than DFA (the re2 approach), which explains the results, in a way. This is really interesting. The most common point raised in the backtracking vs. DFA debates is pathological inputs that induce exponential behavior. But large alternations seem to be affected quite a bit as well, and are more common. Admittedly, there's no exponential behavior there - just an unfortunate constant factor.