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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 if (bufferByteLength % ELEMENT_SIZE !== 0) { | 71 if (bufferByteLength % ELEMENT_SIZE !== 0) { |
72 throw MakeRangeError("invalid_typed_array_alignment", | 72 throw MakeRangeError("invalid_typed_array_alignment", |
73 "byte length", "NAME", ELEMENT_SIZE); | 73 "byte length", "NAME", ELEMENT_SIZE); |
74 } | 74 } |
75 newByteLength = bufferByteLength - offset; | 75 newByteLength = bufferByteLength - offset; |
76 newLength = newByteLength / ELEMENT_SIZE; | 76 newLength = newByteLength / ELEMENT_SIZE; |
77 } else { | 77 } else { |
78 var newLength = ToPositiveInteger(length, "invalid_typed_array_length"); | 78 var newLength = ToPositiveInteger(length, "invalid_typed_array_length"); |
79 newByteLength = newLength * ELEMENT_SIZE; | 79 newByteLength = newLength * ELEMENT_SIZE; |
80 } | 80 } |
81 if (offset + newByteLength > bufferByteLength) { | 81 if ((offset + newByteLength > bufferByteLength) |
| 82 || (newLength > %MaxSmi())) { |
82 throw MakeRangeError("invalid_typed_array_length"); | 83 throw MakeRangeError("invalid_typed_array_length"); |
83 } | 84 } |
84 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); | 85 %TypedArrayInitialize(obj, ARRAY_ID, buffer, offset, newByteLength); |
85 } | 86 } |
86 | 87 |
87 function NAMEConstructByLength(obj, length) { | 88 function NAMEConstructByLength(obj, length) { |
88 var l = IS_UNDEFINED(length) ? | 89 var l = IS_UNDEFINED(length) ? |
89 0 : ToPositiveInteger(length, "invalid_typed_array_length"); | 90 0 : ToPositiveInteger(length, "invalid_typed_array_length"); |
90 if (l > %MaxSmi()) { | 91 if (l > %MaxSmi()) { |
91 throw MakeRangeError("invalid_typed_array_length"); | 92 throw MakeRangeError("invalid_typed_array_length"); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 | 433 |
433 "getFloat32", DataViewGetFloat32, | 434 "getFloat32", DataViewGetFloat32, |
434 "setFloat32", DataViewSetFloat32, | 435 "setFloat32", DataViewSetFloat32, |
435 | 436 |
436 "getFloat64", DataViewGetFloat64, | 437 "getFloat64", DataViewGetFloat64, |
437 "setFloat64", DataViewSetFloat64 | 438 "setFloat64", DataViewSetFloat64 |
438 )); | 439 )); |
439 } | 440 } |
440 | 441 |
441 SetupDataView(); | 442 SetupDataView(); |
OLD | NEW |