[gjs] Replace context with runtime in GC Functions/Callback.



commit 14c6611bb645c98eaa3906974c6d0eaf86f32aac
Author: Tim Lunn <tim feathertop org>
Date:   Sat Jan 12 09:11:50 2013 +1100

    Replace context with runtime in GC Functions/Callback.
    
    Upstream are moving toward each runtime only having a single context. As such
    all GC functions (except JS_MaybeGC), now take runtime as the argument, rather than
    the context.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690982

 gjs/context.c    |   11 ++++++-----
 gjs/jsapi-util.c |    2 +-
 modules/system.c |    2 +-
 test/gjs-tests.c |    2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/gjs/context.c b/gjs/context.c
index 7a6a774..20af947 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -56,7 +56,7 @@ static void     gjs_context_set_property      (GObject               *object,
                                                   guint                  prop_id,
                                                   const GValue          *value,
                                                   GParamSpec            *pspec);
-static JSBool gjs_on_context_gc (JSContext *cx,
+static JSBool gjs_on_context_gc (JSRuntime *rt,
                                  JSGCStatus status);
 
 struct _GjsContext {
@@ -665,7 +665,7 @@ gjs_context_constructor (GType                  type,
     js_context->profiler = gjs_profiler_new(js_context->runtime);
 
     if (js_context->gc_notifications_enabled)
-        JS_SetGCCallback(js_context->context, gjs_on_context_gc);
+        JS_SetGCCallback(js_context->runtime, gjs_on_context_gc);
 
     JS_EndRequest(js_context->context);
 
@@ -870,7 +870,7 @@ gjs_context_maybe_gc (GjsContext  *context)
 void
 gjs_context_gc (GjsContext  *context)
 {
-    JS_GC(context->context);
+    JS_GC(context->runtime);
 }
 
 static gboolean
@@ -886,10 +886,11 @@ gjs_context_idle_emit_gc (gpointer data)
 }
 
 static JSBool
-gjs_on_context_gc (JSContext *cx,
+gjs_on_context_gc (JSRuntime *rt,
                    JSGCStatus status)
 {
-    GjsContext *gjs_context = JS_GetContextPrivate(cx);
+    JSContext *context = JS_GetRuntimePrivate(rt);
+    GjsContext *gjs_context = JS_GetContextPrivate(context);
 
     if (status == JSGC_END) {
         if (gjs_context->idle_emit_gc_id == 0)
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 7be0107..e05b92e 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -1186,7 +1186,7 @@ gjs_maybe_gc (JSContext *context)
          */
         if (rss_size > linux_rss_trigger) {
             linux_rss_trigger = (gulong) MIN(G_MAXULONG, rss_size * 1.25);
-            JS_GC(context);
+            JS_GC(JS_GetRuntime(context));
         } else if (rss_size < (0.75 * linux_rss_trigger)) {
             /* If we've shrunk by 75%, lower the trigger */
             linux_rss_trigger = (rss_size * 1.25);
diff --git a/modules/system.c b/modules/system.c
index 6b68b77..a766646 100644
--- a/modules/system.c
+++ b/modules/system.c
@@ -102,7 +102,7 @@ gjs_gc(JSContext *context,
     jsval *argv = JS_ARGV(cx, vp);
     if (!gjs_parse_args(context, "gc", "", argc, argv))
         return JS_FALSE;
-    JS_GC(context);
+    JS_GC(JS_GetRuntime(context));
     return JS_TRUE;
 }
 
diff --git a/test/gjs-tests.c b/test/gjs-tests.c
index b92b33e..8fb67d3 100644
--- a/test/gjs-tests.c
+++ b/test/gjs-tests.c
@@ -111,7 +111,7 @@ gjstest_test_func_gjs_jsapi_util_array(void)
         gjs_rooted_array_append(context, array, value);
     }
 
-    JS_GC(context);
+    JS_GC(JS_GetRuntime(context));
 
     for (i = 0; i < N_ELEMS; i++) {
         char *ascii;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]