| 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 --expose-gc | 28 // Flags: --allow-natives-syntax --smi-only-arrays --expose-gc |
| 29 // Flags: --noparallel-recompilation | |
| 30 | 29 |
| 31 // Test element kind of objects. | 30 // Test element kind of objects. |
| 32 // Since --smi-only-arrays affects builtins, its default setting at compile | 31 // Since --smi-only-arrays affects builtins, its default setting at compile |
| 33 // time sticks if built with snapshot. If --smi-only-arrays is deactivated | 32 // time sticks if built with snapshot. If --smi-only-arrays is deactivated |
| 34 // by default, only a no-snapshot build actually has smi-only arrays enabled | 33 // by default, only a no-snapshot build actually has smi-only arrays enabled |
| 35 // in this test case. Depending on whether smi-only arrays are actually | 34 // in this test case. Depending on whether smi-only arrays are actually |
| 36 // enabled, this test takes the appropriate code path to check smi-only arrays. | 35 // enabled, this test takes the appropriate code path to check smi-only arrays. |
| 37 | 36 |
| 38 support_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]); | 37 support_smi_only_arrays = %HasFastSmiElements([1,2,3,4,5,6,7,8,9,10]); |
| 39 | 38 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } else { | 136 } else { |
| 138 return new Array(); | 137 return new Array(); |
| 139 } | 138 } |
| 140 } | 139 } |
| 141 | 140 |
| 142 deopt_array(false); | 141 deopt_array(false); |
| 143 deopt_array(false); | 142 deopt_array(false); |
| 144 deopt_array(false); | 143 deopt_array(false); |
| 145 %OptimizeFunctionOnNextCall(deopt_array); | 144 %OptimizeFunctionOnNextCall(deopt_array); |
| 146 var array = deopt_array(false); | 145 var array = deopt_array(false); |
| 147 assertTrue(2 != %GetOptimizationStatus(deopt_array)); | 146 assertOptimized(deopt_array); |
| 148 deopt_array(true); | 147 deopt_array(true); |
| 149 assertTrue(2 != %GetOptimizationStatus(deopt_array)); | 148 assertOptimized(deopt_array); |
| 150 array = deopt_array(false); | 149 array = deopt_array(false); |
| 151 assertTrue(2 != %GetOptimizationStatus(deopt_array)); | 150 assertOptimized(deopt_array); |
| 152 | 151 |
| 153 // Check that unexpected changes in the objects stored into the boilerplate | 152 // Check that unexpected changes in the objects stored into the boilerplate |
| 154 // also force a deopt. | 153 // also force a deopt. |
| 155 function deopt_array_literal_all_smis(a) { | 154 function deopt_array_literal_all_smis(a) { |
| 156 return [0, 1, a]; | 155 return [0, 1, a]; |
| 157 } | 156 } |
| 158 | 157 |
| 159 deopt_array_literal_all_smis(2); | 158 deopt_array_literal_all_smis(2); |
| 160 deopt_array_literal_all_smis(3); | 159 deopt_array_literal_all_smis(3); |
| 161 deopt_array_literal_all_smis(4); | 160 deopt_array_literal_all_smis(4); |
| 162 array = deopt_array_literal_all_smis(4); | 161 array = deopt_array_literal_all_smis(4); |
| 163 assertEquals(0, array[0]); | 162 assertEquals(0, array[0]); |
| 164 assertEquals(1, array[1]); | 163 assertEquals(1, array[1]); |
| 165 assertEquals(4, array[2]); | 164 assertEquals(4, array[2]); |
| 166 %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis); | 165 %OptimizeFunctionOnNextCall(deopt_array_literal_all_smis); |
| 167 array = deopt_array_literal_all_smis(5); | 166 array = deopt_array_literal_all_smis(5); |
| 168 array = deopt_array_literal_all_smis(6); | 167 array = deopt_array_literal_all_smis(6); |
| 169 assertTrue(2 != %GetOptimizationStatus(deopt_array_literal_all_smis)); | 168 assertOptimized(deopt_array_literal_all_smis); |
| 170 assertEquals(0, array[0]); | 169 assertEquals(0, array[0]); |
| 171 assertEquals(1, array[1]); | 170 assertEquals(1, array[1]); |
| 172 assertEquals(6, array[2]); | 171 assertEquals(6, array[2]); |
| 173 | 172 |
| 174 array = deopt_array_literal_all_smis(.5); | 173 array = deopt_array_literal_all_smis(.5); |
| 175 assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_smis)); | 174 assertUnoptimized(deopt_array_literal_all_smis); |
| 176 assertEquals(0, array[0]); | 175 assertEquals(0, array[0]); |
| 177 assertEquals(1, array[1]); | 176 assertEquals(1, array[1]); |
| 178 assertEquals(.5, array[2]); | 177 assertEquals(.5, array[2]); |
| 179 | 178 |
| 180 function deopt_array_literal_all_doubles(a) { | 179 function deopt_array_literal_all_doubles(a) { |
| 181 return [0.5, 1, a]; | 180 return [0.5, 1, a]; |
| 182 } | 181 } |
| 183 | 182 |
| 184 deopt_array_literal_all_doubles(.5); | 183 deopt_array_literal_all_doubles(.5); |
| 185 deopt_array_literal_all_doubles(.5); | 184 deopt_array_literal_all_doubles(.5); |
| 186 deopt_array_literal_all_doubles(.5); | 185 deopt_array_literal_all_doubles(.5); |
| 187 array = deopt_array_literal_all_doubles(0.5); | 186 array = deopt_array_literal_all_doubles(0.5); |
| 188 assertEquals(0.5, array[0]); | 187 assertEquals(0.5, array[0]); |
| 189 assertEquals(1, array[1]); | 188 assertEquals(1, array[1]); |
| 190 assertEquals(0.5, array[2]); | 189 assertEquals(0.5, array[2]); |
| 191 %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles); | 190 %OptimizeFunctionOnNextCall(deopt_array_literal_all_doubles); |
| 192 array = deopt_array_literal_all_doubles(5); | 191 array = deopt_array_literal_all_doubles(5); |
| 193 array = deopt_array_literal_all_doubles(6); | 192 array = deopt_array_literal_all_doubles(6); |
| 194 assertTrue(2 != %GetOptimizationStatus(deopt_array_literal_all_doubles)); | 193 assertOptimized(deopt_array_literal_all_doubles); |
| 195 assertEquals(0.5, array[0]); | 194 assertEquals(0.5, array[0]); |
| 196 assertEquals(1, array[1]); | 195 assertEquals(1, array[1]); |
| 197 assertEquals(6, array[2]); | 196 assertEquals(6, array[2]); |
| 198 | 197 |
| 199 var foo = new Object(); | 198 var foo = new Object(); |
| 200 array = deopt_array_literal_all_doubles(foo); | 199 array = deopt_array_literal_all_doubles(foo); |
| 201 assertTrue(1 != %GetOptimizationStatus(deopt_array_literal_all_doubles)); | 200 assertUnoptimized(deopt_array_literal_all_doubles); |
| 202 assertEquals(0.5, array[0]); | 201 assertEquals(0.5, array[0]); |
| 203 assertEquals(1, array[1]); | 202 assertEquals(1, array[1]); |
| 204 assertEquals(foo, array[2]); | 203 assertEquals(foo, array[2]); |
| 205 } | 204 } |
| 206 | 205 |
| 207 (function literals_after_osr() { | 206 (function literals_after_osr() { |
| 208 var color = [0]; | 207 var color = [0]; |
| 209 // Trigger OSR. | 208 // Trigger OSR. |
| 210 while (%GetOptimizationStatus(literals_after_osr) == 2) {} | 209 while (%GetOptimizationStatus(literals_after_osr, "no sync") == 2) {} |
| 211 return [color[0]]; | 210 return [color[0]]; |
| 212 })(); | 211 })(); |
| OLD | NEW |