2015-02-19 11:36:38 +00:00
|
|
|
// Copyright 2015 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.
|
|
|
|
|
2016-05-09 09:10:19 +00:00
|
|
|
// Flags: --allow-natives-syntax --use-osr
|
2015-02-19 11:36:38 +00:00
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function test(expected, func) {
|
|
|
|
assertEquals(expected, func());
|
|
|
|
assertEquals(expected, func());
|
|
|
|
assertEquals(expected, func());
|
|
|
|
}
|
|
|
|
|
|
|
|
function foo() {
|
|
|
|
var result = 0;
|
|
|
|
{
|
|
|
|
let x = 0;
|
|
|
|
var temp_x = x;
|
|
|
|
var first = 1;
|
|
|
|
outer: while (true) {
|
|
|
|
let x = temp_x;
|
|
|
|
if (first == 1) first = 0;
|
|
|
|
else x = x + 1 | 0;
|
|
|
|
var flag = 1;
|
|
|
|
for (; flag == 1; (flag = 0, temp_x = x)) {
|
|
|
|
if (x < 2) {
|
|
|
|
result = x; %OptimizeOsr();
|
|
|
|
} else {
|
|
|
|
break outer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (flag == 1) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2015-02-19 11:36:38 +00:00
|
|
|
|
|
|
|
test(1, foo);
|
|
|
|
|
|
|
|
|
|
|
|
function smo() {
|
|
|
|
var result = 0;
|
|
|
|
{
|
|
|
|
let x = 11;
|
|
|
|
outer: while (true) {
|
|
|
|
let y = x;
|
|
|
|
for (var i = 0; i < 5; i++) {
|
|
|
|
%OptimizeOsr();
|
|
|
|
if (i) break outer;
|
|
|
|
else result = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(smo);
|
2015-02-19 11:36:38 +00:00
|
|
|
|
|
|
|
test(11, smo);
|