RESOLVED FIXED 188197
Clean up TransformationMatrix implementation
https://bugs.webkit.org/show_bug.cgi?id=188197
Summary Clean up TransformationMatrix implementation
Yusuke Suzuki
Reported 2018-07-31 09:57:02 PDT
Clean up TransformationMatrix implementation
Attachments
Patch (6.11 KB, patch)
2018-07-31 09:59 PDT, Yusuke Suzuki
no flags
Patch (4.88 KB, patch)
2018-07-31 10:17 PDT, Yusuke Suzuki
simon.fraser: review+
Yusuke Suzuki
Comment 1 2018-07-31 09:59:45 PDT
EWS Watchlist
Comment 2 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.
Yusuke Suzuki
Comment 3 2018-07-31 10:17:42 PDT
EWS Watchlist
Comment 4 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.
Yusuke Suzuki
Comment 5 2018-07-31 11:37:23 PDT
Radar WebKit Bug Importer
Comment 6 2018-07-31 11:40:41 PDT
Darin Adler
Comment 7 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.
Yusuke Suzuki
Comment 8 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.
Yusuke Suzuki
Comment 9 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.
Yusuke Suzuki
Comment 10 2018-08-01 21:24:16 PDT
Darin Adler
Comment 11 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.
Note You need to log in before you can comment on or make changes to this bug.