| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { | 51 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
| 52 var bufferByteLength = buffer.byteLength; | 52 var bufferByteLength = buffer.byteLength; |
| 53 var offset; | 53 var offset; |
| 54 if (IS_UNDEFINED(byteOffset)) { | 54 if (IS_UNDEFINED(byteOffset)) { |
| 55 offset = 0; | 55 offset = 0; |
| 56 } else { | 56 } else { |
| 57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length"); | 57 offset = ToPositiveInteger(byteOffset, "invalid_typed_array_length"); |
| 58 | 58 |
| 59 if (offset % ELEMENT_SIZE !== 0) { | 59 if (offset % ELEMENT_SIZE !== 0) { |
| 60 throw MakeRangeError("invalid_typed_array_alignment", | 60 throw MakeRangeError("invalid_typed_array_alignment", |
| 61 "start offset", "NAME", ELEMENT_SIZE); | 61 ["start offset", "NAME", ELEMENT_SIZE]); |
| 62 } | 62 } |
| 63 if (offset > bufferByteLength) { | 63 if (offset > bufferByteLength) { |
| 64 throw MakeRangeError("invalid_typed_array_offset"); | 64 throw MakeRangeError("invalid_typed_array_offset"); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 var newByteLength; | 68 var newByteLength; |
| 69 var newLength; | 69 var newLength; |
| 70 if (IS_UNDEFINED(length)) { | 70 if (IS_UNDEFINED(length)) { |
| 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 || (newLength > %MaxSmi())) { |
| 83 throw MakeRangeError("invalid_typed_array_length"); | 83 throw MakeRangeError("invalid_typed_array_length"); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 for (i = leftIndex; i <= rightIndex; i++) { | 236 for (i = leftIndex; i <= rightIndex; i++) { |
| 237 target[offset + i] = temp[i - leftIndex]; | 237 target[offset + i] = temp[i - leftIndex]; |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| 241 function TypedArraySet(obj, offset) { | 241 function TypedArraySet(obj, offset) { |
| 242 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset); | 242 var intOffset = IS_UNDEFINED(offset) ? 0 : TO_INTEGER(offset); |
| 243 if (intOffset < 0) { | 243 if (intOffset < 0) { |
| 244 throw MakeTypeError("typed_array_set_negative_offset"); | 244 throw MakeTypeError("typed_array_set_negative_offset"); |
| 245 } | 245 } |
| 246 |
| 247 if (intOffset > %MaxSmi()) { |
| 248 throw MakeRangeError("typed_array_set_source_too_large"); |
| 249 } |
| 246 switch (%TypedArraySetFastCases(this, obj, intOffset)) { | 250 switch (%TypedArraySetFastCases(this, obj, intOffset)) { |
| 247 // These numbers should be synchronized with runtime.cc. | 251 // These numbers should be synchronized with runtime.cc. |
| 248 case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE | 252 case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE |
| 249 return; | 253 return; |
| 250 case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING | 254 case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING |
| 251 TypedArraySetFromOverlappingTypedArray(this, obj, intOffset); | 255 TypedArraySetFromOverlappingTypedArray(this, obj, intOffset); |
| 252 return; | 256 return; |
| 253 case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING | 257 case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING |
| 254 TypedArraySetFromArrayLike(this, obj, obj.length, intOffset); | 258 TypedArraySetFromArrayLike(this, obj, obj.length, intOffset); |
| 255 return; | 259 return; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 440 |
| 437 "getFloat32", DataViewGetFloat32, | 441 "getFloat32", DataViewGetFloat32, |
| 438 "setFloat32", DataViewSetFloat32, | 442 "setFloat32", DataViewSetFloat32, |
| 439 | 443 |
| 440 "getFloat64", DataViewGetFloat64, | 444 "getFloat64", DataViewGetFloat64, |
| 441 "setFloat64", DataViewSetFloat64 | 445 "setFloat64", DataViewSetFloat64 |
| 442 )); | 446 )); |
| 443 } | 447 } |
| 444 | 448 |
| 445 SetupDataView(); | 449 SetupDataView(); |
| OLD | NEW |