• bmeurer's avatar
    [builtins] Re-add similar String wrapper optimization for StringAdd. · 17f59878
    bmeurer authored
    For string wrappers (JSValue instances with [[StringData]] internal
    fields), we can shortcirciut the ToPrimitive if
    
      (a) the {input} map matches the initial map of the String function,
      (b) the {input} [[Prototype]] is the unmodified %StringPrototype% (i.e.
          no one monkey-patched toString, @@toPrimitive or valueOf), and
      (c) the %ObjectPrototype% (i.e. the [[Prototype]] of the
          %StringPrototype%) is also unmodified, that is no one sneaked a
          @@toPrimitive into the %ObjectPrototype%.
    
    If all these assumptions hold, we can just take the [[StringData]] value
    and return it.
    
    This just repairs a regression introduced by removing the
    weird (and broken) intrinsic %_IsStringWrapperSafeForDefaultValue, which
    was intendend to something similar to this, although less efficient and
    wrong in the presence of @@toPrimitive. Long-term we might want to move
    into the direction of having a ToPrimitiveStub that can do common cases
    while staying in JavaScript land (i.e. not going to C++).
    
    R=jarin@chromium.org
    BUG=chromium:532524
    LOG=n
    
    Review URL: https://codereview.chromium.org/1366563002
    
    Cr-Commit-Position: refs/heads/master@{#30890}
    17f59878
Name
Last commit
Last update
benchmarks Loading commit data...
build 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/binutils Loading commit data...
tools Loading commit data...
.clang-format Loading commit data...
.gitignore Loading commit data...
.ycm_extra_conf.py Loading commit data...
AUTHORS Loading commit data...
BUILD.gn Loading commit data...
ChangeLog Loading commit data...
DEPS Loading commit data...
LICENSE Loading commit data...
LICENSE.strongtalk Loading commit data...
LICENSE.v8 Loading commit data...
LICENSE.valgrind Loading commit data...
Makefile Loading commit data...
Makefile.android Loading commit data...
Makefile.nacl Loading commit data...
OWNERS Loading commit data...
PRESUBMIT.py Loading commit data...
README.md Loading commit data...
WATCHLISTS Loading commit data...
codereview.settings Loading commit data...
snapshot_toolchain.gni Loading commit data...