[array] Properly handle COW arrays in Array.p.reverse fast-path
Instead of using the slow-path for COW arrays, we now properly copy them and use the fast-path. R=jgruber@chromium.org Change-Id: Iebbad5f761d97c5400c457877571c7930269d52f Reviewed-on: https://chromium-review.googlesource.com/1188130 Commit-Queue: Simon Zünd <szuend@google.com> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#55384}
This commit is contained in:
parent
57c8c85b9f
commit
3470086988
@ -143,14 +143,25 @@ module array {
|
||||
return object;
|
||||
}
|
||||
|
||||
macro EnsureWriteableFastElements(array: JSArray) {
|
||||
const elements: FixedArrayBase = array.elements;
|
||||
if (elements.map != kCOWMap) return;
|
||||
|
||||
// There are no COW *_DOUBLE_ELEMENTS arrays, so we are allowed to always
|
||||
// extract FixedArrays and don't have to worry about FixedDoubleArrays.
|
||||
assert(IsFastSmiOrTaggedElementsKind(array.map.elements_kind));
|
||||
|
||||
const length: Smi = array.length_fast;
|
||||
array.elements = ExtractFixedArray(
|
||||
unsafe_cast<FixedArray>(elements), 0, length, length, kFixedArrays);
|
||||
}
|
||||
|
||||
macro TryFastPackedArrayReverse(receiver: Object) labels Slow {
|
||||
const array: JSArray = cast<JSArray>(receiver) otherwise Slow;
|
||||
const map: Map = array.map;
|
||||
EnsureWriteableFastElements(array);
|
||||
assert(array.elements.map != kCOWMap);
|
||||
|
||||
if (!IsExtensibleMap(map)) goto Slow;
|
||||
if (array.elements.map == kCOWMap) goto Slow;
|
||||
|
||||
const kind: ElementsKind = map.elements_kind;
|
||||
const kind: ElementsKind = array.map.elements_kind;
|
||||
if (kind == PACKED_SMI_ELEMENTS) {
|
||||
FastPackedArrayReverse<FastPackedSmiElements, Smi>(
|
||||
array.elements, array.length_fast);
|
||||
|
@ -109,6 +109,8 @@ type FixedBigInt64Array extends FixedTypedArray;
|
||||
|
||||
const kAllFixedArrays: constexpr ExtractFixedArrayFlags generates
|
||||
'ExtractFixedArrayFlag::kAllFixedArrays';
|
||||
const kFixedArrays: constexpr ExtractFixedArrayFlags generates
|
||||
'ExtractFixedArrayFlag::kFixedArrays';
|
||||
|
||||
const kFixedCOWArrayMapRootIndex: constexpr RootListIndex generates
|
||||
'Heap::kFixedCOWArrayMapRootIndex';
|
||||
|
Loading…
Reference in New Issue
Block a user