Bug 1516697 - Don't use std::abs on a value that could possibly be -2147483648 (whose absolute value can't be computed when |int| is 32-bit-sized). r=arai
authorJeff Walden <jwalden@mit.edu>
Fri, 28 Dec 2018 11:07:23 -0600
changeset 509702 e58454c68f0f9906c62a86a797fd4695977bf506
parent 509701 0e39815d1bcee5861969f7b6db68b6db33b98423
child 509703 c7577c2325910f27ab37688962feba0fd3c8bccf
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1516697
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516697 - Don't use std::abs on a value that could possibly be -2147483648 (whose absolute value can't be computed when |int| is 32-bit-sized). r=arai
js/src/wasm/AsmJS.cpp
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -62,16 +62,17 @@ using namespace js::frontend;
 using namespace js::jit;
 using namespace js::wasm;
 
 using JS::AsmJSOption;
 using JS::AutoStableStringChars;
 using JS::GenericNaN;
 using JS::SourceOwnership;
 using JS::SourceText;
+using mozilla::Abs;
 using mozilla::ArrayEqual;
 using mozilla::CeilingLog2;
 using mozilla::HashGeneric;
 using mozilla::IsNaN;
 using mozilla::IsNegativeZero;
 using mozilla::IsPositiveZero;
 using mozilla::IsPowerOfTwo;
 using mozilla::PodZero;
@@ -4644,17 +4645,17 @@ static bool IsValidIntMultiplyConstant(M
   if (!IsNumericLiteral(m, expr)) {
     return false;
   }
 
   NumLit lit = ExtractNumericLiteral(m, expr);
   switch (lit.which()) {
     case NumLit::Fixnum:
     case NumLit::NegativeInt:
-      if (abs(lit.toInt32()) < (1 << 20)) {
+      if (Abs(lit.toInt32()) < (uint32_t(1) << 20)) {
         return true;
       }
       return false;
     case NumLit::BigUnsigned:
     case NumLit::Double:
     case NumLit::Float:
     case NumLit::OutOfRangeInt:
       return false;