From c5d637fbb15874caa0d9669ac8cc79912ed4d5d9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 9 Apr 2022 19:53:17 -0700 Subject: WIP --- src/javascript/jsc/bindings/ZigGlobalObject.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/javascript/jsc/bindings/ZigGlobalObject.cpp') diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index a2e4fc42a..1bc03ff50 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -87,6 +87,7 @@ #include "Process.h" #include "JavaScriptCore/RemoteInspectorServer.h" +#include "JSDOMGuardedObject.h" using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; @@ -287,6 +288,7 @@ GlobalObject::GlobalObject(JSC::VM& vm, JSC::Structure* structure) , m_constructors(makeUnique()) , m_world(WebCore::DOMWrapperWorld::create(vm, WebCore::DOMWrapperWorld::Type::Normal)) , m_worldIsNormal(true) + , m_guardedObjects() { m_scriptExecutionContext = new WebCore::ScriptExecutionContext(&vm, this); @@ -482,6 +484,16 @@ JSC_DEFINE_CUSTOM_GETTER(property_lazyProcessGetter, return JSC::JSValue::encode(JSC::JSValue(process)); } +void JSDOMGlobalObject::clearDOMGuardedObjects() const +{ + // No locking is necessary here since we are not directly modifying the returned container. + // Calling JSDOMGuardedObject::clear() will however modify the guarded objects container but + // it will grab the lock as needed. + auto guardedObjectsCopy = guardedObjects(); + for (auto& guarded : guardedObjectsCopy) + guarded->clear(); +} + static JSC_DECLARE_HOST_FUNCTION(functionQueueMicrotask); static JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask, @@ -896,8 +908,8 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) for (auto& structure : thisObject->m_structures.values()) visitor.append(structure); - // for (auto& guarded : thisObject->m_guardedObjects) - // guarded->visitAggregate(visitor); + for (auto& guarded : thisObject->m_guardedObjects) + guarded->visitAggregate(visitor); } for (auto& constructor : thisObject->constructors().array()) -- cgit v1.2.3