summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/warp/throw-exception-stack-location.js
blob: bcb7329b0574766e853b73c4c128c31ceba26c2c (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
function throwValue(value) {
  throw value;
}

// Test try-finally keep the exception stack.
function testFinally() {
  function f() {
    try {
      throwValue("exception-value");
    } finally {
      for (let i = 0; i < 100; ++i) {
        // OSR
      }
    }
  }

  let info = getExceptionInfo(f);
  assertEq(info.exception, "exception-value");
  assertEq(info.stack.includes("throwValue"), true);
}
testFinally();

// Test try-catch-finally keep the exception stack.
function testCatchFinally() {
  function f() {
    try {
      throw null;
    } catch {
     throwValue("exception-value");
    } finally {
      for (let i = 0; i < 100; ++i) {
        // OSR
      }
    }
  }

  let info = getExceptionInfo(f);
  assertEq(info.exception, "exception-value");
  assertEq(info.stack.includes("throwValue"), true);
}
testCatchFinally();