2019-04-05 13:42:00 +00:00
|
|
|
// 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
|
|
|
|
|
|
|
|
var s = "hello";
|
|
|
|
|
|
|
|
function foo() {
|
|
|
|
return s[4];
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(foo);
|
|
|
|
assertTrue('o' === foo());
|
2019-04-05 13:42:00 +00:00
|
|
|
assertTrue("o" === foo());
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
assertTrue("o" === foo());
|
|
|
|
|
|
|
|
function bar() {
|
|
|
|
return s[5];
|
2019-06-12 14:00:50 +00:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(bar);
|
2019-04-05 13:42:00 +00:00
|
|
|
assertSame(undefined, bar());
|
|
|
|
assertSame(undefined, bar());
|
|
|
|
%OptimizeFunctionOnNextCall(bar);
|
|
|
|
assertSame(undefined, bar());
|