• jgruber's avatar
    [regexp] Send sticky @@splits to the slow path · 27fd52ab
    jgruber authored
    Due to shortcuts we take on the RegExp.p[@@split] fast path (we don't allocate
    a new instance), we need to send sticky regexps to the slow path.
    
    The problem is a slight impedance mismatch between the spec and our fast-path
    implementation.
    
    Spec: Creates a new regexp instance `splitter` that is guaranteed to be sticky,
    uses `splitter.lastIndex` to advance the search range, advances by itself using
    AdvanceStringIndex if `splitter` did not match at the current position.
    
    Our fast path: Uses the given regexp instance and does not modify stickyness,
    uses last_match_info to advance search range, returns (and assumes no more
    matches) once RegExpExecInternal fails to match.
    
    This is fine if the given regexp is non-sticky, since 1. the value of lastIndex
    is ignored, and 2. non-sticky regexps match if a match is found anywhere in the
    string, not just exactly at the current lastIndex.
    
    Sticky regexps though are a problem. If no match is found exactly at the current
    position, @@split assumes no more matches and exits.
    
    In a follow-up, we could explore other options, such as allocating a new
    instance or saving/restoring flags and lastIndex.
    
    Bug: v8:6706
    Change-Id: I6da2266df72b2f80f00c1ce3cd7c8655de91f680
    Reviewed-on: https://chromium-review.googlesource.com/626065Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#47543}
    27fd52ab
builtins-regexp-gen.cc 106 KB