|
1be4d493
|
2016-09-27T11:15:38
|
|
Fix handling integer overflow in constant folding
Integer operations that overflow are defined to wrap in the ESSL
3.00.6 spec. Constant folding that happens inside the shader
translator should also follow the wrapping rules.
The new implementations of wrapping integer addition and subtraction
use unsigned integers to perform calculations. Unsigned integers are
defined to implement arithmetic in modulo 2^n in the C++ spec. This
behavior is also leveraged to implement wrapping unsigned integer
multiplication.
The implementation of wrapping signed integer multiplication is
slightly trickier. The operands are casted to a wider type to perform
the multiplication in a way that doesn't overflow, and then the result
is truncated and casted back to the narrower integer type.
Incorrect tests that expected errors to be generated from integer
overflow in constant folding are removed.
BUG=chromium:637050
TEST=angle_unittests
Change-Id: I0de7e25881d254803455fbf22907c192f49d09ff
Reviewed-on: https://chromium-review.googlesource.com/390252
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
|
|
2cacb778
|
2016-09-26T08:50:40
|
|
Fix folding shifts when operands have different signedness
The code used to incorrectly assert that the right-hand side of shift
should have the same signedness as the left-hand side. Instead simply
assert that both the lhs and rhs are integer typed, and also don't
rely on aliasing via union when accessing bit shift operands.
Also disallow constant folded bit shifts where the right hand side is
greater than 31. Shifting with values greater than the width of the
type has undefined results in both ESSL and C++.
BUG=chromium:648135
TEST=angle_unittests
Change-Id: I84a99abc55f0eeda549b4781e954d17ba7b87552
Reviewed-on: https://chromium-review.googlesource.com/389351
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
|
|
44ebf6b4
|
2016-09-22T13:00:02
|
|
ConstantUnion: Error on undefined shift.
BUG=chromium:648135
Change-Id: I41581f63af650564a0f61c1baeeb38017c8513ed
Reviewed-on: https://chromium-review.googlesource.com/387470
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
|
|
596018ce
|
2016-09-21T12:57:03
|
|
translator: Refactor Constant Union shift ops.
In preparation for making them robust.
BUG=chromium:648135
Change-Id: I88fc87d8887064fda04087c56de05d8725a6fe5f
Reviewed-on: https://chromium-review.googlesource.com/387469
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
|
5db69f57
|
2016-09-15T12:47:32
|
|
Add robust math to constant folding.
Previously our multiplication and other operators could
do overflows, which can lead to security bugs.
BUG=chromium:637050
Change-Id: Icee22a87909e205b71bda1c5bc1627fcf5e26e90
Reviewed-on: https://chromium-review.googlesource.com/382678
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
|
|
47cb73ab
|
2016-09-09T11:41:44
|
|
Refactor TConstantUnion.
In preparation for constant folding fixes.
BUG=chromium:637050
Change-Id: I9ea49ce96b34c6ac3d2f0478b8fc6732c59e28be
Reviewed-on: https://chromium-review.googlesource.com/373741
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|