LibJS: Don't leak class field initializers

We were storing these in Handle (strong GC roots) hanging off of
ECMAScriptFunctionObject which effectively turned into world leaks.
This commit is contained in:
Andreas Kling 2024-11-10 13:03:38 +01:00 committed by Andreas Kling
commit 5aa1d7837f
Notes: github-actions[bot] 2024-11-10 18:13:56 +00:00
4 changed files with 7 additions and 6 deletions

View file

@ -227,7 +227,7 @@ ThrowCompletionOr<ClassElement::ClassValue> ClassField::class_element_evaluation
auto& realm = *vm.current_realm();
auto property_key_or_private_name = TRY(class_key_to_property_name(vm, *m_key, property_key));
Handle<ECMAScriptFunctionObject> initializer {};
GCPtr<ECMAScriptFunctionObject> initializer;
if (m_initializer) {
auto copy_initializer = m_initializer;
auto name = property_key_or_private_name.visit(
@ -370,7 +370,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_const
ConservativeVector<PrivateElement> static_private_methods(vm.heap());
ConservativeVector<PrivateElement> instance_private_methods(vm.heap());
Vector<ClassFieldDefinition> instance_fields;
ConservativeVector<ClassFieldDefinition> instance_fields(vm.heap());
Vector<StaticElement> static_elements;
for (size_t element_index = 0; element_index < m_elements.size(); element_index++) {