[gjs: 2/5] context: Add more debug logging to dispose
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/5] context: Add more debug logging to dispose
- Date: Mon, 19 Feb 2018 04:42:32 +0000 (UTC)
commit 2be0bb91e6fe559281b31e792e4b675ee4af703f
Author: Philip Chimento <philip chimento gmail com>
Date: Sat Feb 17 23:18:28 2018 -0800
context: Add more debug logging to dispose
When debugging problems that happen during shutdown, it's better to see
when each phase of the shutdown is occurring. That way, when another
thread interferes, it's easier to tell what is happening when.
gjs/context.cpp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 39850a3..22a0638 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -257,23 +257,27 @@ warn_about_unhandled_promise_rejections(GjsContext *gjs_context)
static void
gjs_context_dispose(GObject *object)
{
+ gjs_debug(GJS_DEBUG_CONTEXT, "JS shutdown sequence");
+
GjsContext *js_context;
js_context = GJS_CONTEXT(object);
/* Profiler must be stopped and freed before context is shut down */
+ gjs_debug(GJS_DEBUG_CONTEXT, "Stopping profiler");
if (js_context->profiler)
g_clear_pointer(&js_context->profiler, _gjs_profiler_free);
/* Run dispose notifications first, so that anything releasing
* references in response to this can still get garbage collected */
+ gjs_debug(GJS_DEBUG_CONTEXT,
+ "Notifying reference holders of GjsContext dispose");
G_OBJECT_CLASS(gjs_context_parent_class)->dispose(object);
if (js_context->context != NULL) {
gjs_debug(GJS_DEBUG_CONTEXT,
- "Destroying JS context");
-
+ "Checking unhandled promise rejections");
warn_about_unhandled_promise_rejections(js_context);
JS_BeginRequest(js_context->context);
@@ -282,34 +286,42 @@ gjs_context_dispose(GObject *object)
* that we may not have the JS_GetPrivate() to access the
* context
*/
+ gjs_debug(GJS_DEBUG_CONTEXT, "Final triggered GC");
JS_GC(js_context->context);
JS_EndRequest(js_context->context);
+ gjs_debug(GJS_DEBUG_CONTEXT, "Destroying JS context");
js_context->destroying = true;
/* Now, release all native objects, to avoid recursion between
* the JS teardown and the C teardown. The JSObject proxies
* still exist, but point to NULL.
*/
+ gjs_debug(GJS_DEBUG_CONTEXT, "Releasing all native objects");
gjs_object_prepare_shutdown();
+ gjs_debug(GJS_DEBUG_CONTEXT, "Disabling auto GC");
if (js_context->auto_gc_id > 0) {
g_source_remove (js_context->auto_gc_id);
js_context->auto_gc_id = 0;
}
+ gjs_debug(GJS_DEBUG_CONTEXT, "Ending trace on global object");
JS_RemoveExtraGCRootsTracer(js_context->context, gjs_context_tracer,
js_context);
js_context->global = NULL;
+ gjs_debug(GJS_DEBUG_CONTEXT, "Unrooting atoms");
for (auto& root : js_context->const_strings)
delete root;
+ gjs_debug(GJS_DEBUG_CONTEXT, "Freeing allocated resources");
delete js_context->job_queue;
/* Tear down JS */
JS_DestroyContext(js_context->context);
js_context->context = NULL;
+ gjs_debug(GJS_DEBUG_CONTEXT, "JS context destroyed");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]