Bug 229651

Summary: [JSC] Implement Temporal.Calendar
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, benjamin, cdumez, cmarcelo, ews-watchlist, gyuyoung.kim, keith_miller, mark.lam, msaboff, philip.chimento, ross.kirsling, ryuan.choi, saam, sergio, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 223166    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch ross.kirsling: review+

Description Yusuke Suzuki 2021-08-28 16:13:08 PDT
...
Comment 1 Yusuke Suzuki 2021-08-28 23:21:48 PDT
Created attachment 436730 [details]
Patch
Comment 2 Yusuke Suzuki 2021-08-29 03:41:15 PDT
Created attachment 436735 [details]
Patch
Comment 3 Yusuke Suzuki 2021-08-29 22:42:43 PDT
Created attachment 436757 [details]
Patch
Comment 4 Yusuke Suzuki 2021-08-30 03:00:33 PDT
Created attachment 436761 [details]
Patch
Comment 5 Yusuke Suzuki 2021-08-30 11:56:14 PDT
Created attachment 436799 [details]
Patch
Comment 6 Philip Chimento 2021-08-30 12:24:00 PDT
Comment on attachment 436799 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436799&action=review

> Source/JavaScriptCore/runtime/IntlObject.cpp:1594
> +            if (string.is8Bit())

I believe all the BCP47 identifiers are ASCII-only, by definition?

> Source/JavaScriptCore/runtime/TemporalCalendarPrototype.cpp:98
> +        return throwVMTypeError(globalObject, scope, "Temporal.Calendar.prototype.fields called on value that's not an object initialized as a Calendar"_s);

As in the Duration patch I think the brand check exception message would be clearer to developers without "an object initialized as"
Comment 7 Yusuke Suzuki 2021-08-30 12:45:00 PDT
Comment on attachment 436799 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436799&action=review

>> Source/JavaScriptCore/runtime/IntlObject.cpp:1594
>> +            if (string.is8Bit())
> 
> I believe all the BCP47 identifiers are ASCII-only, by definition?

This is8Bit is WTF::String implementation detail, and it is possible that ASCII-only string can get 16bit strings.
And it would be possible to make String 16bit internally in some cases (e.g. string is determined to be shared with the existing 16bit string). So putting both cases is better for safety and correctness :)
Comment 8 Ross Kirsling 2021-08-30 18:04:05 PDT
Comment on attachment 436799 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436799&action=review

Looks good, given Philip's comments and the resolution of the Slack thread about implementation-definedness.

> Source/WTF/ChangeLog:11
> +        * wtf/text/StringImpl.cpp:
> +        (WTF::StringImpl::createStaticStringImpl):
> +        * wtf/text/StringImpl.h:
> +        (WTF::StringImpl::createStaticStringImpl):

I think this deserves a brief explanation. :)

> JSTests/stress/temporal-calendar.js:80
> +        password: 'hunter2', // Note: Don't really store passwords like that

🤣
Comment 9 Yusuke Suzuki 2021-08-30 18:23:50 PDT
Comment on attachment 436799 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436799&action=review

>> Source/WTF/ChangeLog:11
>> +        (WTF::StringImpl::createStaticStringImpl):
> 
> I think this deserves a brief explanation. :)

Added :)

>> Source/JavaScriptCore/runtime/TemporalCalendarPrototype.cpp:98
>> +        return throwVMTypeError(globalObject, scope, "Temporal.Calendar.prototype.fields called on value that's not an object initialized as a Calendar"_s);
> 
> As in the Duration patch I think the brand check exception message would be clearer to developers without "an object initialized as"

Changed to drop `an object initialized as...` part :)
Comment 10 Yusuke Suzuki 2021-08-30 18:56:41 PDT
Committed r281788 (241125@main): <https://commits.webkit.org/241125@main>
Comment 11 Radar WebKit Bug Importer 2021-08-30 18:57:25 PDT
<rdar://problem/82559111>