Ignore:
Timestamp:
Feb 6, 2022, 12:37:53 PM (3 years ago)
Author:
Cameron McCormack
Message:

Cache the most recent AtomString produced by JSString::toIdentifier
https://bugs.webkit.org/show_bug.cgi?id=236124

Reviewed by Yusuke Suzuki.

JSString::toIdentifier does not store the result of atomizing its string
value, except when it is a rope. We can often end up atomizing the same
JSString a number of times.

This patch caches the last atomized string produced from
JSString::toIdentifier in a given VM. From local testing, this is a 0.5%
Speedometer2 improvement on an M1 MacBook Air, although surprisingly is
neutral on a recent Intel MacBook Pro.

  • runtime/JSString.h:

(JSC::JSRopeString::toIdentifier const):
(JSC::JSString::toIdentifier const):

  • runtime/VM.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r288885 r289177  
    587587    std::unique_ptr<SimpleStats> machineCodeBytesPerBytecodeWordForBaselineJIT;
    588588    Strong<JSString> lastCachedString;
     589    Ref<StringImpl> lastAtomizedIdentifierStringImpl { *StringImpl::empty() };
     590    Ref<AtomStringImpl> lastAtomizedIdentifierAtomStringImpl { *static_cast<AtomStringImpl*>(StringImpl::empty()) };
    589591    JSONAtomStringCache jsonAtomStringCache;
    590592
Note: See TracChangeset for help on using the changeset viewer.