OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 if (offset + newByteLength > bufferByteLength) { | 81 if (offset + newByteLength > bufferByteLength) { |
82 throw MakeRangeError("invalid_typed_array_length"); | 82 throw MakeRangeError("invalid_typed_array_length"); |
83 } | 83 } |
84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); | 84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |
85 } | 85 } |
86 | 86 |
87 function NAMEConstructByLength(obj, length) { | 87 function NAMEConstructByLength(obj, length) { |
88 var l = IS_UNDEFINED(length) ? | 88 var l = IS_UNDEFINED(length) ? |
89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); | 89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); |
90 if (l > %MaxSmi()) { | |
91 throw MakeRangeError(length, "invalid_typed_array_length"); | |
92 } | |
93 var byteLength = l * ELEMENT_SIZE; | 90 var byteLength = l * ELEMENT_SIZE; |
94 var buffer = new $ArrayBuffer(byteLength); | 91 var buffer = new $ArrayBuffer(byteLength); |
95 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); | 92 %TypedArrayInitialize(obj, ARRAY_ID, buffer, 0, byteLength); |
96 } | 93 } |
97 | 94 |
98 function NAMEConstructByArrayLike(obj, arrayLike) { | 95 function NAMEConstructByArrayLike(obj, arrayLike) { |
99 var length = arrayLike.length; | 96 var length = arrayLike.length; |
100 var l = ToPositiveInteger(length, "invalid_typed_array_length"); | 97 var l = ToPositiveInteger(length, "invalid_typed_array_length"); |
101 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { | 98 if(!%TypedArrayInitializeFromArrayLike(obj, ARRAY_ID, arrayLike, l)) { |
102 for (var i = 0; i < l; i++) { | 99 for (var i = 0; i < l; i++) { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 429 |
433 "getFloat32", DataViewGetFloat32, | 430 "getFloat32", DataViewGetFloat32, |
434 "setFloat32", DataViewSetFloat32, | 431 "setFloat32", DataViewSetFloat32, |
435 | 432 |
436 "getFloat64", DataViewGetFloat64, | 433 "getFloat64", DataViewGetFloat64, |
437 "setFloat64", DataViewSetFloat64 | 434 "setFloat64", DataViewSetFloat64 |
438 )); | 435 )); |
439 } | 436 } |
440 | 437 |
441 SetupDataView(); | 438 SetupDataView(); |
OLD | NEW |