2016-03-17 09:58:55 +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.
|
|
|
|
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
function dummy() {}
|
2016-03-17 09:58:55 +00:00
|
|
|
|
|
|
|
(function InlinedFunctionTestContext() {
|
2019-06-12 14:00:50 +00:00
|
|
|
var f = function() {};
|
2016-03-17 09:58:55 +00:00
|
|
|
|
|
|
|
function g() {
|
2019-06-12 14:00:50 +00:00
|
|
|
var s = 'hey';
|
|
|
|
dummy(); // Force a deopt point.
|
|
|
|
if (f()) return s;
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g);
|
2016-03-17 09:58:55 +00:00
|
|
|
g();
|
|
|
|
g();
|
|
|
|
g();
|
|
|
|
%OptimizeFunctionOnNextCall(g);
|
2019-06-12 14:00:50 +00:00
|
|
|
f = function() {
|
|
|
|
return true;
|
|
|
|
};
|
2016-03-17 09:58:55 +00:00
|
|
|
assertEquals("hey", g());
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function InlinedConstructorReturnTestContext() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function c() {
|
|
|
|
return 1;
|
|
|
|
}
|
2016-03-17 09:58:55 +00:00
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
var f = function() {
|
|
|
|
return !new c();
|
|
|
|
};
|
2016-03-17 09:58:55 +00:00
|
|
|
|
|
|
|
function g() {
|
2019-06-12 14:00:50 +00:00
|
|
|
var s = 'hey';
|
|
|
|
dummy(); // Force a deopt point.
|
|
|
|
if (f()) return s;
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g);
|
2016-03-17 09:58:55 +00:00
|
|
|
g();
|
|
|
|
g();
|
|
|
|
g();
|
|
|
|
%OptimizeFunctionOnNextCall(g);
|
2019-06-12 14:00:50 +00:00
|
|
|
f = function() {
|
|
|
|
return true;
|
|
|
|
};
|
2016-03-17 09:58:55 +00:00
|
|
|
assertEquals("hey", g());
|
|
|
|
})();
|
|
|
|
|
|
|
|
(function InlinedConstructorNoReturnTestContext() {
|
2019-06-12 14:00:50 +00:00
|
|
|
function c() {}
|
2016-03-17 09:58:55 +00:00
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
var f = function() {
|
|
|
|
return !new c();
|
|
|
|
};
|
2016-03-17 09:58:55 +00:00
|
|
|
|
|
|
|
function g() {
|
2019-06-12 14:00:50 +00:00
|
|
|
var s = 'hey';
|
|
|
|
dummy(); // Force a deopt point.
|
|
|
|
if (f()) return s;
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g);
|
2016-03-17 09:58:55 +00:00
|
|
|
g();
|
|
|
|
g();
|
|
|
|
g();
|
|
|
|
%OptimizeFunctionOnNextCall(g);
|
2019-06-12 14:00:50 +00:00
|
|
|
f = function() {
|
|
|
|
return true;
|
|
|
|
};
|
2016-03-17 09:58:55 +00:00
|
|
|
assertEquals("hey", g());
|
|
|
|
})();
|