mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:37:35 +00:00
LibJS: Make accessing the current function's arguments cheaper
Instead of going through an environment record, make arguments of the currently executing function generate references via the argument index, which can later be resolved directly through the ExecutionContext.
This commit is contained in:
parent
da296ffd56
commit
12b283f32f
5 changed files with 207 additions and 4 deletions
|
@ -1011,10 +1011,30 @@ Reference Identifier::to_reference(Interpreter& interpreter, GlobalObject&) cons
|
|||
environment = environment->outer_environment();
|
||||
VERIFY(environment);
|
||||
VERIFY(environment->is_declarative_environment());
|
||||
if (!environment->is_permanently_screwed_by_eval())
|
||||
if (!environment->is_permanently_screwed_by_eval()) {
|
||||
if (m_lexically_bound_function_argument.has_value()) {
|
||||
return Reference {
|
||||
*environment,
|
||||
string(),
|
||||
*m_lexically_bound_function_argument,
|
||||
interpreter.vm().in_strict_mode(),
|
||||
m_cached_environment_coordinate,
|
||||
&interpreter.vm().running_execution_context(),
|
||||
};
|
||||
}
|
||||
return Reference { *environment, string(), interpreter.vm().in_strict_mode(), m_cached_environment_coordinate };
|
||||
}
|
||||
m_cached_environment_coordinate = {};
|
||||
}
|
||||
if (m_lexically_bound_function_argument.has_value()) {
|
||||
return Reference {
|
||||
string(),
|
||||
*m_lexically_bound_function_argument,
|
||||
interpreter.vm().in_strict_mode(),
|
||||
&interpreter.vm().running_execution_context(),
|
||||
};
|
||||
}
|
||||
|
||||
auto reference = interpreter.vm().resolve_binding(string());
|
||||
if (reference.environment_coordinate().has_value())
|
||||
m_cached_environment_coordinate = reference.environment_coordinate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue