2016-10-24 10:32:13 +00:00
|
|
|
// 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.
|
|
|
|
|
2017-04-28 13:33:43 +00:00
|
|
|
// Flags: --allow-natives-syntax --opt --no-always-opt
|
2016-10-24 10:32:13 +00:00
|
|
|
|
|
|
|
var s = "12345";
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
function foo() { return s[5]; }
|
|
|
|
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2016-10-24 10:32:13 +00:00
|
|
|
foo();
|
|
|
|
foo();
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo();
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2016-10-24 10:32:13 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo();
|
|
|
|
assertOptimized(foo);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
function foo(i) { return s[i]; }
|
|
|
|
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2016-10-24 10:32:13 +00:00
|
|
|
foo(0);
|
|
|
|
foo(1);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(5);
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2016-10-24 10:32:13 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(5);
|
|
|
|
assertOptimized(foo);
|
|
|
|
})();
|
2017-10-30 15:51:26 +00:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
function foo(s) { return s[5]; }
|
|
|
|
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-10-30 15:51:26 +00:00
|
|
|
foo(s);
|
|
|
|
foo(s);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(s);
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-10-30 15:51:26 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(s);
|
|
|
|
assertOptimized(foo);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
function foo(s, i) { return s[i]; }
|
|
|
|
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-10-30 15:51:26 +00:00
|
|
|
foo(s, 0);
|
|
|
|
foo(s, 1);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(s, 5);
|
2019-03-01 10:19:54 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2017-10-30 15:51:26 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(s, 5);
|
|
|
|
assertOptimized(foo);
|
|
|
|
})();
|