• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7function DeoptFromTry(x) {
8  try {
9    %DeoptimizeFunction(DeoptFromTry);
10    throw x;
11  } catch (e) {
12    return e + 1;
13  }
14  return x + 2;
15}
16%OptimizeFunctionOnNextCall(DeoptFromTry);
17assertEquals(24, DeoptFromTry(23));
18
19
20function DeoptFromCatch(x) {
21  try {
22    throw x;
23  } catch (e) {
24    %DeoptimizeFunction(DeoptFromCatch);
25    return e + 1;
26  }
27  return x + 2;
28}
29%OptimizeFunctionOnNextCall(DeoptFromCatch);
30assertEquals(24, DeoptFromCatch(23));
31
32
33function DeoptFromFinally_Return(x) {
34  try {
35    throw x;
36  } finally {
37    %DeoptimizeFunction(DeoptFromFinally_Return);
38    return x + 1;
39  }
40  return x + 2;
41}
42%OptimizeFunctionOnNextCall(DeoptFromFinally_Return);
43assertEquals(24, DeoptFromFinally_Return(23));
44
45
46function DeoptFromFinally_ReThrow(x) {
47  try {
48    throw x;
49  } finally {
50    %DeoptimizeFunction(DeoptFromFinally_ReThrow);
51  }
52  return x + 2;
53}
54%OptimizeFunctionOnNextCall(DeoptFromFinally_ReThrow);
55assertThrows("DeoptFromFinally_ReThrow(new Error)", Error);
56