OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (!%_IsTypedArray(newTypedArray)) throw MakeTypeError(kNotTypedArray); | 121 if (!%_IsTypedArray(newTypedArray)) throw MakeTypeError(kNotTypedArray); |
122 // TODO(littledan): Check for being detached, here and elsewhere | 122 // TODO(littledan): Check for being detached, here and elsewhere |
123 // All callers where the first argument is a Number have no additional | 123 // All callers where the first argument is a Number have no additional |
124 // arguments. | 124 // arguments. |
125 if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) { | 125 if (IS_NUMBER(arg0) && %_TypedArrayGetLength(newTypedArray) < arg0) { |
126 throw MakeTypeError(kTypedArrayTooShort); | 126 throw MakeTypeError(kTypedArrayTooShort); |
127 } | 127 } |
128 return newTypedArray; | 128 return newTypedArray; |
129 } | 129 } |
130 | 130 |
131 function TypedArraySpeciesCreate(exemplar, arg0, arg1, arg2) { | 131 function TypedArraySpeciesCreate(exemplar, arg0, arg1, arg2, conservative) { |
132 var defaultConstructor = TypedArrayDefaultConstructor(exemplar); | 132 var defaultConstructor = TypedArrayDefaultConstructor(exemplar); |
133 var constructor = SpeciesConstructor(exemplar, defaultConstructor); | 133 var constructor = SpeciesConstructor(exemplar, defaultConstructor, |
| 134 conservative); |
134 return TypedArrayCreate(constructor, arg0, arg1, arg2); | 135 return TypedArrayCreate(constructor, arg0, arg1, arg2); |
135 } | 136 } |
136 | 137 |
137 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) | 138 macro TYPED_ARRAY_CONSTRUCTOR(ARRAY_ID, NAME, ELEMENT_SIZE) |
138 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { | 139 function NAMEConstructByArrayBuffer(obj, buffer, byteOffset, length) { |
139 if (!IS_UNDEFINED(byteOffset)) { | 140 if (!IS_UNDEFINED(byteOffset)) { |
140 byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength); | 141 byteOffset = ToPositiveInteger(byteOffset, kInvalidTypedArrayLength); |
141 } | 142 } |
142 if (!IS_UNDEFINED(length)) { | 143 if (!IS_UNDEFINED(length)) { |
143 length = ToPositiveInteger(length, kInvalidTypedArrayLength); | 144 length = ToPositiveInteger(length, kInvalidTypedArrayLength); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 } | 286 } |
286 | 287 |
287 if (endInt < beginInt) { | 288 if (endInt < beginInt) { |
288 endInt = beginInt; | 289 endInt = beginInt; |
289 } | 290 } |
290 | 291 |
291 var newLength = endInt - beginInt; | 292 var newLength = endInt - beginInt; |
292 var beginByteOffset = | 293 var beginByteOffset = |
293 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; | 294 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; |
294 return TypedArraySpeciesCreate(this, %TypedArrayGetBuffer(this), | 295 return TypedArraySpeciesCreate(this, %TypedArrayGetBuffer(this), |
295 beginByteOffset, newLength); | 296 beginByteOffset, newLength, true); |
296 } | 297 } |
297 endmacro | 298 endmacro |
298 | 299 |
299 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) | 300 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) |
300 | 301 |
301 function TypedArraySubArray(begin, end) { | 302 function TypedArraySubArray(begin, end) { |
302 switch (%_ClassOf(this)) { | 303 switch (%_ClassOf(this)) { |
303 macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) | 304 macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) |
304 case "NAME": | 305 case "NAME": |
305 return %_Call(NAMESubArray, this, begin, end); | 306 return %_Call(NAMESubArray, this, begin, end); |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 "setUint32", DataViewSetUint32JS, | 960 "setUint32", DataViewSetUint32JS, |
960 | 961 |
961 "getFloat32", DataViewGetFloat32JS, | 962 "getFloat32", DataViewGetFloat32JS, |
962 "setFloat32", DataViewSetFloat32JS, | 963 "setFloat32", DataViewSetFloat32JS, |
963 | 964 |
964 "getFloat64", DataViewGetFloat64JS, | 965 "getFloat64", DataViewGetFloat64JS, |
965 "setFloat64", DataViewSetFloat64JS | 966 "setFloat64", DataViewSetFloat64JS |
966 ]); | 967 ]); |
967 | 968 |
968 }) | 969 }) |
OLD | NEW |