[gjs/mozjs78: 14/22] js: Various API renames and adjustments




commit 3d7e7a930a8dc6b0416e97978a2ffda2115bf60e
Author: Evan Welsh <noreply evanwelsh com>
Date:   Sat Jul 4 22:14:39 2020 -0500

    js: Various API renames and adjustments
    
    - INTERNED_STRING_TO_JSID -> JS::PropertyKey::fromPinnedString
    - JSGC_SLICE_TIME_BUDGET -> JSGC_SLICE_TIME_BUDGET_MS.
    - js::gc::detail::GetGCThingZone() -> JS::GetGCThingZone()
    - js::GetCodeCoverageSummary() now returns JS::UniqueChars.
    - JSGC_MAX_MALLOC_BYTES was removed, there is no more malloc counter.
    - JSGC_DYNAMIC_MARK_SLICE is now the default.
    - JSGC_DYNAMIC_HEAP_GROWTH is now the default.
    - JS::RealmCreationOptions::setBigIntEnabled is now the default.
    - JS::RealmCreationOptions::setFieldsEnabled is now the default.
    
    See: GNOME/gjs#329

 gjs/atoms.cpp             | 2 +-
 gjs/coverage.cpp          | 5 ++---
 gjs/engine.cpp            | 5 +----
 gjs/global.cpp            | 3 ---
 gjs/jsapi-util-root.h     | 4 ++--
 gjs/jsapi-util-string.cpp | 4 ++--
 6 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/gjs/atoms.cpp b/gjs/atoms.cpp
