Gentoo Archives: gentoo-commits

From: "Pacho Ramos (pacho)" <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-libs/gjs/files: gjs-1.40.1-ratelimit-rss.patch gjs-1.40.1-ownership-transfer.patch
Date: Fri, 26 Sep 2014 10:39:26
Message-Id: 20140926103922.B1614650D@oystercatcher.gentoo.org
1 pacho 14/09/26 10:39:22
2
3 Added: gjs-1.40.1-ratelimit-rss.patch
4 gjs-1.40.1-ownership-transfer.patch
5 Log:
6 Apply some upstream fixes that also prevent gjs crashes, bug #523608 by Serge Gavrilov
7
8 (Portage version: 2.2.12/cvs/Linux x86_64, signed Manifest commit with key A188FBD4)
9
10 Revision Changes Path
11 1.1 dev-libs/gjs/files/gjs-1.40.1-ratelimit-rss.patch
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/gjs/files/gjs-1.40.1-ratelimit-rss.patch?rev=1.1&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/gjs/files/gjs-1.40.1-ratelimit-rss.patch?rev=1.1&content-type=text/plain
15
16 Index: gjs-1.40.1-ratelimit-rss.patch
17 ===================================================================
18 From 791b1a33424897549f487eb75a80f13c4f94437a Mon Sep 17 00:00:00 2001
19 From: Giovanni Campagna <gcampagna@×××××××××.org>
20 Date: Fri, 11 Apr 2014 18:38:57 +0200
21 Subject: Ratelimit RSS-triggered GCs
22
23 When loading a lot of data in memory (for example in the shell
24 opening the overview, which loads all the desktop files and icons)
25 the RSS can increase a lot, so we would trigger GCs continously
26 without any hope of freeing memory, so ratelimit full GCs to at
27 most one every 5 frames.
28
29 https://bugzilla.gnome.org/show_bug.cgi?id=728048
30
31 --- a/gjs/jsapi-util.cpp
32 +++ b/gjs/jsapi-util.cpp
33 @@ -1176,6 +1176,7 @@
34 }
35
36 static gulong linux_rss_trigger;
37 +static gint64 last_gc_time;
38 #endif
39
40 /**
41 @@ -1193,6 +1194,13 @@
42 /* We initiate a GC if VM or RSS has grown by this much */
43 gulong vmsize;
44 gulong rss_size;
45 + gint64 now;
46 +
47 + /* We rate limit GCs to at most one per 5 frames.
48 + One frame is 16666 microseconds (1000000/60)*/
49 + now = g_get_monotonic_time();
50 + if (now - last_gc_time < 5 * 16666)
51 + return;
52
53 _linux_get_self_process_size (&vmsize, &rss_size);
54
55 @@ -1209,6 +1217,7 @@
56 if (rss_size > linux_rss_trigger) {
57 linux_rss_trigger = (gulong) MIN(G_MAXULONG, rss_size * 1.25);
58 JS_GC(JS_GetRuntime(context));
59 + last_gc_time = now;
60 } else if (rss_size < (0.75 * linux_rss_trigger)) {
61 /* If we've shrunk by 75%, lower the trigger */
62 linux_rss_trigger = (rss_size * 1.25);
63
64
65
66 1.1 dev-libs/gjs/files/gjs-1.40.1-ownership-transfer.patch
67
68 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/gjs/files/gjs-1.40.1-ownership-transfer.patch?rev=1.1&view=markup
69 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/gjs/files/gjs-1.40.1-ownership-transfer.patch?rev=1.1&content-type=text/plain
70
71 Index: gjs-1.40.1-ownership-transfer.patch
72 ===================================================================
73 From a432e83f967f3d15ef14cfa8040f868af13d1e74 Mon Sep 17 00:00:00 2001
74 From: Giovanni Campagna <gcampagna@×××××××××.org>
75 Date: Tue, 6 May 2014 19:03:15 +0200
76 Subject: function: respect ownership transfer of instance parameters
77
78 When calling a method that is (transfer full) on the instance
79 parameter we need to make an extra ref/copy.
80
81 https://bugzilla.gnome.org/show_bug.cgi?id=729545
82
83 diff --git a/gi/function.cpp b/gi/function.cpp
84 index 859ea44..792778c 100644
85 --- a/gi/function.cpp
86 +++ b/gi/function.cpp
87 @@ -543,6 +543,7 @@ gjs_fill_method_instance (JSContext *context,
88 GIBaseInfo *container = g_base_info_get_container((GIBaseInfo *) function->info);
89 GIInfoType type = g_base_info_get_type(container);
90 GType gtype = g_registered_type_info_get_g_type ((GIRegisteredTypeInfo *)container);
91 + GITransfer transfer = g_callable_info_get_instance_ownership_transfer (function->info);
92
93 switch (type) {
94 case GI_INFO_TYPE_STRUCT:
95 @@ -553,6 +554,8 @@ gjs_fill_method_instance (JSContext *context,
96 return JS_FALSE;
97
98 out_arg->v_pointer = gjs_gerror_from_error(context, obj);
99 + if (transfer == GI_TRANSFER_EVERYTHING)
100 + out_arg->v_pointer = g_error_copy ((GError*) out_arg->v_pointer);
101 } else {
102 if (!gjs_typecheck_boxed(context, obj,
103 container, gtype,
104 @@ -560,6 +563,14 @@ gjs_fill_method_instance (JSContext *context,
105 return JS_FALSE;
106
107 out_arg->v_pointer = gjs_c_struct_from_boxed(context, obj);
108 + if (transfer == GI_TRANSFER_EVERYTHING) {
109 + if (gtype != G_TYPE_NONE)
110 + out_arg->v_pointer = g_boxed_copy (gtype, out_arg->v_pointer);
111 + else {
112 + gjs_throw (context, "Cannot transfer ownership of instance argument for non boxed structure");
113 + return JS_FALSE;
114 + }
115 + }
116 }
117 break;
118
119 @@ -569,6 +580,8 @@ gjs_fill_method_instance (JSContext *context,
120 return JS_FALSE;
121
122 out_arg->v_pointer = gjs_c_union_from_union(context, obj);
123 + if (transfer == GI_TRANSFER_EVERYTHING)
124 + out_arg->v_pointer = g_boxed_copy (gtype, out_arg->v_pointer);
125 break;
126
127 case GI_INFO_TYPE_OBJECT:
128 @@ -577,10 +590,14 @@ gjs_fill_method_instance (JSContext *context,
129 if (!gjs_typecheck_object(context, obj, gtype, JS_TRUE))
130 return JS_FALSE;
131 out_arg->v_pointer = gjs_g_object_from_object(context, obj);
132 + if (transfer == GI_TRANSFER_EVERYTHING)
133 + g_object_ref (out_arg->v_pointer);
134 } else if (gjs_typecheck_is_fundamental(context, obj, JS_FALSE)) {
135 if (!gjs_typecheck_fundamental(context, obj, gtype, JS_TRUE))
136 return JS_FALSE;
137 out_arg->v_pointer = gjs_g_fundamental_from_object(context, obj);
138 + if (transfer == GI_TRANSFER_EVERYTHING)
139 + gjs_fundamental_ref (context, out_arg->v_pointer);
140 } else {
141 gjs_throw_custom(context, "TypeError",
142 "%s.%s is not an object instance neither a fundamental instance of a supported type",
143 --
144 cgit v0.10.1