Accepting request 605077 from GNOME:Factory

Add patches lined up in the next unstable release aswell.

- Update to version 1.52.3:
  + Include calc.js example from Seed (glgo#gnome/gjs#130).
  + CI: Un-pin the Fedora Docker image (glgo#gnome/gjs#141,
    (glgo#gnome/gjs#131).
  + Reduce overhead of wrapped objects (glgo#gnome/gjs#142,
    (glgo#gnome/gjs#121).
  + Various CI changes (glgo#gnome/gjs#134, (glgo#gnome/gjs#136).
- Add gjs-Add-API-to-force-GC-schedule.patch: context: Add API to
  force GC schedule. There are situations where we cannot run the
  GC right away, but we also cannot ignore the need of running it.
  For those cases, add a new private function that forces GC to
  happen on idle (glgo"GNOME/gjs#140).
- Add gjs-Queue-forced-GC.patch: object: Queue a forced GC when
  toggling down. Since we cannot know how many more wrapped
  GObjects are going be marked for garbage collection after the
  owner is destroyed, always queue a garbage collection when a
  toggle reference goes down (glgo"GNOME/gjs#140). (forwarded request 604654 from iznogood)

OBS-URL: https://build.opensuse.org/request/show/605077
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gjs?expand=0&rev=74
This commit is contained in:
Dominique Leuenberger 2018-05-10 13:45:38 +00:00 committed by Git OBS Bridge
commit e5d87bbcd3
6 changed files with 248 additions and 5 deletions

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:28bd9c9afabf934f43c55d97fa693a2f207c866c70eeba089a2306d3af47a003
size 625616

3
gjs-1.52.3.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ce21d8a83f6077b011b8834c4936281be65b2b62387f0745c3eb9adf780996fc
size 626512

View File

@ -0,0 +1,91 @@
From 090298512b12e76929bf8bd14dccbfd355f78dce Mon Sep 17 00:00:00 2001
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Fri, 30 Mar 2018 21:37:37 -0300
Subject: [PATCH] context: Add API to force GC schedule
There are situations where we cannot run the
GC right away, but we also cannot ignore the
need of running it.
For those cases, add a new private function
that forces GC to happen on idle.
---
gjs/context-private.h | 2 ++
gjs/context.cpp | 29 +++++++++++++++++++++++++----
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/gjs/context-private.h b/gjs/context-private.h
index 6dbe669..c45c8d0 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -36,6 +36,8 @@ bool _gjs_context_destroying (GjsContext *js_context);
void _gjs_context_schedule_gc_if_needed (GjsContext *js_context);
+void _gjs_context_schedule_gc (GjsContext *js_context);
+
void _gjs_context_exit(GjsContext *js_context,
uint8_t exit_code);
diff --git a/gjs/context.cpp b/gjs/context.cpp
index c509943..77d7eaa 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -90,6 +90,7 @@ struct _GjsContext {
uint8_t exit_code;
guint auto_gc_id;
+ bool force_gc;
std::array<JS::PersistentRootedId*, GJS_STRING_LAST> const_strings;
@@ -592,22 +593,42 @@ trigger_gc_if_needed (gpointer user_data)
{
GjsContext *js_context = GJS_CONTEXT(user_data);
js_context->auto_gc_id = 0;
- gjs_gc_if_needed(js_context->context);
+
+ if (js_context->force_gc)
+ JS_GC(js_context->context);
+ else
+ gjs_gc_if_needed(js_context->context);
+
return G_SOURCE_REMOVE;
}
-void
-_gjs_context_schedule_gc_if_needed (GjsContext *js_context)
+
+static void
+_gjs_context_schedule_gc_internal (GjsContext *js_context,
+ bool force_gc)
{
if (js_context->auto_gc_id > 0)
- return;
+ g_source_remove(js_context->auto_gc_id);
+ js_context->force_gc = force_gc;
js_context->auto_gc_id = g_idle_add_full(G_PRIORITY_LOW,
trigger_gc_if_needed,
js_context, NULL);
}
void
+_gjs_context_schedule_gc (GjsContext *js_context)
+{
+ _gjs_context_schedule_gc_internal(js_context, true);
+}
+
+void
+_gjs_context_schedule_gc_if_needed (GjsContext *js_context)
+{
+ _gjs_context_schedule_gc_internal(js_context, false);
+}
+
+void
_gjs_context_exit(GjsContext *js_context,
uint8_t exit_code)
{
--
libgit2 0.27.0

123
gjs-Queue-forced-GC.patch Normal file
View File

@ -0,0 +1,123 @@
From e9e969553866b0dd29e78b41c0e372569405f46c Mon Sep 17 00:00:00 2001
From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
Date: Wed, 28 Mar 2018 19:21:52 -0300
Subject: [PATCH] object: Queue a forced GC when toggling down
During a GC, the collector asks each object which other
objects that it wants to hold on to so if there's an entire
section of the heap graph that's not connected to anything
else, and not reachable from the root set, then it can be
trashed all at once.
GObjects, however, don't work like that, there's only a
reference count but no notion of who owns the reference so,
a JS object that's proxying a GObject is unconditionally held
alive as long as the GObject has >1 references.
Since we cannot know how many more wrapped GObjects are going
be marked for garbage collection after the owner is destroyed,
always queue a garbage collection when a toggle reference goes
down.
Issue: #140
---
gi/object.cpp | 22 ++++++++++++++++++++++
gjs/context-private.h | 2 +-
gjs/context.cpp | 14 ++++++++------
3 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/gi/object.cpp b/gi/object.cpp
index 3fdfced..606a918 100644
--- a/gi/object.cpp
+++ b/gi/object.cpp
@@ -1001,8 +1001,30 @@ handle_toggle_down(GObject *gobj)
* collected by the GC
*/
if (priv->keep_alive.rooted()) {
+ GjsContext *context;
+
gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "Unrooting object");
priv->keep_alive.switch_to_unrooted();
+
+ /* During a GC, the collector asks each object which other
+ * objects that it wants to hold on to so if there's an entire
+ * section of the heap graph that's not connected to anything
+ * else, and not reachable from the root set, then it can be
+ * trashed all at once.
+ *
+ * GObjects, however, don't work like that, there's only a
+ * reference count but no notion of who owns the reference so,
+ * a JS object that's proxying a GObject is unconditionally held
+ * alive as long as the GObject has >1 references.
+ *
+ * Since we cannot know how many more wrapped GObjects are going
+ * be marked for garbage collection after the owner is destroyed,
+ * always queue a garbage collection when a toggle reference goes
+ * down.
+ */
+ context = gjs_context_get_current();
+ if (!_gjs_context_destroying(context))
+ _gjs_context_schedule_gc(context);
}
}
diff --git a/gjs/context-private.h b/gjs/context-private.h
index c45c8d0..49c0cf9 100644
--- a/gjs/context-private.h
+++ b/gjs/context-private.h
@@ -36,7 +36,7 @@ bool _gjs_context_destroying (GjsContext *js_context);
void _gjs_context_schedule_gc_if_needed (GjsContext *js_context);
-void _gjs_context_schedule_gc (GjsContext *js_context);
+void _gjs_context_schedule_gc(GjsContext *js_context);
void _gjs_context_exit(GjsContext *js_context,
uint8_t exit_code);
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 77d7eaa..a2ce34a 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -599,31 +599,33 @@ trigger_gc_if_needed (gpointer user_data)
else
gjs_gc_if_needed(js_context->context);
+ js_context->force_gc = false;
+
return G_SOURCE_REMOVE;
}
static void
-_gjs_context_schedule_gc_internal (GjsContext *js_context,
- bool force_gc)
+_gjs_context_schedule_gc_internal(GjsContext *js_context,
+ bool force_gc)
{
if (js_context->auto_gc_id > 0)
- g_source_remove(js_context->auto_gc_id);
+ return;
- js_context->force_gc = force_gc;
+ js_context->force_gc |= force_gc;
js_context->auto_gc_id = g_idle_add_full(G_PRIORITY_LOW,
trigger_gc_if_needed,
js_context, NULL);
}
void
-_gjs_context_schedule_gc (GjsContext *js_context)
+_gjs_context_schedule_gc(GjsContext *js_context)
{
_gjs_context_schedule_gc_internal(js_context, true);
}
void
-_gjs_context_schedule_gc_if_needed (GjsContext *js_context)
+_gjs_context_schedule_gc_if_needed(GjsContext *js_context)
{
_gjs_context_schedule_gc_internal(js_context, false);
}
--
libgit2 0.27.0

View File

@ -1,3 +1,28 @@
-------------------------------------------------------------------
Sun May 6 21:21:29 UTC 2018 - bjorn.lie@gmail.com
- Update to version 1.52.3:
+ Include calc.js example from Seed (glgo#gnome/gjs#130).
+ CI: Un-pin the Fedora Docker image (glgo#gnome/gjs#141,
(glgo#gnome/gjs#131).
+ Reduce overhead of wrapped objects (glgo#gnome/gjs#142,
(glgo#gnome/gjs#121).
+ Various CI changes (glgo#gnome/gjs#134, (glgo#gnome/gjs#136).
-------------------------------------------------------------------
Mon Apr 30 06:19:07 UTC 2018 - bjorn.lie@gmail.com
- Add gjs-Add-API-to-force-GC-schedule.patch: context: Add API to
force GC schedule. There are situations where we cannot run the
GC right away, but we also cannot ignore the need of running it.
For those cases, add a new private function that forces GC to
happen on idle (glgo"GNOME/gjs#140).
- Add gjs-Queue-forced-GC.patch: object: Queue a forced GC when
toggling down. Since we cannot know how many more wrapped
GObjects are going be marked for garbage collection after the
owner is destroyed, always queue a garbage collection when a
toggle reference goes down (glgo"GNOME/gjs#140).
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Apr 18 19:07:35 UTC 2018 - bjorn.lie@gmail.com Wed Apr 18 19:07:35 UTC 2018 - bjorn.lie@gmail.com

View File

@ -17,13 +17,17 @@
Name: gjs Name: gjs
Version: 1.52.2 Version: 1.52.3
Release: 0 Release: 0
Summary: JavaScript bindings based on gobject-introspection and Mozilla Summary: JavaScript bindings based on gobject-introspection and Mozilla
License: MIT License: MIT
Group: Development/Libraries/GNOME Group: Development/Libraries/GNOME
URL: https://wiki.gnome.org/Projects/Gjs URL: https://wiki.gnome.org/Projects/Gjs
Source0: http://download.gnome.org/sources/gjs/1.52/%{name}-%{version}.tar.xz Source0: http://download.gnome.org/sources/gjs/1.52/%{name}-%{version}.tar.xz
# PATCH-FIX-UPSTREAM gjs-Add-API-to-force-GC-schedule.patch -- context: Add API to force GC schedule
Patch0: gjs-Add-API-to-force-GC-schedule.patch
# PATCH-FIX-UPSTREAM gjs-Queue-forced-GC.patch -- object: Queue a forced GC when toggling down
Patch1: gjs-Queue-forced-GC.patch
BuildRequires: gcc-c++ BuildRequires: gcc-c++
BuildRequires: mozjs52-devel BuildRequires: mozjs52-devel
BuildRequires: pkgconfig BuildRequires: pkgconfig
@ -83,7 +87,7 @@ This module contains JavaScript bindings based on gobject-introspection and the
Mozilla SpiderMonkey JavaScript engine. Mozilla SpiderMonkey JavaScript engine.
%prep %prep
%setup -q %autosetup -p1
%build %build
%configure \ %configure \