2267ccb1bb
This CheckBounds simplified operator is similar to the HBoundsCheck in Crankshaft, and is hooked up to the new type feedback support in the SimplifiedLowering. We use it to check the index bounds for keyed property accesses. Note to perf sheriffs: This will tank quite a few benchmarks, as the operator makes some redundant branch elimination ineffective for certain patterns of keyed accesses. This does require more serious redundancy elimination, which we will do in a separate CL. So ignore any regressions from this CL, we know there will be a few. R=jarin@chromium.org BUG=v8:4470,v8:5100 Committed: https://crrev.com/85e5567dae66a918500ae94c5568221137a0f5d4 Review-Url: https://codereview.chromium.org/2035893004 Cr-Original-Commit-Position: refs/heads/master@{#36947} Cr-Commit-Position: refs/heads/master@{#37003}
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
// 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.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
var a = [0, 1];
|
|
a["true"] = "true";
|
|
a["false"] = "false";
|
|
a["null"] = "null";
|
|
a["undefined"] = "undefined";
|
|
|
|
// Ensure we don't accidentially truncate true when used to index arrays.
|
|
(function() {
|
|
function f(x) { return a[x]; }
|
|
|
|
assertEquals(0, f(0));
|
|
assertEquals(0, f(0));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("true", f(true));
|
|
})();
|
|
|
|
// Ensure we don't accidentially truncate false when used to index arrays.
|
|
(function() {
|
|
function f( x) { return a[x]; }
|
|
|
|
assertEquals(0, f(0));
|
|
assertEquals(0, f(0));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("false", f(false));
|
|
})();
|
|
|
|
// Ensure we don't accidentially truncate null when used to index arrays.
|
|
(function() {
|
|
function f( x) { return a[x]; }
|
|
|
|
assertEquals(0, f(0));
|
|
assertEquals(0, f(0));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("null", f(null));
|
|
})();
|
|
|
|
// Ensure we don't accidentially truncate undefined when used to index arrays.
|
|
(function() {
|
|
function f( x) { return a[x]; }
|
|
|
|
assertEquals(0, f(0));
|
|
assertEquals(0, f(0));
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals("undefined", f(undefined));
|
|
})();
|