mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-13 04:21:54 +00:00
LibJS: Make class-specific members of ESFO lazily allocated
We don't need the [[Fields]] and [[PrivateMethods]] slots for most ESFO instances, so let's reduce their impact on class size! This shrinks ESFO from 200 bytes to 160 bytes, allowing more allocations before we have to collect garbage.
This commit is contained in:
parent
2a9b6f1d97
commit
4593e19bcf
Notes:
github-actions[bot]
2025-04-08 16:53:42 +00:00
Author: https://github.com/awesomekling
Commit: 4593e19bcf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4283
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/trflynn89
3 changed files with 40 additions and 20 deletions
|
@ -152,11 +152,13 @@ public:
|
|||
[[nodiscard]] ByteString const& source_text() const { return shared_data().m_source_text; }
|
||||
void set_source_text(ByteString source_text) { const_cast<SharedFunctionInstanceData&>(shared_data()).m_source_text = move(source_text); }
|
||||
|
||||
Vector<ClassFieldDefinition> const& fields() const { return m_fields; }
|
||||
void add_field(ClassFieldDefinition field) { m_fields.append(move(field)); }
|
||||
Vector<ClassFieldDefinition> const& fields() const { return ensure_class_data().fields; }
|
||||
void add_field(ClassFieldDefinition field) { ensure_class_data().fields.append(move(field)); }
|
||||
|
||||
Vector<PrivateElement> const& private_methods() const { return m_private_methods; }
|
||||
void add_private_method(PrivateElement method) { m_private_methods.append(move(method)); }
|
||||
Vector<PrivateElement> const& private_methods() const { return ensure_class_data().private_methods; }
|
||||
void add_private_method(PrivateElement method) { ensure_class_data().private_methods.append(move(method)); }
|
||||
|
||||
[[nodiscard]] bool has_class_data() const { return m_class_data; }
|
||||
|
||||
// This is for IsSimpleParameterList (static semantics)
|
||||
bool has_simple_parameter_list() const { return shared_data().m_has_simple_parameter_list; }
|
||||
|
@ -211,8 +213,12 @@ private:
|
|||
GC::Ptr<Realm> m_realm; // [[Realm]]
|
||||
ScriptOrModule m_script_or_module; // [[ScriptOrModule]]
|
||||
GC::Ptr<Object> m_home_object; // [[HomeObject]]
|
||||
Vector<ClassFieldDefinition> m_fields; // [[Fields]]
|
||||
Vector<PrivateElement> m_private_methods; // [[PrivateMethods]]
|
||||
struct ClassData {
|
||||
Vector<ClassFieldDefinition> fields; // [[Fields]]
|
||||
Vector<PrivateElement> private_methods; // [[PrivateMethods]]
|
||||
};
|
||||
ClassData& ensure_class_data() const;
|
||||
mutable OwnPtr<ClassData> m_class_data;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue