Skip to content

Commit

Permalink
[dart2wasm] Fix JSArrayImpl.setRange on BigInt arrays
Browse files Browse the repository at this point in the history
Fixes `setRange` tests reported in #54409.

Change-Id: I04698563f44aa44f634d7c0418f8056d361836a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343160
Reviewed-by: Martin Kustermann <[email protected]>
Commit-Queue: Ömer Ağacan <[email protected]>
  • Loading branch information
osa1 authored and Commit Queue committed Dec 23, 2023
1 parent 5510ef6 commit 5410d97
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sdk/lib/_internal/wasm/lib/js_typed_array.dart
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,18 @@ mixin _IntListMixin implements List<int> {

if (iterable is JSArrayBase) {
final JSArrayBase source = unsafeCast<JSArrayBase>(iterable);
final length = end - start;
final sourceArray = source.toJSArrayExternRef(skipCount, length);
final targetArray = toJSArrayExternRef(start, length);
return _setRangeFast(targetArray, sourceArray);

// JS `TypedArray.prototype.set` does not allow mixing `BigInt` and other
// types. Check that either both of the arrays are `BigInt`s (signed or
// unsigned), or none of them are.
final sourceBigInt = source.elementSizeInBytes == 8;
final targetBigInt = elementSizeInBytes == 8;
if (!(sourceBigInt ^ targetBigInt)) {
final length = end - start;
final sourceArray = source.toJSArrayExternRef(skipCount, length);
final targetArray = toJSArrayExternRef(start, length);
return _setRangeFast(targetArray, sourceArray);
}
}

List<int> otherList = iterable.skip(skipCount).toList(growable: false);
Expand Down

0 comments on commit 5410d97

Please sign in to comment.