[gjs/wip/mozjs-188: 10/10] Replace context with runtime in GC Functions/Callback.



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

    Replace context with runtime in GC Functions/Callback.
    
    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 ce3d3cb..a0566ec 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -54,7 +54,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 {
@@ -673,7 +673,7 @@ gjs_context_constructor (GType                  type,
     }
 
     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);
 
@@ -878,7 +878,7 @@ gjs_context_maybe_gc (GjsContext  *context)
 void
 gjs_context_gc (GjsContext  *context)
 {
-    JS_GC(context->context);
+    JS_GC(context->runtime);
 }
 
 static gboolean
@@ -894,10 +894,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 7ee9a2f..0752649 100644
--- a/modules/system.c
+++ b/modules/system.c
@@ -100,7 +100,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]