d6a60a0ee1
This change significantly improves the performance of string concatenation in optimized code for the case where the resulting string is represented as a ConsString. On the relevant test cases we go from serializeNaive: 10762 ms. serializeClever: 7813 ms. serializeConcat: 10271 ms. to serializeNaive: 10278 ms. serializeClever: 5533 ms. serializeConcat: 10310 ms. which represents a 30% improvement on the "clever" benchmark, which tests specifically the ConsString creation performance. This was accomplished via a couple of different steps, which are briefly outlined here: 1. The empty_string gets its own map, so that we can easily recognize and handle it appropriately in the TurboFan type system. This allows us to express (and assert) that the inputs to NewConsString are non-empty strings, making sure that TurboFan no longer creates "crippled ConsStrings" with empty left or right hand sides. 2. Further split the existing String types in TurboFan to be able to distinguish between OneByte and TwoByte strings on the type system level. This allows us to avoid having to dynamically lookup the resulting ConsString map in case of ConsString creation (i.e. when we know that both input strings are OneByte strings or at least one of the input strings is TwoByte). 3. We also introduced more finegrained feedback for the Add bytecode in the interpreter, having it collect feedback about ConsStrings, specifically ConsOneByteString and ConsTwoByteString. This feedback can be used by TurboFan to only inline the relevant code for what was seen so far. This allows us to remove the Octane/Splay specific magic in JSTypedLowering to detect ConsString creation, and instead purely rely on the feedback of what was seen so far (also making it possible to change the semantics of NewConsString to be a low-level operator, which is only introduced in SimplifiedLowering by looking at the input types of StringConcat). 4. On top of the before mentioned type and interpreter changes we added new operators CheckNonEmptyString, CheckNonEmptyOneByteString, and CheckNonEmptyTwoByteString, which perform the appropriate (dynamic) checks. There are several more improvements that are possible based on this, but since the change was already quite big, we decided not to put everything into the first change, but do some follow up tweaks to the type system, and builtin optimizations later. Tbr: mstarzinger@chromium.org Bug: v8:8834, v8:8931, v8:8939, v8:8951 Change-Id: Ia24e17c6048bf2b04df966d3cd441f0edda05c93 Cq-Include-Trybots: luci.chromium.try:linux-blink-rel Doc: https://bit.ly/fast-string-concatenation-in-javascript Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1499497 Commit-Queue: Michael Achenbach <machenbach@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Reviewed-by: Jaroslav Sevcik <jarin@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#60318} |
||
---|---|---|
.. | ||
compiler | ||
heap | ||
interpreter | ||
libplatform | ||
libsampler | ||
parsing | ||
torque | ||
wasm | ||
assembler-helper-arm.cc | ||
assembler-helper-arm.h | ||
BUILD.gn | ||
cctest.cc | ||
cctest.h | ||
cctest.status | ||
DEPS | ||
expression-type-collector-macros.h | ||
gay-fixed.cc | ||
gay-fixed.h | ||
gay-precision.cc | ||
gay-precision.h | ||
gay-shortest.cc | ||
gay-shortest.h | ||
log-eq-of-logging-and-traversal.js | ||
OWNERS | ||
print-extension.cc | ||
print-extension.h | ||
profiler-extension.cc | ||
profiler-extension.h | ||
scope-test-helper.h | ||
setup-isolate-for-tests.cc | ||
setup-isolate-for-tests.h | ||
test-access-checks.cc | ||
test-accessor-assembler.cc | ||
test-accessors.cc | ||
test-allocation.cc | ||
test-api-accessors.cc | ||
test-api-interceptors.cc | ||
test-api.cc | ||
test-api.h | ||
test-array-list.cc | ||
test-assembler-arm64.cc | ||
test-assembler-arm.cc | ||
test-assembler-ia32.cc | ||
test-assembler-mips64.cc | ||
test-assembler-mips.cc | ||
test-assembler-ppc.cc | ||
test-assembler-s390.cc | ||
test-assembler-x64.cc | ||
test-atomicops.cc | ||
test-bignum-dtoa.cc | ||
test-bignum.cc | ||
test-bit-vector.cc | ||
test-circular-queue.cc | ||
test-code-layout.cc | ||
test-code-stub-assembler.cc | ||
test-compiler.cc | ||
test-constantpool.cc | ||
test-conversions.cc | ||
test-cpu-profiler.cc | ||
test-date.cc | ||
test-debug.cc | ||
test-decls.cc | ||
test-deoptimization.cc | ||
test-dictionary.cc | ||
test-disasm-arm64.cc | ||
test-disasm-arm.cc | ||
test-disasm-ia32.cc | ||
test-disasm-mips64.cc | ||
test-disasm-mips.cc | ||
test-disasm-ppc.cc | ||
test-disasm-s390.cc | ||
test-disasm-x64.cc | ||
test-diy-fp.cc | ||
test-double.cc | ||
test-dtoa.cc | ||
test-elements-kind.cc | ||
test-extra.js | ||
test-factory.cc | ||
test-fast-dtoa.cc | ||
test-feedback-vector.cc | ||
test-feedback-vector.h | ||
test-field-type-tracking.cc | ||
test-fixed-dtoa.cc | ||
test-flags.cc | ||
test-func-name-inference.cc | ||
test-fuzz-arm64.cc | ||
test-global-handles.cc | ||
test-global-object.cc | ||
test-hashcode.cc | ||
test-hashmap.cc | ||
test-heap-profiler.cc | ||
test-icache.cc | ||
test-identity-map.cc | ||
test-inobject-slack-tracking.cc | ||
test-inspector.cc | ||
test-intl.cc | ||
test-javascript-arm64.cc | ||
test-js-arm64-variables.cc | ||
test-js-weak-refs.cc | ||
test-liveedit.cc | ||
test-lockers.cc | ||
test-log-stack-tracer.cc | ||
test-log.cc | ||
test-macro-assembler-arm.cc | ||
test-macro-assembler-mips64.cc | ||
test-macro-assembler-mips.cc | ||
test-macro-assembler-x64.cc | ||
test-managed.cc | ||
test-mementos.cc | ||
test-modules.cc | ||
test-object.cc | ||
test-orderedhashtable.cc | ||
test-parsing.cc | ||
test-platform.cc | ||
test-poison-disasm-arm.cc | ||
test-profile-generator.cc | ||
test-random-number-generator.cc | ||
test-regexp.cc | ||
test-representation.cc | ||
test-roots.cc | ||
test-sampler-api.cc | ||
test-serialize.cc | ||
test-smi-lexicographic-compare.cc | ||
test-strings.cc | ||
test-strtod.cc | ||
test-symbols.cc | ||
test-sync-primitives-arm64.cc | ||
test-sync-primitives-arm.cc | ||
test-thread-termination.cc | ||
test-threads.cc | ||
test-trace-event.cc | ||
test-traced-value.cc | ||
test-transitions.cc | ||
test-transitions.h | ||
test-typedarrays.cc | ||
test-types.cc | ||
test-unbound-queue.cc | ||
test-unboxed-doubles.cc | ||
test-unscopables-hidden-prototype.cc | ||
test-unwinder.cc | ||
test-usecounters.cc | ||
test-utils-arm64.cc | ||
test-utils-arm64.h | ||
test-utils.cc | ||
test-version.cc | ||
test-weakmaps.cc | ||
test-weaksets.cc | ||
testcfg.py | ||
trace-extension.cc | ||
trace-extension.h | ||
unicode-helpers.cc | ||
unicode-helpers.h |