From 74c730a08d3832571d57bed76d974a0fa793dfff Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Tue, 9 Jun 2015 01:16:32 -0700 Subject: [PATCH] [turbofan] Add mjsunit tests for try-catch-finally and OSR. This adds some basic tests of the interaction between try-catch and try-finally statements and OSR in TurboFan. The try-osr test suite follows the structure of try-deopt closely. R=titzer@chromium.org TEST=mjsunit/compiler/try-osr Review URL: https://codereview.chromium.org/1165103003 Cr-Commit-Position: refs/heads/master@{#28855} --- test/cctest/compiler/test-run-jsexceptions.cc | 4 --- test/mjsunit/compiler/try-osr.js | 51 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 test/mjsunit/compiler/try-osr.js diff --git a/test/cctest/compiler/test-run-jsexceptions.cc b/test/cctest/compiler/test-run-jsexceptions.cc index 1a917ef..0e1977b 100644 --- a/test/cctest/compiler/test-run-jsexceptions.cc +++ b/test/cctest/compiler/test-run-jsexceptions.cc @@ -80,10 +80,6 @@ TEST(ThrowMessageIndirectly) { } -// TODO(mstarzinger): Increase test coverage by having similar tests within the -// mjsunit suite to also test integration with other components (e.g. OSR). - - TEST(Catch) { i::FLAG_turbo_try_catch = true; const char* src = diff --git a/test/mjsunit/compiler/try-osr.js b/test/mjsunit/compiler/try-osr.js new file mode 100644 index 0000000..e4eb8dd --- /dev/null +++ b/test/mjsunit/compiler/try-osr.js @@ -0,0 +1,51 @@ +// 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. + +// Flags: --allow-natives-syntax --turbo-osr + +function OSRInsideTry(x) { + try { + for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } + throw x; + } catch (e) { + return e + 1; + } + return x + 2; +} +assertEquals(24, OSRInsideTry(23)); + + +function OSRInsideCatch(x) { + try { + throw x; + } catch (e) { + for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } + return e + 1; + } + return x + 2; +} +assertEquals(24, OSRInsideCatch(23)); + + +function OSRInsideFinally_Return(x) { + try { + throw x; + } finally { + for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } + return x + 1; + } + return x + 2; +} +assertEquals(24, OSRInsideFinally_Return(23)); + + +function OSRInsideFinally_ReThrow(x) { + try { + throw x; + } finally { + for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); } + } + return x + 2; +} +assertThrows("OSRInsideFinally_ReThrow(new Error)", Error); -- 2.7.4