Skip to content

Commit

Permalink
Merged: [turbofan] Fix bounds check for the 'in' operator on typed ar…
Browse files Browse the repository at this point in the history
…rays.

Revision: d2bfdafe200f4d100fc2ffbf5d6b5d1a542bf1f7

BUG=chromium:952586
LOG=N
NOTRY=true
NOPRESUBMIT=true
NOTREECHECKS=true
R=neis@chromium.org

Change-Id: I2cd0e656a0720be737574f0b4d748cad40c84b2b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587380
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/branch-heads/7.5@{#8}
Cr-Branched-From: 35b9bf5-refs/heads/7.5.288@{#1}
Cr-Branched-From: 912b391-refs/heads/master@{#60911}
  • Loading branch information
jaro-sevcik authored and Commit Bot committed Apr 29, 2019
1 parent 5bfdba9 commit 63fa997
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/js-native-context-specialization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ JSNativeContextSpecialization::BuildElementAccess(
// below are performed on unsigned values, which means that all the
// Negative32 values are treated as out-of-bounds.
index = graph()->NewNode(simplified()->NumberToUint32(), index);
} else if (access_mode != AccessMode::kHas) {
} else {
// Check that the {index} is in the valid range for the {receiver}.
index = effect =
graph()->NewNode(simplified()->CheckBounds(VectorSlotPair()), index,
Expand Down
15 changes: 15 additions & 0 deletions test/mjsunit/compiler/regress-952586.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

// Flags: --allow-natives-syntax

a = new Int8Array(1);

function f(i) {
return i in a;
}

assertTrue(f(0));
%OptimizeFunctionOnNextCall(f);
assertFalse(f(-1));

0 comments on commit 63fa997

Please sign in to comment.