• jgruber's avatar
    [string] Add a fast path to String.p.replace · f4ba786d
    jgruber authored
    This adds a fast path to skip runtime calls to GetSubstitution when
    the replacer string does not contain a '$' char.
    
    Extended background:
    
    String.prototype.replace is (roughly) structured as follows:
    
    * Check if {searchValue} has a @@replace Symbol, and delegate to that if
      so. We currently implement efficient fast paths when {searchValue} is
      a String or a fast RegExp.
    * A specialized fast path for single-char {searchValue}, "long" subject
      string, and String {replaceValue} that do not contain '$' chars (yes,
      this fast path is very specialized).
    * Check for the location of the first match using StringIndexOf, and
      exit early if no match is found.
    * Finally build the return value, which is 'prefix + replacement +
      suffix', where replacement is either the result of calling {replaceValue}
      (if it is callable), or GetSubstitution(ToString({replaceValue}))
      otherwise.
    
    There's several spots that could be improved.
    
    StringIndexOf currently calls into C++ runtime for all but the simple
    1-byte, 1-char {searchValue} case. We need to finally add support for
    remaining cases.
    
    The runtime call to GetSubstitution can be skipped if the replacer
    string does not contain any '$' syntax. This CL handles that case.
    
    BUG=
    
    Review-Url: https://codereview.chromium.org/2813843002
    Cr-Commit-Position: refs/heads/master@{#44606}
    f4ba786d
Name
Last commit
Last update
..
arm Loading commit data...
arm64 Loading commit data...
ia32 Loading commit data...
mips Loading commit data...
mips64 Loading commit data...
ppc Loading commit data...
s390 Loading commit data...
x64 Loading commit data...
x87 Loading commit data...
builtins-api.cc Loading commit data...
builtins-arguments-gen.cc Loading commit data...
builtins-arguments-gen.h Loading commit data...
builtins-array-gen.cc Loading commit data...
builtins-array.cc Loading commit data...
builtins-arraybuffer.cc Loading commit data...
builtins-async-function-gen.cc Loading commit data...
builtins-async-gen.cc Loading commit data...
builtins-async-gen.h Loading commit data...
builtins-async-generator-gen.cc Loading commit data...
builtins-async-iterator-gen.cc Loading commit data...
builtins-boolean-gen.cc Loading commit data...
builtins-boolean.cc Loading commit data...
builtins-call-gen.cc Loading commit data...
builtins-call.cc Loading commit data...
builtins-callsite.cc Loading commit data...
builtins-constructor-gen.cc Loading commit data...
builtins-constructor-gen.h Loading commit data...
builtins-constructor.h Loading commit data...
builtins-conversion-gen.cc Loading commit data...
builtins-dataview.cc Loading commit data...
builtins-date-gen.cc Loading commit data...
builtins-date.cc Loading commit data...
builtins-debug.cc Loading commit data...
builtins-definitions.h Loading commit data...
builtins-descriptors.h Loading commit data...
builtins-error.cc Loading commit data...
builtins-forin-gen.cc Loading commit data...
builtins-forin-gen.h Loading commit data...
builtins-function-gen.cc Loading commit data...
builtins-function.cc Loading commit data...
builtins-generator-gen.cc Loading commit data...
builtins-global-gen.cc Loading commit data...
builtins-global.cc Loading commit data...
builtins-handler-gen.cc Loading commit data...
builtins-ic-gen.cc Loading commit data...
builtins-internal-gen.cc Loading commit data...
builtins-internal.cc Loading commit data...
builtins-interpreter-gen.cc Loading commit data...
builtins-interpreter.cc Loading commit data...
builtins-intl.cc Loading commit data...
builtins-json.cc Loading commit data...
builtins-math-gen.cc Loading commit data...
builtins-math.cc Loading commit data...
builtins-number-gen.cc Loading commit data...
builtins-number.cc Loading commit data...
builtins-object-gen.cc Loading commit data...
builtins-object.cc Loading commit data...
builtins-promise-gen.cc Loading commit data...
builtins-promise-gen.h Loading commit data...
builtins-proxy.cc Loading commit data...
builtins-reflect.cc Loading commit data...
builtins-regexp-gen.cc Loading commit data...
builtins-regexp-gen.h Loading commit data...
builtins-regexp.cc Loading commit data...
builtins-sharedarraybuffer-gen.cc Loading commit data...
builtins-sharedarraybuffer.cc Loading commit data...
builtins-string-gen.cc Loading commit data...
builtins-string.cc Loading commit data...
builtins-symbol-gen.cc Loading commit data...
builtins-symbol.cc Loading commit data...
builtins-typedarray-gen.cc Loading commit data...
builtins-typedarray.cc Loading commit data...
builtins-utils-gen.h Loading commit data...
builtins-utils.h Loading commit data...
builtins-wasm-gen.cc Loading commit data...
builtins.cc Loading commit data...
builtins.h Loading commit data...
setup-builtins-internal.cc Loading commit data...