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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 var result_phi = 0; | 193 var result_phi = 0; |
194 result_phi = test_phi(data_phi, 3, true); | 194 result_phi = test_phi(data_phi, 3, true); |
195 assertEquals(12, result_phi); | 195 assertEquals(12, result_phi); |
196 result_phi = test_phi(data_phi, 3, true); | 196 result_phi = test_phi(data_phi, 3, true); |
197 assertEquals(12, result_phi); | 197 assertEquals(12, result_phi); |
198 %OptimizeFunctionOnNextCall(test_phi); | 198 %OptimizeFunctionOnNextCall(test_phi); |
199 result_phi = test_phi(data_phi, 3, true); | 199 result_phi = test_phi(data_phi, 3, true); |
200 assertEquals(12, result_phi); | 200 assertEquals(12, result_phi); |
201 | 201 |
202 | 202 |
| 203 // A test for recursive decomposition |
| 204 var data_composition_long = [0, 1, 2, 3, 4, 5, 6, 7, 8]; |
| 205 var data_composition_short = [0, 1, 2, 3, 4]; |
| 206 function test_composition(a, base0, check) { |
| 207 var base1 = ((base0 + 2)); |
| 208 var base2 = ((base1 + 8) >> 2); |
| 209 var base3 = ((base2 + 6) >> 1); |
| 210 var base4 = ((base3 + 8) >> 1); |
| 211 |
| 212 var result = 0; |
| 213 result += a[base0]; |
| 214 result += a[base1]; |
| 215 result += a[base2]; |
| 216 result += a[base3]; |
| 217 result += a[base4]; |
| 218 |
| 219 return result; |
| 220 } |
| 221 var result_composition = 0; |
| 222 result_composition = test_composition(data_composition_long, 2); |
| 223 assertEquals(19, result_composition); |
| 224 result_composition = test_composition(data_composition_long, 2); |
| 225 assertEquals(19, result_composition); |
| 226 %OptimizeFunctionOnNextCall(test_composition); |
| 227 result_composition = test_composition(data_composition_short, 2); |
| 228 assertEquals(NaN, result_composition); |
| 229 |
| 230 |
203 gc(); | 231 gc(); |
OLD | NEW |