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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 else { | 342 else { |
343 for (var i = 0; i < sourceLength; i++) { | 343 for (var i = 0; i < sourceLength; i++) { |
344 target[i] = source[i]; | 344 target[i] = source[i]; |
345 } | 345 } |
346 } | 346 } |
347 } | 347 } |
348 | 348 |
349 function TypedArraySetFromOverlappingTypedArray(target, source, offset) { | 349 function TypedArraySetFromOverlappingTypedArray(target, source, offset) { |
350 var sourceElementSize = source.BYTES_PER_ELEMENT; | 350 var sourceElementSize = source.BYTES_PER_ELEMENT; |
351 var targetElementSize = target.BYTES_PER_ELEMENT; | 351 var targetElementSize = target.BYTES_PER_ELEMENT; |
352 var sourceLength = source.length; | 352 var sourceLength = %_TypedArrayGetLength(source); |
353 | 353 |
354 // Copy left part. | 354 // Copy left part. |
355 function CopyLeftPart() { | 355 function CopyLeftPart() { |
356 // First un-mutated byte after the next write | 356 // First un-mutated byte after the next write |
357 var targetPtr = target.byteOffset + (offset + 1) * targetElementSize; | 357 var targetPtr = target.byteOffset + (offset + 1) * targetElementSize; |
358 // Next read at sourcePtr. We do not care for memory changing before | 358 // Next read at sourcePtr. We do not care for memory changing before |
359 // sourcePtr - we have already copied it. | 359 // sourcePtr - we have already copied it. |
360 var sourcePtr = source.byteOffset; | 360 var sourcePtr = source.byteOffset; |
361 for (var leftIndex = 0; | 361 for (var leftIndex = 0; |
362 leftIndex < sourceLength && targetPtr <= sourcePtr; | 362 leftIndex < sourceLength && targetPtr <= sourcePtr; |
363 leftIndex++) { | 363 leftIndex++) { |
364 target[offset + leftIndex] = source[leftIndex]; | 364 target[offset + leftIndex] = source[leftIndex]; |
365 targetPtr += targetElementSize; | 365 targetPtr += targetElementSize; |
366 sourcePtr += sourceElementSize; | 366 sourcePtr += sourceElementSize; |
367 } | 367 } |
368 return leftIndex; | 368 return leftIndex; |
369 } | 369 } |
370 var leftIndex = CopyLeftPart(); | 370 var leftIndex = CopyLeftPart(); |
371 | 371 |
372 // Copy rigth part; | 372 // Copy right part; |
373 function CopyRightPart() { | 373 function CopyRightPart() { |
374 // First unmutated byte before the next write | 374 // First unmutated byte before the next write |
375 var targetPtr = | 375 var targetPtr = |
376 target.byteOffset + (offset + sourceLength - 1) * targetElementSize; | 376 target.byteOffset + (offset + sourceLength - 1) * targetElementSize; |
377 // Next read before sourcePtr. We do not care for memory changing after | 377 // Next read before sourcePtr. We do not care for memory changing after |
378 // sourcePtr - we have already copied it. | 378 // sourcePtr - we have already copied it. |
379 var sourcePtr = | 379 var sourcePtr = |
380 source.byteOffset + sourceLength * sourceElementSize; | 380 source.byteOffset + sourceLength * sourceElementSize; |
381 for(var rightIndex = sourceLength - 1; | 381 for(var rightIndex = sourceLength - 1; |
382 rightIndex >= leftIndex && targetPtr >= sourcePtr; | 382 rightIndex >= leftIndex && targetPtr >= sourcePtr; |
(...skipping 23 matching lines...) Expand all Loading... | |
406 throw MakeRangeError(kTypedArraySetSourceTooLarge); | 406 throw MakeRangeError(kTypedArraySetSourceTooLarge); |
407 } | 407 } |
408 switch (%TypedArraySetFastCases(this, obj, intOffset)) { | 408 switch (%TypedArraySetFastCases(this, obj, intOffset)) { |
409 // These numbers should be synchronized with runtime.cc. | 409 // These numbers should be synchronized with runtime.cc. |
410 case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE | 410 case 0: // TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE |
411 return; | 411 return; |
412 case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING | 412 case 1: // TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING |
413 TypedArraySetFromOverlappingTypedArray(this, obj, intOffset); | 413 TypedArraySetFromOverlappingTypedArray(this, obj, intOffset); |
414 return; | 414 return; |
415 case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING | 415 case 2: // TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING |
416 TypedArraySetFromArrayLike(this, obj, obj.length, intOffset); | 416 TypedArraySetFromArrayLike(this, obj, %_TypedArrayGetLength(obj), intOffse t); |
Dan Ehrenberg
2016/06/23 22:12:40
Wrap line longer than 80 chars
bakkot
2016/06/23 22:17:46
Done.
| |
417 return; | 417 return; |
418 case 3: // TYPED_ARRAY_SET_NON_TYPED_ARRAY | 418 case 3: // TYPED_ARRAY_SET_NON_TYPED_ARRAY |
419 var l = obj.length; | 419 var l = obj.length; |
420 if (IS_UNDEFINED(l)) { | 420 if (IS_UNDEFINED(l)) { |
421 if (IS_NUMBER(obj)) { | 421 if (IS_NUMBER(obj)) { |
422 // For number as a first argument, throw TypeError | 422 // For number as a first argument, throw TypeError |
423 // instead of silently ignoring the call, so that | 423 // instead of silently ignoring the call, so that |
424 // the user knows (s)he did something wrong. | 424 // the user knows (s)he did something wrong. |
425 // (Consistent with Firefox and Blink/WebKit) | 425 // (Consistent with Firefox and Blink/WebKit) |
426 throw MakeTypeError(kInvalidArgument); | 426 throw MakeTypeError(kInvalidArgument); |
427 } | 427 } |
428 return; | 428 return; |
429 } | 429 } |
430 l = TO_LENGTH(l); | 430 l = TO_LENGTH(l); |
431 if (intOffset + l > this.length) { | 431 if (intOffset + l > %_TypedArrayGetLength(this)) { |
432 throw MakeRangeError(kTypedArraySetSourceTooLarge); | 432 throw MakeRangeError(kTypedArraySetSourceTooLarge); |
433 } | 433 } |
434 TypedArraySetFromArrayLike(this, obj, l, intOffset); | 434 TypedArraySetFromArrayLike(this, obj, l, intOffset); |
435 return; | 435 return; |
436 } | 436 } |
437 } | 437 } |
438 %FunctionSetLength(TypedArraySet, 1); | 438 %FunctionSetLength(TypedArraySet, 1); |
439 | 439 |
440 function TypedArrayGetToStringTag() { | 440 function TypedArrayGetToStringTag() { |
441 if (!IS_TYPEDARRAY(this)) return; | 441 if (!IS_TYPEDARRAY(this)) return; |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 "setUint32", DataViewSetUint32JS, | 899 "setUint32", DataViewSetUint32JS, |
900 | 900 |
901 "getFloat32", DataViewGetFloat32JS, | 901 "getFloat32", DataViewGetFloat32JS, |
902 "setFloat32", DataViewSetFloat32JS, | 902 "setFloat32", DataViewSetFloat32JS, |
903 | 903 |
904 "getFloat64", DataViewGetFloat64JS, | 904 "getFloat64", DataViewGetFloat64JS, |
905 "setFloat64", DataViewSetFloat64JS | 905 "setFloat64", DataViewSetFloat64JS |
906 ]); | 906 ]); |
907 | 907 |
908 }) | 908 }) |
OLD | NEW |