[gjs/wip/ptomato/mozjs52: 35/38] js: Adapt to misc API changes in SpiderMonkey 52



commit 4868b29a8b634f3b8a1cfc435b44a83466de8e29
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue May 2 22:06:58 2017 -0700

    js: Adapt to misc API changes in SpiderMonkey 52
    
    - JS::InitSelfHostedCode() is now required to be called before the first
      global object is created.
    - js::GCMethods<T>::initial was moved from the friend API to the public
      API and renamed JS::GCPolicy<T>::initial.
    - JSPropertyDescriptor was renamed JS::PropertyDescriptor.
    - JS::CloneAndExecuteScript() now takes a return value parameter, even
      though we don't use it in this case.
    - js::DumpHeapComplete() was renamed to js::DumpHeap() and takes a
      JSContext parameter instead of JSRuntime.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=784196

 gjs/coverage.cpp      |    3 ++-
 gjs/engine.cpp        |    3 +++
 gjs/importer.cpp      |    2 +-
 gjs/jsapi-util-root.h |    4 ++--
 modules/system.cpp    |    4 ++--
 5 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index 41fb681..3281ff3 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -1302,7 +1302,8 @@ gjs_context_eval_file_in_compartment(GjsContext      *context,
                      &compiled_script))
         return false;
 
-    if (!JS::CloneAndExecuteScript(js_context, compiled_script)) {
+    JS::RootedValue dummy_rval(js_context);
+    if (!JS::CloneAndExecuteScript(js_context, compiled_script, &dummy_rval)) {
         g_free(script);
         gjs_log_exception(js_context);
         g_set_error(error, GJS_ERROR, GJS_ERROR_FAILED, "Failed to evaluate %s", filename);
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index 9676166..30aaeef 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -265,6 +265,9 @@ gjs_create_js_context(GjsContext *js_context)
     if (!cx)
         return nullptr;
 
+    if (!JS::InitSelfHostedCode(cx))
+        return nullptr;
+
     // commented are defaults in moz-24
     JS_SetNativeStackQuota(cx, 1024 * 1024);
     JS_SetGCParameter(cx, JSGC_MAX_MALLOC_BYTES, 128 * 1024 * 1024);
diff --git a/gjs/importer.cpp b/gjs/importer.cpp
index b546878..29f21d9 100644
--- a/gjs/importer.cpp
+++ b/gjs/importer.cpp
@@ -196,7 +196,7 @@ seal_import(JSContext       *cx,
             JS::HandleId     id,
             const char      *name)
 {
-    JS::Rooted<JSPropertyDescriptor> descr(cx);
+    JS::Rooted<JS::PropertyDescriptor> descr(cx);
 
     if (!JS_GetOwnPropertyDescriptorById(cx, obj, id, &descr) ||
         descr.object() == NULL) {
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index ab31652..6c6462f 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -217,7 +217,7 @@ public:
     {
         debug("root()");
         g_assert(!m_rooted);
-        g_assert(m_heap.get() == js::GCMethods<T>::initial());
+        g_assert(m_heap.get() == JS::GCPolicy<T>::initial());
         m_rooted = true;
         m_cx = cx;
         m_notify = notify;
@@ -244,7 +244,7 @@ public:
     {
         debug("reset()");
         if (!m_rooted) {
-            m_heap = js::GCMethods<T>::initial();
+            m_heap = JS::GCPolicy<T>::initial();
             return;
         }
 
diff --git a/modules/system.cpp b/modules/system.cpp
index d499758..81b7ae3 100644
--- a/modules/system.cpp
+++ b/modules/system.cpp
@@ -112,11 +112,11 @@ gjs_dump_heap(JSContext *cx,
 
     if (filename) {
         FILE *fp = fopen(filename, "a");
-        js::DumpHeapComplete(JS_GetRuntime(cx), fp, js::IgnoreNurseryObjects);
+        js::DumpHeap(cx, fp, js::IgnoreNurseryObjects);
         fclose(fp);
         g_free(filename);
     } else {
-        js::DumpHeapComplete(JS_GetRuntime(cx), stdout, js::IgnoreNurseryObjects);
+        js::DumpHeap(cx, stdout, js::IgnoreNurseryObjects);
     }
 
     args.rval().setUndefined();


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