mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 16:41:52 +00:00
LibJS: Move computation out of the ECMAScriptFunctionObject constructor
We were doing way too much computation every time an ESFO was instantiated. This was particularly sad, since the results of these computations were identical every time! This patch adds a new SharedFunctionInstanceData object that gets shared between all instances of an ESFO instantiated from some kind of AST FunctionNode. ~5% speedup on Speedometer 2.1 :^)
This commit is contained in:
parent
4209b18b88
commit
2a9b6f1d97
Notes:
github-actions[bot]
2025-04-08 16:53:53 +00:00
Author: https://github.com/awesomekling
Commit: 2a9b6f1d97
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4283
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/trflynn89
7 changed files with 367 additions and 258 deletions
|
@ -35,6 +35,7 @@
|
|||
#include <LibJS/Runtime/RegExpObject.h>
|
||||
#include <LibJS/Runtime/Shape.h>
|
||||
#include <LibJS/Runtime/ValueInlines.h>
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace JS {
|
||||
|
@ -363,7 +364,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_const
|
|||
TRY(class_constructor->internal_set_prototype_of(constructor_parent));
|
||||
|
||||
if (!m_super_class.is_null())
|
||||
class_constructor->set_constructor_kind(ECMAScriptFunctionObject::ConstructorKind::Derived);
|
||||
class_constructor->set_constructor_kind(ConstructorKind::Derived);
|
||||
|
||||
prototype->define_direct_property(vm.names.constructor, class_constructor, Attribute::Writable | Attribute::Configurable);
|
||||
|
||||
|
@ -825,6 +826,34 @@ void BindingPattern::dump(int indent) const
|
|||
}
|
||||
}
|
||||
|
||||
FunctionNode::FunctionNode(RefPtr<Identifier const> name, ByteString source_text, NonnullRefPtr<Statement const> body, NonnullRefPtr<FunctionParameters const> parameters, i32 function_length, FunctionKind kind, bool is_strict_mode, FunctionParsingInsights parsing_insights, bool is_arrow_function, Vector<FlyString> local_variables_names)
|
||||
: m_name(move(name))
|
||||
, m_source_text(move(source_text))
|
||||
, m_body(move(body))
|
||||
, m_parameters(move(parameters))
|
||||
, m_function_length(function_length)
|
||||
, m_kind(kind)
|
||||
, m_is_strict_mode(is_strict_mode)
|
||||
, m_is_arrow_function(is_arrow_function)
|
||||
, m_parsing_insights(parsing_insights)
|
||||
, m_local_variables_names(move(local_variables_names))
|
||||
{
|
||||
if (m_is_arrow_function)
|
||||
VERIFY(!parsing_insights.might_need_arguments_object);
|
||||
}
|
||||
|
||||
FunctionNode::~FunctionNode() = default;
|
||||
|
||||
void FunctionNode::set_shared_data(RefPtr<SharedFunctionInstanceData> shared_data) const
|
||||
{
|
||||
m_shared_data = move(shared_data);
|
||||
}
|
||||
|
||||
RefPtr<SharedFunctionInstanceData> FunctionNode::shared_data() const
|
||||
{
|
||||
return m_shared_data;
|
||||
}
|
||||
|
||||
void FunctionNode::dump(int indent, ByteString const& class_name) const
|
||||
{
|
||||
print_indent(indent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue