OLD | NEW |
1 // Copyright 2011 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. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 var ab = new ArrayBuffer(12); | 53 var ab = new ArrayBuffer(12); |
54 var derived_uint8 = new Uint8Array(ab); | 54 var derived_uint8 = new Uint8Array(ab); |
55 assertEquals(12, derived_uint8.length); | 55 assertEquals(12, derived_uint8.length); |
56 var derived_uint32 = new Uint32Array(ab); | 56 var derived_uint32 = new Uint32Array(ab); |
57 assertEquals(3, derived_uint32.length); | 57 assertEquals(3, derived_uint32.length); |
58 var derived_uint32_2 = new Uint32Array(ab,4); | 58 var derived_uint32_2 = new Uint32Array(ab,4); |
59 assertEquals(2, derived_uint32_2.length); | 59 assertEquals(2, derived_uint32_2.length); |
60 var derived_uint32_3 = new Uint32Array(ab,4,1); | 60 var derived_uint32_3 = new Uint32Array(ab,4,1); |
61 assertEquals(1, derived_uint32_3.length); | 61 assertEquals(1, derived_uint32_3.length); |
62 | 62 |
63 // Resulting array length of zero should fail. | |
64 function abfunc2() { | |
65 new Uint32Array(ab,3); | |
66 } | |
67 assertThrows(abfunc2); | |
68 | |
69 // If a given byteOffset and length references an area beyond the end of the | 63 // If a given byteOffset and length references an area beyond the end of the |
70 // ArrayBuffer an exception is raised. | 64 // ArrayBuffer an exception is raised. |
71 function abfunc3() { | 65 function abfunc3() { |
72 new Uint32Array(ab,4,3); | 66 new Uint32Array(ab,4,3); |
73 } | 67 } |
74 assertThrows(abfunc3); | 68 assertThrows(abfunc3); |
75 function abfunc4() { | 69 function abfunc4() { |
76 new Uint32Array(ab,16); | 70 new Uint32Array(ab,16); |
77 } | 71 } |
78 assertThrows(abfunc4); | 72 assertThrows(abfunc4); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 return a[0] = a[0] = 1; | 310 return a[0] = a[0] = 1; |
317 } | 311 } |
318 | 312 |
319 array_load_set_smi_check2(a); | 313 array_load_set_smi_check2(a); |
320 %OptimizeFunctionOnNextCall(array_load_set_smi_check2); | 314 %OptimizeFunctionOnNextCall(array_load_set_smi_check2); |
321 array_load_set_smi_check2(a); | 315 array_load_set_smi_check2(a); |
322 array_load_set_smi_check2(0); | 316 array_load_set_smi_check2(0); |
323 %DeoptimizeFunction(array_load_set_smi_check2); | 317 %DeoptimizeFunction(array_load_set_smi_check2); |
324 gc(); // Makes V8 forget about type information for array_load_set_smi_check. | 318 gc(); // Makes V8 forget about type information for array_load_set_smi_check. |
325 } | 319 } |
OLD | NEW |