| 1 | = JavaScriptCore RegExp Processing = |
| 2 | ''presented by Michael Saboff'' |
| 3 | |
| 4 | Engine is called: YARR (Yet Another RegExp Runtime) |
| 5 | |
| 6 | Has both interpreter and JIT backends |
| 7 | |
| 8 | Uses backtracking algorithm (not DFA based) |
| 9 | |
| 10 | First thing that happens is that the YARR parses a regex and converts it into a YarrPattern. |
| 11 | |
| 12 | Then the YARR interpreter converts the YarrPattern into byte code that it can run. |
| 13 | |
| 14 | Question: Why not use a DFA based system? |
| 15 | It takes a lot longer to compile a DFA system. Also, because JS regular expressions are irregular you wouldn’t be able to have a DFA based system for that. |
| 16 | |
| 17 | Question: How would you know if you wanted to have more tiers of RexExps? |
| 18 | We would probably want to see what the areas the extra tier would help us. We would also want to know how often we are going see those cases. |
| 19 | |
| 20 | Optimizations that YARR does right now: |
| 21 | |
| 22 | Generate different code for different matching purposes. Sometimes the regexp is only used for matching other times they want to access the captured groups. |
| 23 | |
| 24 | Check multiple adjacent characters at once (up to 8) |
| 25 | |
| 26 | Remove unnecessary enclosing patterns: such as /.*abc.*/ which is the same as /abc/ |
| 27 | |
| 28 | Character class canonicalization. Such as converting [12345] into (1 <= c && 5 <= c) instead of if (c == 1) return match; else if (c == 2) … |
| 29 | |
| 30 | = JSC Goals = |
| 31 | ''presented by Saam Barati'' |
| 32 | |
| 33 | JetStream 2: |
| 34 | |
| 35 | We think that the next thing JSC should optimize is BitInt. |
| 36 | We also want to improve our memory usage. |
| 37 | |
| 38 | New Bytecode format: |
| 39 | It separates the parts of the Bytecode specific to a particular function from the core instructions. This lets us share the core instructions across processes or save it to disk. Hopefully, it is a win for startup and for non-jit cases. |
| 40 | |
| 41 | JetStream 2, which is a new benchmark for JS performance that will be open sourced soon (TM). |