index 5329ddc2..e6d2be69 100644
--- a/gjs/atoms.cpp
+++ b/gjs/atoms.cpp
@@ -39,7 +39,7 @@ bool GjsAtom::init(JSContext* cx, const char* str) {
     JSString* s = JS_AtomizeAndPinString(cx, str);
     if (!s)
         return false;
-    m_jsid = JS::Heap<jsid>{INTERNED_STRING_TO_JSID(cx, s)};
+    m_jsid = JS::Heap<jsid>{JS::PropertyKey::fromPinnedString(s)};
     return true;
 }
 
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index ab5b6ebf..2e00e706 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -205,8 +205,7 @@ write_line(GOutputStream *out,
     GFile *output_file = g_file_get_child(priv->output_dir, "coverage.lcov");
 
     size_t lcov_length;
-    GjsAutoPointer<char, void, free> lcov(
-        js::GetCodeCoverageSummary(cx, &lcov_length));
+    JS::UniqueChars lcov = js::GetCodeCoverageSummary(cx, &lcov_length);
 
     GjsAutoUnref<GOutputStream> ostream =
         G_OUTPUT_STREAM(g_file_append_to(output_file,
@@ -216,7 +215,7 @@ write_line(GOutputStream *out,
     if (!ostream)
         return nullptr;
 
-    GjsAutoStrv lcov_lines = g_strsplit(lcov, "\n", -1);
+    GjsAutoStrv lcov_lines = g_strsplit(lcov.get(), "\n", -1);
     const char* test_name = NULL;
     bool ignoring_file = false;
 
diff --git a/gjs/engine.cpp b/gjs/engine.cpp
index 7b0cb14f..ec44a3e7 100644
--- a/gjs/engine.cpp
+++ b/gjs/engine.cpp
@@ -214,13 +214,10 @@ JSContext* gjs_create_js_context(GjsContextPrivate* uninitialized_gjs) {
 
     // commented are defaults in moz-24
     JS_SetNativeStackQuota(cx, 1024 * 1024);
-    JS_SetGCParameter(cx, JSGC_MAX_MALLOC_BYTES, 128 * 1024 * 1024);
     JS_SetGCParameter(cx, JSGC_MAX_BYTES, -1);
     JS_SetGCParameter(cx, JSGC_MODE, JSGC_MODE_INCREMENTAL);
-    JS_SetGCParameter(cx, JSGC_SLICE_TIME_BUDGET, 10); /* ms */
+    JS_SetGCParameter(cx, JSGC_SLICE_TIME_BUDGET_MS, 10); /* ms */
     // JS_SetGCParameter(cx, JSGC_HIGH_FREQUENCY_TIME_LIMIT, 1000); /* ms */
-    JS_SetGCParameter(cx, JSGC_DYNAMIC_MARK_SLICE, true);
-    JS_SetGCParameter(cx, JSGC_DYNAMIC_HEAP_GROWTH, true);
     // JS_SetGCParameter(cx, JSGC_LOW_FREQUENCY_HEAP_GROWTH, 150);
     // JS_SetGCParameter(cx, JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN, 150);
     // JS_SetGCParameter(cx, JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX, 300);
diff --git a/gjs/global.cpp b/gjs/global.cpp
index 850df908..82fb427c 100644
--- a/gjs/global.cpp
+++ b/gjs/global.cpp
@@ -59,9 +59,6 @@ union Utf8Unit;
 class GjsBaseGlobal {
     static JSObject* base(JSContext* cx, const JSClass* clasp,
                           JS::RealmCreationOptions options) {
-        options.setBigIntEnabled(true);
-        options.setFieldsEnabled(true);
-
         JS::RealmBehaviors behaviors;
         JS::RealmOptions compartment_options(options, behaviors);
 
diff --git a/gjs/jsapi-util-root.h b/gjs/jsapi-util-root.h
index ca1f25cd..8664f14d 100644
--- a/gjs/jsapi-util-root.h
+++ b/gjs/jsapi-util-root.h
@@ -94,7 +94,7 @@ struct GjsHeapOperation<JSObject *> {
     static void expose_to_js(JS::Heap<JSObject *>& thing) {
         JSObject *obj = thing.unbarrieredGet();
         /* If the object has been swept already, then the zone is nullptr */
-        if (!obj || !js::gc::detail::GetGCThingZone(uintptr_t(obj)))
+        if (!obj || !JS::GetGCThingZone(JS::GCCellPtr(obj)))
             return;
         if (!JS::RuntimeHeapIsCollecting())
             JS::ExposeObjectToActiveJS(obj);
@@ -105,7 +105,7 @@ template <>
 struct GjsHeapOperation<JSFunction*> {
     static void expose_to_js(const JS::Heap<JSFunction*>& thing) {
         JSFunction* func = thing.unbarrieredGet();
-        if (!func || !js::gc::detail::GetGCThingZone(uintptr_t(func)))
+        if (!func || !JS::GetGCThingZone(JS::GCCellPtr(func)))
             return;
         if (!JS::RuntimeHeapIsCollecting())
             js::gc::ExposeGCThingToActiveJS(JS::GCCellPtr(func));
diff --git a/gjs/jsapi-util-string.cpp b/gjs/jsapi-util-string.cpp
index 05f9e967..425911ba 100644
--- a/gjs/jsapi-util-string.cpp
+++ b/gjs/jsapi-util-string.cpp
@@ -37,7 +37,7 @@
 #include <js/CharacterEncoding.h>
 #include <js/Class.h>
 #include <js/GCAPI.h>  // for AutoCheckCannotGC
-#include <js/Id.h>     // for JSID_IS_STRING, INTERNED_STRING_TO...
+#include <js/Id.h>     // for JSID_IS_STRING...
 #include <js/RootingAPI.h>
 #include <js/Symbol.h>
 #include <js/TypeDecls.h>
@@ -377,7 +377,7 @@ gjs_intern_string_to_id(JSContext  *cx,
     JS::RootedString str(cx, JS_AtomizeAndPinString(cx, string));
     if (!str)
         return JSID_VOID;
-    return INTERNED_STRING_TO_JSID(cx, str);
+    return JS::PropertyKey::fromPinnedString(str);
 }
 
 [[nodiscard]] static std::string gjs_debug_linear_string(JSLinearString* str) {


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