Bug 1290931: Don't use the exponential operator in tests; r?till draft
authorBenjamin Bouvier <benj@benj.me>
Mon, 01 Aug 2016 18:48:20 +0200
changeset 395000 ab1b8b8f920cc572c531bf88e65915727981f474
parent 394999 ee2db5a60751078c429a83534934765886684220
child 526928 1fb4901741a7dead5ab6707443ea2c95f5612471
push id24696
push userbbouvier@mozilla.com
push dateMon, 01 Aug 2016 16:51:07 +0000
reviewerstill
bugs1290931
milestone50.0a1
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);