[gjs/wip/ptomato/mozjs52: 19/36] js: Adapt to new JS::TraceEdge<T> API



commit a3d22db2918ba1a849afb5f567d2952505c5f851
Author: Philip Chimento <philip chimento gmail com>
Date:   Mon May 1 22:30:16 2017 -0700

    js: Adapt to new JS::TraceEdge<T> API
    
    Replacing the old JS_CallFooTracer() API is a new C++ JS::TraceEdge<T>()
    function. It works the same, but is templated. The old API will be going
    away in SpiderMonkey 52.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784196

 gi/boxed.cpp          |    8 ++++----
 gi/fundamental.cpp    |    4 ++--
 gjs/context.cpp       |    2 +-
 gjs/coverage.cpp      |    3 ++-
 gjs/jsapi-util-root.h |   24 ++----------------------
 5 files changed, 11 insertions(+), 30 deletions(-)
---
diff --git a/gi/boxed.cpp b/gi/boxed.cpp
index ae5a6ff..810871b 100644
--- a/gi/boxed.cpp
+++ b/gi/boxed.cpp
@@ -904,10 +904,10 @@ boxed_trace(JSTracer *tracer,
     if (priv == NULL)
         return;
 
-    JS_CallIdTracer(tracer, &priv->zero_args_constructor_name,
-                    "Boxed::zero_args_constructor_name");
-    JS_CallIdTracer(tracer, &priv->default_constructor_name,
-                    "Boxed::default_constructor_name");
+    JS::TraceEdge<jsid>(tracer, &priv->zero_args_constructor_name,
+                        "Boxed::zero_args_constructor_name");
+    JS::TraceEdge<jsid>(tracer, &priv->default_constructor_name,
+                        "Boxed::default_constructor_name");
 }
 
 /* The bizarre thing about this vtable is that it applies to both
diff --git a/gi/fundamental.cpp b/gi/fundamental.cpp
index a96d1ab..b9040ed 100644
--- a/gi/fundamental.cpp
+++ b/gi/fundamental.cpp
@@ -531,8 +531,8 @@ fundamental_trace(JSTracer *tracer,
     if (priv == nullptr || !fundamental_is_prototype(priv))
         return;  /* Only prototypes need tracing */
 
-    JS_CallIdTracer(tracer, &priv->constructor_name,
-                    "Fundamental::constructor_name");
+    JS::TraceEdge<jsid>(tracer, &priv->constructor_name,
+                        "Fundamental::constructor_name");
 }
 
 /* The bizarre thing about this vtable is that it applies to both
diff --git a/gjs/context.cpp b/gjs/context.cpp
index fb62bf2..6f8967b 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -192,7 +192,7 @@ static void
 gjs_context_tracer(JSTracer *trc, void *data)
 {
     GjsContext *gjs_context = reinterpret_cast<GjsContext *>(data);
-    JS_CallObjectTracer(trc, &gjs_context->global, "GJS global object");
+    JS::TraceEdge<JSObject *>(trc, &gjs_context->global, "GJS global object");
 }
 
 static void
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 67997d0..54326c4 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1488,7 +1488,8 @@ coverage_statistics_tracer(JSTracer *trc, void *data)
     GjsCoverage *coverage = (GjsCoverage *) data;
     GjsCoveragePrivate *priv = (GjsCoveragePrivate *) gjs_coverage_get_instance_private(coverage);
 
-    JS_CallObjectTracer(trc, &priv->coverage_statistics, "coverage_statistics");
+    JS::TraceEdge<JSObject *>(trc, &priv->coverage_statistics,
+                              "coverage_statistics");
 }
 
 /* This function is mainly used in the tests in order to fiddle with
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index 543f537..ab31652 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -66,23 +66,11 @@
  */
 template<typename T>
 struct GjsHeapOperation {
-    static void trace(JSTracer    *tracer,
-                      JS::Heap<T> *thing,
-                      const char  *name);
-
     static bool update_after_gc(JS::Heap<T> *location);
 };
 
 template<>
 struct GjsHeapOperation<JSObject *> {
-    static void
-    trace(JSTracer             *tracer,
-          JS::Heap<JSObject *> *thing,
-          const char           *name)
-    {
-        JS_CallObjectTracer(tracer, thing, name);
-    }
-
     static bool
     update_after_gc(JS::Heap<JSObject *> *location)
     {
@@ -92,15 +80,7 @@ struct GjsHeapOperation<JSObject *> {
 };
 
 template<>
-struct GjsHeapOperation<JS::Value> {
-    static void
-    trace(JSTracer            *tracer,
-          JS::Heap<JS::Value> *thing,
-          const char          *name)
-    {
-        JS_CallValueTracer(tracer, thing, name);
-    }
-};
+struct GjsHeapOperation<JS::Value> {};
 
 /* GjsMaybeOwned is intended only for use in heap allocation. Do not allocate it
  * on the stack, and do not allocate any instances of structures that have it as
@@ -316,7 +296,7 @@ public:
     {
         debug("trace()");
         g_assert(!m_rooted);
-        GjsHeapOperation<T>::trace(tracer, &m_heap, name);
+        JS::TraceEdge<T>(tracer, &m_heap, name);
     }
 
     /* If not tracing, then you must call this method during GC in order to


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