| 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 --expose-gc | 28 // Flags: --allow-natives-syntax |
| 29 | 29 |
| 30 // Helper | 30 // Helper |
| 31 function assertInstance(o, f) { | 31 function assertInstance(o, f) { |
| 32 assertSame(o.constructor, f); | 32 assertSame(o.constructor, f); |
| 33 assertInstanceof(o, f); | 33 assertInstanceof(o, f); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // This is a regression test for overlapping key and value registers. | 36 // This is a regression test for overlapping key and value registers. |
| 37 function f(a) { | 37 function f(a) { |
| 38 a[0] = 0; | 38 a[0] = 0; |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 function run_test(test_func, array, expected_result) { | 295 function run_test(test_func, array, expected_result) { |
| 296 for (var i = 0; i < 5; i++) test_func(array, 0); | 296 for (var i = 0; i < 5; i++) test_func(array, 0); |
| 297 %OptimizeFunctionOnNextCall(test_func); | 297 %OptimizeFunctionOnNextCall(test_func); |
| 298 var sum = 0; | 298 var sum = 0; |
| 299 for (var i = 0; i < kRuns; i++) { | 299 for (var i = 0; i < kRuns; i++) { |
| 300 sum = test_func(array, sum); | 300 sum = test_func(array, sum); |
| 301 } | 301 } |
| 302 assertEquals(expected_result, sum); | 302 assertEquals(expected_result, sum); |
| 303 %DeoptimizeFunction(test_func); | 303 %DeoptimizeFunction(test_func); |
| 304 gc(); // Makes V8 forget about type information for test_func. | 304 %ClearFunctionTypeFeedback(test_func); |
| 305 } | 305 } |
| 306 | 306 |
| 307 function run_bounds_test(test_func, array, expected_result) { | 307 function run_bounds_test(test_func, array, expected_result) { |
| 308 assertEquals(undefined, a[kElementCount]); | 308 assertEquals(undefined, a[kElementCount]); |
| 309 a[kElementCount] = 456; | 309 a[kElementCount] = 456; |
| 310 assertEquals(undefined, a[kElementCount]); | 310 assertEquals(undefined, a[kElementCount]); |
| 311 assertEquals(undefined, a[kElementCount+1]); | 311 assertEquals(undefined, a[kElementCount+1]); |
| 312 a[kElementCount+1] = 456; | 312 a[kElementCount+1] = 456; |
| 313 assertEquals(undefined, a[kElementCount+1]); | 313 assertEquals(undefined, a[kElementCount+1]); |
| 314 } | 314 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 343 assertEquals(kElementCount, a.length); | 343 assertEquals(kElementCount, a.length); |
| 344 assertTrue(delete a.length); | 344 assertTrue(delete a.length); |
| 345 | 345 |
| 346 // Make sure bounds checks are handled correctly for external arrays. | 346 // Make sure bounds checks are handled correctly for external arrays. |
| 347 run_bounds_test(a); | 347 run_bounds_test(a); |
| 348 run_bounds_test(a); | 348 run_bounds_test(a); |
| 349 run_bounds_test(a); | 349 run_bounds_test(a); |
| 350 %OptimizeFunctionOnNextCall(run_bounds_test); | 350 %OptimizeFunctionOnNextCall(run_bounds_test); |
| 351 run_bounds_test(a); | 351 run_bounds_test(a); |
| 352 %DeoptimizeFunction(run_bounds_test); | 352 %DeoptimizeFunction(run_bounds_test); |
| 353 gc(); // Makes V8 forget about type information for test_func. | 353 %ClearFunctionTypeFeedback(run_bounds_test); |
| 354 | |
| 355 } | 354 } |
| 356 | 355 |
| 357 function array_load_set_smi_check(a) { | 356 function array_load_set_smi_check(a) { |
| 358 return a[0] = a[0] = 1; | 357 return a[0] = a[0] = 1; |
| 359 } | 358 } |
| 360 | 359 |
| 361 array_load_set_smi_check(a); | 360 array_load_set_smi_check(a); |
| 362 array_load_set_smi_check(0); | 361 array_load_set_smi_check(0); |
| 363 | 362 |
| 364 function array_load_set_smi_check2(a) { | 363 function array_load_set_smi_check2(a) { |
| 365 return a[0] = a[0] = 1; | 364 return a[0] = a[0] = 1; |
| 366 } | 365 } |
| 367 | 366 |
| 368 array_load_set_smi_check2(a); | 367 array_load_set_smi_check2(a); |
| 369 %OptimizeFunctionOnNextCall(array_load_set_smi_check2); | 368 %OptimizeFunctionOnNextCall(array_load_set_smi_check2); |
| 370 array_load_set_smi_check2(a); | 369 array_load_set_smi_check2(a); |
| 371 array_load_set_smi_check2(0); | 370 array_load_set_smi_check2(0); |
| 372 %DeoptimizeFunction(array_load_set_smi_check2); | 371 %DeoptimizeFunction(array_load_set_smi_check2); |
| 373 gc(); // Makes V8 forget about type information for array_load_set_smi_check. | 372 %ClearFunctionTypeFeedback(array_load_set_smi_check2); |
| 374 } | 373 } |
| 375 | 374 |
| 376 // Check handling of undefined in 32- and 64-bit external float arrays. | 375 // Check handling of undefined in 32- and 64-bit external float arrays. |
| 377 | 376 |
| 378 function store_float32_undefined(ext_array) { | 377 function store_float32_undefined(ext_array) { |
| 379 ext_array[0] = undefined; | 378 ext_array[0] = undefined; |
| 380 } | 379 } |
| 381 | 380 |
| 382 var float32_array = new Float32Array(1); | 381 var float32_array = new Float32Array(1); |
| 383 // Make sure runtime does it right | 382 // Make sure runtime does it right |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 684 |
| 686 built_in_array = new Array(1.5, 2, 3, 4, 5, 6); | 685 built_in_array = new Array(1.5, 2, 3, 4, 5, 6); |
| 687 assertEquals(1.5, goo(built_in_array, 0)); | 686 assertEquals(1.5, goo(built_in_array, 0)); |
| 688 assertEquals(1.5, goo(built_in_array, 0)); | 687 assertEquals(1.5, goo(built_in_array, 0)); |
| 689 %OptimizeFunctionOnNextCall(goo); | 688 %OptimizeFunctionOnNextCall(goo); |
| 690 %OptimizeFunctionOnNextCall(boo); | 689 %OptimizeFunctionOnNextCall(boo); |
| 691 boo(built_in_array, 0, 2.5); | 690 boo(built_in_array, 0, 2.5); |
| 692 assertEquals(2.5, goo(built_in_array, 0)); | 691 assertEquals(2.5, goo(built_in_array, 0)); |
| 693 %ClearFunctionTypeFeedback(goo); | 692 %ClearFunctionTypeFeedback(goo); |
| 694 %ClearFunctionTypeFeedback(boo); | 693 %ClearFunctionTypeFeedback(boo); |
| OLD | NEW |