| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 assertEquals(3.5, array[1]); | 74 assertEquals(3.5, array[1]); |
| 75 for (var i = 0; i < 5; i++) { | 75 for (var i = 0; i < 5; i++) { |
| 76 assertEquals(2.5, get(array, 0)); | 76 assertEquals(2.5, get(array, 0)); |
| 77 assertEquals(3.5, array[1]); | 77 assertEquals(3.5, array[1]); |
| 78 } | 78 } |
| 79 %OptimizeFunctionOnNextCall(get); | 79 %OptimizeFunctionOnNextCall(get); |
| 80 assertEquals(2.5, get(array, 0)); | 80 assertEquals(2.5, get(array, 0)); |
| 81 assertEquals(3.5, get(array, 1)); | 81 assertEquals(3.5, get(array, 1)); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Test non-number parameters. |
| 85 var array_with_length_from_non_number = new Int32Array("2"); |
| 86 assertEquals(2, array_with_length_from_non_number.length); |
| 87 array_with_length_from_non_number = new Int32Array(undefined); |
| 88 assertEquals(0, array_with_length_from_non_number.length); |
| 89 var foo = { valueOf: function() { return 3; } }; |
| 90 array_with_length_from_non_number = new Int32Array(foo); |
| 91 assertEquals(3, array_with_length_from_non_number.length); |
| 92 foo = { toString: function() { return "4"; } }; |
| 93 array_with_length_from_non_number = new Int32Array(foo); |
| 94 assertEquals(4, array_with_length_from_non_number.length); |
| 95 |
| 96 |
| 84 // Test loads and stores. | 97 // Test loads and stores. |
| 85 types = [Array, Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, | 98 types = [Array, Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, |
| 86 Uint32Array, PixelArray, Float32Array, Float64Array]; | 99 Uint32Array, PixelArray, Float32Array, Float64Array]; |
| 87 | 100 |
| 88 test_result_nan = [NaN, 0, 0, 0, 0, 0, 0, 0, NaN, NaN]; | 101 test_result_nan = [NaN, 0, 0, 0, 0, 0, 0, 0, NaN, NaN]; |
| 89 test_result_low_int = [-1, -1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1, -1]; | 102 test_result_low_int = [-1, -1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1, -1]; |
| 90 test_result_low_double = [-1.25, -1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1.25, -
1.25]; | 103 test_result_low_double = [-1.25, -1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1.25, -
1.25]; |
| 91 test_result_middle = [253.75, -3, 253, 253, 253, 253, 253, 254, 253.75, 253.75]; | 104 test_result_middle = [253.75, -3, 253, 253, 253, 253, 253, 254, 253.75, 253.75]; |
| 92 test_result_high_int = [256, 0, 0, 256, 256, 256, 256, 255, 256, 256]; | 105 test_result_high_int = [256, 0, 0, 256, 256, 256, 256, 255, 256, 256]; |
| 93 test_result_high_double = [256.25, 0, 0, 256, 256, 256, 256, 255, 256.25, 256.25
]; | 106 test_result_high_double = [256.25, 0, 0, 256, 256, 256, 256, 255, 256.25, 256.25
]; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 return a[0] = a[0] = 1; | 266 return a[0] = a[0] = 1; |
| 254 } | 267 } |
| 255 | 268 |
| 256 array_load_set_smi_check2(a); | 269 array_load_set_smi_check2(a); |
| 257 %OptimizeFunctionOnNextCall(array_load_set_smi_check2); | 270 %OptimizeFunctionOnNextCall(array_load_set_smi_check2); |
| 258 array_load_set_smi_check2(a); | 271 array_load_set_smi_check2(a); |
| 259 array_load_set_smi_check2(0); | 272 array_load_set_smi_check2(0); |
| 260 %DeoptimizeFunction(array_load_set_smi_check2); | 273 %DeoptimizeFunction(array_load_set_smi_check2); |
| 261 gc(); // Makes V8 forget about type information for array_load_set_smi_check. | 274 gc(); // Makes V8 forget about type information for array_load_set_smi_check. |
| 262 } | 275 } |
| OLD | NEW |