diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 80fe383781..68940271ba 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -149,6 +149,8 @@ ThrowCompletionOr ECMAScriptFunctionObject::internal_call(Value this_argu ExecutionContext callee_context(heap()); + callee_context.local_variables.resize(m_local_variables_names.size()); + // Non-standard callee_context.arguments.extend(move(arguments_list)); if (auto* interpreter = vm.interpreter_if_exists()) @@ -218,6 +220,8 @@ ThrowCompletionOr> ECMAScriptFunctionObject::internal_const ExecutionContext callee_context(heap()); + callee_context.local_variables.resize(m_local_variables_names.size()); + // Non-standard callee_context.arguments.extend(move(arguments_list)); if (auto* interpreter = vm.interpreter_if_exists()) diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp b/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp index 5ff2b39fdc..e94052016e 100644 --- a/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp +++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp @@ -13,17 +13,19 @@ namespace JS { ExecutionContext::ExecutionContext(Heap& heap) : arguments(heap) + , local_variables(heap) { } -ExecutionContext::ExecutionContext(MarkedVector existing_arguments) +ExecutionContext::ExecutionContext(MarkedVector existing_arguments, MarkedVector existing_local_variables) : arguments(move(existing_arguments)) + , local_variables(move(existing_local_variables)) { } ExecutionContext ExecutionContext::copy() const { - ExecutionContext copy { arguments }; + ExecutionContext copy { arguments, local_variables }; copy.function = function; copy.realm = realm; diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h index 180a91c12b..1fe4b2593e 100644 --- a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h +++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h @@ -29,7 +29,7 @@ struct ExecutionContext { void visit_edges(Cell::Visitor&); private: - explicit ExecutionContext(MarkedVector existing_arguments); + explicit ExecutionContext(MarkedVector existing_arguments, MarkedVector existing_local_variables); public: GCPtr function; // [[Function]] @@ -46,6 +46,7 @@ public: DeprecatedFlyString function_name; Value this_value; MarkedVector arguments; + MarkedVector local_variables; bool is_strict_mode { false }; // https://html.spec.whatwg.org/multipage/webappapis.html#skip-when-determining-incumbent-counter