[webkit-changes] [WebKit/WebKit] d2a72f: SerializedScriptValue could be faster by atomizing...

Chris Dumez noreply at github.com
Tue Aug 1 20:36:17 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: d2a72f55c356ddf05a64fb2b0ca44ca3fb03875f
      https://github.com/WebKit/WebKit/commit/d2a72f55c356ddf05a64fb2b0ca44ca3fb03875f
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2023-08-01 (Tue, 01 Aug 2023)

  Changed paths:
    M Source/WebCore/bindings/js/SerializedScriptValue.cpp

  Log Message:
  -----------
  SerializedScriptValue could be faster by atomizing strings early in some cases
https://bugs.webkit.org/show_bug.cgi?id=259267
rdar://112759042

Reviewed by Darin Adler.

Upon deserialization, in the `ObjectStartVisitMember` case, we would call
`readStringData()` which would allocate a String from the raw characters
and we would later construct a JSC::Identifier from it using
JSC::Identifier::fromString(), which would then atomize the string.

To avoid unnecessary string allocations in the case where the string is
already in the AtomString table, we now add a `ShouldAtomize` parameter
to `readStringData()`. Then the parameter is `Yes`, it now constructs an
AtomString right away instead of allocating a String. As a result, we
avoid unnecessary String allocations and the construction of a
JSC::Identifier is cheap using an already atomized string.

* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::CloneSerializer):
(WebCore::CloneDeserializer::deserializeString):
(WebCore::CloneDeserializer::readString):
(WebCore::CloneDeserializer::readNullableString):
(WebCore::CloneDeserializer::readStringData):
(WebCore::CloneDeserializer::deserialize):

Canonical link: https://commits.webkit.org/266503@main




More information about the webkit-changes mailing list