tor-browser

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

regalloc-live.js (631B)


      1 // test local/arg liveness analysis in presence of many locals
      2 
      3 function foo(a, b, c) {
      4  var x = 0, y = 0, z = 0;
      5  if (a < b) {
      6    x = a + 0;
      7    y = b + 0;
      8    z = c + 0;
      9  } else {
     10    x = a;
     11    y = b;
     12    z = c;
     13  }
     14  return x + y + z;
     15 }
     16 assertEq(foo(1, 2, 3), 6);
     17 
     18 // restore liveness correctly before switch statements
     19 
     20 function foo(a, b, c) {
     21  var x = 0, y = 0, z = 0;
     22  if (a < b) {
     23    x = a + 0;
     24    y = b + 0;
     25    z = c + 0;
     26  } else {
     27    switch (c) {
     28    case 1:
     29    case 2:
     30    case 3:
     31    case 4:
     32    case 5: return 0;
     33    }
     34    x = 0;
     35    y = 0;
     36    z = 0;
     37  }
     38  return x + y + z;
     39 }
     40 assertEq(foo(1, 2, 3), 6);