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 | 28 // Flags: --allow-natives-syntax --expose-gc |
29 | 29 |
30 // Test uint32 handing in optimized frames. | 30 // Test uint32 handing in optimized frames. |
31 | 31 |
32 var K1 = 0x7fffffff; | 32 var K1 = 0x7fffffff; |
33 var K2 = 0xffffffff; | 33 var K2 = 0xffffffff; |
34 | 34 |
35 var uint32_array = new Uint32Array(2); | 35 var uint32_array = new Uint32Array(2); |
36 uint32_array[0] = K1; | 36 uint32_array[0] = K1; |
37 uint32_array[1] = K2; | 37 uint32_array[1] = K2; |
38 | 38 |
39 function ChangeI2T(arr, i) { | 39 function ChangeI2T(arr, i) { |
40 return uint32_array[i]; | 40 return uint32_array[i]; |
41 } | 41 } |
42 | 42 |
43 assertEquals(K1, ChangeI2T(uint32_array, 0)); | 43 assertEquals(K1, ChangeI2T(uint32_array, 0)); |
44 assertEquals(K2, ChangeI2T(uint32_array, 1)); | 44 assertEquals(K2, ChangeI2T(uint32_array, 1)); |
45 %OptimizeFunctionOnNextCall(ChangeI2T); | 45 %OptimizeFunctionOnNextCall(ChangeI2T); |
46 assertEquals(K1, ChangeI2T(uint32_array, 0)); | 46 assertEquals(K1, ChangeI2T(uint32_array, 0)); |
47 assertEquals(K2, ChangeI2T(uint32_array, 1)); | 47 // Loop to force inline allocation failure and a call into runtime. |
| 48 for (var i = 0; i < 80000; i++) { |
| 49 assertEquals(K2, ChangeI2T(uint32_array, 1)); |
| 50 } |
48 | 51 |
49 function SideEffect() { | 52 function SideEffect() { |
50 with ({}) { } // not inlinable | 53 with ({}) { } // not inlinable |
51 } | 54 } |
52 | 55 |
53 function Deopt(obj, arr, i) { | 56 function Deopt(obj, arr, i) { |
54 var x = arr[i]; | 57 var x = arr[i]; |
55 SideEffect(); // x will be used by HSimulate. | 58 SideEffect(); // x will be used by HSimulate. |
56 obj.x; | 59 obj.x; |
57 return x; | 60 return x; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 a = (a >>> 0); | 144 a = (a >>> 0); |
142 } | 145 } |
143 } | 146 } |
144 return a + a; | 147 return a + a; |
145 } | 148 } |
146 | 149 |
147 assertEquals(2, PhiOfPhiUnsafe(1)); | 150 assertEquals(2, PhiOfPhiUnsafe(1)); |
148 assertEquals(2, PhiOfPhiUnsafe(1)); | 151 assertEquals(2, PhiOfPhiUnsafe(1)); |
149 %OptimizeFunctionOnNextCall(PhiOfPhiUnsafe); | 152 %OptimizeFunctionOnNextCall(PhiOfPhiUnsafe); |
150 assertEquals(2 * K3, PhiOfPhiUnsafe(K3)); | 153 assertEquals(2 * K3, PhiOfPhiUnsafe(K3)); |
| 154 |
| 155 var old_array = new Array(1000); |
| 156 |
| 157 for (var i = 0; i < old_array.length; i++) old_array[i] = null; |
| 158 |
| 159 // Force promotion. |
| 160 gc(); |
| 161 gc(); |
| 162 |
| 163 function FillOldArrayWithHeapNumbers(N) { |
| 164 for (var i = 0; i < N; i++) { |
| 165 old_array[i] = uint32_array[1]; |
| 166 } |
| 167 } |
| 168 |
| 169 FillOldArrayWithHeapNumbers(1); |
| 170 FillOldArrayWithHeapNumbers(1); |
| 171 %OptimizeFunctionOnNextCall(FillOldArrayWithHeapNumbers); |
| 172 FillOldArrayWithHeapNumbers(old_array.length); |
| 173 gc(); |
OLD | NEW |