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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 endInt = MinSimple(endInt, srcLength); | 293 endInt = MinSimple(endInt, srcLength); |
294 } | 294 } |
295 | 295 |
296 if (endInt < beginInt) { | 296 if (endInt < beginInt) { |
297 endInt = beginInt; | 297 endInt = beginInt; |
298 } | 298 } |
299 | 299 |
300 var newLength = endInt - beginInt; | 300 var newLength = endInt - beginInt; |
301 var beginByteOffset = | 301 var beginByteOffset = |
302 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; | 302 %_ArrayBufferViewGetByteOffset(this) + beginInt * ELEMENT_SIZE; |
303 return TypedArraySpeciesCreate(this, %TypedArrayGetBuffer(this), | 303 // BUG(v8:4665): For web compatibility, subarray needs to always build an |
304 beginByteOffset, newLength, true); | 304 // instance of the default constructor. |
| 305 // TODO(littledan): Switch to the standard or standardize the fix |
| 306 return new GlobalNAME(%TypedArrayGetBuffer(this), beginByteOffset, newLength); |
305 } | 307 } |
306 endmacro | 308 endmacro |
307 | 309 |
308 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) | 310 TYPED_ARRAYS(TYPED_ARRAY_CONSTRUCTOR) |
309 | 311 |
310 function TypedArraySubArray(begin, end) { | 312 function TypedArraySubArray(begin, end) { |
311 switch (%_ClassOf(this)) { | 313 switch (%_ClassOf(this)) { |
312 macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) | 314 macro TYPED_ARRAY_SUBARRAY_CASE(ARRAY_ID, NAME, ELEMENT_SIZE) |
313 case "NAME": | 315 case "NAME": |
314 return %_Call(NAMESubArray, this, begin, end); | 316 return %_Call(NAMESubArray, this, begin, end); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 "setUint32", DataViewSetUint32JS, | 976 "setUint32", DataViewSetUint32JS, |
975 | 977 |
976 "getFloat32", DataViewGetFloat32JS, | 978 "getFloat32", DataViewGetFloat32JS, |
977 "setFloat32", DataViewSetFloat32JS, | 979 "setFloat32", DataViewSetFloat32JS, |
978 | 980 |
979 "getFloat64", DataViewGetFloat64JS, | 981 "getFloat64", DataViewGetFloat64JS, |
980 "setFloat64", DataViewSetFloat64JS | 982 "setFloat64", DataViewSetFloat64JS |
981 ]); | 983 ]); |
982 | 984 |
983 }) | 985 }) |
OLD | NEW |