mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
LibJS: Lazily instantiate "prototype" field on ECMAScriptFunctionObject
This field is rarely accessed but we were creating it for every single script function instantiated. It's a little awkward but the same optimization can be found in other engines, so it's nothing crazy. This avoids creating roughly 80,000 objects on my x.com home feed.
This commit is contained in:
committed by
Andreas Kling
parent
941336505c
commit
cbe75f8251
Notes:
github-actions[bot]
2025-12-17 18:51:45 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/cbe75f8251f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7167
@@ -117,6 +117,8 @@ private:
|
||||
PrivateEnvironment* private_environment,
|
||||
Object& prototype);
|
||||
|
||||
virtual ThrowCompletionOr<Optional<PropertyDescriptor>> internal_get_own_property(PropertyKey const&) const override;
|
||||
|
||||
virtual bool is_strict_mode() const override { return shared_data().m_strict; }
|
||||
|
||||
ThrowCompletionOr<Value> ordinary_call_evaluate_body(VM&, ExecutionContext&);
|
||||
@@ -145,6 +147,8 @@ private:
|
||||
};
|
||||
ClassData& ensure_class_data() const;
|
||||
mutable OwnPtr<ClassData> m_class_data;
|
||||
|
||||
mutable bool m_may_need_lazy_prototype_instantiation { false };
|
||||
};
|
||||
|
||||
template<>
|
||||
|
||||
Reference in New Issue
Block a user