summaryrefslogtreecommitdiff
path: root/gjs/context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gjs/context.cpp')
-rw-r--r--gjs/context.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/gjs/context.cpp b/gjs/context.cpp
index e5a01fcf..10a80a0c 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -61,7 +61,6 @@
#include <mozilla/UniquePtr.h>
#include "gi/closure.h" // for Closure::Ptr, Closure
-#include "gi/function.h"
#include "gi/object.h"
#include "gi/private.h"
#include "gi/repo.h"
@@ -794,7 +793,9 @@ void GjsContextPrivate::on_garbage_collection(JSGCStatus status, JS::GCReason re
// order to minimize the chances of objects having a pending toggle
// up queued when they are garbage collected.
gjs_object_clear_toggles();
- gjs_function_clear_async_closures();
+
+ m_async_closures.clear();
+ m_async_closures.shrink_to_fit();
break;
case JSGC_END:
if (m_profiler && m_gc_begin_time != 0) {
@@ -1089,6 +1090,14 @@ void GjsContextPrivate::unregister_unhandled_promise_rejection(uint64_t id) {
"previously marked as unhandled", erased == 1));
}
+void GjsContextPrivate::async_closure_enqueue_for_gc(Gjs::Closure* trampoline) {
+ // Because we can't free the mmap'd data for a callback
+ // while it's in use, this list keeps track of ones that
+ // will be freed the next time gc happens
+ g_assert(!trampoline->context() || trampoline->context() == m_cx);
+ m_async_closures.emplace_back(trampoline);
+}
+
/**
* gjs_context_maybe_gc:
* @context: a #GjsContext