v8/test/mjsunit/compiler/deopt-string-outofbounds.js
bmeurer 6c5fa8b49e [turbofan] Fix deopt loop in out-of-bounds string element access.
We need to check the KeyedLoadIC state to guard against potential
deoptimization loops due to out-of-bounds accesses, because the IC
system uses the MEGAMORPHIC state to also signal that there was an
out-of-bounds access already.

R=jarin@chromium.org

Review-Url: https://codereview.chromium.org/2443893002
Cr-Commit-Position: refs/heads/master@{#40525}
2016-10-24 10:32:36 +00:00

32 lines
600 B
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 s = "12345";
(function() {
function foo() { return s[5]; }
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
assertOptimized(foo);
})();
(function() {
function foo(i) { return s[i]; }
foo(0);
foo(1);
%OptimizeFunctionOnNextCall(foo);
foo(5);
%OptimizeFunctionOnNextCall(foo);
foo(5);
assertOptimized(foo);
})();