Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix representation issue in FastArrayPushStub
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
camillobruni authored and Commit bot committed Apr 7, 2016
1 parent ce1fe78 commit 9478356
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/code-stubs-hydrogen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,15 @@ HValue* CodeStubGraphBuilderBase::BuildPushElement(HValue* object, HValue* argc,
{
HInstruction* argument =
Add<HAccessArgumentsAt>(argument_elements, argc, key);
Representation r = IsFastSmiElementsKind(kind) ? Representation::Smi()
: Representation::Double();
AddUncasted<HForceRepresentation>(argument, r);
IfBuilder can_store(this);
can_store.IfNot<HIsSmiAndBranch>(argument);
if (IsFastDoubleElementsKind(kind)) {
can_store.And();
can_store.IfNot<HCompareMap>(argument,
isolate()->factory()->heap_number_map());
}
can_store.ThenDeopt(Deoptimizer::kFastArrayPushFailed);
can_store.End();
}
builder.EndBody();
}
Expand Down
10 changes: 10 additions & 0 deletions test/mjsunit/regress/regress-599089-array-push.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2016 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.


var array = [1.2, 1.2];
array.length = 0;
array.push(undefined);
assertEquals(1, array.length);
assertEquals([undefined], array);

0 comments on commit 9478356

Please sign in to comment.