Bug 1843499 - Part 3: Add exception stack to finally. r=iain
commitb65e00781b544fe17e8cb54978f3e5f7119fdb30
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 22 Jan 2024 14:29:41 +0000 (22 14:29 +0000)
committerAndré Bargull <andre.bargull@gmail.com>
Mon, 22 Jan 2024 14:29:41 +0000 (22 14:29 +0000)
treefe109669fc6927b0e268576703a3b3b5570f735a
parent715c5967c73463f5df5627633f9d504a5dbb2c94
Bug 1843499 - Part 3: Add exception stack to finally. r=iain

Similar to the last part 2, re-throw the original stack trace in `finally`
blocks. This is implemented by changing `finally` blocks to push the exception
stack onto the value stack.

Using test262 assertions:
```
try {
  assert.throws(TypeError, () => {});  // This is line 2.
} finally {
  assert.sameValue(0, 0);  // This is line 4. (End of finally block)
}
```

Before:
```
/tmp/a.js:4:10 uncaught exception: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
Stack:
  @/tmp/a.js:4:10
```

Now:
```
/tmp/test262-assert.js:104:9 uncaught exception: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all
Stack:
  assert.throws@/tmp/test262-assert.js:104:9
  @/tmp/a.js:2:10
```

Differential Revision: https://phabricator.services.mozilla.com/D183564
21 files changed:
js/src/frontend/BytecodeControlStructures.cpp
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/ForOfLoopControl.cpp
js/src/frontend/TryEmitter.cpp
js/src/jit-test/tests/basic/throw-exception-stack-location.js
js/src/jit-test/tests/generators/yield-exception-stack-in-finally.js [new file with mode: 0644]
js/src/jit-test/tests/warp/throw-exception-stack-location.js [new file with mode: 0644]
js/src/jit/Bailouts.h
js/src/jit/BaselineBailouts.cpp
js/src/jit/BytecodeAnalysis.cpp
js/src/jit/JitFrames.cpp
js/src/jit/JitFrames.h
js/src/jit/arm/MacroAssembler-arm.cpp
js/src/jit/arm64/MacroAssembler-arm64.cpp
js/src/jit/loong64/MacroAssembler-loong64.cpp
js/src/jit/mips64/MacroAssembler-mips64.cpp
js/src/jit/riscv64/MacroAssembler-riscv64.cpp
js/src/jit/x64/MacroAssembler-x64.cpp
js/src/jit/x86/MacroAssembler-x86.cpp
js/src/vm/BytecodeUtil.cpp
js/src/vm/Interpreter.cpp