[gjs] Remove obsolete calls to JS_EnterLocalRootScope() and JS_LeaveLocalRootScope()



commit 06e8b18a4b594bea9e3d6cdde70e4baac49273a8
Author: Sebastien Lafargue <slaf66 gmail com>
Date:   Tue Jul 16 19:19:13 2013 +0200

    Remove obsolete calls to JS_EnterLocalRootScope() and JS_LeaveLocalRootScope()
    
    Since SpiderMonkey 1.8.5, we no longer need to use this functions because of
    Garbage collector conservative stack scanner
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704343

 doc/SpiderMonkey_Memory.txt |    9 ---------
 gjs/context.c               |    4 ----
 gjs/jsapi-util-error.c      |    4 ----
 gjs/jsapi-util.c            |   24 ------------------------
 4 files changed, 0 insertions(+), 41 deletions(-)
---
diff --git a/doc/SpiderMonkey_Memory.txt b/doc/SpiderMonkey_Memory.txt
index b17a88f..6ef57c6 100644
--- a/doc/SpiderMonkey_Memory.txt
+++ b/doc/SpiderMonkey_Memory.txt
@@ -83,7 +83,6 @@ If you do not immediately add the object to some other object so it's referenced
 
 # call JS_AddRoot() on its location (and JS_RemoveRoot() when done)
 # when defining a [http://developer.mozilla.org/en/docs/JSFunctionSpec JSFunctionSpec], ask for argv to have 
"extra local roots"
-# use [http://developer.mozilla.org/en/docs/JS_EnterLocalRootScope JS_EnterLocalRootScope()]
 
 === JSFunctionSpec and extra local roots ===
 
@@ -91,14 +90,6 @@ When SpiderMonkey is calling a native function, it will pass in an argv of jsval
 
 This is kind of a confusing and unreadable hack IMO, though it is probably efficient and thus justified in 
certain cases. I don't know really.
 
-=== JS_EnterLocalRootScope() ===
-
-[http://developer.mozilla.org/en/docs/JS_EnterLocalRootScope JS_EnterLocalRootScope()] causes SpiderMonkey 
to automatically root all newborns until you call JS_LeaveLocalRootScope(). Remember the default behavior is 
to root only the most recent newborn of each type. 
-
-The downside of JS_EnterLocalRootScope() is that if you start allocating tons of stuff while inside the 
local root scope, none of it will be collected until you JS_LeaveLocalRootScope(). Basically you're disabling 
garbage collection for anything you create. So this function should not be used in an overzealous way.
-
-You can nest JS_EnterLocalRootScope() calls, but must JS_LeaveLocalRootScope() a matching number of times. 
JS_EnterLocalRootScope() can fail so check its return value.
-
 Note that newborn roots are tracked as *values* while JS_AddRoot() tracks *locations*.
 
 == More tips ==
diff --git a/gjs/context.c b/gjs/context.c
index 844e906..120ae96 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -200,7 +200,6 @@ gjs_print_parse_args(JSContext *context,
     JS_BeginRequest(context);
 
     str = g_string_new("");
-    (void)JS_EnterLocalRootScope(context);
     for (n = 0; n < argc; ++n) {
         JSExceptionState *exc_state;
         JSString *jstr;
@@ -217,7 +216,6 @@ gjs_print_parse_args(JSContext *context,
 
         if (jstr != NULL) {
             if (!gjs_string_to_utf8(context, STRING_TO_JSVAL(jstr), &s)) {
-                JS_LeaveLocalRootScope(context);
                 JS_EndRequest(context);
                 g_string_free(str, TRUE);
                 return JS_FALSE;
@@ -228,7 +226,6 @@ gjs_print_parse_args(JSContext *context,
             if (n < (argc-1))
                 g_string_append_c(str, ' ');
         } else {
-            JS_LeaveLocalRootScope(context);
             JS_EndRequest(context);
             *buffer = g_string_free(str, TRUE);
             if (!*buffer)
@@ -237,7 +234,6 @@ gjs_print_parse_args(JSContext *context,
         }
 
     }
-    JS_LeaveLocalRootScope(context);
     *buffer = g_string_free(str, FALSE);
 
     JS_EndRequest(context);
diff --git a/gjs/jsapi-util-error.c b/gjs/jsapi-util-error.c
index 9813515..bb7e85b 100644
--- a/gjs/jsapi-util-error.c
+++ b/gjs/jsapi-util-error.c
@@ -75,8 +75,6 @@ gjs_throw_valist(JSContext       *context,
 
     result = JS_FALSE;
 
-    (void)JS_EnterLocalRootScope(context);
-
     if (!gjs_string_from_utf8(context, s, -1, &v_message)) {
         JS_ReportError(context, "Failed to copy exception string");
         goto out;
@@ -97,8 +95,6 @@ gjs_throw_valist(JSContext       *context,
 
  out:
 
-    JS_LeaveLocalRootScope(context);
-
     if (!result) {
         /* try just reporting it to error handler? should not
          * happen though pretty much
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index ca2f2a6..62b0510 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -212,11 +212,6 @@ gjs_define_string_array(JSContext   *context,
 
     JS_BeginRequest(context);
 
-    if (!JS_EnterLocalRootScope(context)) {
-        JS_EndRequest(context);
-        return JS_FALSE;
-    }
-
     if (array_length == -1)
         array_length = g_strv_length((char**)array_values);
 
@@ -238,8 +233,6 @@ gjs_define_string_array(JSContext   *context,
             array = NULL;
     }
 
-    JS_LeaveLocalRootScope(context);
-
     JS_EndRequest(context);
     return array;
 }
@@ -368,12 +361,6 @@ gjs_log_object_props(JSContext      *context,
 
     JS_BeginRequest(context);
 
-    /* We potentially create new strings, plus the property iterator,
-     * that could get collected as we go through this process. So
-     * create a local root scope.
-     */
-    (void)JS_EnterLocalRootScope(context);
-
     props_iter = JS_NewPropertyIterator(context, obj);
     if (props_iter == NULL) {
         gjs_log_exception(context);
@@ -410,7 +397,6 @@ gjs_log_object_props(JSContext      *context,
     }
 
  done:
-    JS_LeaveLocalRootScope(context);
     JS_EndRequest(context);
 }
 
@@ -429,8 +415,6 @@ gjs_explain_scope(JSContext  *context,
 
     JS_BeginRequest(context);
 
-    (void)JS_EnterLocalRootScope(context);
-
     gjs_debug(GJS_DEBUG_SCOPE,
               "  Context: %p %s",
               context,
@@ -462,8 +446,6 @@ gjs_explain_scope(JSContext  *context,
               chain->str);
     g_string_free(chain, TRUE);
 
-    JS_LeaveLocalRootScope(context);
-
     JS_EndRequest(context);
 }
 
@@ -756,11 +738,6 @@ gjs_date_from_time_t (JSContext *context, time_t time)
 
     JS_BeginRequest(context);
 
-    if (!JS_EnterLocalRootScope(context)) {
-        JS_EndRequest(context);
-        return JSVAL_VOID;
-    }
-
     if (!JS_GetClassObject(context, JS_GetGlobalObject(context), JSProto_Date,
                            &date_constructor))
         g_error("Failed to lookup Date prototype");
@@ -774,7 +751,6 @@ gjs_date_from_time_t (JSContext *context, time_t time)
     date = JS_New(context, JSVAL_TO_OBJECT (date_prototype), 1, args);
 
     result = OBJECT_TO_JSVAL(date);
-    JS_LeaveLocalRootScope(context);
     JS_EndRequest(context);
 
     return result;


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