diff options
author | 2022-04-09 19:53:17 -0700 | |
---|---|---|
committer | 2022-04-09 19:53:17 -0700 | |
commit | c5d637fbb15874caa0d9669ac8cc79912ed4d5d9 (patch) | |
tree | f20a9b0047ba763b0003a60032d6c4ae1f9dcb47 /src/javascript/jsc/bindings/ZigGlobalObject.cpp | |
parent | fb82e2bf86a13211f08b407c3ec80fc0db45a77c (diff) | |
download | bun-jarred/workers.tar.gz bun-jarred/workers.tar.zst bun-jarred/workers.zip |
Diffstat (limited to 'src/javascript/jsc/bindings/ZigGlobalObject.cpp')
-rw-r--r-- | src/javascript/jsc/bindings/ZigGlobalObject.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
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<WebCore::DOMConstructors>()) , 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()) |