2016-04-07 05:36:25 +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
|
|
|
var f1 = function() {
|
|
|
|
while (1) {
|
|
|
|
}
|
|
|
|
};
|
2016-04-07 05:36:25 +00:00
|
|
|
|
|
|
|
function g1() {
|
|
|
|
var s = "hey";
|
2019-06-12 14:00:50 +00:00
|
|
|
f1 = function() {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
if (f1()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g1);
|
2016-04-07 05:36:25 +00:00
|
|
|
%OptimizeFunctionOnNextCall(g1);
|
|
|
|
assertEquals("hey", g1());
|
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
var f2 = function() {
|
|
|
|
do {
|
|
|
|
} while (1);
|
|
|
|
};
|
2016-04-07 05:36:25 +00:00
|
|
|
|
|
|
|
function g2() {
|
|
|
|
var s = "hey";
|
2019-06-12 14:00:50 +00:00
|
|
|
f2 = function() {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
if (f2()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g2);
|
2016-04-07 05:36:25 +00:00
|
|
|
%OptimizeFunctionOnNextCall(g2);
|
|
|
|
assertEquals("hey", g2());
|
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
var f3 = function() {
|
|
|
|
for (;;)
|
|
|
|
;
|
|
|
|
};
|
2016-04-07 05:36:25 +00:00
|
|
|
|
|
|
|
function g3() {
|
|
|
|
var s = "hey";
|
2019-06-12 14:00:50 +00:00
|
|
|
f3 = function() {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
if (f3()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g3);
|
2016-04-07 05:36:25 +00:00
|
|
|
%OptimizeFunctionOnNextCall(g3);
|
|
|
|
assertEquals("hey", g3());
|
|
|
|
|
2019-06-12 14:00:50 +00:00
|
|
|
var f4 = function() {
|
|
|
|
for (;;)
|
|
|
|
;
|
|
|
|
};
|
2016-04-07 05:36:25 +00:00
|
|
|
|
|
|
|
function g4() {
|
|
|
|
var s = "hey";
|
2019-06-12 14:00:50 +00:00
|
|
|
f4 = function() {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
while (f4()) {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(g4);
|
2016-04-07 05:36:25 +00:00
|
|
|
%OptimizeFunctionOnNextCall(g4);
|
|
|
|
assertEquals("hey", g4());
|