OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 a[i - 10] = 0; | 171 a[i - 10] = 0; |
172 } | 172 } |
173 short_test(short_a, 50); | 173 short_test(short_a, 50); |
174 short_test(short_a, 50); | 174 short_test(short_a, 50); |
175 %OptimizeFunctionOnNextCall(short_test); | 175 %OptimizeFunctionOnNextCall(short_test); |
176 short_a.length = 10; | 176 short_a.length = 10; |
177 short_test(a, 0); | 177 short_test(a, 0); |
178 assertTrue(%GetOptimizationStatus(short_test) != 1); | 178 assertTrue(%GetOptimizationStatus(short_test) != 1); |
179 | 179 |
180 | 180 |
| 181 // A test for when we would modify a phi index. |
| 182 var data_phi = [0, 1, 2, 3, 4, 5, 6, 7, 8]; |
| 183 function test_phi(a, base, check) { |
| 184 var index; |
| 185 if (check) { |
| 186 index = base + 1; |
| 187 } else { |
| 188 index = base + 2; |
| 189 } |
| 190 var result = a[index]; |
| 191 result += a[index + 1]; |
| 192 result += a[index - 1]; |
| 193 return result; |
| 194 } |
| 195 var result_phi = 0; |
| 196 result_phi = test_phi(data_phi, 3, true); |
| 197 assertEquals(12, result_phi); |
| 198 result_phi = test_phi(data_phi, 3, true); |
| 199 assertEquals(12, result_phi); |
| 200 %OptimizeFunctionOnNextCall(test_phi); |
| 201 result_phi = test_phi(data_phi, 3, true); |
| 202 assertEquals(12, result_phi); |
| 203 |
| 204 |
181 gc(); | 205 gc(); |
182 | 206 |
OLD | NEW |