• Darius M's avatar
    [compiler] fix bug with string concatenation folding · c0ba94db
    Darius M authored
    We can't freely concatenate strings in the background because they
    could be mutated by the main thread (eg, flattened, internalized,
    externalized...).
    
    So, when there is a JSAdd between 2 constant strings, we first checked
    if they are "safe" (= internalized, I think), and if so, we
    concatenate them at compile time. If they are "unsafe", then we don't.
    
    It turns out that this wasn't an issue with delayed constant strings,
    since the content of the strings were never accessed: the actual
    concatenations were done on the main thread, where it's safe to do.
    
    This CL fixes that for most cases:
    
      - if the strings really cannot be read from the background, but the
        length of their concatenation is more than ConsString::kMinLength,
        then we create a ConsString.
    
      - I added a set to record which strings we created in the turbofan:
        those strings can safely be accessed from turbofan regardless of
        their type.
    
    The only case where delayed constant strings could be a bit better is
    when there is a concatenation of 2 small non-internalized string,
    because right now, we wouldn't fold it. Still, it should happen very
    rarely, if ever.
    
    
    Bug: chromium:1359941
    Change-Id: I651b834273de89f1e3c60654094a4606dd9c62f0
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3891252Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
    Commit-Queue: Darius Mercadier <dmercadier@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#83251}
    c0ba94db
Name
Last commit
Last update
.github Loading commit data...
bazel Loading commit data...
build_overrides Loading commit data...
custom_deps Loading commit data...
docs Loading commit data...
gni Loading commit data...
include Loading commit data...
infra Loading commit data...
samples Loading commit data...
src Loading commit data...
test Loading commit data...
testing Loading commit data...
third_party Loading commit data...
tools Loading commit data...
.bazelrc Loading commit data...
.clang-format Loading commit data...
.clang-tidy Loading commit data...
.editorconfig Loading commit data...
.flake8 Loading commit data...
.git-blame-ignore-revs Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gn Loading commit data...
.mailmap Loading commit data...
.style.yapf Loading commit data...
.vpython Loading commit data...
.vpython3 Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.bazel Loading commit data...
BUILD.gn Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
COMMON_OWNERS Loading commit data...
DEPS Loading commit data...
DIR_METADATA Loading commit data...
ENG_REVIEW_OWNERS Loading commit data...
INFRA_OWNERS Loading commit data...
INTL_OWNERS Loading commit data...
LICENSE Loading commit data...
LICENSE.fdlibm Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LOONG_OWNERS Loading commit data...
MIPS_OWNERS Loading commit data...
OWNERS Loading commit data...
PPC_OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
RISCV_OWNERS Loading commit data...
S390_OWNERS Loading commit data...
WATCHLISTS Loading commit data...
WORKSPACE Loading commit data...
codereview.settings Loading commit data...