| 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 25 matching lines...) Expand all  Loading... | 
|   36 var a = new Int32Array(2); |   36 var a = new Int32Array(2); | 
|   37 for (var i = 0; i < 5; i++) { |   37 for (var i = 0; i < 5; i++) { | 
|   38   f(a); |   38   f(a); | 
|   39 } |   39 } | 
|   40 %OptimizeFunctionOnNextCall(f); |   40 %OptimizeFunctionOnNextCall(f); | 
|   41 f(a); |   41 f(a); | 
|   42  |   42  | 
|   43 assertEquals(0, a[0]); |   43 assertEquals(0, a[0]); | 
|   44 assertEquals(0, a[1]); |   44 assertEquals(0, a[1]); | 
|   45  |   45  | 
 |   46 // No-parameter constructor should fail right now. | 
 |   47 function abfunc1() { | 
 |   48   return new ArrayBuffer(); | 
 |   49 } | 
 |   50 assertThrows(abfunc1); | 
 |   51  | 
 |   52 // Test derivation from an ArrayBuffer | 
 |   53 var ab = new ArrayBuffer(12); | 
 |   54 var derived_uint8 = new Uint8Array(ab); | 
 |   55 assertEquals(12, derived_uint8.length); | 
 |   56 var derived_uint32 = new Uint32Array(ab); | 
 |   57 assertEquals(3, derived_uint32.length); | 
 |   58 var derived_uint32_2 = new Uint32Array(ab,4); | 
 |   59 assertEquals(2, derived_uint32_2.length); | 
 |   60 var derived_uint32_3 = new Uint32Array(ab,4,1); | 
 |   61 assertEquals(1, derived_uint32_3.length); | 
 |   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 | 
 |   70 // ArrayBuffer an exception is raised. | 
 |   71 function abfunc3() { | 
 |   72   new Uint32Array(ab,4,3); | 
 |   73 } | 
 |   74 assertThrows(abfunc3); | 
 |   75 function abfunc4() { | 
 |   76   new Uint32Array(ab,16); | 
 |   77 } | 
 |   78 assertThrows(abfunc4); | 
 |   79  | 
 |   80 // The given byteOffset must be a multiple of the element size of the specific | 
 |   81 // type, otherwise an exception is raised. | 
 |   82 function abfunc5() { | 
 |   83   new Uint32Array(ab,5); | 
 |   84 } | 
 |   85 assertThrows(abfunc5); | 
 |   86  | 
 |   87 // If length is not explicitly specified, the length of the ArrayBuffer minus | 
 |   88 // the byteOffset must be a multiple of the element size of the specific type, | 
 |   89 // or an exception is raised. | 
 |   90 var ab2 = new ArrayBuffer(13); | 
 |   91 function abfunc6() { | 
 |   92   new Uint32Array(ab2,4); | 
 |   93 } | 
 |   94 assertThrows(abfunc6); | 
 |   95  | 
|   46 // Test the correct behavior of the |BYTES_PER_ELEMENT| property (which is |   96 // Test the correct behavior of the |BYTES_PER_ELEMENT| property (which is | 
|   47 // "constant", but not read-only). |   97 // "constant", but not read-only). | 
|   48 a = new Int32Array(2); |   98 a = new Int32Array(2); | 
|   49 assertEquals(4, a.BYTES_PER_ELEMENT); |   99 assertEquals(4, a.BYTES_PER_ELEMENT); | 
|   50 a.BYTES_PER_ELEMENT = 42; |  100 a.BYTES_PER_ELEMENT = 42; | 
|   51 assertEquals(42, a.BYTES_PER_ELEMENT); |  101 assertEquals(42, a.BYTES_PER_ELEMENT); | 
|   52 a = new Uint8Array(2); |  102 a = new Uint8Array(2); | 
|   53 assertEquals(1, a.BYTES_PER_ELEMENT); |  103 assertEquals(1, a.BYTES_PER_ELEMENT); | 
|   54 a = new Int16Array(2); |  104 a = new Int16Array(2); | 
|   55 assertEquals(2, a.BYTES_PER_ELEMENT); |  105 assertEquals(2, a.BYTES_PER_ELEMENT); | 
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  266     return a[0] = a[0] = 1; |  316     return a[0] = a[0] = 1; | 
|  267   } |  317   } | 
|  268  |  318  | 
|  269   array_load_set_smi_check2(a); |  319   array_load_set_smi_check2(a); | 
|  270   %OptimizeFunctionOnNextCall(array_load_set_smi_check2); |  320   %OptimizeFunctionOnNextCall(array_load_set_smi_check2); | 
|  271   array_load_set_smi_check2(a); |  321   array_load_set_smi_check2(a); | 
|  272   array_load_set_smi_check2(0); |  322   array_load_set_smi_check2(0); | 
|  273   %DeoptimizeFunction(array_load_set_smi_check2); |  323   %DeoptimizeFunction(array_load_set_smi_check2); | 
|  274   gc();  // Makes V8 forget about type information for array_load_set_smi_check. |  324   gc();  // Makes V8 forget about type information for array_load_set_smi_check. | 
|  275 } |  325 } | 
| OLD | NEW |