mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:55:09 +00:00
LibJS/Bytecode: Remove unnecessary variable environment stack
The var environments will unwind as needed with the ExecutionContext and there's no need to include it in the unwind info. We still need to do this for lexical environments though, since they can have short local lifetimes inside a function.
This commit is contained in:
parent
e2b0cacb89
commit
dc884aa0d3
3 changed files with 2 additions and 10 deletions
|
@ -19,7 +19,6 @@ struct UnwindInfo {
|
|||
BasicBlock const* finalizer;
|
||||
|
||||
JS::GCPtr<Environment> lexical_environment;
|
||||
JS::GCPtr<Environment> variable_environment;
|
||||
};
|
||||
|
||||
class BasicBlock {
|
||||
|
|
|
@ -221,7 +221,7 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Execu
|
|||
if (in_frame)
|
||||
push_register_window(in_frame, executable.number_of_registers);
|
||||
else
|
||||
push_register_window(make<RegisterWindow>(MarkedVector<Value>(vm().heap()), MarkedVector<GCPtr<Environment>>(vm().heap()), MarkedVector<GCPtr<Environment>>(vm().heap()), Vector<UnwindInfo> {}), executable.number_of_registers);
|
||||
push_register_window(make<RegisterWindow>(), executable.number_of_registers);
|
||||
|
||||
for (;;) {
|
||||
Bytecode::InstructionStreamIterator pc(m_current_block->instruction_stream());
|
||||
|
@ -244,7 +244,6 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Realm& realm, Execu
|
|||
break;
|
||||
if (unwind_context.handler) {
|
||||
vm().running_execution_context().lexical_environment = unwind_context.lexical_environment;
|
||||
vm().running_execution_context().variable_environment = unwind_context.variable_environment;
|
||||
m_current_block = unwind_context.handler;
|
||||
unwind_context.handler = nullptr;
|
||||
|
||||
|
@ -361,8 +360,7 @@ void Interpreter::enter_unwind_context(Optional<Label> handler_target, Optional<
|
|||
m_current_executable,
|
||||
handler_target.has_value() ? &handler_target->block() : nullptr,
|
||||
finalizer_target.has_value() ? &finalizer_target->block() : nullptr,
|
||||
vm().running_execution_context().lexical_environment,
|
||||
vm().running_execution_context().variable_environment);
|
||||
vm().running_execution_context().lexical_environment);
|
||||
}
|
||||
|
||||
void Interpreter::leave_unwind_context()
|
||||
|
|
|
@ -26,16 +26,12 @@ struct RegisterWindow {
|
|||
visitor.visit(value);
|
||||
for (auto const& environment : saved_lexical_environments)
|
||||
visitor.visit(environment);
|
||||
for (auto const& environment : saved_variable_environments)
|
||||
visitor.visit(environment);
|
||||
for (auto& context : unwind_contexts) {
|
||||
visitor.visit(context.lexical_environment);
|
||||
visitor.visit(context.variable_environment);
|
||||
}
|
||||
}
|
||||
Vector<Value> registers;
|
||||
Vector<GCPtr<Environment>> saved_lexical_environments;
|
||||
Vector<GCPtr<Environment>> saved_variable_environments;
|
||||
Vector<UnwindInfo> unwind_contexts;
|
||||
};
|
||||
|
||||
|
@ -70,7 +66,6 @@ public:
|
|||
Value& reg(Register const& r) { return registers()[r.index()]; }
|
||||
|
||||
auto& saved_lexical_environment_stack() { return window().saved_lexical_environments; }
|
||||
auto& saved_variable_environment_stack() { return window().saved_variable_environments; }
|
||||
auto& unwind_contexts() { return window().unwind_contexts; }
|
||||
|
||||
void jump(Label const& label)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue