[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: Tobias Tebbi <tebbi@chromium.org> Cr-Commit-Position: refs/heads/master@{#61618}
This commit is contained in:
parent
dbe16b171c
commit
c9b48e96ec
@ -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;
|
||||
|
11
test/mjsunit/regress/regress-crbug-940274.js
Normal file
11
test/mjsunit/regress/regress-crbug-940274.js
Normal file
@ -0,0 +1,11 @@
|
||||
// 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();
|
Loading…
Reference in New Issue
Block a user