tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

inline-arguments-slice-5.js (2743B)


      1 // |jit-test| --fast-warmup
      2 
      3 function blackhole() {
      4  // Prevent Ion from optimising away this function and its arguments.
      5  with ({});
      6 }
      7 
      8 function inner() {
      9  // Compile-time constants after GVN, but not during scalar replacement.
     10  // We don't want these to be constants during scalar replacement to ensure
     11  // we don't optimise away the slice() call.
     12  const zero = Math.pow(0, 1);
     13  const one = Math.pow(1, 1);
     14  const two = Math.pow(2, 1);
     15  const three = Math.pow(3, 1);
     16  const four = Math.pow(4, 1);
     17 
     18  // Test with constant |begin| and |count| a constant after GVN.
     19  {
     20    let a0 = Array.prototype.slice.call(arguments, 0, zero);
     21    let a1 = Array.prototype.slice.call(arguments, 0, one);
     22    let a2 = Array.prototype.slice.call(arguments, 0, two);
     23    let a3 = Array.prototype.slice.call(arguments, 0, three);
     24    let a4 = Array.prototype.slice.call(arguments, 0, four);
     25    blackhole(a0, a1, a2, a3, a4);
     26  }
     27  {
     28    let a0 = Array.prototype.slice.call(arguments, 1, zero);
     29    let a1 = Array.prototype.slice.call(arguments, 1, one);
     30    let a2 = Array.prototype.slice.call(arguments, 1, two);
     31    let a3 = Array.prototype.slice.call(arguments, 1, three);
     32    let a4 = Array.prototype.slice.call(arguments, 1, four);
     33    blackhole(a0, a1, a2, a3, a4);
     34  }
     35 
     36  // Same as above, but this time |begin| isn't a constant during scalar replacement.
     37  {
     38    let a0 = Array.prototype.slice.call(arguments, zero, zero);
     39    let a1 = Array.prototype.slice.call(arguments, zero, one);
     40    let a2 = Array.prototype.slice.call(arguments, zero, two);
     41    let a3 = Array.prototype.slice.call(arguments, zero, three);
     42    let a4 = Array.prototype.slice.call(arguments, zero, four);
     43    blackhole(a0, a1, a2, a3, a4);
     44  }
     45  {
     46    let a0 = Array.prototype.slice.call(arguments, one, zero);
     47    let a1 = Array.prototype.slice.call(arguments, one, one);
     48    let a2 = Array.prototype.slice.call(arguments, one, two);
     49    let a3 = Array.prototype.slice.call(arguments, one, three);
     50    let a4 = Array.prototype.slice.call(arguments, one, four);
     51    blackhole(a0, a1, a2, a3, a4);
     52  }
     53 }
     54 
     55 // Ensure |inner| can be inlined.
     56 assertEq(isSmallFunction(inner), true);
     57 
     58 // Zero arguments.
     59 function outer0() {
     60  trialInline();
     61  return inner();
     62 }
     63 
     64 // One argument.
     65 function outer1() {
     66  trialInline();
     67  return inner(1);
     68 }
     69 
     70 // Two arguments.
     71 function outer2() {
     72  trialInline();
     73  return inner(1, 2);
     74 }
     75 
     76 // Three arguments.
     77 function outer3() {
     78  trialInline();
     79  return inner(1, 2, 3);
     80 }
     81 
     82 // Four arguments. (|inner| can't be inlined anymore!)
     83 function outer4() {
     84  trialInline();
     85  return inner(1, 2, 3, 4);
     86 }
     87 
     88 // Don't Ion compile the top-level script.
     89 with ({});
     90 
     91 for (var i = 0; i < 50; i++) {
     92  outer0();
     93  outer1();
     94  outer2();
     95  outer3();
     96  outer4();
     97 }