Bug 188197 - Clean up TransformationMatrix implementation
Summary: Clean up TransformationMatrix implementation
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-07-31 09:57 PDT by Yusuke Suzuki
Modified: 2018-08-02 09:22 PDT (History)
4 users (show)

See Also:


Attachments
Patch (6.11 KB, patch)
2018-07-31 09:59 PDT, Yusuke Suzuki
no flags Details | Formatted Diff | Diff
Patch (4.88 KB, patch)
2018-07-31 10:17 PDT, Yusuke Suzuki
simon.fraser: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yusuke Suzuki 2018-07-31 09:57:02 PDT
Clean up TransformationMatrix implementation
Comment 1 Yusuke Suzuki 2018-07-31 09:59:45 PDT
Created attachment 346173 [details]
Patch
Comment 2 EWS Watchlist 2018-07-31 10:02:01 PDT
Attachment 346173 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:338:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Yusuke Suzuki 2018-07-31 10:17:42 PDT
Created attachment 346174 [details]
Patch
Comment 4 EWS Watchlist 2018-07-31 10:19:52 PDT
Attachment 346174 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:338:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 1 in 3 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Yusuke Suzuki 2018-07-31 11:37:23 PDT
Committed r234433: <https://trac.webkit.org/changeset/234433>
Comment 6 Radar WebKit Bug Importer 2018-07-31 11:40:41 PDT
<rdar://problem/42780654>
Comment 7 Darin Adler 2018-08-01 19:54:09 PDT
Comment on attachment 346174 [details]
Patch

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

> Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:338
> -        return (m_matrix[0][0] == m2.m_matrix[0][0] &&
> -                m_matrix[0][1] == m2.m_matrix[0][1] &&
> -                m_matrix[0][2] == m2.m_matrix[0][2] &&
> -                m_matrix[0][3] == m2.m_matrix[0][3] &&
> -                m_matrix[1][0] == m2.m_matrix[1][0] &&
> -                m_matrix[1][1] == m2.m_matrix[1][1] &&
> -                m_matrix[1][2] == m2.m_matrix[1][2] &&
> -                m_matrix[1][3] == m2.m_matrix[1][3] &&
> -                m_matrix[2][0] == m2.m_matrix[2][0] &&
> -                m_matrix[2][1] == m2.m_matrix[2][1] &&
> -                m_matrix[2][2] == m2.m_matrix[2][2] &&
> -                m_matrix[2][3] == m2.m_matrix[2][3] &&
> -                m_matrix[3][0] == m2.m_matrix[3][0] &&
> -                m_matrix[3][1] == m2.m_matrix[3][1] &&
> -                m_matrix[3][2] == m2.m_matrix[3][2] &&
> -                m_matrix[3][3] == m2.m_matrix[3][3]);
> +        return memcmp(&m_matrix[0][0], &m2.m_matrix[0][0], sizeof(Matrix4)) == 0;

This is a semantic change for two reasons:

1) double == double and memcmp of the double memory are not the same for numbers like NANs for example.
2) This now potentially compares padding bytes that could have uninitialized data in them; in practice I suppose those won’t be present since doubles are so big.
Comment 8 Yusuke Suzuki 2018-08-01 21:19:16 PDT
Comment on attachment 346174 [details]
Patch

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

>> Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:338
>> +        return memcmp(&m_matrix[0][0], &m2.m_matrix[0][0], sizeof(Matrix4)) == 0;
> 
> This is a semantic change for two reasons:
> 
> 1) double == double and memcmp of the double memory are not the same for numbers like NANs for example.
> 2) This now potentially compares padding bytes that could have uninitialized data in them; in practice I suppose those won’t be present since doubles are so big.

Nice catch! Oops, yeah. I'll revert this part.
Comment 9 Yusuke Suzuki 2018-08-01 21:20:43 PDT
Comment on attachment 346174 [details]
Patch

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

>>> Source/WebCore/platform/graphics/transforms/TransformationMatrix.h:338
>>> +        return memcmp(&m_matrix[0][0], &m2.m_matrix[0][0], sizeof(Matrix4)) == 0;
>> 
>> This is a semantic change for two reasons:
>> 
>> 1) double == double and memcmp of the double memory are not the same for numbers like NANs for example.
>> 2) This now potentially compares padding bytes that could have uninitialized data in them; in practice I suppose those won’t be present since doubles are so big.
> 
> Nice catch! Oops, yeah. I'll revert this part.

I think this (2) never happens since TransformationMatrix (and Matrix4 m_matrix member) does not have padding.
Comment 10 Yusuke Suzuki 2018-08-01 21:24:16 PDT
Committed r234493: <https://trac.webkit.org/changeset/234493>
Comment 11 Darin Adler 2018-08-02 09:22:45 PDT
(In reply to Yusuke Suzuki from comment #9)
> I think this (2) never happens since TransformationMatrix (and Matrix4
> m_matrix member) does not have padding.

Yes, in practice there is no padding. I was just pointing out that the language doesn’t guarantee that.