Bug 239464

Summary: Introduce makeAtomString()
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: Web Template FrameworkAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, changseok, cmarcelo, darin, dino, esprehn+autocc, ews-watchlist, fmalita, gyuyoung.kim, pdr, sabouhallawa, sam, schenney, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=239427
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Chris Dumez
Reported 2022-04-18 14:09:29 PDT
Introduce makeAtomString() which is an optimized version of makeString() when the caller knows it wants an AtomString. It may avoid a StringImpl allocation when the string is already in the AtomStringTable.
Attachments
Patch (6.51 KB, patch)
2022-04-18 14:12 PDT, Chris Dumez
ews-feeder: commit-queue-
Patch (7.29 KB, patch)
2022-04-18 14:42 PDT, Chris Dumez
no flags
Patch (8.73 KB, patch)
2022-04-18 16:34 PDT, Chris Dumez
no flags
Patch (8.87 KB, patch)
2022-04-18 16:37 PDT, Chris Dumez
no flags
Patch (8.89 KB, patch)
2022-04-18 16:37 PDT, Chris Dumez
no flags
Patch (8.62 KB, patch)
2022-04-18 16:55 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2022-04-18 14:12:51 PDT
Chris Dumez
Comment 2 2022-04-18 14:42:56 PDT
Darin Adler
Comment 3 2022-04-18 15:17:45 PDT
Comment on attachment 457824 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457824&action=review > Source/WTF/wtf/text/StringConcatenate.h:502 > + if (areAllAdapters8Bit) { > + LChar buffer[maxLengthToUseStackVariable]; > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + return AtomString { buffer, length }; > + } > + UChar buffer[maxLengthToUseStackVariable]; > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + return AtomString { buffer, length }; I wonder if the compiler is smart enough to not allocate both buffers. > Source/WTF/wtf/text/StringConcatenate.h:525 > + if (areAllAdapters8Bit) { > + LChar* buffer; > + RefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer); > + if (!resultImpl) > + return nullAtom(); > + > + if (buffer) > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + > + return resultImpl.get(); > + } > + > + UChar* buffer; > + RefPtr<StringImpl> resultImpl = StringImpl::tryCreateUninitialized(length, buffer); > + if (!resultImpl) > + return nullAtom(); > + > + if (buffer) > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > + > + return resultImpl.get(); Is there a way to share code with tryMakeStringFromAdapters here?
Chris Dumez
Comment 4 2022-04-18 16:34:50 PDT
Chris Dumez
Comment 5 2022-04-18 16:37:07 PDT
Chris Dumez
Comment 6 2022-04-18 16:37:44 PDT
Darin Adler
Comment 7 2022-04-18 16:51:54 PDT
Comment on attachment 457838 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=457838&action=review > Source/WebCore/svg/SVGLengthValue.cpp:30 > +#include <wtf/text/StringConcatenate.h> > #include <wtf/text/StringConcatenateNumbers.h> I thought "StringConcatenateNumbers.h" included "StringConcatenate.h"
Chris Dumez
Comment 8 2022-04-18 16:52:51 PDT
(In reply to Darin Adler from comment #7) > Comment on attachment 457838 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=457838&action=review > > > Source/WebCore/svg/SVGLengthValue.cpp:30 > > +#include <wtf/text/StringConcatenate.h> > > #include <wtf/text/StringConcatenateNumbers.h> > > I thought "StringConcatenateNumbers.h" included "StringConcatenate.h" Oh, I think that was me trying to fix a build error the wrong way. I'll drop.
Chris Dumez
Comment 9 2022-04-18 16:55:32 PDT
Chris Dumez
Comment 10 2022-04-18 18:54:44 PDT
(In reply to Darin Adler from comment #3) > Comment on attachment 457824 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=457824&action=review > > > Source/WTF/wtf/text/StringConcatenate.h:502 > > + if (areAllAdapters8Bit) { > > + LChar buffer[maxLengthToUseStackVariable]; > > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > > + return AtomString { buffer, length }; > > + } > > + UChar buffer[maxLengthToUseStackVariable]; > > + stringTypeAdapterAccumulator(buffer, adapter, adapters...); > > + return AtomString { buffer, length }; > > I wonder if the compiler is smart enough to not allocate both buffers. Good question. I am not quite sure how to find out though.
Sam Weinig
Comment 11 2022-04-19 10:06:54 PDT
Comment on attachment 457841 [details] Patch Very nice.
EWS
Comment 12 2022-04-19 10:59:05 PDT
Committed r293024 (249763@main): <https://commits.webkit.org/249763@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 457841 [details].
Radar WebKit Bug Importer
Comment 13 2022-04-19 11:00:14 PDT
Note You need to log in before you can comment on or make changes to this bug.