Commit c9b48e96 authored by Mike Stanton's avatar Mike Stanton Committed by Commit Bot

[Torque] Array.prototype.shift correctness fix

Fastpath failed to store the hole on the array left side.

Bug: chromium:940274
Change-Id: I1eca7b241030474cf5aed6c68f155a1d22ae553e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1617255
Commit-Queue: Michael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61618}
parent dbe16b17
......@@ -34,6 +34,7 @@ namespace array_shift {
const result = witness.LoadElementOrUndefined(0);
witness.ChangeLength(newLength);
witness.MoveElements(0, 1, Convert<intptr>(newLength));
witness.StoreHole(newLength);
return result;
}
label Runtime {
......
......@@ -2571,6 +2571,18 @@ struct FastJSArrayWitness {
}
}
StoreHole(k: Smi) {
if (this.hasDoubles) {
const elements = Cast<FixedDoubleArray>(this.unstable.elements)
otherwise unreachable;
StoreFixedDoubleArrayHoleSmi(elements, k);
} else {
const elements = Cast<FixedArray>(this.unstable.elements)
otherwise unreachable;
StoreFixedArrayElement(elements, k, Hole);
}
}
LoadElementOrUndefined(implicit context: Context)(k: Smi): Object {
try {
return this.LoadElementNoHole(k) otherwise FoundHole;
......
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function foo() {
var a = new Array({});
a.shift();
assertFalse(a.hasOwnProperty(0));
}
foo();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment