WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
211499
Make a helper for ICU functions that may need to be called twice to populate a buffer
https://bugs.webkit.org/show_bug.cgi?id=211499
Summary
Make a helper for ICU functions that may need to be called twice to populate ...
Darin Adler
Reported
2020-05-05 23:37:42 PDT
Make a helper for the pattern of ICU functions that may need to be called twice to populate a buffer
Attachments
Patch
(30.64 KB, patch)
2020-05-05 23:39 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(31.91 KB, patch)
2020-05-06 08:08 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(32.06 KB, patch)
2020-05-06 09:13 PDT
,
Darin Adler
no flags
Details
Formatted Diff
Diff
Patch
(32.49 KB, patch)
2020-05-06 14:06 PDT
,
Darin Adler
ross.kirsling
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2020-05-05 23:39:46 PDT
Comment hidden (obsolete)
Created
attachment 398594
[details]
Patch
Darin Adler
Comment 2
2020-05-05 23:40:35 PDT
Looking for feedback on the name of the function template, and also the other design considerations.
Darin Adler
Comment 3
2020-05-06 00:01:34 PDT
Comment hidden (obsolete)
Comment on
attachment 398594
[details]
Patch Have to rebase and re-upload.
Darin Adler
Comment 4
2020-05-06 08:08:14 PDT
Comment hidden (obsolete)
Created
attachment 398617
[details]
Patch
Darin Adler
Comment 5
2020-05-06 08:20:32 PDT
Comment hidden (obsolete)
Comment on
attachment 398617
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=398617&action=review
> Source/JavaScriptCore/runtime/StringPrototype.cpp:1614 > + Vector<UChar> buffer(s.length());
On reflection, I think I’ll change this to: Vector<UChar> buffer; buffer.reserveInitialCapacity(s.length());
Darin Adler
Comment 6
2020-05-06 08:58:37 PDT
Comment hidden (obsolete)
Guess this is not working right yet. Tests are failing.
Darin Adler
Comment 7
2020-05-06 09:13:33 PDT
Comment hidden (obsolete)
Created
attachment 398624
[details]
Patch
Darin Adler
Comment 8
2020-05-06 11:38:30 PDT
Comment hidden (obsolete)
Interesting, looks like one of the JSC stress tests is failing: stress/intl-relativetimeformat.js.intl-relativetimeformat-enabled I don’t know much about how to investigate and debug; have to figure that out.
Darin Adler
Comment 9
2020-05-06 14:06:17 PDT
Created
attachment 398655
[details]
Patch
Ross Kirsling
Comment 10
2020-05-06 14:22:36 PDT
Comment on
attachment 398655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=398655&action=review
r=me pending EWS, this is really cool.
> Source/WTF/ChangeLog:10 > + specia considerations because of null character terminatorion, or destinations that are
spelling: specia, terminatorion
> Source/WTF/wtf/unicode/icu/ICUHelpers.h:77 > +template<typename FirstArgumentType, typename ...OtherArgumentTypes> auto argumentTuple(FirstArgumentType&&, OtherArgumentTypes&&...);
How come this declaration is needed for argumentTuple but not for findVector?
Darin Adler
Comment 11
2020-05-06 14:31:22 PDT
Comment on
attachment 398655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=398655&action=review
>> Source/WTF/ChangeLog:10 >> + specia considerations because of null character terminatorion, or destinations that are > > spelling: specia, terminatorion
OK, I’ll fix those.
>> Source/WTF/wtf/unicode/icu/ICUHelpers.h:77 >> +template<typename FirstArgumentType, typename ...OtherArgumentTypes> auto argumentTuple(FirstArgumentType&&, OtherArgumentTypes&&...); > > How come this declaration is needed for argumentTuple but not for findVector?
Must admit I am not 100% sure. Without it, the code does not compile, though!
Saam Barati
Comment 12
2020-05-06 14:40:10 PDT
Comment on
attachment 398655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=398655&action=review
LGTM too
> Source/WTF/wtf/unicode/icu/ICUHelpers.h:81 > + return tuple_cat(std::make_tuple(buffer.data(), buffer.size()), argumentTuple(std::forward<OtherArgumentTypes>(otherArguments)...));
Nice
> Source/WTF/wtf/unicode/icu/ICUHelpers.h:91 > +template<typename FunctionType, typename ...ArgumentTypes> UErrorCode callBufferProducingFunction(const FunctionType& function, ArgumentTypes&&... arguments)
This is nice. I like how you solved passing in a Vector
Darin Adler
Comment 13
2020-05-06 14:56:59 PDT
Comment on
attachment 398655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=398655&action=review
>>> Source/WTF/wtf/unicode/icu/ICUHelpers.h:77 >>> +template<typename FirstArgumentType, typename ...OtherArgumentTypes> auto argumentTuple(FirstArgumentType&&, OtherArgumentTypes&&...); >> >> How come this declaration is needed for argumentTuple but not for findVector? > > Must admit I am not 100% sure. Without it, the code does not compile, though!
Oh, I figured it out. The difference is that the Vector overload of findVector never recursively calls the other findVector; just returns the reference to the vector. But in the case of argumentTuple, the overload that handles the Vector *does* recursively call argumentTuple. And to resolve it correctly it apparently needs to have already seen the template declaration.
Darin Adler
Comment 14
2020-05-06 15:00:29 PDT
Comment on
attachment 398655
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=398655&action=review
> Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp:622 > - Vector<UChar, 32> patternBuffer(32); > - status = U_ZERO_ERROR; > - auto patternLength = udatpg_getBestPatternWithOptions(generator, skeletonView.upconvertedCharacters(), skeletonView.length(), UDATPG_MATCH_HOUR_FIELD_LENGTH, patternBuffer.data(), patternBuffer.size(), &status); > - if (needsToGrowToProduceBuffer(status)) { > - status = U_ZERO_ERROR; > - patternBuffer.grow(patternLength); > - udatpg_getBestPattern(generator, skeletonView.upconvertedCharacters(), skeletonView.length(), patternBuffer.data(), patternLength, &status); > - } > + Vector<UChar, 32> patternBuffer; > + status = callBufferProducingFunction(udatpg_getBestPatternWithOptions, generator, skeletonView.upconvertedCharacters(), skeletonView.length(), UDATPG_MATCH_HOUR_FIELD_LENGTH, patternBuffer);
I just noticed a behavior change here. The old code called udatpg_getBestPatternWithOptions first, but then called udatpg_getBestPattern the second time. I suspect the refactoring fixed a potential bug.
Darin Adler
Comment 15
2020-05-06 16:01:11 PDT
Committed
r261257
: <
https://trac.webkit.org/changeset/261257
>
Radar WebKit Bug Importer
Comment 16
2020-05-06 16:02:17 PDT
<
rdar://problem/62949588
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug