Skip to content

Commit 17359d8

Browse files
sygV8 LUCI CQ
authored and
V8 LUCI CQ
committed
[change-array-by-copy] Allow LO allocation in Array#toSorted
Bug: v8:12764, chromium:1367136 Change-Id: Ia73f507bf480035d883be1bb5189a5b464327d29 Fixed: chromium:1367136 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3916281 Commit-Queue: Shu-yu Guo <[email protected]> Reviewed-by: Adam Klein <[email protected]> Cr-Commit-Position: refs/heads/main@{#83403}
1 parent 0cccb6f commit 17359d8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/builtins/array-to-sorted.tq

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ CopyWorkArrayToNewFastJSArray(implicit context: Context, sortState: SortState)(
1515
dcheck(len <= kMaxFastArrayLength);
1616

1717
const copy: FixedArray = UnsafeCast<FixedArray>(AllocateFixedArray(
18-
elementsKind, Convert<intptr>(len), AllocationFlag::kNone));
18+
elementsKind, Convert<intptr>(len),
19+
AllocationFlag::kAllowLargeObjectAllocation));
1920

2021
const workArray = sortState.workArray;
2122
CopyElements(

test/mjsunit/harmony/array-to-sorted.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ TestToSortedBasicBehaviorHelper({ length: 4,
9494
assertEquals(0, a.length);
9595
})();
9696

97+
(function TestBig() {
98+
const a = [];
99+
a[50001] = 42.42;
100+
a.toSorted();
101+
})();
102+
97103
(function TestTooBig() {
98104
const a = { length: Math.pow(2, 32) };
99105
assertThrows(() => Array.prototype.toSorted.call(a), RangeError);

0 commit comments

Comments
 (0)