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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 var result_phi = 0; | 195 var result_phi = 0; |
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 result_phi = test_phi(data_phi, 3, true); | 198 result_phi = test_phi(data_phi, 3, true); |
199 assertEquals(12, result_phi); | 199 assertEquals(12, result_phi); |
200 %OptimizeFunctionOnNextCall(test_phi); | 200 %OptimizeFunctionOnNextCall(test_phi); |
201 result_phi = test_phi(data_phi, 3, true); | 201 result_phi = test_phi(data_phi, 3, true); |
202 assertEquals(12, result_phi); | 202 assertEquals(12, result_phi); |
203 | 203 |
204 | 204 |
205 // A test for recursive decomposition | |
206 var data_composition_long = [0, 1, 2, 3, 4, 5, 6, 7, 8]; | |
207 var data_composition_short = [0, 1, 2, 3, 4]; | |
208 function test_composition(a, base0, check) { | |
209 var base1 = ((base0 + 2)); | |
210 var base2 = ((base1 + 8) >> 2); | |
211 var base3 = ((base2 + 6) >> 1); | |
212 var base4 = ((base3 + 8) >> 1); | |
213 | |
214 var result = 0; | |
215 result += a[base0]; | |
216 result += a[base1]; | |
217 result += a[base2]; | |
218 result += a[base3]; | |
219 result += a[base4]; | |
220 | |
221 if (false) { | |
Jakob Kummerow
2013/03/14 16:18:16
debugging leftover?
| |
222 print("base0: " + base0 + | |
223 ", base1: " + base1 + | |
224 ", base2: " + base2 + | |
225 ", base3: " + base3 + | |
226 ", base4: " + base4 + | |
227 ", result: " + result + | |
228 ", length: " + a.length); | |
229 } | |
230 | |
231 return result; | |
232 } | |
233 var result_composition = 0; | |
234 result_composition = test_composition(data_composition_long, 2); | |
235 assertEquals(19, result_composition); | |
236 result_composition = test_composition(data_composition_long, 2); | |
237 assertEquals(19, result_composition); | |
238 %OptimizeFunctionOnNextCall(test_composition); | |
239 result_composition = test_composition(data_composition_short, 2); | |
240 assertEquals(NaN, result_composition); | |
241 | |
242 | |
205 gc(); | 243 gc(); |
206 | 244 |
OLD | NEW |