Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplification of ES2015 RegExp semantics #89

Closed
wants to merge 3 commits into from

Commits on Oct 16, 2015

  1. Specialize RegExp methods to only work on real RegExp instances

    In ES2015, regular expression methods like RegExp.prototype[Symbol.search]
    invoked the receiver's "exec" method to get at the core of matching.
    This patch removes that extra degree of genericity to call out to
    the builtin RegExp exec implementation directly. Type checks are
    added where appropriate to ensure that this direct call is safe.
    littledan committed Oct 16, 2015
    Configuration menu
    Copy the full SHA
    bb7d2a3 View commit details
    Browse the repository at this point in the history
  2. Replace internal use of flag getters with [[OriginalFlags]]

    In some places in the ES2015 RegExp specification, flag values are
    read from [[OriginalFlags]], and in other places, they are read
    by invoking Get() on the RegExp to get the flag value.
    This inconsistency does not have any obvious benefits for subclassing
    and may have some performance cost. This patch standardizes on
    reading flag values from [[OriginalFlags]].
    littledan committed Oct 16, 2015
    Configuration menu
    Copy the full SHA
    795cf17 View commit details
    Browse the repository at this point in the history
  3. Factor out a stateless InnerRegExpExec

    Previously, the ES spec matched RegExps using a RegExpExec internal
    algorithm. This algorithm has a couple properties which don't
    completely with its usages, leading to awkward workarounds:
    
    - It modifies lastIndex
    - There is no mechanism for passing additional flags
    
    Now that "exec" is not called as a method, but rather RegExpExec
    is directly invoked from methods like RegExp.prototype[Symbol.split],
    it is possible to refactor RegExpExec to create InnerRegExpExec
    which does not have these issues.
    
    This patch does that refactoring and takes advantage of it to remove
    the lastIndex "save and restore" from RegExp.prototype[Symbol.search]
    and, more importantly, the extra RegExp allocation from
    RegExp.prototype[Symbol.split]. This is a normative change, since
    it affects when the lastIndex property is read and written.
    littledan committed Oct 16, 2015
    Configuration menu
    Copy the full SHA
    9acca20 View commit details
    Browse the repository at this point in the history