Simplify Checked<> multiplication
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2013 21:51:07 +0000 (21:51 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2013 21:51:07 +0000 (21:51 +0000)
commitbb7ebdf79ff814998c937ce49fa9ff33118bc649
treebc1c808b45270eef6e28808b553385afbbbadcb5
parent3e2e27292d471f5bf25fe0e912842140c715d2f1
Simplify Checked<> multiplication
https://bugs.webkit.org/show_bug.cgi?id=112286

Reviewed by James Robinson.

Source/WTF:

Trying to correctly identify multiplication by zero complicated the
unsigned * unsigned multiply, and still didn't handle all cases correctly.
Now we just do the normal division based approach to overflow detection
leading to much simpler reasoning.

Would be nice if we could have a jo style intrinsic one day.

* wtf/CheckedArithmetic.h:

Tools:

Add tests for multiplication by zero and max to ensure we don't
mess them up should we ever make changes to Checked<> in future.

* TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
(TestWebKitAPI):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@145759 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/CheckedArithmetic.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp