tor-browser

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

has.js (1763B)


      1 var max = 40;
      2 var key = "d";
      3 setJitCompilerOption("ion.warmup.trigger", max - 10);
      4 
      5 function simple() {
      6    var array = [{a: 1}, {b: 1, a: 1}, {c: 1, a: 1}];
      7    for (var i = 0; i < array.length; i++) {
      8        var x = array[i];
      9        assertEq("a" in x, true);
     10        assertEq("d" in x, false);
     11    }
     12 }
     13 
     14 function megamorphic() {
     15    var array = [{a: 1}, {b: 1, a: 1}, {c: 1, a: 1},
     16                 {a: 1, b: 1}, {c: 1, e: 1, a: 1},
     17                 {__proto__:{e: 1, f: 1, a: 1, g: 1}},
     18                 {__proto__:{e: 1, f: 1, a: 1, g: 1, h: 1}}];
     19    for (var i = 0; i < array.length; i++) {
     20        var x = array[i];
     21        assertEq("a" in x, true);
     22        assertEq("d" in x, false);
     23    }
     24 }
     25 
     26 function protoSetProp() {
     27    var base = {a: 1};
     28    var array = [{__proto__: base},
     29                 {__proto__: base, b: 1, a: 1},
     30                 {__proto__: base, c: 1, a: 1}];
     31    for (var j = 0; j < 2; j++) {
     32        for (var i = 0; i < array.length; i++) {
     33            var x = array[i];
     34            assertEq("a" in x, true);
     35            assertEq("d" in x, (j > 0));
     36        }
     37        base.d = 1; // Define property on prototype
     38    }
     39 }
     40 
     41 function protoSetElem() {
     42    var base = {a: 1};
     43    var array = [{__proto__: base},
     44                 {__proto__: base, b: 1, a: 1},
     45                 {__proto__: base, c: 1, a: 1}];
     46    for (var j = 0; j < 2; j++) {
     47        for (var i = 0; i < array.length; i++) {
     48            var x = array[i];
     49            assertEq("a" in x, true);
     50            assertEq("d" in x, (j > 0));
     51        }
     52        base[key] = 1; // Define property on prototype
     53    }
     54 }
     55 
     56 function test() {
     57    for (var i = 0; i < max; i++) {
     58        simple();
     59        megamorphic();
     60        protoSetProp();
     61        protoSetElem();
     62    }
     63 }
     64 
     65 test();
     66 test();