| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 { | 152 { |
| 153 // Signed target with an unsigned source | 153 // Signed target with an unsigned source |
| 154 if (sizeof(Target) <= sizeof(Source)) | 154 if (sizeof(Target) <= sizeof(Source)) |
| 155 return value <= static_cast<Source>(std::numeric_limits<Target>::max
()); | 155 return value <= static_cast<Source>(std::numeric_limits<Target>::max
()); |
| 156 // Target is Wider than Source so we're guaranteed to fit any value in | 156 // Target is Wider than Source so we're guaranteed to fit any value in |
| 157 // unsigned Source | 157 // unsigned Source |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 }; | 160 }; |
| 161 | 161 |
| 162 template <typename Target, typename Source, bool CanElide = IsSameType<Target, S
ource>::value || (sizeof(Target) > sizeof(Source)) > struct BoundsCheckElider; | 162 template <typename Target, typename Source, bool CanElide = std::is_same<Target,
Source>::value || (sizeof(Target) > sizeof(Source)) > struct BoundsCheckElider; |
| 163 template <typename Target, typename Source> struct BoundsCheckElider<Target, Sou
rce, true> { | 163 template <typename Target, typename Source> struct BoundsCheckElider<Target, Sou
rce, true> { |
| 164 static bool inBounds(Source) { return true; } | 164 static bool inBounds(Source) { return true; } |
| 165 }; | 165 }; |
| 166 template <typename Target, typename Source> struct BoundsCheckElider<Target, Sou
rce, false> : public BoundsChecker<Target, Source> { | 166 template <typename Target, typename Source> struct BoundsCheckElider<Target, Sou
rce, false> : public BoundsChecker<Target, Source> { |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 template <typename Target, typename Source> static inline bool isInBounds(Source
value) | 169 template <typename Target, typename Source> static inline bool isInBounds(Source
value) |
| 170 { | 170 { |
| 171 return BoundsCheckElider<Target, Source>::inBounds(value); | 171 return BoundsCheckElider<Target, Source>::inBounds(value); |
| 172 } | 172 } |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 return Checked<U, OverflowHandler>(lhs) * rhs; | 705 return Checked<U, OverflowHandler>(lhs) * rhs; |
| 706 } | 706 } |
| 707 | 707 |
| 708 } | 708 } |
| 709 | 709 |
| 710 using WTF::Checked; | 710 using WTF::Checked; |
| 711 using WTF::CheckedState; | 711 using WTF::CheckedState; |
| 712 using WTF::RecordOverflow; | 712 using WTF::RecordOverflow; |
| 713 | 713 |
| 714 #endif | 714 #endif |
| OLD | NEW |