| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // Flags: --allow-natives-syntax --smi-only-arrays --noparallel-recompilation | 28 // Flags: --allow-natives-syntax --smi-only-arrays --notrack-allocation-sites |
| 29 // Flags: --notrack-allocation-sites | |
| 30 | 29 |
| 31 // No tracking of allocation sites because it interfers with the semantics | 30 // No tracking of allocation sites because it interfers with the semantics |
| 32 // the test is trying to ensure. | 31 // the test is trying to ensure. |
| 33 | 32 |
| 34 // Ensure that ElementsKind transitions in various situations are hoisted (or | 33 // Ensure that ElementsKind transitions in various situations are hoisted (or |
| 35 // not hoisted) correctly, don't change the semantics programs and don't trigger | 34 // not hoisted) correctly, don't change the semantics programs and don't trigger |
| 36 // deopt through hoisting in important situations. | 35 // deopt through hoisting in important situations. |
| 37 | 36 |
| 38 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); | 37 support_smi_only_arrays = %HasFastSmiElements(new Array(1,2,3,4,5,6)); |
| 39 | 38 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 56 } while (--count > 0); | 55 } while (--count > 0); |
| 57 } | 56 } |
| 58 | 57 |
| 59 testDoubleConversion4(new Array(5)); | 58 testDoubleConversion4(new Array(5)); |
| 60 testDoubleConversion4(new Array(5)); // Call twice to make sure that second | 59 testDoubleConversion4(new Array(5)); // Call twice to make sure that second |
| 61 // store is a transition and not | 60 // store is a transition and not |
| 62 // optimistically MONOMORPHIC | 61 // optimistically MONOMORPHIC |
| 63 %OptimizeFunctionOnNextCall(testDoubleConversion4); | 62 %OptimizeFunctionOnNextCall(testDoubleConversion4); |
| 64 testDoubleConversion4(new Array(5)); | 63 testDoubleConversion4(new Array(5)); |
| 65 testDoubleConversion4(new Array(5)); | 64 testDoubleConversion4(new Array(5)); |
| 66 assertTrue(2 != %GetOptimizationStatus(testDoubleConversion4)); | 65 assertOptimized(testDoubleConversion4); |
| 67 %ClearFunctionTypeFeedback(testDoubleConversion4); | 66 %ClearFunctionTypeFeedback(testDoubleConversion4); |
| 68 | 67 |
| 69 // Make sure that non-element related map checks that are not preceded by | 68 // Make sure that non-element related map checks that are not preceded by |
| 70 // transitions in a loop still get hoisted in a way that doesn't generate a | 69 // transitions in a loop still get hoisted in a way that doesn't generate a |
| 71 // deopt in simple cases. | 70 // deopt in simple cases. |
| 72 function testExactMapHoisting(a) { | 71 function testExactMapHoisting(a) { |
| 73 var object = new Object(); | 72 var object = new Object(); |
| 74 a.foo = {}; | 73 a.foo = {}; |
| 75 a[0] = 0; | 74 a[0] = 0; |
| 76 a[1] = 1; | 75 a[1] = 1; |
| 77 var count = 3; | 76 var count = 3; |
| 78 do { | 77 do { |
| 79 a.foo = object; // This map check should be hoistable | 78 a.foo = object; // This map check should be hoistable |
| 80 a[1] = object; | 79 a[1] = object; |
| 81 result = a.foo == object && a[1] == object; | 80 result = a.foo == object && a[1] == object; |
| 82 } while (--count > 0); | 81 } while (--count > 0); |
| 83 } | 82 } |
| 84 | 83 |
| 85 testExactMapHoisting(new Array(5)); | 84 testExactMapHoisting(new Array(5)); |
| 86 testExactMapHoisting(new Array(5)); // Call twice to make sure that second | 85 testExactMapHoisting(new Array(5)); // Call twice to make sure that second |
| 87 // store is a transition and not | 86 // store is a transition and not |
| 88 // optimistically MONOMORPHIC | 87 // optimistically MONOMORPHIC |
| 89 %OptimizeFunctionOnNextCall(testExactMapHoisting); | 88 %OptimizeFunctionOnNextCall(testExactMapHoisting); |
| 90 testExactMapHoisting(new Array(5)); | 89 testExactMapHoisting(new Array(5)); |
| 91 testExactMapHoisting(new Array(5)); | 90 testExactMapHoisting(new Array(5)); |
| 92 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting)); | 91 assertOptimized(testExactMapHoisting); |
| 93 %ClearFunctionTypeFeedback(testExactMapHoisting); | 92 %ClearFunctionTypeFeedback(testExactMapHoisting); |
| 94 | 93 |
| 95 // Make sure that non-element related map checks do NOT get hoisted if they | 94 // Make sure that non-element related map checks do NOT get hoisted if they |
| 96 // depend on an elements transition before them and it's not possible to hoist | 95 // depend on an elements transition before them and it's not possible to hoist |
| 97 // that transition. | 96 // that transition. |
| 98 function testExactMapHoisting2(a) { | 97 function testExactMapHoisting2(a) { |
| 99 var object = new Object(); | 98 var object = new Object(); |
| 100 a.foo = 0; | 99 a.foo = 0; |
| 101 a[0] = 0; | 100 a[0] = 0; |
| 102 a[1] = 1; | 101 a[1] = 1; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 } | 113 } |
| 115 | 114 |
| 116 testExactMapHoisting2(new Array(5)); | 115 testExactMapHoisting2(new Array(5)); |
| 117 testExactMapHoisting2(new Array(5)); // Call twice to make sure that second | 116 testExactMapHoisting2(new Array(5)); // Call twice to make sure that second |
| 118 // store is a transition and not | 117 // store is a transition and not |
| 119 // optimistically MONOMORPHIC | 118 // optimistically MONOMORPHIC |
| 120 %OptimizeFunctionOnNextCall(testExactMapHoisting2); | 119 %OptimizeFunctionOnNextCall(testExactMapHoisting2); |
| 121 testExactMapHoisting2(new Array(5)); | 120 testExactMapHoisting2(new Array(5)); |
| 122 testExactMapHoisting2(new Array(5)); | 121 testExactMapHoisting2(new Array(5)); |
| 123 // Temporarily disabled - see bug 2176. | 122 // Temporarily disabled - see bug 2176. |
| 124 // assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting2)); | 123 // assertOptimized(testExactMapHoisting2); |
| 125 %ClearFunctionTypeFeedback(testExactMapHoisting2); | 124 %ClearFunctionTypeFeedback(testExactMapHoisting2); |
| 126 | 125 |
| 127 // Make sure that non-element related map checks do get hoisted if they use | 126 // Make sure that non-element related map checks do get hoisted if they use |
| 128 // the transitioned map for the check and all transitions that they depend | 127 // the transitioned map for the check and all transitions that they depend |
| 129 // upon can hoisted, too. | 128 // upon can hoisted, too. |
| 130 function testExactMapHoisting3(a) { | 129 function testExactMapHoisting3(a) { |
| 131 var object = new Object(); | 130 var object = new Object(); |
| 132 a.foo = null; | 131 a.foo = null; |
| 133 a[0] = 0; | 132 a[0] = 0; |
| 134 a[1] = 1; | 133 a[1] = 1; |
| 135 var count = 3; | 134 var count = 3; |
| 136 do { | 135 do { |
| 137 a[1] = 2.5; | 136 a[1] = 2.5; |
| 138 a.foo = object; // This map check should be hoistable because all element
s | 137 a.foo = object; // This map check should be hoistable because all element
s |
| 139 // transitions in the loop can also be hoisted. | 138 // transitions in the loop can also be hoisted. |
| 140 } while (--count > 0); | 139 } while (--count > 0); |
| 141 } | 140 } |
| 142 | 141 |
| 143 var add_transition = new Array(5); | 142 var add_transition = new Array(5); |
| 144 add_transition.foo = 0; | 143 add_transition.foo = 0; |
| 145 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be create
d | 144 add_transition[0] = new Object(); // For FAST_ELEMENT transition to be create
d |
| 146 testExactMapHoisting3(new Array(5)); | 145 testExactMapHoisting3(new Array(5)); |
| 147 testExactMapHoisting3(new Array(5)); // Call twice to make sure that second | 146 testExactMapHoisting3(new Array(5)); // Call twice to make sure that second |
| 148 // store is a transition and not | 147 // store is a transition and not |
| 149 // optimistically MONOMORPHIC | 148 // optimistically MONOMORPHIC |
| 150 %OptimizeFunctionOnNextCall(testExactMapHoisting3); | 149 %OptimizeFunctionOnNextCall(testExactMapHoisting3); |
| 151 testExactMapHoisting3(new Array(5)); | 150 testExactMapHoisting3(new Array(5)); |
| 152 testExactMapHoisting3(new Array(5)); | 151 testExactMapHoisting3(new Array(5)); |
| 153 assertTrue(2 != %GetOptimizationStatus(testExactMapHoisting3)); | 152 assertOptimized(testExactMapHoisting3); |
| 154 %ClearFunctionTypeFeedback(testExactMapHoisting3); | 153 %ClearFunctionTypeFeedback(testExactMapHoisting3); |
| 155 | 154 |
| 156 function testDominatingTransitionHoisting1(a) { | 155 function testDominatingTransitionHoisting1(a) { |
| 157 var object = new Object(); | 156 var object = new Object(); |
| 158 a[0] = 0; | 157 a[0] = 0; |
| 159 var count = 3; | 158 var count = 3; |
| 160 do { | 159 do { |
| 161 if (a.baz != true) { | 160 if (a.baz != true) { |
| 162 a[1] = 2.5; | 161 a[1] = 2.5; |
| 163 } | 162 } |
| 164 a[0] = object; | 163 a[0] = object; |
| 165 } while (--count > 3); | 164 } while (--count > 3); |
| 166 } | 165 } |
| 167 | 166 |
| 168 /* | 167 /* |
| 169 testDominatingTransitionHoisting1(new Array(5)); | 168 testDominatingTransitionHoisting1(new Array(5)); |
| 170 testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure | 169 testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure |
| 171 // that second store is a | 170 // that second store is a |
| 172 // transition and not | 171 // transition and not |
| 173 // optimistically MONOMORPHI
C | 172 // optimistically MONOMORPHI
C |
| 174 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); | 173 %OptimizeFunctionOnNextCall(testDominatingTransitionHoisting1); |
| 175 testDominatingTransitionHoisting1(new Array(5)); | 174 testDominatingTransitionHoisting1(new Array(5)); |
| 176 testDominatingTransitionHoisting1(new Array(5)); | 175 testDominatingTransitionHoisting1(new Array(5)); |
| 177 // TODO(verwaest) With current changes the elements transition gets hoisted | 176 // TODO(verwaest) With current changes the elements transition gets hoisted |
| 178 // above the access, causing a deopt. We should update the type of access | 177 // above the access, causing a deopt. We should update the type of access |
| 179 // rather than forbid hoisting the transition. | 178 // rather than forbid hoisting the transition. |
| 180 assertTrue(2 != %GetOptimizationStatus(testDominatingTransitionHoisting1)); | 179 assertOptimized(testDominatingTransitionHoisting1); |
| 181 %ClearFunctionTypeFeedback(testDominatingTransitionHoisting1); | 180 %ClearFunctionTypeFeedback(testDominatingTransitionHoisting1); |
| 182 */ | 181 */ |
| 183 | 182 |
| 184 function testHoistingWithSideEffect(a) { | 183 function testHoistingWithSideEffect(a) { |
| 185 var object = new Object(); | 184 var object = new Object(); |
| 186 a[0] = 0; | 185 a[0] = 0; |
| 187 var count = 3; | 186 var count = 3; |
| 188 do { | 187 do { |
| 189 assertTrue(true); | 188 assertTrue(true); |
| 190 a[0] = object; | 189 a[0] = object; |
| 191 } while (--count > 3); | 190 } while (--count > 3); |
| 192 } | 191 } |
| 193 | 192 |
| 194 testHoistingWithSideEffect(new Array(5)); | 193 testHoistingWithSideEffect(new Array(5)); |
| 195 testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that | 194 testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that |
| 196 // second store is a transition and | 195 // second store is a transition and |
| 197 // not optimistically MONOMORPHIC | 196 // not optimistically MONOMORPHIC |
| 198 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); | 197 %OptimizeFunctionOnNextCall(testHoistingWithSideEffect); |
| 199 testHoistingWithSideEffect(new Array(5)); | 198 testHoistingWithSideEffect(new Array(5)); |
| 200 testHoistingWithSideEffect(new Array(5)); | 199 testHoistingWithSideEffect(new Array(5)); |
| 201 assertTrue(2 != %GetOptimizationStatus(testHoistingWithSideEffect)); | 200 assertOptimized(testHoistingWithSideEffect); |
| 202 %ClearFunctionTypeFeedback(testHoistingWithSideEffect); | 201 %ClearFunctionTypeFeedback(testHoistingWithSideEffect); |
| 203 | 202 |
| 204 function testStraightLineDupeElinination(a,b,c,d,e,f) { | 203 function testStraightLineDupeElinination(a,b,c,d,e,f) { |
| 205 var count = 3; | 204 var count = 3; |
| 206 do { | 205 do { |
| 207 assertTrue(true); | 206 assertTrue(true); |
| 208 a[0] = b; | 207 a[0] = b; |
| 209 a[1] = c; | 208 a[1] = c; |
| 210 a[2] = d; | 209 a[2] = d; |
| 211 assertTrue(true); | 210 assertTrue(true); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 230 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); | 229 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); |
| 231 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); | 230 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); |
| 232 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); | 231 testStraightLineDupeElinination(new Array(5),.5,0,0,0,0); |
| 233 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); | 232 testStraightLineDupeElinination(new Array(5),0,.5,0,0,0); |
| 234 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); | 233 testStraightLineDupeElinination(new Array(5),0,0,.5,0,0); |
| 235 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); | 234 testStraightLineDupeElinination(new Array(5),0,0,0,.5,0); |
| 236 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); | 235 testStraightLineDupeElinination(new Array(5),0,0,0,0,.5); |
| 237 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination); | 236 %OptimizeFunctionOnNextCall(testStraightLineDupeElinination); |
| 238 testStraightLineDupeElinination(new Array(5),0,0,0,0,0); | 237 testStraightLineDupeElinination(new Array(5),0,0,0,0,0); |
| 239 testStraightLineDupeElinination(new Array(5),0,0,0,0,0); | 238 testStraightLineDupeElinination(new Array(5),0,0,0,0,0); |
| 240 assertTrue(2 != %GetOptimizationStatus(testStraightLineDupeElinination)); | 239 assertOptimized(testStraightLineDupeElinination); |
| 241 %ClearFunctionTypeFeedback(testStraightLineDupeElinination); | 240 %ClearFunctionTypeFeedback(testStraightLineDupeElinination); |
| 242 } | 241 } |
| OLD | NEW |