1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:08:11 +00:00

LibJS: Fix the execution context for the bytecode interpreter

Because we now push an execution context when creating the "normal"
interpreter without valid environments we have to check for that case
as well when running the bytecode interpreter.
This commit is contained in:
davidot 2022-01-22 13:03:06 +01:00 committed by Linus Groh
parent a821aa5f50
commit 6fa600fce3

View file

@ -46,7 +46,8 @@ Interpreter::ValueAndFrame Interpreter::run_and_return_frame(Executable const& e
TemporaryChange restore_executable { m_current_executable, &executable };
ExecutionContext execution_context(vm().heap());
if (vm().execution_context_stack().is_empty()) {
if (vm().execution_context_stack().is_empty() || !vm().running_execution_context().lexical_environment) {
// The "normal" interpreter pushes an execution context without environment so in that case we also want to push one.
execution_context.this_value = &global_object();
static FlyString global_execution_context_name = "(*BC* global execution context)";
execution_context.function_name = global_execution_context_name;