1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:27:43 +00:00

LibJS: Move the current exception from Interpreter to VM

This will allow us to throw exceptions even when there is no active
interpreter in the VM.
This commit is contained in:
Andreas Kling 2020-09-21 15:28:09 +02:00
parent 675b482fe7
commit 4a8bfcdd1c
12 changed files with 26 additions and 23 deletions

View file

@ -81,6 +81,8 @@ VM::InterpreterExecutionScope::~InterpreterExecutionScope()
void VM::gather_roots(HashTable<Cell*>& roots)
{
if (m_exception)
roots.set(m_exception);
for (auto* interpreter : m_interpreters)
interpreter->gather_roots(roots);
}

View file

@ -45,10 +45,18 @@ public:
void push_interpreter(Interpreter&);
void pop_interpreter(Interpreter&);
Exception* exception()
{
return m_exception;
}
void set_exception(Badge<Interpreter>, Exception* exception) { m_exception = exception; }
void clear_exception() { m_exception = nullptr; }
class InterpreterExecutionScope {
public:
InterpreterExecutionScope(Interpreter&);
~InterpreterExecutionScope();
private:
Interpreter& m_interpreter;
};
@ -58,6 +66,8 @@ public:
private:
VM();
Exception* m_exception { nullptr };
Heap m_heap;
Vector<Interpreter*> m_interpreters;
};