Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | |
| 2 // Redistribution and use in source and binary forms, with or without | |
| 3 // modification, are permitted provided that the following conditions are | |
| 4 // met: | |
| 5 // | |
| 6 // * Redistributions of source code must retain the above copyright | |
| 7 // notice, this list of conditions and the following disclaimer. | |
| 8 // * Redistributions in binary form must reproduce the above | |
| 9 // copyright notice, this list of conditions and the following | |
| 10 // disclaimer in the documentation and/or other materials provided | |
| 11 // with the distribution. | |
| 12 // * Neither the name of Google Inc. nor the names of its | |
| 13 // contributors may be used to endorse or promote products derived | |
| 14 // from this software without specific prior written permission. | |
| 15 // | |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 27 | |
| 28 // Flags: --allow-natives-syntax --smi-only-arrays | |
| 29 | |
| 30 // Ensure that ElementsKind transitions in various situations are hoisted (or | |
| 31 // not hoisted) correctly, don't change the semantics programs and don't trigger | |
| 32 // deopt through hoisting in important situations. | |
| 33 | |
| 34 support_smi_only_arrays = %HasFastSmiOnlyElements(new Array(1,2,3,4,5,6)); | |
| 35 | |
| 36 if (support_smi_only_arrays) { | |
| 37 print("Tests include smi-only arrays."); | |
| 38 } else { | |
| 39 print("Tests do NOT include smi-only arrays."); | |
| 40 } | |
| 41 | |
| 42 var global_false = false; | |
| 43 | |
| 44 if (support_smi_only_arrays) { | |
| 45 // Make sure that multiple stores to an object array get hoisted in a way that | |
|
fschneider
2012/02/07 10:05:05
What is meant by hoisting multiple stores? Stores
danno
2012/02/08 17:18:42
Done.
| |
| 46 // doesn't generate a deopt in simple cases. | |
| 47 function testDoubleConversion4(a) { | |
| 48 var object = new Object(); | |
| 49 a[0] = 0; | |
| 50 do { | |
| 51 a[0] = object; | |
| 52 } while (global_false); | |
|
fschneider
2012/02/07 10:05:05
Maybe you should go around the loop >1 times in al
danno
2012/02/08 17:18:42
Done.
| |
| 53 } | |
| 54 | |
| 55 testDoubleConversion4(new Array(5)); | |
| 56 %OptimizeFunctionOnNextCall(testDoubleConversion4); | |
| 57 testDoubleConversion4(new Array(5)); | |
| 58 testDoubleConversion4(new Array(5)); | |
| 59 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4)); | |
| 60 | |
| 61 // Make sure that non-element related map checks still get hoisted in a way | |
| 62 // that doesn't generate a deopt in simple cases. | |
| 63 function testExactMapHoisting(a) { | |
| 64 var object = new Object(); | |
| 65 a.foo = 0; | |
| 66 a[0] = 0; | |
| 67 a[1] = 1; | |
| 68 do { | |
| 69 a.foo = object; // This map check should be hoistable | |
| 70 a[1] = object; | |
| 71 result = a.foo == object && a[1] == object; | |
| 72 } while (global_false); | |
| 73 } | |
| 74 | |
| 75 testExactMapHoisting(new Array(5)); | |
| 76 %OptimizeFunctionOnNextCall(testExactMapHoisting); | |
| 77 testExactMapHoisting(new Array(5)); | |
| 78 testExactMapHoisting(new Array(5)); | |
| 79 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting)); | |
| 80 | |
| 81 // Make sure that non-element related map checks still get hoisted if all | |
| 82 // known element transitions have been done by the time the map check is done. | |
| 83 // Make sure it's done in a way that doesn't deopt later. | |
| 84 function testExactMapHoisting2(a) { | |
| 85 var object = new Object(); | |
| 86 a.foo = 0; | |
| 87 a[0] = 0; | |
| 88 a[1] = 1; | |
| 89 do { | |
| 90 a[1] = 2.5; | |
| 91 a.foo = object; // This map check should be hoistable | |
| 92 } while (global_false); | |
| 93 } | |
| 94 | |
| 95 testExactMapHoisting2(new Array(5)); | |
| 96 %OptimizeFunctionOnNextCall(testExactMapHoisting2); | |
| 97 testExactMapHoisting2(new Array(5)); | |
| 98 testExactMapHoisting2(new Array(5)); | |
| 99 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2)); | |
| 100 | |
| 101 // Make sure that non-element related map checks still get hoisted if all | |
|
fschneider
2012/02/07 10:05:05
The description of this test does not match the co
danno
2012/02/08 17:18:42
Done.
| |
| 102 // known element transitions have been done by the time the map check is done. | |
| 103 // Make sure it's done in a way that doesn't deopt later. | |
| 104 function testExactMapHoisting3(a) { | |
| 105 var object = new Object(); | |
| 106 a.foo = 0; | |
| 107 a[0] = 0; | |
| 108 a[1] = 1; | |
| 109 do { | |
| 110 a[1] = 2.5; | |
| 111 a.foo = object; // This map check should NOT be hoistable because includes | |
|
fschneider
2012/02/07 10:05:05
When running this test I see this map check hoiste
danno
2012/02/08 17:18:42
Done.
| |
| 112 // a check for the FAST_ELEMENTS map as well as the | |
| 113 // FAST_DOUBLE_ELEMENTS map. | |
| 114 } while (global_false); | |
| 115 } | |
| 116 | |
| 117 var add_transition = new Array(5); | |
| 118 add_transition.foo = 0; | |
| 119 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be created | |
| 120 testExactMapHoisting3(new Array(5)); | |
| 121 %OptimizeFunctionOnNextCall(testExactMapHoisting3); | |
| 122 testExactMapHoisting3(new Array(5)); | |
| 123 testExactMapHoisting3(new Array(5)); | |
| 124 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3)); | |
| 125 | |
| 126 function testDominatingTransitionHoisting1(a) { | |
| 127 var object = new Object(); | |
| 128 a.foo = 0; | |
|
fschneider
2012/02/07 10:05:05
Since a.foo is not used in the loop, I don't see w
danno
2012/02/08 17:18:42
Done.
| |
| 129 a[0] = 0; | |
| 130 do { | |
| 131 if (global_false != true) { | |
|
fschneider
2012/02/07 10:05:05
if (!global_false)
Otherwise the compare is gener
danno
2012/02/08 17:18:42
Done.
| |
| 132 a[1] = 2.5; | |
| 133 } | |
| 134 a[0] = object; | |
| 135 } while (global_false); | |
| 136 } | |
| 137 | |
| 138 testDominatingTransitionHoisting1(new Array(5)); | |
| 139 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); | |
| 140 testDominatingTransitionHoisting1(new Array(5)); | |
| 141 testDominatingTransitionHoisting1(new Array(5)); | |
| 142 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1)); | |
| 143 | |
| 144 function testHoistingWithSideEffect(a) { | |
| 145 var object = new Object(); | |
| 146 a.foo = 0; | |
|
fschneider
2012/02/07 10:05:05
Since a.foo is not used in the loop, I don't see w
danno
2012/02/08 17:18:42
Done.
| |
| 147 a[0] = 0; | |
| 148 do { | |
| 149 assertTrue(true); | |
| 150 a[0] = object; | |
| 151 } while (global_false); | |
| 152 } | |
| 153 | |
| 154 testHoistingWithSideEffect(new Array(5)); | |
| 155 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); | |
| 156 testHoistingWithSideEffect(new Array(5)); | |
| 157 testHoistingWithSideEffect(new Array(5)); | |
| 158 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); | |
| 159 } | |
| OLD | NEW |