From dfa62b660d6bde4dc210158920b4bf397ca8cd45 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 20 Nov 2022 07:02:14 -0800 Subject: [internal] Implement `visitAdditionalChildren` --- src/bun.js/bindings/ZigGeneratedClasses.h | 72 +++++++++++++++++++------------ 1 file changed, 45 insertions(+), 27 deletions(-) (limited to 'src/bun.js/bindings/ZigGeneratedClasses.h') diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h index e94b33335..27665927f 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses.h +++ b/src/bun.js/bindings/ZigGeneratedClasses.h @@ -66,21 +66,21 @@ public: void finishCreation(JSC::VM&); JSC::Weak m_weakThis; - bool internalHasPendingActivity(); - bool hasPendingActivity() - { - if (UNLIKELY(!m_ctx)) - return false; - return this->internalHasPendingActivity(); - } + static bool hasPendingActivity(void* ctx); class Owner final : public JSC::WeakHandleOwner { public: - bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final { auto* controller = JSC::jsCast(handle.slot()->asCell()); - return controller->hasPendingActivity(); + if (JSTCPSocket::hasPendingActivity(controller->wrapped())) { + if (UNLIKELY(reason)) + *reason = "has pending activity"; + return true; + } + + return visitor.containsOpaqueRoot(context); } void finalize(JSC::Handle, void* context) final {} }; @@ -92,6 +92,8 @@ public: } DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_data; mutable JSC::WriteBarrier m_remoteAddress; @@ -148,21 +150,21 @@ public: void finishCreation(JSC::VM&); JSC::Weak m_weakThis; - bool internalHasPendingActivity(); - bool hasPendingActivity() - { - if (UNLIKELY(!m_ctx)) - return false; - return this->internalHasPendingActivity(); - } + static bool hasPendingActivity(void* ctx); class Owner final : public JSC::WeakHandleOwner { public: - bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final { auto* controller = JSC::jsCast(handle.slot()->asCell()); - return controller->hasPendingActivity(); + if (JSTLSSocket::hasPendingActivity(controller->wrapped())) { + if (UNLIKELY(reason)) + *reason = "has pending activity"; + return true; + } + + return visitor.containsOpaqueRoot(context); } void finalize(JSC::Handle, void* context) final {} }; @@ -174,6 +176,8 @@ public: } DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_data; mutable JSC::WriteBarrier m_remoteAddress; @@ -229,6 +233,8 @@ public: void finishCreation(JSC::VM&); DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_hostname; mutable JSC::WriteBarrier m_unix; @@ -285,21 +291,21 @@ public: void finishCreation(JSC::VM&); JSC::Weak m_weakThis; - bool internalHasPendingActivity(); - bool hasPendingActivity() - { - if (UNLIKELY(!m_ctx)) - return false; - return this->internalHasPendingActivity(); - } + static bool hasPendingActivity(void* ctx); class Owner final : public JSC::WeakHandleOwner { public: - bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor&, const char**) final + bool isReachableFromOpaqueRoots(JSC::Handle handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final { auto* controller = JSC::jsCast(handle.slot()->asCell()); - return controller->hasPendingActivity(); + if (JSSubprocess::hasPendingActivity(controller->wrapped())) { + if (UNLIKELY(reason)) + *reason = "has pending activity"; + return true; + } + + return visitor.containsOpaqueRoot(context); } void finalize(JSC::Handle, void* context) final {} }; @@ -311,6 +317,8 @@ public: } DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_stderr; mutable JSC::WriteBarrier m_stdin; @@ -767,6 +775,8 @@ public: void finishCreation(JSC::VM&); DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_data; mutable JSC::WriteBarrier m_remoteAddress; @@ -822,6 +832,8 @@ public: void finishCreation(JSC::VM&); DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_capturedValue; mutable JSC::WriteBarrier m_resultValue; @@ -877,6 +889,8 @@ public: void finishCreation(JSC::VM&); DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_encoding; }; @@ -931,6 +945,8 @@ public: void finishCreation(JSC::VM&); DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_body; mutable JSC::WriteBarrier m_headers; @@ -987,6 +1003,8 @@ public: void finishCreation(JSC::VM&); DECLARE_VISIT_CHILDREN; + template void visitAdditionalChildren(Visitor&); + DECLARE_VISIT_OUTPUT_CONSTRAINTS; mutable JSC::WriteBarrier m_body; mutable JSC::WriteBarrier m_headers; -- cgit v1.2.3