mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
LibJS: Stash thrown exception in a register before executing finalizer
This kills 2 birds with one stone: 1. It makes sure generated check_exception() calls in the finalizer don't mis-read the pending exception as caused by their matching operation. 2. It implicitly ensures that terminated finally blocks (by a return statement) overwrite any pending exceptions, since they will never execute the ContinuePendingUnwind operation that restores the stashed exception. This additional logic is required in the JIT (as opposed to the interpreter), since the JIT uses the exception register to store and check the possibly-exceptional results from each individual operation, while the interpreter only modifies it when an operation has thrown an exception.
This commit is contained in:
parent
aaa81cd3b9
commit
58e2fe895c
2 changed files with 13 additions and 2 deletions
|
@ -45,7 +45,13 @@ public:
|
|||
return Register(return_value_index);
|
||||
}
|
||||
|
||||
static constexpr u32 reserved_register_count = 5;
|
||||
static constexpr Register saved_exception()
|
||||
{
|
||||
constexpr u32 saved_exception_index = 5;
|
||||
return Register(saved_exception_index);
|
||||
}
|
||||
|
||||
static constexpr u32 reserved_register_count = 6;
|
||||
|
||||
constexpr explicit Register(u32 index)
|
||||
: m_index(index)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue