From 726f2cfb11a15b6a152c1ca1b3fc55cd23096a24 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 16 Nov 2024 18:45:19 -0700 Subject: [PATCH] LibGC: Expose deferred state publicly, annotate DeferGC for Swift While we don't want arbitrary callers deferring GC, we do want deferral to be available to the Swift. In order for Swift to understand the RAII nature of DeferGC, we need to mark it as non-copyable. --- Libraries/LibGC/DeferGC.h | 3 ++- Libraries/LibGC/Heap.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGC/DeferGC.h b/Libraries/LibGC/DeferGC.h index addeed7a53a..39ae6fc0319 100644 --- a/Libraries/LibGC/DeferGC.h +++ b/Libraries/LibGC/DeferGC.h @@ -6,6 +6,7 @@ #pragma once +#include #include namespace GC { @@ -25,6 +26,6 @@ public: private: Heap& m_heap; -}; +} SWIFT_NONCOPYABLE; } diff --git a/Libraries/LibGC/Heap.h b/Libraries/LibGC/Heap.h index 89e31d998d2..ecadf745ad7 100644 --- a/Libraries/LibGC/Heap.h +++ b/Libraries/LibGC/Heap.h @@ -73,6 +73,8 @@ public: void uproot_cell(Cell* cell); + bool is_gc_deferred() const { return m_gc_deferrals > 0; } + private: friend class MarkingVisitor; friend class GraphConstructorVisitor;