summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/compiler/try-deopt.js
blob: dc44e7326fa23d17296c7e7cbf75717bd794a225 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 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.

// TODO(mstarzinger): Add FLAG_turbo_exceptions once we want ClusterFuzz.
// Flags: --allow-natives-syntax --turbo-deoptimization

function DeoptFromTry(x) {
  try {
    %DeoptimizeFunction(DeoptFromTry);
    throw x;
  } catch (e) {
    return e + 1;
  }
  return x + 2;
}
%OptimizeFunctionOnNextCall(DeoptFromTry);
assertEquals(24, DeoptFromTry(23));


function DeoptFromCatch(x) {
  try {
    throw x;
  } catch (e) {
    %DeoptimizeFunction(DeoptFromCatch);
    return e + 1;
  }
  return x + 2;
}
%OptimizeFunctionOnNextCall(DeoptFromCatch);
assertEquals(24, DeoptFromCatch(23));


function DeoptFromFinally_Return(x) {
  try {
    throw x;
  } finally {
    %DeoptimizeFunction(DeoptFromFinally_Return);
    return x + 1;
  }
  return x + 2;
}
%OptimizeFunctionOnNextCall(DeoptFromFinally_Return);
assertEquals(24, DeoptFromFinally_Return(23));


function DeoptFromFinally_ReThrow(x) {
  try {
    throw x;
  } finally {
    %DeoptimizeFunction(DeoptFromFinally_ReThrow);
  }
  return x + 2;
}
%OptimizeFunctionOnNextCall(DeoptFromFinally_ReThrow);
assertThrows("DeoptFromFinally_ReThrow(new Error)", Error);