[gjs/ewlsh/fix-barried-get-in-rooting] Enqueue toggle ups when the heap is collecting
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/ewlsh/fix-barried-get-in-rooting] Enqueue toggle ups when the heap is collecting
- Date: Wed, 28 Jul 2021 06:09:32 +0000 (UTC)
commit 5a5ba15a384d472af09cf2ea506ec5898bd0f636
Author: Evan Welsh <contact evanwelsh com>
Date: Tue Jul 27 21:59:04 2021 -0700
Enqueue toggle ups when the heap is collecting
gi/object.cpp | 4 +++-
gjs/jsapi-util-root.h | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gi/object.cpp b/gi/object.cpp
index 3bfa42e8..a834a5be 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -28,6 +28,7 @@
#include <js/ComparisonOperators.h>
#include <js/GCAPI.h> // for JS_AddWeakPointerCompartmentCallback
#include <js/GCVector.h> // for MutableWrappedPtrOperations
+#include <js/HeapAPI.h>
#include <js/MemoryFunctions.h> // for AddAssociatedMemory, RemoveAssoci...
#include <js/PropertyDescriptor.h> // for JSPROP_PERMANENT, JSPROP_READONLY
#include <js/TypeDecls.h>
@@ -1353,7 +1354,8 @@ void ObjectInstance::wrapped_gobj_toggle_notify(void* instance, GObject*,
* The JSObject associated with the gobject is not rooted,
* but it needs to be. We'll root it.
*/
- if (is_main_thread && !anything_queued) {
+ if (is_main_thread && !anything_queued &&
+ !JS::RuntimeHeapIsCollecting()) {
self->toggle_up();
} else {
toggle_queue->enqueue(self, ToggleQueue::UP, toggle_handler);
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index cf6369a7..5433a09b 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -276,7 +276,7 @@ class GjsMaybeOwned {
/* Prevent the thing from being garbage collected while it is in neither
* m_heap nor m_root */
- JS::Rooted<T> thing(cx, m_heap.unbarrieredGet());
+ JS::Rooted<T> thing(cx, m_heap);
reset();
root(cx, thing, notify, data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]