Skip to content
This repository was archived by the owner on Feb 11, 2020. It is now read-only.

Commit 9478356

Browse files
camillobruniCommit bot
authored andcommitted
Fix representation issue in FastArrayPushStub
Pushing undefined onto a FAST_DOUBLE_ARRAY does not enforce the right representation checks. BUG=chromuim:599089 LOG=n Review URL: https://codereview.chromium.org/1868973002 Cr-Commit-Position: refs/heads/master@{#35332}
1 parent ce1fe78 commit 9478356

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/code-stubs-hydrogen.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,9 +721,15 @@ HValue* CodeStubGraphBuilderBase::BuildPushElement(HValue* object, HValue* argc,
721721
{
722722
HInstruction* argument =
723723
Add<HAccessArgumentsAt>(argument_elements, argc, key);
724-
Representation r = IsFastSmiElementsKind(kind) ? Representation::Smi()
725-
: Representation::Double();
726-
AddUncasted<HForceRepresentation>(argument, r);
724+
IfBuilder can_store(this);
725+
can_store.IfNot<HIsSmiAndBranch>(argument);
726+
if (IsFastDoubleElementsKind(kind)) {
727+
can_store.And();
728+
can_store.IfNot<HCompareMap>(argument,
729+
isolate()->factory()->heap_number_map());
730+
}
731+
can_store.ThenDeopt(Deoptimizer::kFastArrayPushFailed);
732+
can_store.End();
727733
}
728734
builder.EndBody();
729735
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2016 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
6+
var array = [1.2, 1.2];
7+
array.length = 0;
8+
array.push(undefined);
9+
assertEquals(1, array.length);
10+
assertEquals([undefined], array);

0 commit comments

Comments
 (0)