Bug 185589

Summary: [JSC] timeClip(-0) should produce +0
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, darin, dbates, ews-watchlist, fpizlo, mark.lam, rniwa, saam, sam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews101 for mac-sierra
none
Archive of layout-test-results from ews107 for mac-sierra-wk2
none
Archive of layout-test-results from ews113 for mac-sierra
none
Archive of layout-test-results from ews126 for ios-simulator-wk2
none
Archive of layout-test-results from ews201 for win-future
none
Patch
saam: review+, ews-watchlist: commit-queue-
Archive of layout-test-results from ews200 for win-future none

Description Yusuke Suzuki 2018-05-13 12:16:07 PDT
[JSC] timeClip(-0) should produce +0
Comment 1 Yusuke Suzuki 2018-05-13 12:17:16 PDT
Created attachment 340272 [details]
Patch
Comment 2 EWS Watchlist 2018-05-13 13:21:25 PDT
Comment on attachment 340272 [details]
Patch

Attachment 340272 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/7670542

New failing tests:
sputnik/Implementation_Diagnostics/S15.9.1.14_D1.html
Comment 3 EWS Watchlist 2018-05-13 13:21:26 PDT
Created attachment 340273 [details]
Archive of layout-test-results from ews101 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 4 EWS Watchlist 2018-05-13 13:27:06 PDT
Comment on attachment 340272 [details]
Patch

Attachment 340272 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/7670552

New failing tests:
sputnik/Implementation_Diagnostics/S15.9.1.14_D1.html
Comment 5 EWS Watchlist 2018-05-13 13:27:07 PDT
Created attachment 340274 [details]
Archive of layout-test-results from ews107 for mac-sierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-sierra-wk2  Platform: Mac OS X 10.12.6
Comment 6 EWS Watchlist 2018-05-13 13:46:15 PDT
Comment on attachment 340272 [details]
Patch

Attachment 340272 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/7670558

New failing tests:
sputnik/Implementation_Diagnostics/S15.9.1.14_D1.html
Comment 7 EWS Watchlist 2018-05-13 13:46:17 PDT
Created attachment 340275 [details]
Archive of layout-test-results from ews113 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 8 EWS Watchlist 2018-05-13 13:58:50 PDT
Comment on attachment 340272 [details]
Patch

Attachment 340272 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/7670589

New failing tests:
sputnik/Implementation_Diagnostics/S15.9.1.14_D1.html
Comment 9 EWS Watchlist 2018-05-13 13:58:51 PDT
Created attachment 340276 [details]
Archive of layout-test-results from ews126 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews126  Port: ios-simulator-wk2  Platform: Mac OS X 10.13.4
Comment 10 EWS Watchlist 2018-05-13 14:02:39 PDT
Comment on attachment 340272 [details]
Patch

Attachment 340272 [details] did not pass win-ews (win):
Output: http://webkit-queues.webkit.org/results/7670677

New failing tests:
sputnik/Implementation_Diagnostics/S15.9.1.14_D1.html
Comment 11 EWS Watchlist 2018-05-13 14:02:50 PDT
Created attachment 340277 [details]
Archive of layout-test-results from ews201 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews201  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 12 Yusuke Suzuki 2018-05-13 21:24:36 PDT
Created attachment 340289 [details]
Patch
Comment 13 EWS Watchlist 2018-05-13 23:45:38 PDT
Comment on attachment 340289 [details]
Patch

Attachment 340289 [details] did not pass win-ews (win):
Output: http://webkit-queues.webkit.org/results/7674124

New failing tests:
http/tests/security/canvas-remote-read-remote-video-localhost.html
Comment 14 EWS Watchlist 2018-05-13 23:45:49 PDT
Created attachment 340293 [details]
Archive of layout-test-results from ews200 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews200  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 15 Yusuke Suzuki 2018-05-14 02:42:05 PDT
(In reply to Build Bot from comment #13)
> Comment on attachment 340289 [details]
> Patch
> 
> Attachment 340289 [details] did not pass win-ews (win):
> Output: http://webkit-queues.webkit.org/results/7674124
> 
> New failing tests:
> http/tests/security/canvas-remote-read-remote-video-localhost.html

It is not related to this change.
Comment 16 Saam Barati 2018-05-14 08:51:23 PDT
Comment on attachment 340289 [details]
Patch

Please add a test
Comment 17 Yusuke Suzuki 2018-05-14 10:17:50 PDT
(In reply to Saam Barati from comment #16)
> Comment on attachment 340289 [details]
> Patch
> 
> Please add a test

Thank you for your review!
I've added a stress test for this, which is separate from sputnik and test262's ones.
Comment 18 Yusuke Suzuki 2018-05-14 10:18:10 PDT
Committed r231762: <https://trac.webkit.org/changeset/231762>
Comment 19 Radar WebKit Bug Importer 2018-05-14 10:27:00 PDT
<rdar://problem/40222300>
Comment 20 Darin Adler 2018-05-14 12:27:04 PDT
Comment on attachment 340289 [details]
Patch

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

> Source/WTF/wtf/DateMath.cpp:1159
>          return std::numeric_limits<double>::quiet_NaN();

Not critical, but I think that the isfinite test is not needed. We could remove it without having any effect on test results except the code should be a tiny bit faster.

> Source/WTF/wtf/DateMath.cpp:1162
>      if (fabs(t) > maxECMAScriptTime)
>          return std::numeric_limits<double>::quiet_NaN();
> -    return trunc(t);
> +    return trunc(t) + 0.0;

If this was written recently we would probably be using std::abs and std::trunc.

I am also wondering if this gives the right result for values just a tiny bit larger than maxECMAScriptTime: in other words, should they be truncated first and then checked rather than checked first and then truncated?
Comment 21 Yusuke Suzuki 2018-05-16 12:29:52 PDT
Comment on attachment 340289 [details]
Patch

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

>> Source/WTF/wtf/DateMath.cpp:1159
>>          return std::numeric_limits<double>::quiet_NaN();
> 
> Not critical, but I think that the isfinite test is not needed. We could remove it without having any effect on test results except the code should be a tiny bit faster.

I was considering about NaN case, but it seems that NaN can work with the following code. Nice catch. I'll remove this.

>> Source/WTF/wtf/DateMath.cpp:1162
>> +    return trunc(t) + 0.0;
> 
> If this was written recently we would probably be using std::abs and std::trunc.
> 
> I am also wondering if this gives the right result for values just a tiny bit larger than maxECMAScriptTime: in other words, should they be truncated first and then checked rather than checked first and then truncated?

Using std::abs and std::trunc sounds fine. I'll do it in a follow-up change.

I think this order is OK since this is corresponding to the spec https://tc39.github.io/ecma262/#sec-timeclip.
I believe that the rationale behind this is if t is larger than maxECMAScriptTime, even if it can be trunc-ed to maxECMAScriptTime, it returns NaN since the original value was actually larger than maxECMAScriptTime.
Comment 22 Yusuke Suzuki 2018-05-16 12:46:31 PDT
Committed r231864: <https://trac.webkit.org/changeset/231864>