I'm afraid I don't agree with these wrappers, because they require callers to
perform the actual computation again, making the overflow check optional. On
success, the result should be retrieved from the checked_result object (so that maybe long-term we can entirely blacklist unchecked operations). That requires
either the wrapper to return both a bool and a value, or the CheckedNumerics
object to be used directly.

Also, I think for the multiplication part, the actual bug is that "return 31 - ElementsKindToShiftSize(elements_kind_);" should s/31/30/ (or the caller must "1 << (array_operation->MaxBaseOffsetBits() - 1)", because it's used as shift width
and 1 << 31 overflows. With that fixed, we still need to guard the addition,
where safe_math comes in handy.

https://codereview.chromium.org/335063005/

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to