Bug 1290931: Don't use the exponential operator in tests; r=till
authorBenjamin Bouvier <benj@benj.me>
Mon, 01 Aug 2016 18:48:20 +0200
changeset 307653 34aad88c6d11fe12f3b0a94b9b0436c6f17d0a60
parent 307652 effd2a452de92a1cf34a987d27c25a41a6bcbe26
child 307654 f478cabf6ecf04a8c9035b774f0e87d768f99c41
push id30516
push usercbook@mozilla.com
push dateTue, 02 Aug 2016 15:10:10 +0000
treeherdermozilla-central@f299890191b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1290931
milestone50.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 1290931: Don't use the exponential operator in tests; r=till MozReview-Commit-ID: HTUmcNj7SEZ
js/src/jit-test/tests/wasm/basic-bce.js
js/src/jit-test/tests/wasm/binary.js
js/src/jit-test/tests/wasm/conversion.js
--- a/js/src/jit-test/tests/wasm/basic-bce.js
+++ b/js/src/jit-test/tests/wasm/basic-bce.js
@@ -24,18 +24,18 @@ let baseOp = {
   '16_s': 'i32',
   '16_u':   'i32',
   '': 'i32',
   'f32':  'f32',
   'f64':  'f64',
 }
 
 function toSigned(width, num) {
-  let unsignedMax = 2 ** (accessWidth[width] * 8) - 1;
-  let signedMax = 2 ** (accessWidth[width] * 8 - 1) - 1;
+  let unsignedMax = Math.pow(2, accessWidth[width] * 8) - 1;
+  let signedMax = Math.pow(2, accessWidth[width] * 8 - 1) - 1;
 
   return (num <= signedMax ? num : -(unsignedMax + 1 - num));
 }
 
 function fromLittleEndianNum(width, bytes) {
   let base = 1;
   var res = 0;
   for (var i = 0; i < accessWidth[width]; i++) {
--- a/js/src/jit-test/tests/wasm/binary.js
+++ b/js/src/jit-test/tests/wasm/binary.js
@@ -252,17 +252,17 @@ wasmEval(moduleWithSections([sigSection(
 var manyBlocks = [];
 for (var i = 0; i < 20000; i++)
     manyBlocks.push(Block, End);
 wasmEval(moduleWithSections([sigSection([v2vSig]), declSection([0]), bodySection([funcBody({locals:[], body:manyBlocks})])]));
 
 // Ignore errors in name section.
 var tooBigNameSection = {
     name: nameId,
-    body: [...varU32(2**31)] // declare 2**31 functions.
+    body: [...varU32(Math.pow(2, 31))] // declare 2**31 functions.
 };
 wasmEval(moduleWithSections([tooBigNameSection]));
 
 // Checking stack trace.
 function runStackTraceTest(namesContent, expectedName) {
     var sections = [
         sigSection([v2vSig]),
         importSection([{sigIndex:0, module:"env", func:"callback"}]),
--- a/js/src/jit-test/tests/wasm/conversion.js
+++ b/js/src/jit-test/tests/wasm/conversion.js
@@ -220,60 +220,61 @@ if (hasI64()) {
         throw new Error('hasI64() in wasm.js needs an update!');
     } catch(e) {
         assertEq(e.toString().indexOf("NYI on this platform") >= 0, true);
     }
 }
 
 // i32.trunc_s* : all values in ] -2**31 - 1; 2**31 [ are acceptable.
 // f32:
+var p = Math.pow;
 testConversion('i32', 'trunc_s', 'f32', 40.1, 40);
-testConversion('i32', 'trunc_s', 'f32', 2**31 - 128, 2**31 - 128); // last f32 value exactly representable < 2**31.
-testConversion('i32', 'trunc_s', 'f32', -2**31, -2**31); // last f32 value exactly representable > -2**31 - 1.
+testConversion('i32', 'trunc_s', 'f32', p(2, 31) - 128, p(2, 31) - 128); // last f32 value exactly representable < 2**31.
+testConversion('i32', 'trunc_s', 'f32', -p(2, 31), -p(2,31)); // last f32 value exactly representable > -2**31 - 1.
 
 testTrap('i32', 'trunc_s', 'f32', 'nan');
 testTrap('i32', 'trunc_s', 'f32', 'infinity');
 testTrap('i32', 'trunc_s', 'f32', '-infinity');
-testTrap('i32', 'trunc_s', 'f32', 2**31);
-testTrap('i32', 'trunc_s', 'f32', -(2**31) - 256);
+testTrap('i32', 'trunc_s', 'f32', p(2, 31));
+testTrap('i32', 'trunc_s', 'f32', -p(2,31) - 256);
 
 testConversion('i32', 'trunc_s', 'f64', 40.1, 40);
-testConversion('i32', 'trunc_s', 'f64', 2**31 - 0.001, 2**31 - 1); // example value near the top.
-testConversion('i32', 'trunc_s', 'f64', -2**31 - 0.999, -2**31); // example value near the bottom.
+testConversion('i32', 'trunc_s', 'f64', p(2,31) - 0.001, p(2,31) - 1); // example value near the top.
+testConversion('i32', 'trunc_s', 'f64', -p(2,31) - 0.999, -p(2,31)); // example value near the bottom.
 
 // f64:
 testTrap('i32', 'trunc_s', 'f64', 'nan');
 testTrap('i32', 'trunc_s', 'f64', 'infinity');
 testTrap('i32', 'trunc_s', 'f64', '-infinity');
-testTrap('i32', 'trunc_s', 'f64', 2**31);
-testTrap('i32', 'trunc_s', 'f64', -(2**31) - 1);
+testTrap('i32', 'trunc_s', 'f64', p(2,31));
+testTrap('i32', 'trunc_s', 'f64', -p(2,31) - 1);
 
 // i32.trunc_u* : all values in ] -1; 2**32 [ are acceptable.
 // f32:
 testConversion('i32', 'trunc_u', 'f32', 40.1, 40);
-testConversion('i32', 'trunc_u', 'f32', 2**31, (2**31)|0);
-testConversion('i32', 'trunc_u', 'f32', 2**32 - 256, (2**32 - 256)|0); // last f32 value exactly representable < 2**32.
+testConversion('i32', 'trunc_u', 'f32', p(2,31), p(2,31)|0);
+testConversion('i32', 'trunc_u', 'f32', p(2,32) - 256, (p(2,32) - 256)|0); // last f32 value exactly representable < 2**32.
 testConversion('i32', 'trunc_u', 'f32', -0.99, 0); // example value near the bottom.
 
 testTrap('i32', 'trunc_u', 'f32', 'nan');
 testTrap('i32', 'trunc_u', 'f32', 'infinity');
 testTrap('i32', 'trunc_u', 'f32', '-infinity');
 testTrap('i32', 'trunc_u', 'f32', -1);
-testTrap('i32', 'trunc_u', 'f32', 2**32);
+testTrap('i32', 'trunc_u', 'f32', p(2,32));
 
 // f64:
 testConversion('i32', 'trunc_u', 'f64', 40.1, 40);
-testConversion('i32', 'trunc_u', 'f64', 2**32 - 0.001, (2**32 - 1)|0); // example value near the top.
+testConversion('i32', 'trunc_u', 'f64', p(2,32) - 0.001, (p(2,32) - 1)|0); // example value near the top.
 testConversion('i32', 'trunc_u', 'f64', -0.99999, 0); // example value near the bottom.
 
 testTrap('i32', 'trunc_u', 'f32', 'nan');
 testTrap('i32', 'trunc_u', 'f32', 'infinity');
 testTrap('i32', 'trunc_u', 'f32', '-infinity');
 testTrap('i32', 'trunc_u', 'f32', -1);
-testTrap('i32', 'trunc_u', 'f32', 2**32);
+testTrap('i32', 'trunc_u', 'f32', p(2,32));
 
 // Other opcodes.
 testConversion('i32', 'reinterpret', 'f32', 40.1, 1109419622);
 testConversion('f32', 'reinterpret', 'i32', 40, 5.605193857299268e-44);
 
 testConversion('f32', 'convert_s', 'i32', 40, 40);
 testConversion('f32', 'convert_u', 'i32', 40, 40);