(test_double, test_object, set, length)
| 40 | } |
| 41 | |
| 42 | function test(test_double, test_object, set, length) { |
| 43 | // We apply the same operations to two identical arrays. The first array |
| 44 | // triggers an IC miss, upon which the conversion stub is generated, but the |
| 45 | // actual conversion is done in runtime. The second array, arriving at |
| 46 | // the previously patched IC, is then converted using the conversion stub. |
| 47 | var array_1 = make_array(length); |
| 48 | var array_2 = make_array(length); |
| 49 | |
| 50 | // false, true, nice setter function, 20 |
| 51 | assertTrue(%HasSmiElements(array_1)); |
| 52 | assertTrue(%HasSmiElements(array_2)); |
| 53 | for (var i = 0; i < length; i++) { |
| 54 | if (i == length - 5 && test_double) { |
| 55 | // Trigger conversion to fast double elements at length-5. |
| 56 | set(array_1, i, 0.5); |
| 57 | set(array_2, i, 0.5); |
| 58 | assertTrue(%HasDoubleElements(array_1)); |
| 59 | assertTrue(%HasDoubleElements(array_2)); |
| 60 | } else if (i == length - 3 && test_object) { |
| 61 | // Trigger conversion to fast object elements at length-3. |
| 62 | set(array_1, i, 'object'); |
| 63 | set(array_2, i, 'object'); |
| 64 | assertTrue(%HasObjectElements(array_1)); |
| 65 | assertTrue(%HasObjectElements(array_2)); |
| 66 | } else if (i != length - 7) { |
| 67 | // Set the element to an integer but leave a hole at length-7. |
| 68 | set(array_1, i, 2*i+1); |
| 69 | set(array_2, i, 2*i+1); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | for (var i = 0; i < length; i++) { |
| 74 | if (i == length - 5 && test_double) { |
| 75 | assertEquals(0.5, array_1[i]); |
| 76 | assertEquals(0.5, array_2[i]); |
| 77 | } else if (i == length - 3 && test_object) { |
| 78 | assertEquals('object', array_1[i]); |
| 79 | assertEquals('object', array_2[i]); |
| 80 | } else if (i != length - 7) { |
| 81 | assertEquals(2*i+1, array_1[i]); |
| 82 | assertEquals(2*i+1, array_2[i]); |
| 83 | } else { |
| 84 | assertEquals(undefined, array_1[i]); |
| 85 | assertEquals(undefined, array_2[i]); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | assertEquals(length, array_1.length); |
| 90 | assertEquals(length, array_2.length); |
| 91 | } |
| 92 | |
| 93 | function run_test(test_double, test_object, set, length) { |
| 94 | test(test_double, test_object, set, length); |
no test coverage detected
searching dependent graphs…