2017-07-26 12:30:38 +00:00
|
|
|
// Copyright 2017 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
|
|
|
|
|
|
|
|
// This tests checks some possible wrong exception handling due to,
|
|
|
|
// for instance, the OSR loop peeling. If exception handlers are not updated
|
|
|
|
// correctly, when we run the second iteration of the outermost loop, which
|
|
|
|
// is the OSR optimised version, the try-catch will fail... which should not
|
|
|
|
// fail on a correct code.
|
|
|
|
|
|
|
|
function SingleLoop() {
|
|
|
|
for (var a = 0; a < 2; a++) {
|
|
|
|
try { throw 'The exception should have been caught.'; }
|
|
|
|
catch(e) {}
|
2022-02-21 14:01:31 +00:00
|
|
|
for (var b = 0; b < 1; b++) {
|
|
|
|
%OptimizeOsr();
|
2019-06-18 16:03:44 +00:00
|
|
|
%PrepareFunctionForOptimization(SingleLoop);
|
2017-07-26 12:30:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(SingleLoop);
|
2017-07-26 12:30:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
// These function could also fail if the exception handlers are not updated at
|
|
|
|
// the right time: a JSStackCheck gets created for the print, just after the
|
|
|
|
// bytecode for the while LoopHeader. If the OSR phase did not exit properly
|
|
|
|
// the exception before visiting the bytecode for the print, it will fail
|
|
|
|
// because some IfSuccess gets created for nothing (the IfException will
|
|
|
|
// become dead code and removed).
|
|
|
|
function EmptyBody() {
|
|
|
|
try {; } catch(e) {; }
|
|
|
|
var a = 0;
|
|
|
|
while (1) {
|
2022-02-21 14:01:31 +00:00
|
|
|
%OptimizeOsr();
|
2017-07-26 12:30:38 +00:00
|
|
|
print("foo");
|
|
|
|
|
2022-02-21 14:01:31 +00:00
|
|
|
if (a == 1) break;
|
2017-07-26 12:30:38 +00:00
|
|
|
a++;
|
2019-06-18 16:03:44 +00:00
|
|
|
%PrepareFunctionForOptimization(EmptyBody);
|
2017-07-26 12:30:38 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(EmptyBody);
|
2017-07-26 12:30:38 +00:00
|
|
|
|
|
|
|
function NestedLoops() {
|
|
|
|
for (var a = 0; a < 2; a++) {
|
|
|
|
try {; } catch(e) {; }
|
2022-02-21 14:01:31 +00:00
|
|
|
%OptimizeOsr();
|
2017-07-26 12:30:38 +00:00
|
|
|
var b = 0;
|
|
|
|
while (1) {
|
|
|
|
print("bar");
|
|
|
|
|
2022-02-21 14:01:31 +00:00
|
|
|
if (b == 1) break;
|
2017-07-26 12:30:38 +00:00
|
|
|
b++;
|
|
|
|
}
|
2019-06-18 16:03:44 +00:00
|
|
|
%PrepareFunctionForOptimization(NestedLoops);
|
2017-07-26 12:30:38 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(NestedLoops);
|
2017-07-26 12:30:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
SingleLoop();
|
|
|
|
EmptyBody();
|
|
|
|
NestedLoops();
|