mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[internal] Implement visitAdditionalChildren
This commit is contained in:
@@ -489,9 +489,9 @@ extern "C" EncodedJSValue TCPSocket__getConstructor(Zig::GlobalObject* globalObj
|
||||
}
|
||||
|
||||
extern "C" bool TCPSocket__hasPendingActivity(void* ptr);
|
||||
bool JSTCPSocket::internalHasPendingActivity()
|
||||
bool JSTCPSocket::hasPendingActivity(void* ctx)
|
||||
{
|
||||
return TCPSocket__hasPendingActivity(m_ctx);
|
||||
return TCPSocket__hasPendingActivity(ctx);
|
||||
}
|
||||
|
||||
JSTCPSocket::~JSTCPSocket()
|
||||
@@ -575,9 +575,33 @@ void JSTCPSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
|
||||
visitor.append(thisObject->m_data);
|
||||
visitor.append(thisObject->m_remoteAddress);
|
||||
visitor.addOpaqueRoot(thisObject->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSTCPSocket);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSTCPSocket::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSTCPSocket* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_data);
|
||||
visitor.append(thisObject->m_remoteAddress);
|
||||
visitor.addOpaqueRoot(this->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTCPSocket);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSTCPSocket::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSTCPSocket* thisObject = jsCast<JSTCPSocket*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTCPSocket);
|
||||
class JSTLSSocketPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -1040,9 +1064,9 @@ extern "C" EncodedJSValue TLSSocket__getConstructor(Zig::GlobalObject* globalObj
|
||||
}
|
||||
|
||||
extern "C" bool TLSSocket__hasPendingActivity(void* ptr);
|
||||
bool JSTLSSocket::internalHasPendingActivity()
|
||||
bool JSTLSSocket::hasPendingActivity(void* ctx)
|
||||
{
|
||||
return TLSSocket__hasPendingActivity(m_ctx);
|
||||
return TLSSocket__hasPendingActivity(ctx);
|
||||
}
|
||||
|
||||
JSTLSSocket::~JSTLSSocket()
|
||||
@@ -1126,9 +1150,33 @@ void JSTLSSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
|
||||
visitor.append(thisObject->m_data);
|
||||
visitor.append(thisObject->m_remoteAddress);
|
||||
visitor.addOpaqueRoot(thisObject->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSTLSSocket);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSTLSSocket::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSTLSSocket* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_data);
|
||||
visitor.append(thisObject->m_remoteAddress);
|
||||
visitor.addOpaqueRoot(this->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTLSSocket);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSTLSSocket::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSTLSSocket* thisObject = jsCast<JSTLSSocket*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTLSSocket);
|
||||
class JSListenerPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -1578,6 +1626,29 @@ void JSListener::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSListener);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSListener::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSListener* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_hostname);
|
||||
visitor.append(thisObject->m_unix);
|
||||
;
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSListener);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSListener::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSListener* thisObject = jsCast<JSListener*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSListener);
|
||||
class JSSubprocessPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -2047,9 +2118,9 @@ extern "C" EncodedJSValue Subprocess__getConstructor(Zig::GlobalObject* globalOb
|
||||
}
|
||||
|
||||
extern "C" bool Subprocess__hasPendingActivity(void* ptr);
|
||||
bool JSSubprocess::internalHasPendingActivity()
|
||||
bool JSSubprocess::hasPendingActivity(void* ctx)
|
||||
{
|
||||
return Subprocess__hasPendingActivity(m_ctx);
|
||||
return Subprocess__hasPendingActivity(ctx);
|
||||
}
|
||||
|
||||
JSSubprocess::~JSSubprocess()
|
||||
@@ -2134,9 +2205,34 @@ void JSSubprocess::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
visitor.append(thisObject->m_stderr);
|
||||
visitor.append(thisObject->m_stdin);
|
||||
visitor.append(thisObject->m_stdout);
|
||||
visitor.addOpaqueRoot(thisObject->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSSubprocess);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSSubprocess::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSSubprocess* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_stderr);
|
||||
visitor.append(thisObject->m_stdin);
|
||||
visitor.append(thisObject->m_stdout);
|
||||
visitor.addOpaqueRoot(this->wrapped());
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSSubprocess);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSSubprocess::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSSubprocess* thisObject = jsCast<JSSubprocess*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSSubprocess);
|
||||
class JSSHA1Prototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -5264,6 +5360,29 @@ void JSServerWebSocket::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSServerWebSocket);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSServerWebSocket::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSServerWebSocket* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_data);
|
||||
visitor.append(thisObject->m_remoteAddress);
|
||||
;
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSServerWebSocket);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSServerWebSocket::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSServerWebSocket* thisObject = jsCast<JSServerWebSocket*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSServerWebSocket);
|
||||
class JSExpectPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -6301,6 +6420,29 @@ void JSExpect::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSExpect);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSExpect::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSExpect* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
visitor.append(thisObject->m_capturedValue);
|
||||
visitor.append(thisObject->m_resultValue);
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSExpect);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSExpect::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSExpect* thisObject = jsCast<JSExpect*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSExpect);
|
||||
class JSTextDecoderPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -6642,6 +6784,28 @@ void JSTextDecoder::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSTextDecoder);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSTextDecoder::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSTextDecoder* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_encoding);
|
||||
;
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSTextDecoder);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSTextDecoder::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSTextDecoder);
|
||||
class JSRequestPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -7267,6 +7431,30 @@ void JSRequest::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSRequest);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSRequest::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSRequest* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_body);
|
||||
visitor.append(thisObject->m_headers);
|
||||
visitor.append(thisObject->m_url);
|
||||
;
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSRequest);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSRequest::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSRequest* thisObject = jsCast<JSRequest*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSRequest);
|
||||
class JSResponsePrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
@@ -7857,6 +8045,31 @@ void JSResponse::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSResponse);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSResponse::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
JSResponse* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
|
||||
visitor.append(thisObject->m_body);
|
||||
visitor.append(thisObject->m_headers);
|
||||
visitor.append(thisObject->m_statusText);
|
||||
visitor.append(thisObject->m_url);
|
||||
;
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(JSResponse);
|
||||
|
||||
template<typename Visitor>
|
||||
void JSResponse::visitOutputConstraintsImpl(JSCell* cell, Visitor& visitor)
|
||||
{
|
||||
JSResponse* thisObject = jsCast<JSResponse*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(JSResponse);
|
||||
class JSBlobPrototype final : public JSC::JSNonFinalObject {
|
||||
public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
|
||||
@@ -66,21 +66,21 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
JSC::Weak<JSTCPSocket> 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<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<JSTCPSocket*>(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<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
@@ -92,6 +92,8 @@ public:
|
||||
}
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_data;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
|
||||
@@ -148,21 +150,21 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
JSC::Weak<JSTLSSocket> 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<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<JSTLSSocket*>(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<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
@@ -174,6 +176,8 @@ public:
|
||||
}
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_data;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
|
||||
@@ -229,6 +233,8 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_hostname;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_unix;
|
||||
@@ -285,21 +291,21 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
JSC::Weak<JSSubprocess> 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<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<JSSubprocess*>(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<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
@@ -311,6 +317,8 @@ public:
|
||||
}
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_stderr;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_stdin;
|
||||
@@ -767,6 +775,8 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_data;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_remoteAddress;
|
||||
@@ -822,6 +832,8 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_capturedValue;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_resultValue;
|
||||
@@ -877,6 +889,8 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_encoding;
|
||||
};
|
||||
@@ -931,6 +945,8 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_body;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
|
||||
@@ -987,6 +1003,8 @@ public:
|
||||
void finishCreation(JSC::VM&);
|
||||
|
||||
DECLARE_VISIT_CHILDREN;
|
||||
template<typename Visitor> void visitAdditionalChildren(Visitor&);
|
||||
DECLARE_VISIT_OUTPUT_CONSTRAINTS;
|
||||
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_body;
|
||||
mutable JSC::WriteBarrier<JSC::Unknown> m_headers;
|
||||
|
||||
@@ -908,47 +908,48 @@ function generateClassHeader(typeName, obj: ClassDefinition) {
|
||||
const DECLARE_VISIT_CHILDREN =
|
||||
values.length ||
|
||||
obj.estimatedSize ||
|
||||
obj.hasPendingActivity ||
|
||||
[...Object.values(klass), ...Object.values(proto)].find((a) => !!a.cache)
|
||||
? "DECLARE_VISIT_CHILDREN;"
|
||||
? "DECLARE_VISIT_CHILDREN;\ntemplate<typename Visitor> void visitAdditionalChildren(Visitor&);\nDECLARE_VISIT_OUTPUT_CONSTRAINTS;\n"
|
||||
: "";
|
||||
const sizeEstimator = obj.estimatedSize
|
||||
? "static size_t estimatedSize(JSCell* cell, VM& vm);"
|
||||
: "";
|
||||
|
||||
var weakOwner = "";
|
||||
var weakInit = "";
|
||||
|
||||
var weakInit = ``;
|
||||
if (obj.hasPendingActivity) {
|
||||
weakInit = `m_weakThis = JSC::Weak<${name}>(this, getOwner());`;
|
||||
weakOwner = `
|
||||
JSC::Weak<${name}> m_weakThis;
|
||||
bool internalHasPendingActivity();
|
||||
bool hasPendingActivity() {
|
||||
if (UNLIKELY(!m_ctx))
|
||||
return false;
|
||||
JSC::Weak<${name}> m_weakThis;
|
||||
|
||||
|
||||
return this->internalHasPendingActivity();
|
||||
static bool hasPendingActivity(void* ctx);
|
||||
|
||||
class Owner final : public JSC::WeakHandleOwner {
|
||||
public:
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor& visitor, const char** reason) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<${name}*>(handle.slot()->asCell());
|
||||
if (${name}::hasPendingActivity(controller->wrapped())) {
|
||||
if (UNLIKELY(reason))
|
||||
*reason = "has pending activity";
|
||||
return true;
|
||||
}
|
||||
|
||||
return visitor.containsOpaqueRoot(context);
|
||||
}
|
||||
void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
|
||||
static JSC::WeakHandleOwner* getOwner()
|
||||
{
|
||||
static NeverDestroyed<Owner> m_owner;
|
||||
return &m_owner.get();
|
||||
}
|
||||
|
||||
class Owner final : public JSC::WeakHandleOwner {
|
||||
public:
|
||||
bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void* context, JSC::AbstractSlotVisitor&, const char**) final
|
||||
{
|
||||
auto* controller = JSC::jsCast<${name}*>(handle.slot()->asCell());
|
||||
return controller->hasPendingActivity();
|
||||
}
|
||||
void finalize(JSC::Handle<JSC::Unknown>, void* context) final {}
|
||||
};
|
||||
|
||||
static JSC::WeakHandleOwner* getOwner()
|
||||
{
|
||||
static NeverDestroyed<Owner> m_owner;
|
||||
return &m_owner.get();
|
||||
}
|
||||
`;
|
||||
weakInit = `
|
||||
m_weakThis = JSC::Weak<${name}>(this, getOwner());
|
||||
`;
|
||||
}
|
||||
|
||||
return `
|
||||
class ${name} final : public JSC::JSDestructibleObject {
|
||||
public:
|
||||
@@ -1046,7 +1047,12 @@ function generateClassImpl(typeName, obj: ClassDefinition) {
|
||||
})
|
||||
.join("\n");
|
||||
var DEFINE_VISIT_CHILDREN = "";
|
||||
if (DEFINE_VISIT_CHILDREN_LIST.length || estimatedSize || values.length) {
|
||||
if (
|
||||
DEFINE_VISIT_CHILDREN_LIST.length ||
|
||||
estimatedSize ||
|
||||
values.length ||
|
||||
hasPendingActivity
|
||||
) {
|
||||
DEFINE_VISIT_CHILDREN = `
|
||||
template<typename Visitor>
|
||||
void ${name}::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
@@ -1063,9 +1069,33 @@ visitor.reportExtraMemoryVisited(${symbolName(obj.name, "estimatedSize")}(ptr));
|
||||
: ""
|
||||
}
|
||||
${DEFINE_VISIT_CHILDREN_LIST}
|
||||
${hasPendingActivity ? `visitor.addOpaqueRoot(thisObject->wrapped());` : ""}
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(${name});
|
||||
|
||||
template<typename Visitor>
|
||||
void ${name}::visitAdditionalChildren(Visitor& visitor)
|
||||
{
|
||||
${name}* thisObject = this;
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
${values}
|
||||
${DEFINE_VISIT_CHILDREN_LIST}
|
||||
${hasPendingActivity ? "visitor.addOpaqueRoot(this->wrapped())" : ""};
|
||||
}
|
||||
|
||||
DEFINE_VISIT_ADDITIONAL_CHILDREN(${name});
|
||||
|
||||
template<typename Visitor>
|
||||
void ${name}::visitOutputConstraintsImpl(JSCell *cell, Visitor& visitor)
|
||||
{
|
||||
${name}* thisObject = jsCast<${name}*>(cell);
|
||||
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
|
||||
thisObject->visitAdditionalChildren<Visitor>(visitor);
|
||||
}
|
||||
|
||||
DEFINE_VISIT_OUTPUT_CONSTRAINTS(${name});
|
||||
|
||||
`.trim();
|
||||
}
|
||||
|
||||
@@ -1074,8 +1104,8 @@ DEFINE_VISIT_CHILDREN(${name});
|
||||
if (hasPendingActivity) {
|
||||
output += `
|
||||
extern "C" bool ${symbolName(typeName, "hasPendingActivity")}(void* ptr);
|
||||
bool ${name}::internalHasPendingActivity() {
|
||||
return ${symbolName(typeName, "hasPendingActivity")}(m_ctx);
|
||||
bool ${name}::hasPendingActivity(void* ctx) {
|
||||
return ${symbolName(typeName, "hasPendingActivity")}(ctx);
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user