1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-28 21:02:07 +00:00

LibJS: Partially revert 12b283f

This commit partially reverts "LibJS: Make accessing the current
function's arguments cheaper".
While the change passed all the currently passing test262 tests, it
seems to have _some_ flaw that silently breaks with some real-world
websites.
As the speedup with negligible at best, let's just revert it until we
can implement it more correctly.
This commit is contained in:
Ali Mohammad Pur 2021-10-08 19:56:02 +03:30
parent fa6c06ce8d
commit 13138811df
4 changed files with 0 additions and 107 deletions

View file

@ -48,31 +48,6 @@ void Reference::put_value(GlobalObject& global_object, Value value)
}
VERIFY(m_base_type == BaseType::Environment);
// Note: Optimisation, not from the spec.
if (m_function_argument_index.has_value()) {
// Note: Modifying this binding requires us to sync with the environment.
if (!m_base_environment) {
auto real_reference = global_object.vm().resolve_binding(m_name.as_string(), m_referenced_function_context->lexical_environment);
m_base_environment = real_reference.m_base_environment;
}
if (!global_object.vm().execution_context_stack().is_empty() && m_referenced_function_context == &global_object.vm().running_execution_context()) {
auto& arguments = m_referenced_function_context->arguments;
auto index = m_function_argument_index.value();
if (arguments.size() > index) {
arguments[index] = value;
} else {
arguments.ensure_capacity(index + 1);
for (size_t i = arguments.size(); i < index; ++i)
arguments.append(js_undefined());
arguments.append(value);
}
m_base_environment->set_mutable_binding(global_object, name().as_string(), value, is_strict());
return;
}
}
VERIFY(m_base_environment);
if (m_environment_coordinate.has_value())
static_cast<DeclarativeEnvironment*>(m_base_environment)->set_mutable_binding_direct(global_object, m_environment_coordinate->index, value, m_strict);
@ -106,16 +81,6 @@ Value Reference::get_value(GlobalObject& global_object) const
VERIFY(m_base_type == BaseType::Environment);
// Note: Optimisation, not from the spec.
if (m_function_argument_index.has_value()) {
if (!global_object.vm().execution_context_stack().is_empty() && m_referenced_function_context == &global_object.vm().running_execution_context())
return global_object.vm().argument(m_function_argument_index.value());
if (!m_base_environment) {
auto real_reference = global_object.vm().resolve_binding(m_name.as_string(), m_referenced_function_context->lexical_environment);
m_base_environment = real_reference.m_base_environment;
}
}
VERIFY(m_base_environment);
if (m_environment_coordinate.has_value())
return static_cast<DeclarativeEnvironment*>(m_base_environment)->get_binding_value_direct(global_object, m_environment_coordinate->index, m_strict);
@ -177,12 +142,6 @@ bool Reference::delete_(GlobalObject& global_object)
VERIFY(m_base_type == BaseType::Environment);
// Note: Optimisation, not from the spec.
if (m_function_argument_index.has_value()) {
// This is a direct reference to a function argument.
return false;
}
// c. Return ? base.DeleteBinding(ref.[[ReferencedName]]).
return m_base_environment->delete_binding(global_object, m_name.as_string());
}