1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 08:25:07 +00:00

LibJS: Use the IdentifierTable for NewFunction and NewClass lhs names

This makes them trivially copyable, which is an assumption multiple
optimizations use when rebuilding the instruction stream.

This fixes most optimized crashes in the test262 suite.
This commit is contained in:
Hendiadyoin1 2023-06-28 18:17:13 +02:00 committed by Andreas Kling
parent c21255da7f
commit 37067cf3ca
6 changed files with 32 additions and 28 deletions

View file

@ -452,7 +452,7 @@ void Generator::pop_home_object()
m_home_objects.take_last();
}
void Generator::emit_new_function(FunctionExpression const& function_node, Optional<DeprecatedFlyString const&> lhs_name)
void Generator::emit_new_function(FunctionExpression const& function_node, Optional<IdentifierTableIndex> lhs_name)
{
if (m_home_objects.is_empty())
emit<Op::NewFunction>(function_node, lhs_name);
@ -460,7 +460,7 @@ void Generator::emit_new_function(FunctionExpression const& function_node, Optio
emit<Op::NewFunction>(function_node, lhs_name, m_home_objects.last());
}
CodeGenerationErrorOr<void> Generator::emit_named_evaluation_if_anonymous_function(Expression const& expression, Optional<DeprecatedFlyString const&> lhs_name)
CodeGenerationErrorOr<void> Generator::emit_named_evaluation_if_anonymous_function(Expression const& expression, Optional<IdentifierTableIndex> lhs_name)
{
if (is<FunctionExpression>(expression)) {
auto const& function_expression = static_cast<FunctionExpression const&>(expression);