Bug 60866 - Evaluation order broken for empty alternatives in subpatterns
Summary: Evaluation order broken for empty alternatives in subpatterns
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gavin Barraclough
URL:
Keywords:
Depends on: 60860
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-15 19:28 PDT by Gavin Barraclough
Modified: 2011-05-23 13:51 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Barraclough 2011-05-15 19:28:57 PDT
for example:
    /(|a)/.exec("a");
should return ["",""], but instead returns ["a","a"].

This was broken by https://bugs.webkit.org/show_bug.cgi?id=51395, which will be reverted (this unsafe optimization does not appear significant to any benchmarks we are tracking, we should reimplement in a more restricted, safe fashion only if we can demonstrate an important workload benefitting from doing so).
Comment 1 Gavin Barraclough 2011-05-15 19:33:28 PDT
This unsafe optimization is masking further problems in the JIT, reverting the optimization causes failures in fast/regex/parentheses.

These issues are fixed by 60860.
Comment 2 Geoffrey Garen 2011-05-16 00:08:29 PDT
rs=me to roll out that optimization with a layout test for

/(|a)/.exec("a")
/(a|)/.exec("b")
Comment 3 Gavin Barraclough 2011-05-16 02:08:37 PDT
Fixed in r86547.
Comment 4 Zoltan Herczeg 2011-05-18 06:24:45 PDT
Perhaps a non-greedy conversion? (|a) == a?? (a|) == a?
Comment 5 Gavin Barraclough 2011-05-23 13:51:01 PDT
Conversion to an appropriately greedy quantifier would be possible, but would limit the scope of this optimization.  We would consider such a patch if it were to provide a useful performance gain on an interesting workload.